const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PostcardManager-BXjSoQ2f.js","assets/usePostcardZones-CDDN4NlS.js","assets/DirectMail-DA9iFmMT.js"])))=>i.map(i=>d[i]); var lmt=Object.defineProperty;var dTe=t=>{throw TypeError(t)};var cmt=(t,s,r)=>s in t?lmt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r;var Nn=(t,s,r)=>cmt(t,typeof s!="symbol"?s+"":s,r),yfe=(t,s,r)=>s.has(t)||dTe("Cannot "+r);var ls=(t,s,r)=>(yfe(t,s,"read from private field"),r?r.call(t):s.get(t)),Xa=(t,s,r)=>s.has(t)?dTe("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(t):s.set(t,r),Kn=(t,s,r,n)=>(yfe(t,s,"write to private field"),n?n.call(t,r):s.set(t,r),r),Qi=(t,s,r)=>(yfe(t,s,"access private method"),r);var p7=(t,s,r,n)=>({set _(a){Kn(t,s,a,r)},get _(){return ls(t,s,n)}});function dmt(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)}})();var Vv=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ao(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function p9e(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 f9e={exports:{}},sde={},x9e={exports:{}},go={};/** * @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 cO=Symbol.for("react.element"),umt=Symbol.for("react.portal"),hmt=Symbol.for("react.fragment"),mmt=Symbol.for("react.strict_mode"),pmt=Symbol.for("react.profiler"),fmt=Symbol.for("react.provider"),xmt=Symbol.for("react.context"),gmt=Symbol.for("react.forward_ref"),ymt=Symbol.for("react.suspense"),vmt=Symbol.for("react.memo"),bmt=Symbol.for("react.lazy"),uTe=Symbol.iterator;function _mt(t){return t===null||typeof t!="object"?null:(t=uTe&&t[uTe]||t["@@iterator"],typeof t=="function"?t:null)}var g9e={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y9e=Object.assign,v9e={};function IA(t,s,r){this.props=t,this.context=s,this.refs=v9e,this.updater=r||g9e}IA.prototype.isReactComponent={};IA.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")};IA.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function b9e(){}b9e.prototype=IA.prototype;function uwe(t,s,r){this.props=t,this.context=s,this.refs=v9e,this.updater=r||g9e}var hwe=uwe.prototype=new b9e;hwe.constructor=uwe;y9e(hwe,IA.prototype);hwe.isPureReactComponent=!0;var hTe=Array.isArray,_9e=Object.prototype.hasOwnProperty,mwe={current:null},w9e={key:!0,ref:!0,__self:!0,__source:!0};function j9e(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)_9e.call(s,n)&&!w9e.hasOwnProperty(n)&&(a[n]=s[n]);var i=arguments.length-2;if(i===1)a.children=r;else if(1>>1,fe=le[_e];if(0>>1;_ea(Ne,xe))Aea(Fe,Ne)?(le[_e]=Fe,le[Ae]=xe,_e=Ae):(le[_e]=Ne,le[Ie]=xe,_e=Ie);else if(Aea(Fe,xe))le[_e]=Fe,le[Ae]=xe,_e=Ae;else break e}}return pe}function a(le,pe){var xe=le.sortIndex-pe.sortIndex;return xe!==0?xe:le.id-pe.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,b=!1,_=!1,j=!1,w=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,C=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(le){for(var pe=r(u);pe!==null;){if(pe.callback===null)n(u);else if(pe.startTime<=le)n(u),pe.sortIndex=pe.expirationTime,s(c,pe);else break;pe=r(u)}}function I(le){if(j=!1,M(le),!_)if(r(c)!==null)_=!0,ne(L);else{var pe=r(u);pe!==null&&re(I,pe.startTime-le)}}function L(le,pe){_=!1,j&&(j=!1,N(U),U=-1),b=!0;var xe=g;try{for(M(pe),f=r(c);f!==null&&(!(f.expirationTime>pe)||le&&!Y());){var _e=f.callback;if(typeof _e=="function"){f.callback=null,g=f.priorityLevel;var fe=_e(f.expirationTime<=pe);pe=t.unstable_now(),typeof fe=="function"?f.callback=fe:f===r(c)&&n(c),M(pe)}else n(c);f=r(c)}if(f!==null)var we=!0;else{var Ie=r(u);Ie!==null&&re(I,Ie.startTime-pe),we=!1}return we}finally{f=null,g=xe,b=!1}}var R=!1,q=null,U=-1,B=5,V=-1;function Y(){return!(t.unstable_now()-Vle||125_e?(le.sortIndex=xe,s(u,le),r(c)===null&&le===r(u)&&(j?(N(U),U=-1):j=!0,re(I,xe-_e))):(le.sortIndex=fe,s(c,le),_||b||(_=!0,ne(L))),le},t.unstable_shouldYield=Y,t.unstable_wrapCallback=function(le){var pe=g;return function(){var xe=g;g=pe;try{return le.apply(this,arguments)}finally{g=xe}}}})(M9e);C9e.exports=M9e;var Pmt=C9e.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 Imt=k,Sf=Pmt;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"),Lye=Object.prototype.hasOwnProperty,Lmt=/^[: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]*$/,pTe={},fTe={};function Dmt(t){return Lye.call(fTe,t)?!0:Lye.call(pTe,t)?!1:Lmt.test(t)?fTe[t]=!0:(pTe[t]=!0,!1)}function Omt(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 Rmt(t,s,r,n){if(s===null||typeof s>"u"||Omt(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 Vm(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 Eh={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){Eh[t]=new Vm(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var s=t[0];Eh[s]=new Vm(s,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){Eh[t]=new Vm(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){Eh[t]=new Vm(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){Eh[t]=new Vm(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){Eh[t]=new Vm(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){Eh[t]=new Vm(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){Eh[t]=new Vm(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){Eh[t]=new Vm(t,5,!1,t.toLowerCase(),null,!1,!1)});var xwe=/[\-:]([a-z])/g;function gwe(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(xwe,gwe);Eh[s]=new Vm(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(xwe,gwe);Eh[s]=new Vm(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(xwe,gwe);Eh[s]=new Vm(s,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){Eh[t]=new Vm(t,1,!1,t.toLowerCase(),null,!1,!1)});Eh.xlinkHref=new Vm("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){Eh[t]=new Vm(t,1,!1,t.toLowerCase(),null,!0,!0)});function ywe(t,s,r,n){var a=Eh.hasOwnProperty(s)?Eh[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{_fe=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?hI(t):""}function Fmt(t){switch(t.tag){case 5:return hI(t.type);case 16:return hI("Lazy");case 13:return hI("Suspense");case 19:return hI("SuspenseList");case 0:case 2:case 15:return t=wfe(t.type,!1),t;case 11:return t=wfe(t.type.render,!1),t;case 1:return t=wfe(t.type,!0),t;default:return""}}function Fye(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 U5:return"Fragment";case q5:return"Portal";case Dye:return"Profiler";case vwe:return"StrictMode";case Oye:return"Suspense";case Rye:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case E9e:return(t.displayName||"Context")+".Consumer";case A9e:return(t._context.displayName||"Context")+".Provider";case bwe:var s=t.render;return t=t.displayName,t||(t=s.displayName||s.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case _we:return s=t.displayName||null,s!==null?s:Fye(t.type)||"Memo";case Ub:s=t._payload,t=t._init;try{return Fye(t(s))}catch{}}return null}function zmt(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 Fye(s);case 8:return s===vwe?"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 rw(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function I9e(t){var s=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(s==="checkbox"||s==="radio")}function Bmt(t){var s=I9e(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 g7(t){t._valueTracker||(t._valueTracker=Bmt(t))}function L9e(t){if(!t)return!1;var s=t._valueTracker;if(!s)return!0;var r=s.getValue(),n="";return t&&(n=I9e(t)?t.checked?"true":"false":t.value),t=n,t!==r?(s.setValue(t),!0):!1}function Lie(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 zye(t,s){var r=s.checked;return sd({},s,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function gTe(t,s){var r=s.defaultValue==null?"":s.defaultValue,n=s.checked!=null?s.checked:s.defaultChecked;r=rw(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 D9e(t,s){s=s.checked,s!=null&&ywe(t,"checked",s,!1)}function Bye(t,s){D9e(t,s);var r=rw(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")?$ye(t,s.type,r):s.hasOwnProperty("defaultValue")&&$ye(t,s.type,rw(s.defaultValue)),s.checked==null&&s.defaultChecked!=null&&(t.defaultChecked=!!s.defaultChecked)}function yTe(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 $ye(t,s,r){(s!=="number"||Lie(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var mI=Array.isArray;function mM(t,s,r,n){if(t=t.options,s){s={};for(var a=0;a"+s.valueOf().toString()+"",s=y7.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;s.firstChild;)t.appendChild(s.firstChild)}});function w8(t,s){if(s){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=s;return}}t.textContent=s}var PI={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},$mt=["Webkit","ms","Moz","O"];Object.keys(PI).forEach(function(t){$mt.forEach(function(s){s=s+t.charAt(0).toUpperCase()+t.substring(1),PI[s]=PI[t]})});function z9e(t,s,r){return s==null||typeof s=="boolean"||s===""?"":r||typeof s!="number"||s===0||PI.hasOwnProperty(t)&&PI[t]?(""+s).trim():s+"px"}function B9e(t,s){t=t.style;for(var r in s)if(s.hasOwnProperty(r)){var n=r.indexOf("--")===0,a=z9e(r,s[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,a):t[r]=a}}var qmt=sd({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 Vye(t,s){if(s){if(qmt[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 Hye(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 Wye=null;function wwe(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Gye=null,pM=null,fM=null;function _Te(t){if(t=hO(t)){if(typeof Gye!="function")throw Error(Xr(280));var s=t.stateNode;s&&(s=ode(s),Gye(t.stateNode,t.type,s))}}function $9e(t){pM?fM?fM.push(t):fM=[t]:pM=t}function q9e(){if(pM){var t=pM,s=fM;if(fM=pM=null,_Te(t),s)for(t=0;t>>=0,t===0?32:31-(Jmt(t)/ept|0)|0}var v7=64,b7=4194304;function pI(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 Fie(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=pI(i):(o&=l,o!==0&&(n=pI(o)))}else l=r&~a,l!==0?n=pI(l):o!==0&&(n=pI(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 dO(t,s,r){t.pendingLanes|=s,s!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,s=31-Gg(s),t[s]=r}function npt(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=LI),ATe=" ",ETe=!1;function lBe(t,s){switch(t){case"keyup":return Ppt.indexOf(s.keyCode)!==-1;case"keydown":return s.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function cBe(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var V5=!1;function Lpt(t,s){switch(t){case"compositionend":return cBe(s);case"keypress":return s.which!==32?null:(ETe=!0,ATe);case"textInput":return t=s.data,t===ATe&&ETe?null:t;default:return null}}function Dpt(t,s){if(V5)return t==="compositionend"||!Awe&&lBe(t,s)?(t=iBe(),i9=Cwe=y_=null,V5=!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=DTe(r)}}function mBe(t,s){return t&&s?t===s?!0:t&&t.nodeType===3?!1:s&&s.nodeType===3?mBe(t,s.parentNode):"contains"in t?t.contains(s):t.compareDocumentPosition?!!(t.compareDocumentPosition(s)&16):!1:!1}function pBe(){for(var t=window,s=Lie();s instanceof t.HTMLIFrameElement;){try{var r=typeof s.contentWindow.location.href=="string"}catch{r=!1}if(r)t=s.contentWindow;else break;s=Lie(t.document)}return s}function Ewe(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 Vpt(t){var s=pBe(),r=t.focusedElem,n=t.selectionRange;if(s!==r&&r&&r.ownerDocument&&mBe(r.ownerDocument.documentElement,r)){if(n!==null&&Ewe(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=OTe(r,o);var l=OTe(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,H5=null,Jye=null,OI=null,e0e=!1;function RTe(t,s,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;e0e||H5==null||H5!==Lie(n)||(n=H5,"selectionStart"in n&&Ewe(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}),OI&&M8(OI,n)||(OI=n,n=$ie(Jye,"onSelect"),0K5||(t.current=i0e[K5],i0e[K5]=null,K5--)}function Kl(t,s){K5++,i0e[K5]=t.current,t.current=s}var nw={},Zh=bw(nw),_p=bw(!1),SS=nw;function jT(t,s){var r=t.type.contextTypes;if(!r)return nw;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 wp(t){return t=t.childContextTypes,t!=null}function Uie(){vc(_p),vc(Zh)}function VTe(t,s,r){if(Zh.current!==nw)throw Error(Xr(168));Kl(Zh,s),Kl(_p,r)}function jBe(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,zmt(t)||"Unknown",a));return sd({},r,n)}function Vie(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||nw,SS=Zh.current,Kl(Zh,t),Kl(_p,_p.current),!0}function HTe(t,s,r){var n=t.stateNode;if(!n)throw Error(Xr(169));r?(t=jBe(t,s,SS),n.__reactInternalMemoizedMergedChildContext=t,vc(_p),vc(Zh),Kl(Zh,t)):vc(_p),Kl(_p,r)}var Iv=null,lde=!1,Ofe=!1;function NBe(t){Iv===null?Iv=[t]:Iv.push(t)}function sft(t){lde=!0,NBe(t)}function _w(){if(!Ofe&&Iv!==null){Ofe=!0;var t=0,s=yl;try{var r=Iv;for(yl=1;t>=l,a-=l,Hv=1<<32-Gg(s)+a|r<U?(B=q,q=null):B=q.sibling;var V=g(N,q,M[U],I);if(V===null){q===null&&(q=B);break}t&&q&&V.alternate===null&&s(N,q),C=o(V,C,U),R===null?L=V:R.sibling=V,R=V,q=B}if(U===M.length)return r(N,q),Dc&&$2(N,U),L;if(q===null){for(;UU?(B=q,q=null):B=q.sibling;var Y=g(N,q,V.value,I);if(Y===null){q===null&&(q=B);break}t&&q&&Y.alternate===null&&s(N,q),C=o(Y,C,U),R===null?L=Y:R.sibling=Y,R=Y,q=B}if(V.done)return r(N,q),Dc&&$2(N,U),L;if(q===null){for(;!V.done;U++,V=M.next())V=f(N,V.value,I),V!==null&&(C=o(V,C,U),R===null?L=V:R.sibling=V,R=V);return Dc&&$2(N,U),L}for(q=n(N,q);!V.done;U++,V=M.next())V=b(q,N,U,V.value,I),V!==null&&(t&&V.alternate!==null&&q.delete(V.key===null?U:V.key),C=o(V,C,U),R===null?L=V:R.sibling=V,R=V);return t&&q.forEach(function(J){return s(N,J)}),Dc&&$2(N,U),L}function w(N,C,M,I){if(typeof M=="object"&&M!==null&&M.type===U5&&M.key===null&&(M=M.props.children),typeof M=="object"&&M!==null){switch(M.$$typeof){case x7:e:{for(var L=M.key,R=C;R!==null;){if(R.key===L){if(L=M.type,L===U5){if(R.tag===7){r(N,R.sibling),C=a(R,M.props.children),C.return=N,N=C;break e}}else if(R.elementType===L||typeof L=="object"&&L!==null&&L.$$typeof===Ub&&KTe(L)===R.type){r(N,R.sibling),C=a(R,M.props),C.ref=IP(N,R,M),C.return=N,N=C;break e}r(N,R);break}else s(N,R);R=R.sibling}M.type===U5?(C=$4(M.props.children,N.mode,I,M.key),C.return=N,N=C):(I=p9(M.type,M.key,M.props,null,N.mode,I),I.ref=IP(N,C,M),I.return=N,N=I)}return l(N);case q5:e:{for(R=M.key;C!==null;){if(C.key===R)if(C.tag===4&&C.stateNode.containerInfo===M.containerInfo&&C.stateNode.implementation===M.implementation){r(N,C.sibling),C=a(C,M.children||[]),C.return=N,N=C;break e}else{r(N,C);break}else s(N,C);C=C.sibling}C=Vfe(M,N.mode,I),C.return=N,N=C}return l(N);case Ub:return R=M._init,w(N,C,R(M._payload),I)}if(mI(M))return _(N,C,M,I);if(MP(M))return j(N,C,M,I);C7(N,M)}return typeof M=="string"&&M!==""||typeof M=="number"?(M=""+M,C!==null&&C.tag===6?(r(N,C.sibling),C=a(C,M),C.return=N,N=C):(r(N,C),C=Ufe(M,N.mode,I),C.return=N,N=C),l(N)):r(N,C)}return w}var kT=MBe(!0),TBe=MBe(!1),Gie=bw(null),Kie=null,X5=null,Dwe=null;function Owe(){Dwe=X5=Kie=null}function Rwe(t){var s=Gie.current;vc(Gie),t._currentValue=s}function c0e(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 gM(t,s){Kie=t,Dwe=X5=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&s&&(xp=!0),t.firstContext=null)}function Px(t){var s=t._currentValue;if(Dwe!==t)if(t={context:t,memoizedValue:s,next:null},X5===null){if(Kie===null)throw Error(Xr(308));X5=t,Kie.dependencies={lanes:0,firstContext:t}}else X5=X5.next=t;return s}var u4=null;function Fwe(t){u4===null?u4=[t]:u4.push(t)}function ABe(t,s,r,n){var a=s.interleaved;return a===null?(r.next=r,Fwe(s)):(r.next=a.next,a.next=r),s.interleaved=r,j1(t,n)}function j1(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 Vb=!1;function zwe(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function EBe(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 Qv(t,s){return{eventTime:t,lane:s,tag:0,payload:null,callback:null,next:null}}function E_(t,s,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,Fo&2){var a=n.pending;return a===null?s.next=s:(s.next=a.next,a.next=s),n.pending=s,j1(t,r)}return a=n.interleaved,a===null?(s.next=s,Fwe(n)):(s.next=a.next,a.next=s),n.interleaved=s,j1(t,r)}function l9(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,Nwe(t,r)}}function ZTe(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 Zie(t,s,r,n){var a=t.updateQueue;Vb=!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,b=i.eventTime;if((n&g)===g){p!==null&&(p=p.next={eventTime:b,lane:0,tag:i.tag,payload:i.payload,callback:i.callback,next:null});e:{var _=t,j=i;switch(g=s,b=r,j.tag){case 1:if(_=j.payload,typeof _=="function"){f=_.call(b,f,g);break e}f=_;break e;case 3:_.flags=_.flags&-65537|128;case 0:if(_=j.payload,g=typeof _=="function"?_.call(b,f,g):_,g==null)break e;f=sd({},f,g);break e;case 2:Vb=!0}}i.callback!==null&&i.lane!==0&&(t.flags|=64,g=a.effects,g===null?a.effects=[i]:g.push(i))}else b={eventTime:b,lane:g,tag:i.tag,payload:i.payload,callback:i.callback,next:null},p===null?(u=p=b,c=f):p=p.next=b,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);TS|=l,t.lanes=l,t.memoizedState=f}}function YTe(t,s,r){if(t=s.effects,s.effects=null,t!==null)for(s=0;sr?r:4,t(!0);var n=Ffe.transition;Ffe.transition={};try{t(!1),s()}finally{yl=r,Ffe.transition=n}}function KBe(){return Ix().memoizedState}function ift(t,s,r){var n=I_(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},ZBe(t))YBe(s,r);else if(r=ABe(t,s,r,n),r!==null){var a=Em();Kg(r,t,n,a),XBe(r,s,n)}}function oft(t,s,r){var n=I_(t),a={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(ZBe(t))YBe(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,ry(i,l)){var c=s.interleaved;c===null?(a.next=a,Fwe(s)):(a.next=c.next,c.next=a),s.interleaved=a;return}}catch{}finally{}r=ABe(t,s,a,n),r!==null&&(a=Em(),Kg(r,t,n,a),XBe(r,s,n))}}function ZBe(t){var s=t.alternate;return t===Jc||s!==null&&s===Jc}function YBe(t,s){RI=Xie=!0;var r=t.pending;r===null?s.next=s:(s.next=r.next,r.next=s),t.pending=s}function XBe(t,s,r){if(r&4194240){var n=s.lanes;n&=t.pendingLanes,r|=n,s.lanes=r,Nwe(t,r)}}var Qie={readContext:Px,useCallback:Oh,useContext:Oh,useEffect:Oh,useImperativeHandle:Oh,useInsertionEffect:Oh,useLayoutEffect:Oh,useMemo:Oh,useReducer:Oh,useRef:Oh,useState:Oh,useDebugValue:Oh,useDeferredValue:Oh,useTransition:Oh,useMutableSource:Oh,useSyncExternalStore:Oh,useId:Oh,unstable_isNewReconciler:!1},lft={readContext:Px,useCallback:function(t,s){return Uy().memoizedState=[t,s===void 0?null:s],t},useContext:Px,useEffect:QTe,useImperativeHandle:function(t,s,r){return r=r!=null?r.concat([t]):null,d9(4194308,4,UBe.bind(null,s,t),r)},useLayoutEffect:function(t,s){return d9(4194308,4,t,s)},useInsertionEffect:function(t,s){return d9(4,2,t,s)},useMemo:function(t,s){var r=Uy();return s=s===void 0?null:s,t=t(),r.memoizedState=[t,s],t},useReducer:function(t,s,r){var n=Uy();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=ift.bind(null,Jc,t),[n.memoizedState,t]},useRef:function(t){var s=Uy();return t={current:t},s.memoizedState=t},useState:XTe,useDebugValue:Gwe,useDeferredValue:function(t){return Uy().memoizedState=t},useTransition:function(){var t=XTe(!1),s=t[0];return t=aft.bind(null,t[1]),Uy().memoizedState=t,[s,t]},useMutableSource:function(){},useSyncExternalStore:function(t,s,r){var n=Jc,a=Uy();if(Dc){if(r===void 0)throw Error(Xr(407));r=r()}else{if(r=s(),Xu===null)throw Error(Xr(349));MS&30||DBe(n,s,r)}a.memoizedState=r;var o={value:r,getSnapshot:s};return a.queue=o,QTe(RBe.bind(null,n,o,t),[t]),n.flags|=2048,O8(9,OBe.bind(null,n,o,r,s),void 0,null),r},useId:function(){var t=Uy(),s=Xu.identifierPrefix;if(Dc){var r=Wv,n=Hv;r=(n&~(1<<32-Gg(n)-1)).toString(32)+r,s=":"+s+"R"+r,r=L8++,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[e0]=s,t[E8]=n,o$e(t,s,!1,!1),s.stateNode=t;e:{switch(l=Hye(r,n),r){case"dialog":uc("cancel",t),uc("close",t),a=n;break;case"iframe":case"object":case"embed":uc("load",t),a=n;break;case"video":case"audio":for(a=0;aMT&&(s.flags|=128,n=!0,LP(o,!1),s.lanes=4194304)}else{if(!n)if(t=Yie(l),t!==null){if(s.flags|=128,n=!0,r=t.updateQueue,r!==null&&(s.updateQueue=r,s.flags|=4),LP(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!Dc)return Rh(s),null}else 2*Pd()-o.renderingStartTime>MT&&r!==1073741824&&(s.flags|=128,n=!0,LP(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=Pd(),s.sibling=null,r=Zc.current,Kl(Zc,n?r&1|2:r&1),s):(Rh(s),null);case 22:case 23:return Jwe(),n=s.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(s.flags|=8192),n&&s.mode&1?ef&1073741824&&(Rh(s),s.subtreeFlags&6&&(s.flags|=8192)):Rh(s),null;case 24:return null;case 25:return null}throw Error(Xr(156,s.tag))}function xft(t,s){switch(Iwe(s),s.tag){case 1:return wp(s.type)&&Uie(),t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 3:return ST(),vc(_p),vc(Zh),qwe(),t=s.flags,t&65536&&!(t&128)?(s.flags=t&-65537|128,s):null;case 5:return $we(s),null;case 13:if(vc(Zc),t=s.memoizedState,t!==null&&t.dehydrated!==null){if(s.alternate===null)throw Error(Xr(340));NT()}return t=s.flags,t&65536?(s.flags=t&-65537|128,s):null;case 19:return vc(Zc),null;case 4:return ST(),null;case 10:return Rwe(s.type._context),null;case 22:case 23:return Jwe(),null;case 24:return null;default:return null}}var T7=!1,qh=!1,gft=typeof WeakSet=="function"?WeakSet:Set,sa=null;function Q5(t,s){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){hd(t,s,n)}else r.current=null}function y0e(t,s,r){try{r()}catch(n){hd(t,s,n)}}var cAe=!1;function yft(t,s){if(t0e=zie,t=pBe(),Ewe(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 b;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),(b=f.firstChild)!==null;)g=f,f=b;for(;;){if(f===t)break t;if(g===r&&++u===a&&(i=l),g===o&&++p===n&&(c=l),(b=f.nextSibling)!==null)break;f=g,g=f.parentNode}f=b}r=i===-1||c===-1?null:{start:i,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(s0e={focusedElem:t,selectionRange:r},zie=!1,sa=s;sa!==null;)if(s=sa,t=s.child,(s.subtreeFlags&1028)!==0&&t!==null)t.return=s,sa=t;else for(;sa!==null;){s=sa;try{var _=s.alternate;if(s.flags&1024)switch(s.tag){case 0:case 11:case 15:break;case 1:if(_!==null){var j=_.memoizedProps,w=_.memoizedState,N=s.stateNode,C=N.getSnapshotBeforeUpdate(s.elementType===s.type?j:Ag(s.type,j),w);N.__reactInternalSnapshotBeforeUpdate=C}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(I){hd(s,s.return,I)}if(t=s.sibling,t!==null){t.return=s.return,sa=t;break}sa=s.return}return _=cAe,cAe=!1,_}function FI(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&&y0e(s,r,o)}a=a.next}while(a!==n)}}function ude(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 v0e(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 d$e(t){var s=t.alternate;s!==null&&(t.alternate=null,d$e(s)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(s=t.stateNode,s!==null&&(delete s[e0],delete s[E8],delete s[a0e],delete s[eft],delete s[tft])),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 u$e(t){return t.tag===5||t.tag===3||t.tag===4}function dAe(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||u$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 b0e(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=qie));else if(n!==4&&(t=t.child,t!==null))for(b0e(t,s,r),t=t.sibling;t!==null;)b0e(t,s,r),t=t.sibling}function _0e(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(_0e(t,s,r),t=t.sibling;t!==null;)_0e(t,s,r),t=t.sibling}var fh=null,Lg=!1;function Cb(t,s,r){for(r=r.child;r!==null;)h$e(t,s,r),r=r.sibling}function h$e(t,s,r){if(c0&&typeof c0.onCommitFiberUnmount=="function")try{c0.onCommitFiberUnmount(rde,r)}catch{}switch(r.tag){case 5:qh||Q5(r,s);case 6:var n=fh,a=Lg;fh=null,Cb(t,s,r),fh=n,Lg=a,fh!==null&&(Lg?(t=fh,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):fh.removeChild(r.stateNode));break;case 18:fh!==null&&(Lg?(t=fh,r=r.stateNode,t.nodeType===8?Dfe(t.parentNode,r):t.nodeType===1&&Dfe(t,r),S8(t)):Dfe(fh,r.stateNode));break;case 4:n=fh,a=Lg,fh=r.stateNode.containerInfo,Lg=!0,Cb(t,s,r),fh=n,Lg=a;break;case 0:case 11:case 14:case 15:if(!qh&&(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)&&y0e(r,s,l),a=a.next}while(a!==n)}Cb(t,s,r);break;case 1:if(!qh&&(Q5(r,s),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(i){hd(r,s,i)}Cb(t,s,r);break;case 21:Cb(t,s,r);break;case 22:r.mode&1?(qh=(n=qh)||r.memoizedState!==null,Cb(t,s,r),qh=n):Cb(t,s,r);break;default:Cb(t,s,r)}}function uAe(t){var s=t.updateQueue;if(s!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new gft),s.forEach(function(n){var a=Cft.bind(null,t,n);r.has(n)||(r.add(n),n.then(a,a))})}}function _g(t,s){var r=s.deletions;if(r!==null)for(var n=0;na&&(a=l),n&=~o}if(n=a,n=Pd()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*bft(n/1960))-n,10t?16:t,v_===null)var n=!1;else{if(t=v_,v_=null,toe=0,Fo&6)throw Error(Xr(331));var a=Fo;for(Fo|=4,sa=t.current;sa!==null;){var o=sa,l=o.child;if(sa.flags&16){var i=o.deletions;if(i!==null){for(var c=0;cPd()-Xwe?B4(t,0):Ywe|=r),jp(t,s)}function b$e(t,s){s===0&&(t.mode&1?(s=b7,b7<<=1,!(b7&130023424)&&(b7=4194304)):s=1);var r=Em();t=j1(t,s),t!==null&&(dO(t,s,r),jp(t,r))}function Sft(t){var s=t.memoizedState,r=0;s!==null&&(r=s.retryLane),b$e(t,r)}function Cft(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),b$e(t,r)}var _$e;_$e=function(t,s,r){if(t!==null)if(t.memoizedProps!==s.pendingProps||_p.current)xp=!0;else{if(!(t.lanes&r)&&!(s.flags&128))return xp=!1,pft(t,s,r);xp=!!(t.flags&131072)}else xp=!1,Dc&&s.flags&1048576&&kBe(s,Wie,s.index);switch(s.lanes=0,s.tag){case 2:var n=s.type;u9(t,s),t=s.pendingProps;var a=jT(s,Zh.current);gM(s,r),a=Vwe(null,s,n,t,a,r);var o=Hwe();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,wp(n)?(o=!0,Vie(s)):o=!1,s.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,zwe(s),a.updater=dde,s.stateNode=a,a._reactInternals=s,u0e(s,n,t,r),s=p0e(null,s,n,!0,o,r)):(s.tag=0,Dc&&o&&Pwe(s),vm(null,s,a,r),s=s.child),s;case 16:n=s.elementType;e:{switch(u9(t,s),t=s.pendingProps,a=n._init,n=a(n._payload),s.type=n,a=s.tag=Tft(n),t=Ag(n,t),a){case 0:s=m0e(null,s,n,t,r);break e;case 1:s=iAe(null,s,n,t,r);break e;case 11:s=nAe(null,s,n,t,r);break e;case 14:s=aAe(null,s,n,Ag(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:Ag(n,a),m0e(t,s,n,a,r);case 1:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Ag(n,a),iAe(t,s,n,a,r);case 3:e:{if(n$e(s),t===null)throw Error(Xr(387));n=s.pendingProps,o=s.memoizedState,a=o.element,EBe(t,s),Zie(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=CT(Error(Xr(423)),s),s=oAe(t,s,n,r,a);break e}else if(n!==a){a=CT(Error(Xr(424)),s),s=oAe(t,s,n,r,a);break e}else for(uf=A_(s.stateNode.containerInfo.firstChild),mf=s,Dc=!0,zg=null,r=TBe(s,null,n,r),s.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(NT(),n===a){s=N1(t,s,r);break e}vm(t,s,n,r)}s=s.child}return s;case 5:return PBe(s),t===null&&l0e(s),n=s.type,a=s.pendingProps,o=t!==null?t.memoizedProps:null,l=a.children,r0e(n,a)?l=null:o!==null&&r0e(n,o)&&(s.flags|=32),r$e(t,s),vm(t,s,l,r),s.child;case 6:return t===null&&l0e(s),null;case 13:return a$e(t,s,r);case 4:return Bwe(s,s.stateNode.containerInfo),n=s.pendingProps,t===null?s.child=kT(s,null,n,r):vm(t,s,n,r),s.child;case 11:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Ag(n,a),nAe(t,s,n,a,r);case 7:return vm(t,s,s.pendingProps,r),s.child;case 8:return vm(t,s,s.pendingProps.children,r),s.child;case 12:return vm(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,Kl(Gie,n._currentValue),n._currentValue=l,o!==null)if(ry(o.value,l)){if(o.children===a.children&&!_p.current){s=N1(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=Qv(-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),c0e(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),c0e(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}vm(t,s,a.children,r),s=s.child}return s;case 9:return a=s.type,n=s.pendingProps.children,gM(s,r),a=Px(a),n=n(a),s.flags|=1,vm(t,s,n,r),s.child;case 14:return n=s.type,a=Ag(n,s.pendingProps),a=Ag(n.type,a),aAe(t,s,n,a,r);case 15:return t$e(t,s,s.type,s.pendingProps,r);case 17:return n=s.type,a=s.pendingProps,a=s.elementType===n?a:Ag(n,a),u9(t,s),s.tag=1,wp(n)?(t=!0,Vie(s)):t=!1,gM(s,r),QBe(s,n,a),u0e(s,n,a,r),p0e(null,s,n,!0,t,r);case 19:return i$e(t,s,r);case 22:return s$e(t,s,r)}throw Error(Xr(156,s.tag))};function w$e(t,s){return Z9e(t,s)}function Mft(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 vx(t,s,r,n){return new Mft(t,s,r,n)}function t2e(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Tft(t){if(typeof t=="function")return t2e(t)?1:0;if(t!=null){if(t=t.$$typeof,t===bwe)return 11;if(t===_we)return 14}return 2}function L_(t,s){var r=t.alternate;return r===null?(r=vx(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 p9(t,s,r,n,a,o){var l=2;if(n=t,typeof t=="function")t2e(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case U5:return $4(r.children,a,o,s);case vwe:l=8,a|=8;break;case Dye:return t=vx(12,r,s,a|2),t.elementType=Dye,t.lanes=o,t;case Oye:return t=vx(13,r,s,a),t.elementType=Oye,t.lanes=o,t;case Rye:return t=vx(19,r,s,a),t.elementType=Rye,t.lanes=o,t;case P9e:return mde(r,a,o,s);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case A9e:l=10;break e;case E9e:l=9;break e;case bwe:l=11;break e;case _we:l=14;break e;case Ub:l=16,n=null;break e}throw Error(Xr(130,t==null?t:typeof t,""))}return s=vx(l,r,s,a),s.elementType=t,s.type=n,s.lanes=o,s}function $4(t,s,r,n){return t=vx(7,t,n,s),t.lanes=r,t}function mde(t,s,r,n){return t=vx(22,t,n,s),t.elementType=P9e,t.lanes=r,t.stateNode={isHidden:!1},t}function Ufe(t,s,r){return t=vx(6,t,null,s),t.lanes=r,t}function Vfe(t,s,r){return s=vx(4,t.children!==null?t.children:[],t.key,s),s.lanes=r,s.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},s}function Aft(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=Nfe(0),this.expirationTimes=Nfe(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Nfe(0),this.identifierPrefix=n,this.onRecoverableError=a,this.mutableSourceEagerHydrationData=null}function s2e(t,s,r,n,a,o,l,i,c){return t=new Aft(t,s,r,i,c),s===1?(s=1,o===!0&&(s|=8)):s=0,o=vx(3,null,null,s),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},zwe(o),t}function Eft(t,s,r){var n=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(S$e)}catch(t){console.error(t)}}S$e(),S9e.exports=Ef;var gp=S9e.exports;const i2e=Ao(gp);var C$e,vAe=gp;C$e=vAe.createRoot,vAe.hydrateRoot;const Oft="modulepreload",Rft=function(t){return"/"+t},bAe={},jc=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=Rft(c),c in bAe)return;bAe[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":Oft,u||(f.as="script"),f.crossOrigin="",f.href=c,i&&f.setAttribute("nonce",i),document.head.appendChild(f),u)return new Promise((g,b)=>{f.addEventListener("load",g),f.addEventListener("error",()=>b(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)})},Fft=1,zft=1e6;let Hfe=0;function Bft(){return Hfe=(Hfe+1)%Number.MAX_SAFE_INTEGER,Hfe.toString()}const Wfe=new Map,_Ae=t=>{if(Wfe.has(t))return;const s=setTimeout(()=>{Wfe.delete(t),$I({type:"REMOVE_TOAST",toastId:t})},zft);Wfe.set(t,s)},$ft=(t,s)=>{switch(s.type){case"ADD_TOAST":return{...t,toasts:[s.toast,...t.toasts].slice(0,Fft)};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?_Ae(r):t.toasts.forEach(n=>{_Ae(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)}}},f9=[];let x9={toasts:[]};function $I(t){x9=$ft(x9,t),f9.forEach(s=>{s(x9)})}function vn({...t}){const s=Bft(),r=a=>$I({type:"UPDATE_TOAST",toast:{...a,id:s}}),n=()=>$I({type:"DISMISS_TOAST",toastId:s});return $I({type:"ADD_TOAST",toast:{...t,id:s,open:!0,onOpenChange:a=>{a||n()}}}),{id:s,dismiss:n,update:r}}function qa(){const[t,s]=k.useState(x9);return k.useEffect(()=>(f9.push(s),()=>{const r=f9.indexOf(s);r>-1&&f9.splice(r,1)}),[t]),{...t,toast:vn,dismiss:r=>$I({type:"DISMISS_TOAST",toastId:r})}}function Ir(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 wAe(t,s){if(typeof t=="function")return t(s);t!=null&&(t.current=s)}function k1(...t){return s=>{let r=!1;const n=t.map(a=>{const o=wAe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{children:l,...i}=o,c=k.useMemo(()=>i,Object.values(i));return e.jsx(r.Provider,{value:c,children:l})};n.displayName=t+"Provider";function a(o){const l=k.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 nd(t,s=[]){let r=[];function n(o,l){const i=k.createContext(l),c=r.length;r=[...r,l];const u=f=>{var N;const{scope:g,children:b,..._}=f,j=((N=g==null?void 0:g[t])==null?void 0:N[c])||i,w=k.useMemo(()=>_,Object.values(_));return e.jsx(j.Provider,{value:w,children:b})};u.displayName=o+"Provider";function p(f,g){var j;const b=((j=g==null?void 0:g[t])==null?void 0:j[c])||i,_=k.useContext(b);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=>k.createContext(l));return function(i){const c=(i==null?void 0:i[t])||o;return k.useMemo(()=>({[`__scope${t}`]:{...i,[t]:c}}),[i,c])}};return a.scopeName=t,[n,Uft(a,...s)]}function Uft(...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 k.useMemo(()=>({[`__scope${s.scopeName}`]:l}),[l])}};return r.scopeName=s.scopeName,r}function aw(t){const s=Vft(t),r=k.forwardRef((n,a)=>{const{children:o,...l}=n,i=k.Children.toArray(o),c=i.find(Hft);if(c){const u=c.props.children,p=i.map(f=>f===c?k.Children.count(u)>1?k.Children.only(null):k.isValidElement(u)?u.props.children:null:f);return e.jsx(s,{...l,ref:a,children:k.isValidElement(u)?k.cloneElement(u,void 0,p):null})}return e.jsx(s,{...l,ref:a,children:o})});return r.displayName=`${t}.Slot`,r}var o2e=aw("Slot");function Vft(t){const s=k.forwardRef((r,n)=>{const{children:a,...o}=r;if(k.isValidElement(a)){const l=Gft(a),i=Wft(o,a.props);return a.type!==k.Fragment&&(i.ref=n?k1(n,l):l),k.cloneElement(a,i)}return k.Children.count(a)>1?k.Children.only(null):null});return s.displayName=`${t}.SlotClone`,s}var M$e=Symbol("radix.slottable");function T$e(t){const s=({children:r})=>e.jsx(e.Fragment,{children:r});return s.displayName=`${t}.Slottable`,s.__radixId=M$e,s}function Hft(t){return k.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===M$e}function Wft(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 Gft(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 pO(t){const s=t+"CollectionProvider",[r,n]=nd(s),[a,o]=r(s,{collectionRef:{current:null},itemMap:new Map}),l=j=>{const{scope:w,children:N}=j,C=ht.useRef(null),M=ht.useRef(new Map).current;return e.jsx(a,{scope:w,itemMap:M,collectionRef:C,children:N})};l.displayName=s;const i=t+"CollectionSlot",c=aw(i),u=ht.forwardRef((j,w)=>{const{scope:N,children:C}=j,M=o(i,N),I=$a(w,M.collectionRef);return e.jsx(c,{ref:I,children:C})});u.displayName=i;const p=t+"CollectionItemSlot",f="data-radix-collection-item",g=aw(p),b=ht.forwardRef((j,w)=>{const{scope:N,children:C,...M}=j,I=ht.useRef(null),L=$a(w,I),R=o(p,N);return ht.useEffect(()=>(R.itemMap.set(I,{ref:I,...M}),()=>void R.itemMap.delete(I))),e.jsx(g,{[f]:"",ref:L,children:C})});b.displayName=p;function _(j){const w=o(t+"CollectionConsumer",j);return ht.useCallback(()=>{const C=w.collectionRef.current;if(!C)return[];const M=Array.from(C.querySelectorAll(`[${f}]`));return Array.from(w.itemMap.values()).sort((R,q)=>M.indexOf(R.ref.current)-M.indexOf(q.ref.current))},[w.collectionRef,w.itemMap])}return[{Provider:l,Slot:u,ItemSlot:b},_,n]}var Kft=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],sn=Kft.reduce((t,s)=>{const r=aw(`Primitive.${s}`),n=k.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 l2e(t,s){t&&gp.flushSync(()=>t.dispatchEvent(s))}function gd(t){const s=k.useRef(t);return k.useEffect(()=>{s.current=t}),k.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}function Zft(t,s=globalThis==null?void 0:globalThis.document){const r=gd(t);k.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 Yft="DismissableLayer",S0e="dismissableLayer.update",Xft="dismissableLayer.pointerDownOutside",Qft="dismissableLayer.focusOutside",jAe,A$e=k.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ww=k.forwardRef((t,s)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,onDismiss:i,...c}=t,u=k.useContext(A$e),[p,f]=k.useState(null),g=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,b]=k.useState({}),_=$a(s,q=>f(q)),j=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),N=j.indexOf(w),C=p?j.indexOf(p):-1,M=u.layersWithOutsidePointerEventsDisabled.size>0,I=C>=N,L=ext(q=>{const U=q.target,B=[...u.branches].some(V=>V.contains(U));!I||B||(a==null||a(q),l==null||l(q),q.defaultPrevented||i==null||i())},g),R=txt(q=>{const U=q.target;[...u.branches].some(V=>V.contains(U))||(o==null||o(q),l==null||l(q),q.defaultPrevented||i==null||i())},g);return Zft(q=>{C===u.layers.size-1&&(n==null||n(q),!q.defaultPrevented&&i&&(q.preventDefault(),i()))},g),k.useEffect(()=>{if(p)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(jAe=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),NAe(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(g.body.style.pointerEvents=jAe)}},[p,g,r,u]),k.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),NAe())},[p,u]),k.useEffect(()=>{const q=()=>b({});return document.addEventListener(S0e,q),()=>document.removeEventListener(S0e,q)},[]),e.jsx(sn.div,{...c,ref:_,style:{pointerEvents:M?I?"auto":"none":void 0,...t.style},onFocusCapture:Ir(t.onFocusCapture,R.onFocusCapture),onBlurCapture:Ir(t.onBlurCapture,R.onBlurCapture),onPointerDownCapture:Ir(t.onPointerDownCapture,L.onPointerDownCapture)})});ww.displayName=Yft;var Jft="DismissableLayerBranch",E$e=k.forwardRef((t,s)=>{const r=k.useContext(A$e),n=k.useRef(null),a=$a(s,n);return k.useEffect(()=>{const o=n.current;if(o)return r.branches.add(o),()=>{r.branches.delete(o)}},[r.branches]),e.jsx(sn.div,{...t,ref:a})});E$e.displayName=Jft;function ext(t,s=globalThis==null?void 0:globalThis.document){const r=gd(t),n=k.useRef(!1),a=k.useRef(()=>{});return k.useEffect(()=>{const o=i=>{if(i.target&&!n.current){let c=function(){P$e(Xft,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=gd(t),n=k.useRef(!1);return k.useEffect(()=>{const a=o=>{o.target&&!n.current&&P$e(Qft,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 NAe(){const t=new CustomEvent(S0e);document.dispatchEvent(t)}function P$e(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?l2e(a,o):a.dispatchEvent(o)}var sxt=ww,rxt=E$e,wd=globalThis!=null&&globalThis.document?k.useLayoutEffect:()=>{},nxt="Portal",OA=k.forwardRef((t,s)=>{var i;const{container:r,...n}=t,[a,o]=k.useState(!1);wd(()=>o(!0),[]);const l=r||a&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return l?i2e.createPortal(e.jsx(sn.div,{...n,ref:s}),l):null});OA.displayName=nxt;function axt(t,s){return k.useReducer((r,n)=>s[r][n]??r,t)}var Fd=t=>{const{present:s,children:r}=t,n=ixt(s),a=typeof r=="function"?r({present:n.isPresent}):k.Children.only(r),o=$a(n.ref,oxt(a));return typeof r=="function"||n.isPresent?k.cloneElement(a,{ref:o}):null};Fd.displayName="Presence";function ixt(t){const[s,r]=k.useState(),n=k.useRef(null),a=k.useRef(t),o=k.useRef("none"),l=t?"mounted":"unmounted",[i,c]=axt(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return k.useEffect(()=>{const u=P7(n.current);o.current=i==="mounted"?u:"none"},[i]),wd(()=>{const u=n.current,p=a.current;if(p!==t){const g=o.current,b=P7(u);t?c("MOUNT"):b==="none"||(u==null?void 0:u.display)==="none"?c("UNMOUNT"):c(p&&g!==b?"ANIMATION_OUT":"UNMOUNT"),a.current=t}},[t,c]),wd(()=>{if(s){let u;const p=s.ownerDocument.defaultView??window,f=b=>{const j=P7(n.current).includes(b.animationName);if(b.target===s&&j&&(c("ANIMATION_END"),!a.current)){const w=s.style.animationFillMode;s.style.animationFillMode="forwards",u=p.setTimeout(()=>{s.style.animationFillMode==="forwards"&&(s.style.animationFillMode=w)})}},g=b=>{b.target===s&&(o.current=P7(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:k.useCallback(u=>{n.current=u?getComputedStyle(u):null,r(u)},[])}}function P7(t){return(t==null?void 0:t.animationName)||"none"}function oxt(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 lxt=fwe[" useInsertionEffect ".trim().toString()]||wd;function rh({prop:t,defaultProp:s,onChange:r=()=>{},caller:n}){const[a,o,l]=cxt({defaultProp:s,onChange:r}),i=t!==void 0,c=i?t:a;{const p=k.useRef(t!==void 0);k.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=k.useCallback(p=>{var f;if(i){const g=dxt(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 cxt({defaultProp:t,onChange:s}){const[r,n]=k.useState(t),a=k.useRef(r),o=k.useRef(s);return lxt(()=>{o.current=s},[s]),k.useEffect(()=>{var l;a.current!==r&&((l=o.current)==null||l.call(o,r),a.current=r)},[r,a]),[r,n,o]}function dxt(t){return typeof t=="function"}var I$e=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"}),uxt="VisuallyHidden",yde=k.forwardRef((t,s)=>e.jsx(sn.span,{...t,ref:s,style:{...I$e,...t.style}}));yde.displayName=uxt;var hxt=yde,c2e="ToastProvider",[d2e,mxt,pxt]=pO("Toast"),[L$e]=nd("Toast",[pxt]),[fxt,vde]=L$e(c2e),D$e=t=>{const{__scopeToast:s,label:r="Notification",duration:n=5e3,swipeDirection:a="right",swipeThreshold:o=50,children:l}=t,[i,c]=k.useState(null),[u,p]=k.useState(0),f=k.useRef(!1),g=k.useRef(!1);return r.trim()||console.error(`Invalid prop \`label\` supplied to \`${c2e}\`. Expected non-empty \`string\`.`),e.jsx(d2e.Provider,{scope:s,children:e.jsx(fxt,{scope:s,label:r,duration:n,swipeDirection:a,swipeThreshold:o,toastCount:u,viewport:i,onViewportChange:c,onToastAdd:k.useCallback(()=>p(b=>b+1),[]),onToastRemove:k.useCallback(()=>p(b=>b-1),[]),isFocusedToastEscapeKeyDownRef:f,isClosePausedRef:g,children:l})})};D$e.displayName=c2e;var O$e="ToastViewport",xxt=["F8"],C0e="toast.viewportPause",M0e="toast.viewportResume",R$e=k.forwardRef((t,s)=>{const{__scopeToast:r,hotkey:n=xxt,label:a="Notifications ({hotkey})",...o}=t,l=vde(O$e,r),i=mxt(r),c=k.useRef(null),u=k.useRef(null),p=k.useRef(null),f=k.useRef(null),g=$a(s,f,l.onViewportChange),b=n.join("+").replace(/Key/g,"").replace(/Digit/g,""),_=l.toastCount>0;k.useEffect(()=>{const w=N=>{var M;n.length!==0&&n.every(I=>N[I]||N.code===I)&&((M=f.current)==null||M.focus())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]),k.useEffect(()=>{const w=c.current,N=f.current;if(_&&w&&N){const C=()=>{if(!l.isClosePausedRef.current){const R=new CustomEvent(C0e);N.dispatchEvent(R),l.isClosePausedRef.current=!0}},M=()=>{if(l.isClosePausedRef.current){const R=new CustomEvent(M0e);N.dispatchEvent(R),l.isClosePausedRef.current=!1}},I=R=>{!w.contains(R.relatedTarget)&&M()},L=()=>{w.contains(document.activeElement)||M()};return w.addEventListener("focusin",C),w.addEventListener("focusout",I),w.addEventListener("pointermove",C),w.addEventListener("pointerleave",L),window.addEventListener("blur",C),window.addEventListener("focus",M),()=>{w.removeEventListener("focusin",C),w.removeEventListener("focusout",I),w.removeEventListener("pointermove",C),w.removeEventListener("pointerleave",L),window.removeEventListener("blur",C),window.removeEventListener("focus",M)}}},[_,l.isClosePausedRef]);const j=k.useCallback(({tabbingDirection:w})=>{const C=i().map(M=>{const I=M.ref.current,L=[I,...Txt(I)];return w==="forwards"?L:L.reverse()});return(w==="forwards"?C.reverse():C).flat()},[i]);return k.useEffect(()=>{const w=f.current;if(w){const N=C=>{var L,R,q;const M=C.altKey||C.ctrlKey||C.metaKey;if(C.key==="Tab"&&!M){const U=document.activeElement,B=C.shiftKey;if(C.target===w&&B){(L=u.current)==null||L.focus();return}const J=j({tabbingDirection:B?"backwards":"forwards"}),te=J.findIndex(X=>X===U);Gfe(J.slice(te+1))?C.preventDefault():B?(R=u.current)==null||R.focus():(q=p.current)==null||q.focus()}};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)}},[i,j]),e.jsxs(rxt,{ref:c,role:"region","aria-label":a.replace("{hotkey}",b),tabIndex:-1,style:{pointerEvents:_?void 0:"none"},children:[_&&e.jsx(T0e,{ref:u,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"forwards"});Gfe(w)}}),e.jsx(d2e.Slot,{scope:r,children:e.jsx(sn.ol,{tabIndex:-1,...o,ref:g})}),_&&e.jsx(T0e,{ref:p,onFocusFromOutsideViewport:()=>{const w=j({tabbingDirection:"backwards"});Gfe(w)}})]})});R$e.displayName=O$e;var F$e="ToastFocusProxy",T0e=k.forwardRef((t,s)=>{const{__scopeToast:r,onFocusFromOutsideViewport:n,...a}=t,o=vde(F$e,r);return e.jsx(yde,{"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()}})});T0e.displayName=F$e;var fO="Toast",gxt="toast.swipeStart",yxt="toast.swipeMove",vxt="toast.swipeCancel",bxt="toast.swipeEnd",z$e=k.forwardRef((t,s)=>{const{forceMount:r,open:n,defaultOpen:a,onOpenChange:o,...l}=t,[i,c]=rh({prop:n,defaultProp:a??!0,onChange:o,caller:fO});return e.jsx(Fd,{present:r||i,children:e.jsx(jxt,{open:i,...l,ref:s,onClose:()=>c(!1),onPause:gd(t.onPause),onResume:gd(t.onResume),onSwipeStart:Ir(t.onSwipeStart,u=>{u.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ir(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:Ir(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:Ir(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)})})})});z$e.displayName=fO;var[_xt,wxt]=L$e(fO,{onClose(){}}),jxt=k.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:b,..._}=t,j=vde(fO,r),[w,N]=k.useState(null),C=$a(s,X=>N(X)),M=k.useRef(null),I=k.useRef(null),L=a||j.duration,R=k.useRef(0),q=k.useRef(L),U=k.useRef(0),{onToastAdd:B,onToastRemove:V}=j,Y=gd(()=>{var ce;(w==null?void 0:w.contains(document.activeElement))&&((ce=j.viewport)==null||ce.focus()),l()}),J=k.useCallback(X=>{!X||X===1/0||(window.clearTimeout(U.current),R.current=new Date().getTime(),U.current=window.setTimeout(Y,X))},[Y]);k.useEffect(()=>{const X=j.viewport;if(X){const ce=()=>{J(q.current),u==null||u()},ne=()=>{const re=new Date().getTime()-R.current;q.current=q.current-re,window.clearTimeout(U.current),c==null||c()};return X.addEventListener(C0e,ne),X.addEventListener(M0e,ce),()=>{X.removeEventListener(C0e,ne),X.removeEventListener(M0e,ce)}}},[j.viewport,L,c,u,J]),k.useEffect(()=>{o&&!j.isClosePausedRef.current&&J(L)},[o,L,j.isClosePausedRef,J]),k.useEffect(()=>(B(),()=>V()),[B,V]);const te=k.useMemo(()=>w?W$e(w):null,[w]);return j.viewport?e.jsxs(e.Fragment,{children:[te&&e.jsx(Nxt,{__scopeToast:r,role:"status","aria-live":n==="foreground"?"assertive":"polite","aria-atomic":!0,children:te}),e.jsx(_xt,{scope:r,onClose:Y,children:gp.createPortal(e.jsx(d2e.ItemSlot,{scope:r,children:e.jsx(sxt,{asChild:!0,onEscapeKeyDown:Ir(i,()=>{j.isFocusedToastEscapeKeyDownRef.current||Y(),j.isFocusedToastEscapeKeyDownRef.current=!1}),children:e.jsx(sn.li,{role:"status","aria-live":"off","aria-atomic":!0,tabIndex:0,"data-state":o?"open":"closed","data-swipe-direction":j.swipeDirection,..._,ref:C,style:{userSelect:"none",touchAction:"none",...t.style},onKeyDown:Ir(t.onKeyDown,X=>{X.key==="Escape"&&(i==null||i(X.nativeEvent),X.nativeEvent.defaultPrevented||(j.isFocusedToastEscapeKeyDownRef.current=!0,Y()))}),onPointerDown:Ir(t.onPointerDown,X=>{X.button===0&&(M.current={x:X.clientX,y:X.clientY})}),onPointerMove:Ir(t.onPointerMove,X=>{if(!M.current)return;const ce=X.clientX-M.current.x,ne=X.clientY-M.current.y,re=!!I.current,le=["left","right"].includes(j.swipeDirection),pe=["left","up"].includes(j.swipeDirection)?Math.min:Math.max,xe=le?pe(0,ce):0,_e=le?0:pe(0,ne),fe=X.pointerType==="touch"?10:2,we={x:xe,y:_e},Ie={originalEvent:X,delta:we};re?(I.current=we,I7(yxt,f,Ie,{discrete:!1})):kAe(we,j.swipeDirection,fe)?(I.current=we,I7(gxt,p,Ie,{discrete:!1}),X.target.setPointerCapture(X.pointerId)):(Math.abs(ce)>fe||Math.abs(ne)>fe)&&(M.current=null)}),onPointerUp:Ir(t.onPointerUp,X=>{const ce=I.current,ne=X.target;if(ne.hasPointerCapture(X.pointerId)&&ne.releasePointerCapture(X.pointerId),I.current=null,M.current=null,ce){const re=X.currentTarget,le={originalEvent:X,delta:ce};kAe(ce,j.swipeDirection,j.swipeThreshold)?I7(bxt,b,le,{discrete:!0}):I7(vxt,g,le,{discrete:!0}),re.addEventListener("click",pe=>pe.preventDefault(),{once:!0})}})})})}),j.viewport)})]}):null}),Nxt=t=>{const{__scopeToast:s,children:r,...n}=t,a=vde(fO,s),[o,l]=k.useState(!1),[i,c]=k.useState(!1);return Cxt(()=>l(!0)),k.useEffect(()=>{const u=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(u)},[]),i?null:e.jsx(OA,{asChild:!0,children:e.jsx(yde,{...n,children:o&&e.jsxs(e.Fragment,{children:[a.label," ",r]})})})},kxt="ToastTitle",B$e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(sn.div,{...n,ref:s})});B$e.displayName=kxt;var Sxt="ToastDescription",$$e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t;return e.jsx(sn.div,{...n,ref:s})});$$e.displayName=Sxt;var q$e="ToastAction",U$e=k.forwardRef((t,s)=>{const{altText:r,...n}=t;return r.trim()?e.jsx(H$e,{altText:r,asChild:!0,children:e.jsx(u2e,{...n,ref:s})}):(console.error(`Invalid prop \`altText\` supplied to \`${q$e}\`. Expected non-empty \`string\`.`),null)});U$e.displayName=q$e;var V$e="ToastClose",u2e=k.forwardRef((t,s)=>{const{__scopeToast:r,...n}=t,a=wxt(V$e,r);return e.jsx(H$e,{asChild:!0,children:e.jsx(sn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,a.onClose)})})});u2e.displayName=V$e;var H$e=k.forwardRef((t,s)=>{const{__scopeToast:r,altText:n,...a}=t;return e.jsx(sn.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":n||void 0,...a,ref:s})});function W$e(t){const s=[];return Array.from(t.childNodes).forEach(n=>{if(n.nodeType===n.TEXT_NODE&&n.textContent&&s.push(n.textContent),Mxt(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(...W$e(n))}}),s}function I7(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?l2e(a,o):a.dispatchEvent(o)}var kAe=(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 Cxt(t=()=>{}){const s=gd(t);wd(()=>{let r=0,n=0;return r=window.requestAnimationFrame(()=>n=window.requestAnimationFrame(s)),()=>{window.cancelAnimationFrame(r),window.cancelAnimationFrame(n)}},[s])}function Mxt(t){return t.nodeType===t.ELEMENT_NODE}function Txt(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 Gfe(t){const s=document.activeElement;return t.some(r=>r===s?!0:(r.focus(),document.activeElement!==s))}var Axt=D$e,G$e=R$e,K$e=z$e,Z$e=B$e,Y$e=$$e,X$e=U$e,Q$e=u2e;function J$e(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,CAe=Vi,lC=(t,s)=>r=>{var n;if((s==null?void 0:s.variants)==null)return CAe(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=SAe(p)||SAe(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,...b}=p;return Object.entries(b).every(_=>{let[j,w]=_;return Array.isArray(w)?w.includes({...o,...i}[j]):{...o,...i}[j]===w})?[...u,f,g]:u},[]);return CAe(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 Ext=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),eqe=(...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 Pxt={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 tqe=k.forwardRef(({color:t="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:l,...i},c)=>k.createElement("svg",{ref:c,...Pxt,width:s,height:s,stroke:t,strokeWidth:n?Number(r)*24/Number(s):r,className:eqe("lucide",a),...i},[...l.map(([u,p])=>k.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=k.forwardRef(({className:n,...a},o)=>k.createElement(tqe,{ref:o,iconNode:s,className:eqe(`lucide-${Ext(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 g9=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 y9=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 v9=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 b9=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 jh=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 _9=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 w9=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 U2=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 V2=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 j9=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 H2=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 N9=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 k9=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 S9=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 C9=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 M9=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 T9=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 A9=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 E9=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 P9=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 I9=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 L9=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 D9=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 O9=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 R9=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 F9=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 z9=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 U4=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 V4=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 B9=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 $9=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 q9=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 U9=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 V9=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 H9=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 W9=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 G9=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 K9=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 Z9=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 Y9=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 X9=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 Q9=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 J9=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 eB=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 tB=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 sB=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 rB=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 nB=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 aB=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 iB=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 qI=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 oB=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 UI=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 lB=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 vM=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 cB=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 dB=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 uB=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 hB=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 mB=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 pB=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 fB=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 xB=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 gB=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 yB=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 vB=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 W2=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 bB=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 _B=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 wB=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 VI=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 jB=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 NB=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 kB=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 G2=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 K2=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 Hh=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 SB=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 CB=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 MB=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 ri=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 TB=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 Jv=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 AB=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 fi=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 EB=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 PB=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 Z2=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 yd=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 IB=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 LB=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 DB=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 Y2=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 HI=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 OB=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 RB=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 X2=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 Nu=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 FB=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 zB=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 BB=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 $B=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 qB=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 UB=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 bc=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 VB=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 Q2=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 HB=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 WB=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 GB=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 KB=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 J2=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 ZB=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 YB=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 XB=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 QB=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 JB=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 e$=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 t$=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 s$=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 r$=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 n$=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 a$=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 i$=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 o$=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 l$=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 c$=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 WI=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 d$=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 u$=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 h$=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 m$=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 p$=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 Nh=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 f$=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 x$=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 g$=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 y$=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 v$=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 b$=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 _$=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 w$=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 j$=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 H4=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 N$=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 Np=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 k$=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 S$=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 C$=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 M$=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 T$=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 A$=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 e1=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 E$=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 P$=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 Pm=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 ej=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 tj=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 I$=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 L$=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 D$=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 O$=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 R$=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 F$=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 z$=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 B$=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 $$=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 q$=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 U$=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 V$=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 H$=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 W$=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 G$=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 K$=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 W4=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 Z$=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 Y$=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 X$=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 Q$=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 J$=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 eq=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 tq=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 sj=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 sq=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 rq=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 nq=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 aq=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 iq=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 oq=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 lq=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 cq=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 dq=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 uq=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 kh=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 hq=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 mq=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 pq=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 fq=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 xq=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 gq=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 yq=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 vq=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 bq=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 _q=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 GI=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 wq=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 Nx=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 jq=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 Nq=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 kq=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 bM=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 Sq=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 Cq=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 rj=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 Mq=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 Tq=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 Aq=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 KI=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 Eq=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 Pq=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 Iq=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 Lq=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 Wh=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 Dq=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 Oq=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 Rq=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 Fq=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 zq=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 wa=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 G4=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 Bq=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 $q=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 qq=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 Uq=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 Vq=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 Sh=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 ZI=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 Hq=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 Wq=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 Gq=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 Kq=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 YI=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 XI=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 Zq=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 Dd=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 Yq=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 Xq=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 Qq=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 Jq=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 QI=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 eU=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 D_=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 tU=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 sU=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 rU=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 nU=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 aU=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 cn=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 iU=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 kx=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 oU=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 lU=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 cU=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 dU=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 uU=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 nj=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 hU=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 mU=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 _M=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 pU=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 fU=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 xU=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 gU=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 yU=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 vU=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 bU=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 _U=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 wU=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 jU=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 aj=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 ij=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 NU=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 kU=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 SU=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 oj=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 lj=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 cj=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 CU=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 dj=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 MU=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 Ro=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 TU=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 uj=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 AU=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 EU=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 hj=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 mj=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 PU=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 pj=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 fj=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 xj=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 IU=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 LU=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 fa=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 DU=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 OU=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 To=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 RU=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 FU=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 ll=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 xa=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 pf=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 zU=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 BU=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 $U=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 qU=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 UU=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 VU=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 HU=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 Sx=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 WU=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 GU=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 KU=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 ZU=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 YU=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 Nl=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 gj=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 yj=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 vj=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 bj=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 _j=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 wj=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 jj=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 Nj=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 xi=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 la=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 kj=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 Sj=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 Cj=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 Mj=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 XU=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 Tj=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 QU=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 JU=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 eV=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 tV=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 sV=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 rV=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 nV=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 Aj=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 Lv=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 Ej=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 aV=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 Pj=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 Ij=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 Lj=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 Dj=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 mp=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 Oj=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 Rj=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 Fj=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 iV=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 zj=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 Bj=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 $j=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 xc=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 vd=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 oV=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 lV=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 cV=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 wM=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 dV=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 O_=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 uV=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 hV=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 Uj=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 mV=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 pV=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 fV=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 xV=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 gV=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 yV=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 vV=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 bV=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 _V=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 wV=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 jV=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 NV=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 kV=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 SV=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 CV=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 MV=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 TV=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 AV=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 EV=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 mn=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 PV=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 IV=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 Vj=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 LV=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 DV=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 OV=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 RV=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 FV=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 zV=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 BV=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 $V=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 qV=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 UV=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 VV=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 HV=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 Hj=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 WV=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 GV=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 Gv=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 KV=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 Wj=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 K4=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 ZV=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 YV=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 Z4=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 XV=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 JI=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 Gj=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 Kj=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 QV=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 JV=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 eH=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 tH=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 sH=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 rH=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 nH=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 aH=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 iH=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 Zj=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 Y4=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 oH=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 lH=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 cH=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 dH=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 uH=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 hH=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 pH=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 fH=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 gi=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 xH=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 gH=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 yH=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 vH=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 bH=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 _H=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 wH=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 jH=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 NH=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 kH=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 SH=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 CH=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 Cx=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 MH=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 TH=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 AH=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 EH=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 Im=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 PH=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 IH=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 LH=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 DH=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 OH=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 RH=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 FH=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 eL=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 zH=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 BH=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 $H=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 qH=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 Yj=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 UH=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 VH=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 HH=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 WH=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 GH=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 KH=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 ZH=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 YH=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 XH=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 QH=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 JH=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 eW=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 tW=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 sW=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 rW=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 nW=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 aW=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 iW=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 oW=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 wc=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 lW=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 cW=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 t1=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 dW=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 Ci=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 uW=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 hW=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 mW=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 pW=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 fW=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 Zg=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 xW=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 gW=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 yW=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 vW=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 bW=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 _W=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 Xj=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 wW=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 jW=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 NW=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 jM=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 mx=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 px=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 kW=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 SW=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 CW=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 MW=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 TW=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 AW=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 tL=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 an=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 EW=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 qn=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 ku=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 PW=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 IW=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 LW=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 DW=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 OW=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 RW=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 FW=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 zW=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 BW=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 $W=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 Qj=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 qW=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 UW=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 VW=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 Jj=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 eN=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 tN=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 sN=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 HW=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 WW=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 GW=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 KW=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 ZW=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 rN=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 YW=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 XW=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 QW=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 JW=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 R_=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 eG=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 tG=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 sG=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 rG=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 nG=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 aG=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 iG=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 oG=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 lG=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 cG=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 dG=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 nN=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 aN=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 uG=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 hG=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 mG=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 pG=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 fG=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 xG=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 gG=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 s1=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 sL=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 yG=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 vG=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 En=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 bG=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 _G=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 wG=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 jG=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 NG=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 kG=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 SG=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 CG=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 MG=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 TG=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 AG=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 NM=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 EG=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 xu=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 PG=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 Yg=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 IG=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 LG=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 DG=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 OG=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 RG=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 FG=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 zG=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 BG=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 r1=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 $G=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 Qu=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 qG=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 UG=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 VG=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 F_=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 HG=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 WG=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 rL=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 GG=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 KG=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 Vg=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 ZG=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 YG=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 XG=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 QG=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 JG=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 eK=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 tK=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 sK=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 rK=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 iN=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 nK=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 aK=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 iK=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 oK=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 lK=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 cK=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 dK=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 uK=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 hK=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 pK=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 Lm=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 fK=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 oN=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 xK=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 gK=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 yK=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 vK=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 bK=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 _K=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 wK=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 jK=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 NK=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 kK=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 SK=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 CK=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 MK=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 TK=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 AK=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 EK=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 PK=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 IK=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 LK=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 DK=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 OK=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 RK=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 FK=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 zK=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 BK=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 $K=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 qK=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 UK=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 VK=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 X4=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 No=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 HK=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 WK=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 lN=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 GK=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 KK=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 ZK=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 YK=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 XK=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 QK=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 JK=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 eZ=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 tZ=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 sZ=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 rZ=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 nZ=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 aZ=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 iZ=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 oZ=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 lZ=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 cZ=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 Su=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 dZ=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 uZ=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 Gh=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 hZ=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 cN=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 pZ=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 dN=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 nx=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 fZ=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 Ju=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 xZ=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 gZ=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 yZ=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 vZ=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 bZ=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 _Z=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 wZ=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 uN=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 jZ=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 NZ=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 nL=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 aL=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 kZ=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 SZ=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 iL=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 CZ=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 z_=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 MZ=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 TZ=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 kM=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 SM=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 oL=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 AZ=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 EZ=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 PZ=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 IZ=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 LZ=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 DZ=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 OZ=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 RZ=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 FZ=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 zZ=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 BZ=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 ii=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 $Z=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 qZ=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 UZ=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 CM=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 VZ=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 HZ=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 WZ=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 GZ=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 KZ=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 ZZ=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 YZ=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 Sn=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 hN=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 mN=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 XZ=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 QZ=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 JZ=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 eY=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 tY=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 n1=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 sY=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 rY=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 fl=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 nY=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 aY=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 iY=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 pN=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 fN=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 oY=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 lY=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 lL=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 cY=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 Cu=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 Q4=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 dY=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 uY=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 hY=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 u0=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 J4=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 pY=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 fY=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 xY=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 gY=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 yY=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 vY=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 bY=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 _Y=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 wY=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 jY=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 NY=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 kY=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 SY=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 CY=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 xN=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 MY=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 TY=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 AY=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 EY=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 PY=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 IY=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 MM=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 eS=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 LY=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 DY=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 OY=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 tS=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 RY=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 FY=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 zY=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 BY=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 $Y=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 TM=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 AM=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 qY=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 UY=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 B_=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 VY=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 cl=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 zo=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 HY=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 WY=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 GY=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 KY=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 ZY=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 YY=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 XY=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 h0=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 QY=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 JY=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 eX=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 tX=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 sX=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 rX=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 nX=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 Ch=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 ws=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 aX=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 iX=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 oX=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 lX=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 cX=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 gN=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 dX=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 yN=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 Mh=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 EM=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 sS=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 uX=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 hX=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 mX=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 pX=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 fX=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 xX=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 gX=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 cL=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 yX=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 vX=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 bX=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 dL=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 dr=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 _X=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 wX=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 jX=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 NX=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 kX=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 SX=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 CX=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 MX=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 TX=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 AX=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 EX=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 PX=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 Ba=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 IX=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 PM=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 LX=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 DX=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 rS=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 a1=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 OX=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 Kh=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 RX=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 FX=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 IM=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 zX=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 BX=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 $X=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 LM=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 qX=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 UX=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 VX=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 uL=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 HX=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 WX=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 GX=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 zc=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 KX=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 ZX=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 YX=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 XX=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 QX=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 JX=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 hL=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 eQ=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 DM=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 tQ=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 sQ=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 rQ=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 nQ=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 aQ=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 io=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 iQ=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 oQ=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 vN=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 pL=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 lQ=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 cQ=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 dQ=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 uQ=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 hQ=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 mQ=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 pQ=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 fQ=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 m0=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 xQ=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 gQ=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 yQ=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 vQ=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 bQ=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 _Q=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 wQ=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 jQ=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 NQ=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 kQ=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 nS=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 SQ=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 aS=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 CQ=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 MQ=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 TQ=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 AQ=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 EQ=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 PQ=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 IQ=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 Xg=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 bh=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 LQ=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 bN=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 DQ=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 OQ=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 RQ=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 FQ=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 zQ=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 BQ=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 $Q=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 qQ=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 UQ=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 VQ=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 HQ=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 WQ=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 GQ=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 KQ=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 ZQ=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 YQ=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 XQ=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 QQ=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 JQ=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 eJ=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 tJ=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 sJ=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 i1=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 rJ=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 nJ=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 aJ=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 iJ=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 oJ=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 lJ=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 cJ=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 dJ=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 uJ=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 Dv=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 hJ=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 _N=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 wN=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 mJ=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 pJ=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 fJ=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 xJ=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 gJ=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 yJ=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 vJ=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 bJ=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 _J=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 wJ=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 jJ=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 NJ=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 Cl=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 kJ=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 SJ=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 jN=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 CJ=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 sc=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 MJ=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 NN=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 TJ=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 AJ=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 kN=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 SN=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 CN=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 MN=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 EJ=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 TN=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 PJ=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 IJ=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 LJ=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 AN=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 DJ=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 OJ=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 RJ=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 FJ=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 Ov=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 iS=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 zJ=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 BJ=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 tu=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 Dm=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 $J=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 qJ=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 Rv=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 UJ=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 $_=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 Qy=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 VJ=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 HJ=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 WJ=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 Da=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 GJ=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 OM=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 KJ=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 ZJ=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 YJ=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 XJ=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 QJ=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 JJ=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 eee=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 tee=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 Un=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 see=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 ree=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 nee=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 aee=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 iee=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 oee=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 lee=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 cee=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 dee=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 uee=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 hee=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 fL=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 mee=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 pee=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 fee=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 xee=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 gee=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 rl=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 yee=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 EN=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 xL=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 vee=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 bee=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 _ee=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 wee=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 jee=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 Nee=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 kee=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 See=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 Cee=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 gL=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 Qg=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 Mee=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 yL=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 Tee=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 Aee=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 Eee=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 Pee=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 o1=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 U_=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 Iee=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 Lee=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 Dee=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 Oee=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 Ree=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 Fee=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 l1=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 zee=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 Bee=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 $ee=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 qee=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 Uee=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 Vee=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 Hee=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 Wee=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 Gee=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 Kee=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 Zee=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 Yee=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 Xee=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 Qee=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 PN=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 Jee=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 ete=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 tte=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 ste=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 rte=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 oS=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 nte=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 RM=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 ate=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 ite=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 ote=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 lte=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 cte=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 dte=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 vL=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 ute=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 hte=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 mte=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 bL=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 pte=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 fte=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 p0=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 xte=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 gte=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 IN=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 yte=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 c1=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 vte=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 _L=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 bte=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 _te=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 wte=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 LN=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 DN=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 jte=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 Nte=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 d1=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 kte=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 Ste=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 Cte=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 Mte=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 Tte=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 Ate=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 Ete=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 Pte=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 ed=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 ON=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 wL=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 Ite=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 Lte=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 Dte=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 Ote=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 Rte=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 Fte=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 zte=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 Bte=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 $te=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 qte=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 Ute=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 Vte=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 Hte=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 Wte=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 Gte=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 Kte=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 Zte=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 Yte=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 Xte=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 jL=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 hn=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 Qte=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 RN=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 Jte=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 Rn=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 ese=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 tse=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 sse=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 rse=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 nse=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 ase=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 NL=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 Yo=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 ise=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 bd=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 kL=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 ose=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 lse=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 cse=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 dse=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 SL=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 use=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 hse=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 mse=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 pse=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 fse=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 xse=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 FN=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 Th=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 gse=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 yse=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 vse=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 f0=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 bse=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 yp=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 _se=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 wse=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 jse=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 Nse=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 lS=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 kse=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 Sse=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 Cse=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 Mse=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 Tse=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 Ase=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 Ese=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 Pse=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 Ise=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 Lse=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 Dse=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 Ose=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 Rse=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 Fse=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 zse=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 Bse=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 FM=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 zN=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 $se=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 qse=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 u1=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 Use=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 Vse=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 Hse=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 r0=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 Wse=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 Gse=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 Kse=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 Zse=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 Yse=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 un=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 Xse=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 Qse=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 Jse=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 ere=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 tre=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 sre=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 rre=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 nre=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 BN=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 $N=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 UN=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 VN=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 HN=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 WN=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 GN=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 KN=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 ZN=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 YN=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 XN=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 QN=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 JN=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 ek=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 qy=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 Fv=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 tk=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 sk=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 rk=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 nk=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 ak=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 ik=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 are=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 ire=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 ok=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 lk=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 ck=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 dk=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 uk=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 hk=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 mk=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 pk=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 fk=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 xk=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 gk=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 yk=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 vk=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 bk=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 _k=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 dd=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 wk=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 jk=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 Nk=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 kk=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 Sk=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 Ck=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 ore=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 Mk=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 Tk=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 Ak=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 Ek=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 Pk=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 lre=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 cre=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 Ik=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 Lk=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 Dk=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 Ok=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 x0=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 dre=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 ure=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 hre=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 mre=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 pre=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 fre=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 xre=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 gre=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 yre=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 vre=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 zM=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 bre=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 _re=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 CL=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 wre=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 jre=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 Nre=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 kre=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 Sre=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 h1=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 Cre=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 Mre=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 Tre=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 Are=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 Ere=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 Pre=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 Ire=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 Lre=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 Dre=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 BM=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 Ore=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 Rre=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 Fre=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 zre=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 Bre=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 $re=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 $M=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 qre=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 Ure=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 Vre=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 Om=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 Hre=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 Wre=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 Gre=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 Kre=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 Zre=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 Yre=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 Xre=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 Rm=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 Qre=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 Jre=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 ene=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 tne=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 Rk=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 sne=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 rne=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 nne=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 ane=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 ine=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 one=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 Fk=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 lne=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 cne=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 dne=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 une=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 ML=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 TL=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 eh=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 hne=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 mne=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 pne=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 fne=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 xne=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 gne=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 AL=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 yne=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 vne=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 bne=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 _ne=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 wne=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 jne=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 Nne=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 kne=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 Sne=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 Cne=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 Mne=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 Tne=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 Ane=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 Ene=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 Pne=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 Ine=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 Lne=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 Dne=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 One=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 zk=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 Rne=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 Fne=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 Bk=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 m1=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 zne=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 Bne=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 cS=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 $ne=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 Ol=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 Gu=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 qne=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 Une=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 xo=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 EL=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 Vne=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 Hne=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 $k=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 Wne=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 Gne=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 Kne=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 Zne=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 Yne=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 Xne=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 Qne=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 PL=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 Jne=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 eae=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 dS=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 tae=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 sae=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 rae=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 nae=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 uS=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 aae=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 oi=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 iae=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 V_=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 IL=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 LL=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 oae=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 rc=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 Uk=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 Vk=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 Hk=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 lae=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 Wk=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 cae=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 Gk=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 Kk=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 dae=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 uae=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 to=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 Zk=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 mr=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 Yk=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 Xk=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 hae=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 qM=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 mae=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 pae=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 fae=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 xae=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 gae=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 yae=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 vae=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 bae=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 _ae=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 wae=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 jae=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 Nae=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 kae=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 Sae=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 Cae=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 Mae=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 Tae=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 Qk=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 DL=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 Aae=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 zv=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 Eae=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 Pae=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 Iae=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 Lae=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 OL=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 Dae=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 Oae=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 Rae=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 Fae=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 zae=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 Bae=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 $ae=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 qae=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 Uae=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 Vae=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 Hae=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 Wae=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 Gae=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 Kae=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 Zae=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 Yae=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 Xae=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 Qae=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 Jae=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 eie=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 Jg=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 Or=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 tie=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 sie=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 Fm=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 H_=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 UM=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 Ixt=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:g9,AArrowUp:y9,ALargeSmall:v9,Accessibility:b9,Activity:jh,AirVent:_9,Airplay:w9,AlarmClock:N9,AlarmClockCheck:U2,AlarmClockMinus:V2,AlarmClockOff:j9,AlarmClockPlus:H2,AlarmSmoke:k9,Album:S9,AlignCenter:q4,AlignCenterHorizontal:C9,AlignCenterVertical:M9,AlignEndHorizontal:T9,AlignEndVertical:A9,AlignHorizontalDistributeCenter:E9,AlignHorizontalDistributeEnd:P9,AlignHorizontalDistributeStart:I9,AlignHorizontalJustifyCenter:L9,AlignHorizontalJustifyEnd:D9,AlignHorizontalJustifyStart:O9,AlignHorizontalSpaceAround:R9,AlignHorizontalSpaceBetween:F9,AlignJustify:z9,AlignLeft:U4,AlignRight:V4,AlignStartHorizontal:B9,AlignStartVertical:$9,AlignVerticalDistributeCenter:q9,AlignVerticalDistributeEnd:U9,AlignVerticalDistributeStart:V9,AlignVerticalJustifyCenter:H9,AlignVerticalJustifyEnd:W9,AlignVerticalJustifyStart:G9,AlignVerticalSpaceAround:K9,AlignVerticalSpaceBetween:Z9,Ambulance:Y9,Ampersand:X9,Ampersands:Q9,Amphora:J9,Anchor:eB,Angry:tB,Annoyed:sB,Antenna:rB,Anvil:nB,Aperture:aB,AppWindow:qI,AppWindowMac:iB,Apple:oB,Archive:vM,ArchiveRestore:UI,ArchiveX:lB,Armchair:cB,ArrowBigDown:uB,ArrowBigDownDash:dB,ArrowBigLeft:mB,ArrowBigLeftDash:hB,ArrowBigRight:fB,ArrowBigRightDash:pB,ArrowBigUp:gB,ArrowBigUpDash:xB,ArrowDown:Hh,ArrowDown01:yB,ArrowDown10:vB,ArrowDownAZ:W2,ArrowDownFromLine:bB,ArrowDownLeft:_B,ArrowDownNarrowWide:wB,ArrowDownRight:VI,ArrowDownToDot:jB,ArrowDownToLine:NB,ArrowDownUp:kB,ArrowDownWideNarrow:G2,ArrowDownZA:K2,ArrowLeft:ri,ArrowLeftFromLine:SB,ArrowLeftRight:CB,ArrowLeftToLine:MB,ArrowRight:fi,ArrowRightFromLine:TB,ArrowRightLeft:Jv,ArrowRightToLine:AB,ArrowUp:Nu,ArrowUp01:EB,ArrowUp10:PB,ArrowUpAZ:Z2,ArrowUpDown:yd,ArrowUpFromDot:IB,ArrowUpFromLine:LB,ArrowUpLeft:DB,ArrowUpNarrowWide:Y2,ArrowUpRight:HI,ArrowUpToLine:OB,ArrowUpWideNarrow:RB,ArrowUpZA:X2,ArrowsUpFromLine:FB,Asterisk:zB,AtSign:BB,Atom:$B,AudioLines:qB,AudioWaveform:UB,Award:bc,Axe:VB,Axis3d:Q2,Baby:HB,Backpack:WB,Badge:l$,BadgeAlert:GB,BadgeCent:KB,BadgeCheck:J2,BadgeDollarSign:ZB,BadgeEuro:YB,BadgeHelp:XB,BadgeIndianRupee:QB,BadgeInfo:JB,BadgeJapaneseYen:e$,BadgeMinus:t$,BadgePercent:s$,BadgePlus:r$,BadgePoundSterling:n$,BadgeRussianRuble:a$,BadgeSwissFranc:i$,BadgeX:o$,BaggageClaim:c$,Ban:WI,Banana:d$,Bandage:u$,Banknote:h$,Barcode:m$,Baseline:p$,Bath:Nh,Battery:b$,BatteryCharging:f$,BatteryFull:x$,BatteryLow:g$,BatteryMedium:y$,BatteryWarning:v$,Beaker:_$,Bean:j$,BeanOff:w$,Bed:Np,BedDouble:H4,BedSingle:N$,Beef:k$,Beer:C$,BeerOff:S$,Bell:Pm,BellDot:M$,BellElectric:T$,BellMinus:A$,BellOff:e1,BellPlus:E$,BellRing:P$,BetweenHorizontalEnd:ej,BetweenHorizontalStart:tj,BetweenVerticalEnd:I$,BetweenVerticalStart:L$,BicepsFlexed:D$,Bike:O$,Binary:R$,Binoculars:F$,Biohazard:z$,Bird:B$,Bitcoin:$$,Blend:q$,Blinds:U$,Blocks:V$,Bluetooth:K$,BluetoothConnected:H$,BluetoothOff:W$,BluetoothSearching:G$,Bold:W4,Bolt:Z$,Bomb:Y$,Bone:X$,Book:vq,BookA:Q$,BookAudio:J$,BookCheck:eq,BookCopy:tq,BookDashed:sj,BookDown:sq,BookHeadphones:rq,BookHeart:nq,BookImage:aq,BookKey:iq,BookLock:oq,BookMarked:lq,BookMinus:cq,BookOpen:kh,BookOpenCheck:dq,BookOpenText:uq,BookPlus:hq,BookText:mq,BookType:pq,BookUp:xq,BookUp2:fq,BookUser:gq,BookX:yq,Bookmark:Nx,BookmarkCheck:bq,BookmarkMinus:_q,BookmarkPlus:GI,BookmarkX:wq,BoomBox:jq,Bot:bM,BotMessageSquare:Nq,BotOff:kq,Box:Sq,Boxes:Cq,Braces:rj,Brackets:Mq,Brain:KI,BrainCircuit:Tq,BrainCog:Aq,BrickWall:Eq,Briefcase:Wh,BriefcaseBusiness:Pq,BriefcaseConveyorBelt:Iq,BriefcaseMedical:Lq,BringToFront:Dq,Brush:Oq,Bug:zq,BugOff:Rq,BugPlay:Fq,Building:G4,Building2:wa,Bus:$q,BusFront:Bq,Cable:Uq,CableCar:qq,Cake:Sh,CakeSlice:Vq,Calculator:ZI,Calendar:cn,Calendar1:Hq,CalendarArrowDown:Wq,CalendarArrowUp:Gq,CalendarCheck:YI,CalendarCheck2:Kq,CalendarClock:XI,CalendarCog:Zq,CalendarDays:Dd,CalendarFold:Yq,CalendarHeart:Xq,CalendarMinus:Jq,CalendarMinus2:Qq,CalendarOff:QI,CalendarPlus:D_,CalendarPlus2:eU,CalendarRange:tU,CalendarSearch:sU,CalendarSync:rU,CalendarX:aU,CalendarX2:nU,Camera:kx,CameraOff:iU,Candy:cU,CandyCane:oU,CandyOff:lU,Cannabis:dU,Captions:nj,CaptionsOff:uU,Car:_M,CarFront:hU,CarTaxiFront:mU,Caravan:pU,Carrot:fU,CaseLower:xU,CaseSensitive:gU,CaseUpper:yU,CassetteTape:vU,Cast:bU,Castle:_U,Cat:wU,Cctv:jU,ChartArea:aj,ChartBar:oj,ChartBarBig:ij,ChartBarDecreasing:NU,ChartBarIncreasing:kU,ChartBarStacked:SU,ChartCandlestick:lj,ChartColumn:Ro,ChartColumnBig:cj,ChartColumnDecreasing:CU,ChartColumnIncreasing:dj,ChartColumnStacked:MU,ChartGantt:TU,ChartLine:uj,ChartNetwork:AU,ChartNoAxesColumn:mj,ChartNoAxesColumnDecreasing:EU,ChartNoAxesColumnIncreasing:hj,ChartNoAxesCombined:PU,ChartNoAxesGantt:pj,ChartPie:fj,ChartScatter:xj,ChartSpline:IU,Check:fa,CheckCheck:LU,ChefHat:DU,Cherry:OU,ChevronDown:To,ChevronFirst:RU,ChevronLast:FU,ChevronLeft:ll,ChevronRight:xa,ChevronUp:pf,ChevronsDown:BU,ChevronsDownUp:zU,ChevronsLeft:UU,ChevronsLeftRight:qU,ChevronsLeftRightEllipsis:$U,ChevronsRight:HU,ChevronsRightLeft:VU,ChevronsUp:WU,ChevronsUpDown:Sx,Chrome:GU,Church:KU,Cigarette:YU,CigaretteOff:ZU,Circle:vd,CircleAlert:Nl,CircleArrowDown:gj,CircleArrowLeft:yj,CircleArrowOutDownLeft:vj,CircleArrowOutDownRight:bj,CircleArrowOutUpLeft:_j,CircleArrowOutUpRight:wj,CircleArrowRight:jj,CircleArrowUp:Nj,CircleCheck:la,CircleCheckBig:xi,CircleChevronDown:kj,CircleChevronLeft:Sj,CircleChevronRight:Cj,CircleChevronUp:Mj,CircleDashed:XU,CircleDivide:Tj,CircleDollarSign:QU,CircleDot:eV,CircleDotDashed:JU,CircleEllipsis:tV,CircleEqual:sV,CircleFadingArrowUp:rV,CircleFadingPlus:nV,CircleGauge:Aj,CircleHelp:Lv,CircleMinus:Ej,CircleOff:aV,CircleParking:Ij,CircleParkingOff:Pj,CirclePause:Lj,CirclePercent:Dj,CirclePlay:mp,CirclePlus:Oj,CirclePower:Rj,CircleSlash:iV,CircleSlash2:Fj,CircleStop:zj,CircleUser:$j,CircleUserRound:Bj,CircleX:xc,CircuitBoard:oV,Citrus:lV,Clapperboard:cV,Clipboard:xV,ClipboardCheck:wM,ClipboardCopy:dV,ClipboardList:O_,ClipboardMinus:uV,ClipboardPaste:hV,ClipboardPen:Uj,ClipboardPenLine:qj,ClipboardPlus:mV,ClipboardType:pV,ClipboardX:fV,Clock:mn,Clock1:gV,Clock10:yV,Clock11:vV,Clock12:bV,Clock2:_V,Clock3:wV,Clock4:jV,Clock5:NV,Clock6:kV,Clock7:SV,Clock8:CV,Clock9:MV,ClockAlert:TV,ClockArrowDown:AV,ClockArrowUp:EV,Cloud:WV,CloudAlert:PV,CloudCog:IV,CloudDownload:Vj,CloudDrizzle:LV,CloudFog:DV,CloudHail:OV,CloudLightning:RV,CloudMoon:zV,CloudMoonRain:FV,CloudOff:BV,CloudRain:qV,CloudRainWind:$V,CloudSnow:UV,CloudSun:HV,CloudSunRain:VV,CloudUpload:Hj,Cloudy:GV,Clover:Gv,Club:KV,Code:K4,CodeXml:Wj,Codepen:ZV,Codesandbox:YV,Coffee:Z4,Cog:XV,Coins:JI,Columns2:Gj,Columns3:Kj,Columns4:QV,Combine:JV,Command:eH,Compass:tH,Component:sH,Computer:rH,ConciergeBell:nH,Cone:aH,Construction:iH,Contact:Y4,ContactRound:Zj,Container:oH,Contrast:lH,Cookie:cH,CookingPot:dH,Copy:gi,CopyCheck:uH,CopyMinus:hH,CopyPlus:mH,CopySlash:pH,CopyX:fH,Copyleft:xH,Copyright:gH,CornerDownLeft:yH,CornerDownRight:vH,CornerLeftDown:bH,CornerLeftUp:_H,CornerRightDown:wH,CornerRightUp:jH,CornerUpLeft:NH,CornerUpRight:kH,Cpu:SH,CreativeCommons:CH,CreditCard:Cx,Croissant:MH,Crop:TH,Cross:AH,Crosshair:EH,Crown:Im,Cuboid:PH,CupSoda:IH,Currency:LH,Cylinder:DH,Dam:OH,Database:eL,DatabaseBackup:RH,DatabaseZap:FH,Delete:zH,Dessert:BH,Diameter:$H,Diamond:VH,DiamondMinus:qH,DiamondPercent:Yj,DiamondPlus:UH,Dice1:HH,Dice2:WH,Dice3:GH,Dice4:KH,Dice5:ZH,Dice6:YH,Dices:XH,Diff:QH,Disc:sW,Disc2:JH,Disc3:eW,DiscAlbum:tW,Divide:rW,Dna:aW,DnaOff:nW,Dock:iW,Dog:oW,DollarSign:wc,Donut:lW,DoorClosed:cW,DoorOpen:t1,Dot:dW,Download:Ci,DraftingCompass:uW,Drama:hW,Dribbble:mW,Drill:pW,Droplet:fW,Droplets:Zg,Drum:xW,Drumstick:gW,Dumbbell:yW,Ear:bW,EarOff:vW,Earth:Xj,EarthLock:_W,Eclipse:wW,Egg:jM,EggFried:jW,EggOff:NW,Ellipsis:px,EllipsisVertical:mx,Equal:CW,EqualApproximately:kW,EqualNot:SW,Eraser:MW,EthernetPort:TW,Euro:AW,Expand:tL,ExternalLink:an,Eye:qn,EyeClosed:EW,EyeOff:kp,Facebook:ku,Factory:PW,Fan:IW,FastForward:LW,Feather:DW,Fence:OW,FerrisWheel:RW,Figma:FW,File:NM,FileArchive:zW,FileAudio:$W,FileAudio2:BW,FileAxis3d:Qj,FileBadge:UW,FileBadge2:qW,FileBox:VW,FileChartColumn:eN,FileChartColumnIncreasing:Jj,FileChartLine:tN,FileChartPie:sN,FileCheck:WW,FileCheck2:HW,FileClock:GW,FileCode:ZW,FileCode2:KW,FileCog:rN,FileDiff:YW,FileDigit:XW,FileDown:QW,FileHeart:JW,FileImage:R_,FileInput:eG,FileJson:sG,FileJson2:tG,FileKey:nG,FileKey2:rG,FileLock:iG,FileLock2:aG,FileMinus:lG,FileMinus2:oG,FileMusic:cG,FileOutput:dG,FilePen:aN,FilePenLine:nN,FilePlus:hG,FilePlus2:uG,FileQuestion:mG,FileScan:pG,FileSearch:xG,FileSearch2:fG,FileSliders:gG,FileSpreadsheet:s1,FileStack:sL,FileSymlink:yG,FileTerminal:vG,FileText:En,FileType:_G,FileType2:bG,FileUp:wG,FileUser:jG,FileVideo:kG,FileVideo2:NG,FileVolume:CG,FileVolume2:SG,FileWarning:MG,FileX:AG,FileX2:TG,Files:EG,Film:xu,Filter:Yg,FilterX:PG,Fingerprint:IG,FireExtinguisher:LG,Fish:RG,FishOff:DG,FishSymbol:OG,Flag:r1,FlagOff:FG,FlagTriangleLeft:zG,FlagTriangleRight:BG,Flame:Qu,FlameKindling:$G,Flashlight:UG,FlashlightOff:qG,FlaskConical:F_,FlaskConicalOff:VG,FlaskRound:HG,FlipHorizontal:rL,FlipHorizontal2:WG,FlipVertical:KG,FlipVertical2:GG,Flower:ZG,Flower2:Vg,Focus:YG,FoldHorizontal:XG,FoldVertical:QG,Folder:kK,FolderArchive:JG,FolderCheck:eK,FolderClock:tK,FolderClosed:sK,FolderCode:rK,FolderCog:iN,FolderDot:nK,FolderDown:aK,FolderGit:oK,FolderGit2:iK,FolderHeart:lK,FolderInput:cK,FolderKanban:dK,FolderKey:uK,FolderLock:hK,FolderMinus:mK,FolderOpen:Lm,FolderOpenDot:pK,FolderOutput:fK,FolderPen:oN,FolderPlus:xK,FolderRoot:gK,FolderSearch:vK,FolderSearch2:yK,FolderSymlink:bK,FolderSync:_K,FolderTree:wK,FolderUp:jK,FolderX:NK,Folders:SK,Footprints:CK,Forklift:MK,Forward:TK,Frame:AK,Framer:EK,Frown:PK,Fuel:IK,Fullscreen:LK,GalleryHorizontal:OK,GalleryHorizontalEnd:DK,GalleryThumbnails:RK,GalleryVertical:zK,GalleryVerticalEnd:FK,Gamepad:$K,Gamepad2:BK,Gauge:qK,Gavel:UK,Gem:VK,Ghost:X4,Gift:No,GitBranch:WK,GitBranchPlus:HK,GitCommitHorizontal:lN,GitCommitVertical:GK,GitCompare:ZK,GitCompareArrows:KK,GitFork:YK,GitGraph:XK,GitMerge:QK,GitPullRequest:nZ,GitPullRequestArrow:JK,GitPullRequestClosed:eZ,GitPullRequestCreate:sZ,GitPullRequestCreateArrow:tZ,GitPullRequestDraft:rZ,Github:aZ,Gitlab:iZ,GlassWater:oZ,Glasses:lZ,Globe:Su,GlobeLock:cZ,Goal:dZ,Grab:uZ,GraduationCap:Gh,Grape:hZ,Grid2x2:dN,Grid2x2Check:mZ,Grid2x2Plus:cN,Grid2x2X:pZ,Grid3x3:nx,Grip:xZ,GripHorizontal:fZ,GripVertical:Ju,Group:gZ,Guitar:yZ,Ham:vZ,Hammer:bZ,Hand:nL,HandCoins:_Z,HandHeart:wZ,HandHelping:uN,HandMetal:jZ,HandPlatter:NZ,Handshake:aL,HardDrive:iL,HardDriveDownload:kZ,HardDriveUpload:SZ,HardHat:CZ,Hash:z_,Haze:MZ,HdmiPort:TZ,Heading:IZ,Heading1:kM,Heading2:SM,Heading3:oL,Heading4:AZ,Heading5:EZ,Heading6:PZ,HeadphoneOff:LZ,Headphones:DZ,Headset:OZ,Heart:ii,HeartCrack:RZ,HeartHandshake:FZ,HeartOff:zZ,HeartPulse:BZ,Heater:$Z,Hexagon:qZ,Highlighter:UZ,History:CM,Hop:HZ,HopOff:VZ,Hospital:WZ,Hotel:GZ,Hourglass:KZ,House:Sn,HousePlug:ZZ,HousePlus:YZ,IceCreamBowl:hN,IceCreamCone:mN,IdCard:XZ,Image:fl,ImageDown:QZ,ImageMinus:JZ,ImageOff:eY,ImagePlay:tY,ImagePlus:n1,ImageUp:sY,ImageUpscale:rY,Images:nY,Import:aY,Inbox:iY,IndentDecrease:pN,IndentIncrease:fN,IndianRupee:oY,Infinity:lY,Info:lL,InspectionPanel:cY,Instagram:Cu,Italic:Q4,IterationCcw:dY,IterationCw:uY,JapaneseYen:hY,Joystick:mY,Kanban:u0,Key:Sp,KeyRound:J4,KeySquare:pY,Keyboard:gY,KeyboardMusic:fY,KeyboardOff:xY,Lamp:jY,LampCeiling:yY,LampDesk:vY,LampFloor:bY,LampWallDown:_Y,LampWallUp:wY,LandPlot:NY,Landmark:kY,Languages:SY,Laptop:MY,LaptopMinimal:xN,LaptopMinimalCheck:CY,Lasso:AY,LassoSelect:TY,Laugh:EY,Layers:MM,Layers2:PY,Layers3:IY,LayoutDashboard:eS,LayoutGrid:Cp,LayoutList:LY,LayoutPanelLeft:DY,LayoutPanelTop:OY,LayoutTemplate:tS,Leaf:RY,LeafyGreen:FY,Lectern:zY,LetterText:BY,Library:TM,LibraryBig:$Y,LifeBuoy:AM,Ligature:qY,Lightbulb:B_,LightbulbOff:UY,Link:zo,Link2:cl,Link2Off:VY,Linkedin:Mp,List:Ch,ListCheck:HY,ListChecks:WY,ListCollapse:GY,ListEnd:KY,ListFilter:ZY,ListMinus:YY,ListMusic:XY,ListOrdered:h0,ListPlus:QY,ListRestart:JY,ListStart:eX,ListTodo:tX,ListTree:sX,ListVideo:rX,ListX:nX,Loader:iX,LoaderCircle:ws,LoaderPinwheel:aX,Locate:cX,LocateFixed:oX,LocateOff:lX,Lock:Mh,LockKeyhole:dX,LockKeyholeOpen:gN,LockOpen:yN,LogIn:EM,LogOut:sS,Logs:uX,Lollipop:hX,Luggage:mX,Magnet:pX,Mail:dr,MailCheck:fX,MailMinus:xX,MailOpen:gX,MailPlus:cL,MailQuestion:yX,MailSearch:vX,MailWarning:bX,MailX:dL,Mailbox:_X,Mails:wX,Map:PM,MapPin:Ba,MapPinCheck:NX,MapPinCheckInside:jX,MapPinHouse:kX,MapPinMinus:CX,MapPinMinusInside:SX,MapPinOff:MX,MapPinPlus:AX,MapPinPlusInside:TX,MapPinX:PX,MapPinXInside:EX,MapPinned:IX,Martini:LX,Maximize:rS,Maximize2:DX,Medal:a1,Megaphone:Kh,MegaphoneOff:OX,Meh:RX,MemoryStick:FX,Menu:IM,Merge:zX,MessageCircle:zc,MessageCircleCode:BX,MessageCircleDashed:$X,MessageCircleHeart:LM,MessageCircleMore:qX,MessageCircleOff:UX,MessageCirclePlus:VX,MessageCircleQuestion:uL,MessageCircleReply:HX,MessageCircleWarning:WX,MessageCircleX:GX,MessageSquare:io,MessageSquareCode:KX,MessageSquareDashed:ZX,MessageSquareDiff:YX,MessageSquareDot:XX,MessageSquareHeart:QX,MessageSquareLock:JX,MessageSquareMore:hL,MessageSquareOff:eQ,MessageSquarePlus:DM,MessageSquareQuote:mL,MessageSquareReply:tQ,MessageSquareShare:sQ,MessageSquareText:rQ,MessageSquareWarning:nQ,MessageSquareX:aQ,MessagesSquare:iQ,Mic:pL,MicOff:oQ,MicVocal:vN,Microchip:lQ,Microscope:cQ,Microwave:dQ,Milestone:uQ,Milk:mQ,MilkOff:hQ,Minimize:fQ,Minimize2:pQ,Minus:m0,Monitor:aS,MonitorCheck:xQ,MonitorCog:gQ,MonitorDot:yQ,MonitorDown:vQ,MonitorOff:bQ,MonitorPause:_Q,MonitorPlay:wQ,MonitorSmartphone:jQ,MonitorSpeaker:NQ,MonitorStop:kQ,MonitorUp:nS,MonitorX:SQ,Moon:MQ,MoonStar:CQ,Mountain:AQ,MountainSnow:TQ,Mouse:LQ,MouseOff:EQ,MousePointer:bh,MousePointer2:PQ,MousePointerBan:IQ,MousePointerClick:Xg,Move:GQ,Move3d:bN,MoveDiagonal:OQ,MoveDiagonal2:DQ,MoveDown:zQ,MoveDownLeft:RQ,MoveDownRight:FQ,MoveHorizontal:BQ,MoveLeft:$Q,MoveRight:qQ,MoveUp:HQ,MoveUpLeft:UQ,MoveUpRight:VQ,MoveVertical:WQ,Music:XQ,Music2:KQ,Music3:ZQ,Music4:YQ,Navigation:tJ,Navigation2:JQ,Navigation2Off:QQ,NavigationOff:eJ,Network:sJ,Newspaper:i1,Nfc:rJ,Notebook:oJ,NotebookPen:nJ,NotebookTabs:aJ,NotebookText:iJ,NotepadText:cJ,NotepadTextDashed:lJ,Nut:uJ,NutOff:dJ,Octagon:mJ,OctagonAlert:Dv,OctagonMinus:hJ,OctagonPause:_N,OctagonX:wN,Omega:pJ,Option:fJ,Orbit:xJ,Origami:gJ,Package:Cl,Package2:yJ,PackageCheck:vJ,PackageMinus:bJ,PackageOpen:_J,PackagePlus:wJ,PackageSearch:jJ,PackageX:NJ,PaintBucket:kJ,PaintRoller:SJ,Paintbrush:CJ,PaintbrushVertical:jN,Palette:sc,PanelBottom:AJ,PanelBottomClose:MJ,PanelBottomDashed:NN,PanelBottomOpen:TJ,PanelLeft:MN,PanelLeftClose:kN,PanelLeftDashed:SN,PanelLeftOpen:CN,PanelRight:IJ,PanelRightClose:EJ,PanelRightDashed:TN,PanelRightOpen:PJ,PanelTop:OJ,PanelTopClose:LJ,PanelTopDashed:AN,PanelTopOpen:DJ,PanelsLeftBottom:RJ,PanelsRightBottom:FJ,PanelsTopLeft:Ov,Paperclip:iS,Parentheses:zJ,ParkingMeter:BJ,PartyPopper:tu,Pause:Dm,PawPrint:$J,PcCase:qJ,Pen:Qy,PenLine:Rv,PenOff:UJ,PenTool:$_,Pencil:Da,PencilLine:VJ,PencilOff:HJ,PencilRuler:WJ,Pentagon:GJ,Percent:OM,PersonStanding:KJ,PhilippinePeso:ZJ,Phone:Un,PhoneCall:YJ,PhoneForwarded:XJ,PhoneIncoming:QJ,PhoneMissed:JJ,PhoneOff:eee,PhoneOutgoing:tee,Pi:see,Piano:ree,Pickaxe:nee,PictureInPicture:iee,PictureInPicture2:aee,PiggyBank:oee,Pilcrow:dee,PilcrowLeft:lee,PilcrowRight:cee,Pill:hee,PillBottle:uee,Pin:q_,PinOff:fL,Pipette:mee,Pizza:pee,Plane:gee,PlaneLanding:fee,PlaneTakeoff:xee,Play:rl,Plug:xL,Plug2:yee,PlugZap:EN,Plus:qs,Pocket:bee,PocketKnife:vee,Podcast:_ee,Pointer:jee,PointerOff:wee,Popcorn:Nee,Popsicle:kee,PoundSterling:See,Power:gL,PowerOff:Cee,Presentation:Qg,Printer:yL,PrinterCheck:Mee,Projector:Tee,Proportions:Aee,Puzzle:Eee,Pyramid:Pee,QrCode:o1,Quote:U_,Rabbit:Iee,Radar:Lee,Radiation:Dee,Radical:Oee,Radio:l1,RadioReceiver:Ree,RadioTower:Fee,Radius:zee,RailSymbol:Bee,Rainbow:$ee,Rat:qee,Ratio:Uee,Receipt:Qee,ReceiptCent:Vee,ReceiptEuro:Hee,ReceiptIndianRupee:Wee,ReceiptJapaneseYen:Gee,ReceiptPoundSterling:Kee,ReceiptRussianRuble:Zee,ReceiptSwissFranc:Yee,ReceiptText:Xee,RectangleEllipsis:PN,RectangleHorizontal:Jee,RectangleVertical:ete,Recycle:tte,Redo:oS,Redo2:ste,RedoDot:rte,RefreshCcw:RM,RefreshCcwDot:nte,RefreshCw:Wo,RefreshCwOff:ate,Refrigerator:ite,Regex:ote,RemoveFormatting:lte,Repeat:vL,Repeat1:cte,Repeat2:dte,Replace:hte,ReplaceAll:ute,Reply:bL,ReplyAll:mte,Rewind:pte,Ribbon:fte,Rocket:p0,RockingChair:xte,RollerCoaster:gte,Rotate3d:IN,RotateCcw:c1,RotateCcwSquare:yte,RotateCw:_L,RotateCwSquare:vte,Route:_te,RouteOff:bte,Router:wte,Rows2:LN,Rows3:DN,Rows4:jte,Rss:Nte,Ruler:d1,RussianRuble:kte,Sailboat:Ste,Salad:Cte,Sandwich:Mte,Satellite:Ate,SatelliteDish:Tte,Save:ed,SaveAll:Ete,SaveOff:Pte,Scale:wL,Scale3d:ON,Scaling:Ite,Scan:$te,ScanBarcode:Lte,ScanEye:Dte,ScanFace:Ote,ScanLine:Rte,ScanQrCode:Fte,ScanSearch:zte,ScanText:Bte,School:qte,Scissors:Vte,ScissorsLineDashed:Ute,ScreenShare:Wte,ScreenShareOff:Hte,Scroll:Kte,ScrollText:Gte,Search:hn,SearchCheck:Zte,SearchCode:Yte,SearchSlash:Xte,SearchX:jL,Section:Qte,Send:Rn,SendHorizontal:RN,SendToBack:Jte,SeparatorHorizontal:ese,SeparatorVertical:tse,Server:ase,ServerCog:sse,ServerCrash:rse,ServerOff:nse,Settings:Yo,Settings2:NL,Shapes:ise,Share:kL,Share2:bd,Sheet:ose,Shell:lse,Shield:Th,ShieldAlert:cse,ShieldBan:dse,ShieldCheck:SL,ShieldEllipsis:use,ShieldHalf:hse,ShieldMinus:mse,ShieldOff:pse,ShieldPlus:fse,ShieldQuestion:xse,ShieldX:FN,Ship:yse,ShipWheel:gse,Shirt:vse,ShoppingBag:f0,ShoppingBasket:bse,ShoppingCart:yp,Shovel:_se,ShowerHead:wse,Shrink:jse,Shrub:Nse,Shuffle:lS,Sigma:kse,Signal:Ase,SignalHigh:Sse,SignalLow:Cse,SignalMedium:Mse,SignalZero:Tse,Signature:Ese,Signpost:Ise,SignpostBig:Pse,Siren:Lse,SkipBack:Dse,SkipForward:Ose,Skull:Rse,Slack:Fse,Slash:zse,Slice:Bse,SlidersHorizontal:FM,SlidersVertical:zN,Smartphone:u1,SmartphoneCharging:$se,SmartphoneNfc:qse,Smile:Vse,SmilePlus:Use,Snail:Hse,Snowflake:r0,Sofa:Wse,Soup:Gse,Space:Kse,Spade:Zse,Sparkle:Yse,Sparkles:un,Speaker:Xse,Speech:Qse,SpellCheck:ere,SpellCheck2:Jse,Spline:tre,Split:sre,SprayCan:rre,Sprout:nre,Square:x0,SquareActivity:BN,SquareArrowDown:UN,SquareArrowDownLeft:$N,SquareArrowDownRight:qN,SquareArrowLeft:VN,SquareArrowOutDownLeft:HN,SquareArrowOutDownRight:WN,SquareArrowOutUpLeft:GN,SquareArrowOutUpRight:KN,SquareArrowRight:ZN,SquareArrowUp:QN,SquareArrowUpLeft:YN,SquareArrowUpRight:XN,SquareAsterisk:JN,SquareBottomDashedScissors:ek,SquareChartGantt:qy,SquareCheck:tk,SquareCheckBig:Fv,SquareChevronDown:sk,SquareChevronLeft:rk,SquareChevronRight:nk,SquareChevronUp:ak,SquareCode:ik,SquareDashed:ck,SquareDashedBottom:ire,SquareDashedBottomCode:are,SquareDashedKanban:ok,SquareDashedMousePointer:lk,SquareDivide:dk,SquareDot:uk,SquareEqual:hk,SquareFunction:mk,SquareKanban:pk,SquareLibrary:fk,SquareM:xk,SquareMenu:gk,SquareMinus:yk,SquareMousePointer:vk,SquareParking:_k,SquareParkingOff:bk,SquarePen:dd,SquarePercent:wk,SquarePi:jk,SquarePilcrow:Nk,SquarePlay:kk,SquarePlus:Sk,SquarePower:Ck,SquareRadical:ore,SquareScissors:Mk,SquareSigma:Tk,SquareSlash:Ak,SquareSplitHorizontal:Ek,SquareSplitVertical:Pk,SquareSquare:lre,SquareStack:cre,SquareTerminal:Ik,SquareUser:Dk,SquareUserRound:Lk,SquareX:Ok,Squircle:dre,Squirrel:ure,Stamp:hre,Star:Jn,StarHalf:mre,StarOff:pre,StepBack:fre,StepForward:xre,Stethoscope:gre,Sticker:yre,StickyNote:vre,Store:zM,StretchHorizontal:bre,StretchVertical:_re,Strikethrough:CL,Subscript:wre,Sun:h1,SunDim:jre,SunMedium:Nre,SunMoon:kre,SunSnow:Sre,Sunrise:Cre,Sunset:Mre,Superscript:Tre,SwatchBook:Are,SwissFranc:Ere,SwitchCamera:Pre,Sword:Ire,Swords:Lre,Syringe:Dre,Table:$M,Table2:BM,TableCellsMerge:Ore,TableCellsSplit:Rre,TableColumnsSplit:Fre,TableOfContents:zre,TableProperties:Bre,TableRowsSplit:$re,Tablet:Ure,TabletSmartphone:qre,Tablets:Vre,Tag:Om,Tags:Hre,Tally1:Wre,Tally2:Gre,Tally3:Kre,Tally4:Zre,Tally5:Yre,Tangent:Xre,Target:Rm,Telescope:Qre,Tent:ene,TentTree:Jre,Terminal:tne,TestTube:sne,TestTubeDiagonal:Rk,TestTubes:rne,Text:lne,TextCursor:ane,TextCursorInput:nne,TextQuote:ine,TextSearch:one,TextSelect:Fk,Theater:cne,Thermometer:ML,ThermometerSnowflake:dne,ThermometerSun:une,ThumbsDown:TL,ThumbsUp:eh,Ticket:AL,TicketCheck:hne,TicketMinus:mne,TicketPercent:pne,TicketPlus:fne,TicketSlash:xne,TicketX:gne,Tickets:vne,TicketsPlane:yne,Timer:wne,TimerOff:bne,TimerReset:_ne,ToggleLeft:jne,ToggleRight:Nne,Toilet:kne,Tornado:Sne,Torus:Cne,Touchpad:Tne,TouchpadOff:Mne,TowerControl:Ane,ToyBrick:Ene,Tractor:Pne,TrafficCone:Ine,TrainFront:Dne,TrainFrontTunnel:Lne,TrainTrack:One,TramFront:zk,Trash:Rne,Trash2:Nr,TreeDeciduous:Fne,TreePalm:Bk,TreePine:m1,Trees:zne,Trello:Bne,TrendingDown:cS,TrendingUp:Ol,TrendingUpDown:$ne,Triangle:Une,TriangleAlert:Gu,TriangleRight:qne,Trophy:xo,Truck:EL,Turtle:Vne,Tv:Wne,TvMinimal:$k,TvMinimalPlay:Hne,Twitch:Gne,Twitter:Kne,Type:Yne,TypeOutline:Zne,Umbrella:Qne,UmbrellaOff:Xne,Underline:PL,Undo:dS,Undo2:Jne,UndoDot:eae,UnfoldHorizontal:tae,UnfoldVertical:sae,Ungroup:rae,University:qk,Unlink:uS,Unlink2:nae,Unplug:aae,Upload:oi,Usb:iae,User:to,UserCheck:V_,UserCog:IL,UserMinus:LL,UserPen:oae,UserPlus:rc,UserRound:Kk,UserRoundCheck:Uk,UserRoundCog:Vk,UserRoundMinus:Hk,UserRoundPen:lae,UserRoundPlus:Wk,UserRoundSearch:cae,UserRoundX:Gk,UserSearch:dae,UserX:uae,Users:mr,UsersRound:Zk,Utensils:Xk,UtensilsCrossed:Yk,UtilityPole:hae,Variable:qM,Vault:mae,Vegan:pae,VenetianMask:fae,Vibrate:gae,VibrateOff:xae,Video:Cn,VideoOff:yae,Videotape:vae,View:bae,Voicemail:_ae,Volleyball:wae,Volume:Cae,Volume1:jae,Volume2:Nae,VolumeOff:kae,VolumeX:Sae,Vote:Mae,Wallet:DL,WalletCards:Tae,WalletMinimal:Qk,Wallpaper:Aae,Wand:Eae,WandSparkles:zv,Warehouse:Pae,WashingMachine:Iae,Watch:Lae,Waves:OL,Waypoints:Dae,Webcam:Oae,Webhook:Fae,WebhookOff:Rae,Weight:zae,Wheat:$ae,WheatOff:Bae,WholeWord:qae,Wifi:Gae,WifiHigh:Uae,WifiLow:Vae,WifiOff:Hae,WifiZero:Wae,Wind:Zae,WindArrowDown:Kae,Wine:Xae,WineOff:Yae,Workflow:Qae,Worm:Jae,WrapText:eie,Wrench:Jg,X:Or,Youtube:tie,Zap:Fm,ZapOff:sie,ZoomIn:H_,ZoomOut:UM},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 h2e=Object.freeze(Object.defineProperty({__proto__:null,AArrowDown:g9,AArrowDownIcon:g9,AArrowUp:y9,AArrowUpIcon:y9,ALargeSmall:v9,ALargeSmallIcon:v9,Accessibility:b9,AccessibilityIcon:b9,Activity:jh,ActivityIcon:jh,ActivitySquare:BN,ActivitySquareIcon:BN,AirVent:_9,AirVentIcon:_9,Airplay:w9,AirplayIcon:w9,AlarmCheck:U2,AlarmCheckIcon:U2,AlarmClock:N9,AlarmClockCheck:U2,AlarmClockCheckIcon:U2,AlarmClockIcon:N9,AlarmClockMinus:V2,AlarmClockMinusIcon:V2,AlarmClockOff:j9,AlarmClockOffIcon:j9,AlarmClockPlus:H2,AlarmClockPlusIcon:H2,AlarmMinus:V2,AlarmMinusIcon:V2,AlarmPlus:H2,AlarmPlusIcon:H2,AlarmSmoke:k9,AlarmSmokeIcon:k9,Album:S9,AlbumIcon:S9,AlertCircle:Nl,AlertCircleIcon:Nl,AlertOctagon:Dv,AlertOctagonIcon:Dv,AlertTriangle:Gu,AlertTriangleIcon:Gu,AlignCenter:q4,AlignCenterHorizontal:C9,AlignCenterHorizontalIcon:C9,AlignCenterIcon:q4,AlignCenterVertical:M9,AlignCenterVerticalIcon:M9,AlignEndHorizontal:T9,AlignEndHorizontalIcon:T9,AlignEndVertical:A9,AlignEndVerticalIcon:A9,AlignHorizontalDistributeCenter:E9,AlignHorizontalDistributeCenterIcon:E9,AlignHorizontalDistributeEnd:P9,AlignHorizontalDistributeEndIcon:P9,AlignHorizontalDistributeStart:I9,AlignHorizontalDistributeStartIcon:I9,AlignHorizontalJustifyCenter:L9,AlignHorizontalJustifyCenterIcon:L9,AlignHorizontalJustifyEnd:D9,AlignHorizontalJustifyEndIcon:D9,AlignHorizontalJustifyStart:O9,AlignHorizontalJustifyStartIcon:O9,AlignHorizontalSpaceAround:R9,AlignHorizontalSpaceAroundIcon:R9,AlignHorizontalSpaceBetween:F9,AlignHorizontalSpaceBetweenIcon:F9,AlignJustify:z9,AlignJustifyIcon:z9,AlignLeft:U4,AlignLeftIcon:U4,AlignRight:V4,AlignRightIcon:V4,AlignStartHorizontal:B9,AlignStartHorizontalIcon:B9,AlignStartVertical:$9,AlignStartVerticalIcon:$9,AlignVerticalDistributeCenter:q9,AlignVerticalDistributeCenterIcon:q9,AlignVerticalDistributeEnd:U9,AlignVerticalDistributeEndIcon:U9,AlignVerticalDistributeStart:V9,AlignVerticalDistributeStartIcon:V9,AlignVerticalJustifyCenter:H9,AlignVerticalJustifyCenterIcon:H9,AlignVerticalJustifyEnd:W9,AlignVerticalJustifyEndIcon:W9,AlignVerticalJustifyStart:G9,AlignVerticalJustifyStartIcon:G9,AlignVerticalSpaceAround:K9,AlignVerticalSpaceAroundIcon:K9,AlignVerticalSpaceBetween:Z9,AlignVerticalSpaceBetweenIcon:Z9,Ambulance:Y9,AmbulanceIcon:Y9,Ampersand:X9,AmpersandIcon:X9,Ampersands:Q9,AmpersandsIcon:Q9,Amphora:J9,AmphoraIcon:J9,Anchor:eB,AnchorIcon:eB,Angry:tB,AngryIcon:tB,Annoyed:sB,AnnoyedIcon:sB,Antenna:rB,AntennaIcon:rB,Anvil:nB,AnvilIcon:nB,Aperture:aB,ApertureIcon:aB,AppWindow:qI,AppWindowIcon:qI,AppWindowMac:iB,AppWindowMacIcon:iB,Apple:oB,AppleIcon:oB,Archive:vM,ArchiveIcon:vM,ArchiveRestore:UI,ArchiveRestoreIcon:UI,ArchiveX:lB,ArchiveXIcon:lB,AreaChart:aj,AreaChartIcon:aj,Armchair:cB,ArmchairIcon:cB,ArrowBigDown:uB,ArrowBigDownDash:dB,ArrowBigDownDashIcon:dB,ArrowBigDownIcon:uB,ArrowBigLeft:mB,ArrowBigLeftDash:hB,ArrowBigLeftDashIcon:hB,ArrowBigLeftIcon:mB,ArrowBigRight:fB,ArrowBigRightDash:pB,ArrowBigRightDashIcon:pB,ArrowBigRightIcon:fB,ArrowBigUp:gB,ArrowBigUpDash:xB,ArrowBigUpDashIcon:xB,ArrowBigUpIcon:gB,ArrowDown:Hh,ArrowDown01:yB,ArrowDown01Icon:yB,ArrowDown10:vB,ArrowDown10Icon:vB,ArrowDownAZ:W2,ArrowDownAZIcon:W2,ArrowDownAz:W2,ArrowDownAzIcon:W2,ArrowDownCircle:gj,ArrowDownCircleIcon:gj,ArrowDownFromLine:bB,ArrowDownFromLineIcon:bB,ArrowDownIcon:Hh,ArrowDownLeft:_B,ArrowDownLeftFromCircle:vj,ArrowDownLeftFromCircleIcon:vj,ArrowDownLeftFromSquare:HN,ArrowDownLeftFromSquareIcon:HN,ArrowDownLeftIcon:_B,ArrowDownLeftSquare:$N,ArrowDownLeftSquareIcon:$N,ArrowDownNarrowWide:wB,ArrowDownNarrowWideIcon:wB,ArrowDownRight:VI,ArrowDownRightFromCircle:bj,ArrowDownRightFromCircleIcon:bj,ArrowDownRightFromSquare:WN,ArrowDownRightFromSquareIcon:WN,ArrowDownRightIcon:VI,ArrowDownRightSquare:qN,ArrowDownRightSquareIcon:qN,ArrowDownSquare:UN,ArrowDownSquareIcon:UN,ArrowDownToDot:jB,ArrowDownToDotIcon:jB,ArrowDownToLine:NB,ArrowDownToLineIcon:NB,ArrowDownUp:kB,ArrowDownUpIcon:kB,ArrowDownWideNarrow:G2,ArrowDownWideNarrowIcon:G2,ArrowDownZA:K2,ArrowDownZAIcon:K2,ArrowDownZa:K2,ArrowDownZaIcon:K2,ArrowLeft:ri,ArrowLeftCircle:yj,ArrowLeftCircleIcon:yj,ArrowLeftFromLine:SB,ArrowLeftFromLineIcon:SB,ArrowLeftIcon:ri,ArrowLeftRight:CB,ArrowLeftRightIcon:CB,ArrowLeftSquare:VN,ArrowLeftSquareIcon:VN,ArrowLeftToLine:MB,ArrowLeftToLineIcon:MB,ArrowRight:fi,ArrowRightCircle:jj,ArrowRightCircleIcon:jj,ArrowRightFromLine:TB,ArrowRightFromLineIcon:TB,ArrowRightIcon:fi,ArrowRightLeft:Jv,ArrowRightLeftIcon:Jv,ArrowRightSquare:ZN,ArrowRightSquareIcon:ZN,ArrowRightToLine:AB,ArrowRightToLineIcon:AB,ArrowUp:Nu,ArrowUp01:EB,ArrowUp01Icon:EB,ArrowUp10:PB,ArrowUp10Icon:PB,ArrowUpAZ:Z2,ArrowUpAZIcon:Z2,ArrowUpAz:Z2,ArrowUpAzIcon:Z2,ArrowUpCircle:Nj,ArrowUpCircleIcon:Nj,ArrowUpDown:yd,ArrowUpDownIcon:yd,ArrowUpFromDot:IB,ArrowUpFromDotIcon:IB,ArrowUpFromLine:LB,ArrowUpFromLineIcon:LB,ArrowUpIcon:Nu,ArrowUpLeft:DB,ArrowUpLeftFromCircle:_j,ArrowUpLeftFromCircleIcon:_j,ArrowUpLeftFromSquare:GN,ArrowUpLeftFromSquareIcon:GN,ArrowUpLeftIcon:DB,ArrowUpLeftSquare:YN,ArrowUpLeftSquareIcon:YN,ArrowUpNarrowWide:Y2,ArrowUpNarrowWideIcon:Y2,ArrowUpRight:HI,ArrowUpRightFromCircle:wj,ArrowUpRightFromCircleIcon:wj,ArrowUpRightFromSquare:KN,ArrowUpRightFromSquareIcon:KN,ArrowUpRightIcon:HI,ArrowUpRightSquare:XN,ArrowUpRightSquareIcon:XN,ArrowUpSquare:QN,ArrowUpSquareIcon:QN,ArrowUpToLine:OB,ArrowUpToLineIcon:OB,ArrowUpWideNarrow:RB,ArrowUpWideNarrowIcon:RB,ArrowUpZA:X2,ArrowUpZAIcon:X2,ArrowUpZa:X2,ArrowUpZaIcon:X2,ArrowsUpFromLine:FB,ArrowsUpFromLineIcon:FB,Asterisk:zB,AsteriskIcon:zB,AsteriskSquare:JN,AsteriskSquareIcon:JN,AtSign:BB,AtSignIcon:BB,Atom:$B,AtomIcon:$B,AudioLines:qB,AudioLinesIcon:qB,AudioWaveform:UB,AudioWaveformIcon:UB,Award:bc,AwardIcon:bc,Axe:VB,AxeIcon:VB,Axis3D:Q2,Axis3DIcon:Q2,Axis3d:Q2,Axis3dIcon:Q2,Baby:HB,BabyIcon:HB,Backpack:WB,BackpackIcon:WB,Badge:l$,BadgeAlert:GB,BadgeAlertIcon:GB,BadgeCent:KB,BadgeCentIcon:KB,BadgeCheck:J2,BadgeCheckIcon:J2,BadgeDollarSign:ZB,BadgeDollarSignIcon:ZB,BadgeEuro:YB,BadgeEuroIcon:YB,BadgeHelp:XB,BadgeHelpIcon:XB,BadgeIcon:l$,BadgeIndianRupee:QB,BadgeIndianRupeeIcon:QB,BadgeInfo:JB,BadgeInfoIcon:JB,BadgeJapaneseYen:e$,BadgeJapaneseYenIcon:e$,BadgeMinus:t$,BadgeMinusIcon:t$,BadgePercent:s$,BadgePercentIcon:s$,BadgePlus:r$,BadgePlusIcon:r$,BadgePoundSterling:n$,BadgePoundSterlingIcon:n$,BadgeRussianRuble:a$,BadgeRussianRubleIcon:a$,BadgeSwissFranc:i$,BadgeSwissFrancIcon:i$,BadgeX:o$,BadgeXIcon:o$,BaggageClaim:c$,BaggageClaimIcon:c$,Ban:WI,BanIcon:WI,Banana:d$,BananaIcon:d$,Bandage:u$,BandageIcon:u$,Banknote:h$,BanknoteIcon:h$,BarChart:hj,BarChart2:mj,BarChart2Icon:mj,BarChart3:Ro,BarChart3Icon:Ro,BarChart4:dj,BarChart4Icon:dj,BarChartBig:cj,BarChartBigIcon:cj,BarChartHorizontal:oj,BarChartHorizontalBig:ij,BarChartHorizontalBigIcon:ij,BarChartHorizontalIcon:oj,BarChartIcon:hj,Barcode:m$,BarcodeIcon:m$,Baseline:p$,BaselineIcon:p$,Bath:Nh,BathIcon:Nh,Battery:b$,BatteryCharging:f$,BatteryChargingIcon:f$,BatteryFull:x$,BatteryFullIcon:x$,BatteryIcon:b$,BatteryLow:g$,BatteryLowIcon:g$,BatteryMedium:y$,BatteryMediumIcon:y$,BatteryWarning:v$,BatteryWarningIcon:v$,Beaker:_$,BeakerIcon:_$,Bean:j$,BeanIcon:j$,BeanOff:w$,BeanOffIcon:w$,Bed:Np,BedDouble:H4,BedDoubleIcon:H4,BedIcon:Np,BedSingle:N$,BedSingleIcon:N$,Beef:k$,BeefIcon:k$,Beer:C$,BeerIcon:C$,BeerOff:S$,BeerOffIcon:S$,Bell:Pm,BellDot:M$,BellDotIcon:M$,BellElectric:T$,BellElectricIcon:T$,BellIcon:Pm,BellMinus:A$,BellMinusIcon:A$,BellOff:e1,BellOffIcon:e1,BellPlus:E$,BellPlusIcon:E$,BellRing:P$,BellRingIcon:P$,BetweenHorizonalEnd:ej,BetweenHorizonalEndIcon:ej,BetweenHorizonalStart:tj,BetweenHorizonalStartIcon:tj,BetweenHorizontalEnd:ej,BetweenHorizontalEndIcon:ej,BetweenHorizontalStart:tj,BetweenHorizontalStartIcon:tj,BetweenVerticalEnd:I$,BetweenVerticalEndIcon:I$,BetweenVerticalStart:L$,BetweenVerticalStartIcon:L$,BicepsFlexed:D$,BicepsFlexedIcon:D$,Bike:O$,BikeIcon:O$,Binary:R$,BinaryIcon:R$,Binoculars:F$,BinocularsIcon:F$,Biohazard:z$,BiohazardIcon:z$,Bird:B$,BirdIcon:B$,Bitcoin:$$,BitcoinIcon:$$,Blend:q$,BlendIcon:q$,Blinds:U$,BlindsIcon:U$,Blocks:V$,BlocksIcon:V$,Bluetooth:K$,BluetoothConnected:H$,BluetoothConnectedIcon:H$,BluetoothIcon:K$,BluetoothOff:W$,BluetoothOffIcon:W$,BluetoothSearching:G$,BluetoothSearchingIcon:G$,Bold:W4,BoldIcon:W4,Bolt:Z$,BoltIcon:Z$,Bomb:Y$,BombIcon:Y$,Bone:X$,BoneIcon:X$,Book:vq,BookA:Q$,BookAIcon:Q$,BookAudio:J$,BookAudioIcon:J$,BookCheck:eq,BookCheckIcon:eq,BookCopy:tq,BookCopyIcon:tq,BookDashed:sj,BookDashedIcon:sj,BookDown:sq,BookDownIcon:sq,BookHeadphones:rq,BookHeadphonesIcon:rq,BookHeart:nq,BookHeartIcon:nq,BookIcon:vq,BookImage:aq,BookImageIcon:aq,BookKey:iq,BookKeyIcon:iq,BookLock:oq,BookLockIcon:oq,BookMarked:lq,BookMarkedIcon:lq,BookMinus:cq,BookMinusIcon:cq,BookOpen:kh,BookOpenCheck:dq,BookOpenCheckIcon:dq,BookOpenIcon:kh,BookOpenText:uq,BookOpenTextIcon:uq,BookPlus:hq,BookPlusIcon:hq,BookTemplate:sj,BookTemplateIcon:sj,BookText:mq,BookTextIcon:mq,BookType:pq,BookTypeIcon:pq,BookUp:xq,BookUp2:fq,BookUp2Icon:fq,BookUpIcon:xq,BookUser:gq,BookUserIcon:gq,BookX:yq,BookXIcon:yq,Bookmark:Nx,BookmarkCheck:bq,BookmarkCheckIcon:bq,BookmarkIcon:Nx,BookmarkMinus:_q,BookmarkMinusIcon:_q,BookmarkPlus:GI,BookmarkPlusIcon:GI,BookmarkX:wq,BookmarkXIcon:wq,BoomBox:jq,BoomBoxIcon:jq,Bot:bM,BotIcon:bM,BotMessageSquare:Nq,BotMessageSquareIcon:Nq,BotOff:kq,BotOffIcon:kq,Box:Sq,BoxIcon:Sq,BoxSelect:ck,BoxSelectIcon:ck,Boxes:Cq,BoxesIcon:Cq,Braces:rj,BracesIcon:rj,Brackets:Mq,BracketsIcon:Mq,Brain:KI,BrainCircuit:Tq,BrainCircuitIcon:Tq,BrainCog:Aq,BrainCogIcon:Aq,BrainIcon:KI,BrickWall:Eq,BrickWallIcon:Eq,Briefcase:Wh,BriefcaseBusiness:Pq,BriefcaseBusinessIcon:Pq,BriefcaseConveyorBelt:Iq,BriefcaseConveyorBeltIcon:Iq,BriefcaseIcon:Wh,BriefcaseMedical:Lq,BriefcaseMedicalIcon:Lq,BringToFront:Dq,BringToFrontIcon:Dq,Brush:Oq,BrushIcon:Oq,Bug:zq,BugIcon:zq,BugOff:Rq,BugOffIcon:Rq,BugPlay:Fq,BugPlayIcon:Fq,Building:G4,Building2:wa,Building2Icon:wa,BuildingIcon:G4,Bus:$q,BusFront:Bq,BusFrontIcon:Bq,BusIcon:$q,Cable:Uq,CableCar:qq,CableCarIcon:qq,CableIcon:Uq,Cake:Sh,CakeIcon:Sh,CakeSlice:Vq,CakeSliceIcon:Vq,Calculator:ZI,CalculatorIcon:ZI,Calendar:cn,Calendar1:Hq,Calendar1Icon:Hq,CalendarArrowDown:Wq,CalendarArrowDownIcon:Wq,CalendarArrowUp:Gq,CalendarArrowUpIcon:Gq,CalendarCheck:YI,CalendarCheck2:Kq,CalendarCheck2Icon:Kq,CalendarCheckIcon:YI,CalendarClock:XI,CalendarClockIcon:XI,CalendarCog:Zq,CalendarCogIcon:Zq,CalendarDays:Dd,CalendarDaysIcon:Dd,CalendarFold:Yq,CalendarFoldIcon:Yq,CalendarHeart:Xq,CalendarHeartIcon:Xq,CalendarIcon:cn,CalendarMinus:Jq,CalendarMinus2:Qq,CalendarMinus2Icon:Qq,CalendarMinusIcon:Jq,CalendarOff:QI,CalendarOffIcon:QI,CalendarPlus:D_,CalendarPlus2:eU,CalendarPlus2Icon:eU,CalendarPlusIcon:D_,CalendarRange:tU,CalendarRangeIcon:tU,CalendarSearch:sU,CalendarSearchIcon:sU,CalendarSync:rU,CalendarSyncIcon:rU,CalendarX:aU,CalendarX2:nU,CalendarX2Icon:nU,CalendarXIcon:aU,Camera:kx,CameraIcon:kx,CameraOff:iU,CameraOffIcon:iU,CandlestickChart:lj,CandlestickChartIcon:lj,Candy:cU,CandyCane:oU,CandyCaneIcon:oU,CandyIcon:cU,CandyOff:lU,CandyOffIcon:lU,Cannabis:dU,CannabisIcon:dU,Captions:nj,CaptionsIcon:nj,CaptionsOff:uU,CaptionsOffIcon:uU,Car:_M,CarFront:hU,CarFrontIcon:hU,CarIcon:_M,CarTaxiFront:mU,CarTaxiFrontIcon:mU,Caravan:pU,CaravanIcon:pU,Carrot:fU,CarrotIcon:fU,CaseLower:xU,CaseLowerIcon:xU,CaseSensitive:gU,CaseSensitiveIcon:gU,CaseUpper:yU,CaseUpperIcon:yU,CassetteTape:vU,CassetteTapeIcon:vU,Cast:bU,CastIcon:bU,Castle:_U,CastleIcon:_U,Cat:wU,CatIcon:wU,Cctv:jU,CctvIcon:jU,ChartArea:aj,ChartAreaIcon:aj,ChartBar:oj,ChartBarBig:ij,ChartBarBigIcon:ij,ChartBarDecreasing:NU,ChartBarDecreasingIcon:NU,ChartBarIcon:oj,ChartBarIncreasing:kU,ChartBarIncreasingIcon:kU,ChartBarStacked:SU,ChartBarStackedIcon:SU,ChartCandlestick:lj,ChartCandlestickIcon:lj,ChartColumn:Ro,ChartColumnBig:cj,ChartColumnBigIcon:cj,ChartColumnDecreasing:CU,ChartColumnDecreasingIcon:CU,ChartColumnIcon:Ro,ChartColumnIncreasing:dj,ChartColumnIncreasingIcon:dj,ChartColumnStacked:MU,ChartColumnStackedIcon:MU,ChartGantt:TU,ChartGanttIcon:TU,ChartLine:uj,ChartLineIcon:uj,ChartNetwork:AU,ChartNetworkIcon:AU,ChartNoAxesColumn:mj,ChartNoAxesColumnDecreasing:EU,ChartNoAxesColumnDecreasingIcon:EU,ChartNoAxesColumnIcon:mj,ChartNoAxesColumnIncreasing:hj,ChartNoAxesColumnIncreasingIcon:hj,ChartNoAxesCombined:PU,ChartNoAxesCombinedIcon:PU,ChartNoAxesGantt:pj,ChartNoAxesGanttIcon:pj,ChartPie:fj,ChartPieIcon:fj,ChartScatter:xj,ChartScatterIcon:xj,ChartSpline:IU,ChartSplineIcon:IU,Check:fa,CheckCheck:LU,CheckCheckIcon:LU,CheckCircle:xi,CheckCircle2:la,CheckCircle2Icon:la,CheckCircleIcon:xi,CheckIcon:fa,CheckSquare:Fv,CheckSquare2:tk,CheckSquare2Icon:tk,CheckSquareIcon:Fv,ChefHat:DU,ChefHatIcon:DU,Cherry:OU,CherryIcon:OU,ChevronDown:To,ChevronDownCircle:kj,ChevronDownCircleIcon:kj,ChevronDownIcon:To,ChevronDownSquare:sk,ChevronDownSquareIcon:sk,ChevronFirst:RU,ChevronFirstIcon:RU,ChevronLast:FU,ChevronLastIcon:FU,ChevronLeft:ll,ChevronLeftCircle:Sj,ChevronLeftCircleIcon:Sj,ChevronLeftIcon:ll,ChevronLeftSquare:rk,ChevronLeftSquareIcon:rk,ChevronRight:xa,ChevronRightCircle:Cj,ChevronRightCircleIcon:Cj,ChevronRightIcon:xa,ChevronRightSquare:nk,ChevronRightSquareIcon:nk,ChevronUp:pf,ChevronUpCircle:Mj,ChevronUpCircleIcon:Mj,ChevronUpIcon:pf,ChevronUpSquare:ak,ChevronUpSquareIcon:ak,ChevronsDown:BU,ChevronsDownIcon:BU,ChevronsDownUp:zU,ChevronsDownUpIcon:zU,ChevronsLeft:UU,ChevronsLeftIcon:UU,ChevronsLeftRight:qU,ChevronsLeftRightEllipsis:$U,ChevronsLeftRightEllipsisIcon:$U,ChevronsLeftRightIcon:qU,ChevronsRight:HU,ChevronsRightIcon:HU,ChevronsRightLeft:VU,ChevronsRightLeftIcon:VU,ChevronsUp:WU,ChevronsUpDown:Sx,ChevronsUpDownIcon:Sx,ChevronsUpIcon:WU,Chrome:GU,ChromeIcon:GU,Church:KU,ChurchIcon:KU,Cigarette:YU,CigaretteIcon:YU,CigaretteOff:ZU,CigaretteOffIcon:ZU,Circle:vd,CircleAlert:Nl,CircleAlertIcon:Nl,CircleArrowDown:gj,CircleArrowDownIcon:gj,CircleArrowLeft:yj,CircleArrowLeftIcon:yj,CircleArrowOutDownLeft:vj,CircleArrowOutDownLeftIcon:vj,CircleArrowOutDownRight:bj,CircleArrowOutDownRightIcon:bj,CircleArrowOutUpLeft:_j,CircleArrowOutUpLeftIcon:_j,CircleArrowOutUpRight:wj,CircleArrowOutUpRightIcon:wj,CircleArrowRight:jj,CircleArrowRightIcon:jj,CircleArrowUp:Nj,CircleArrowUpIcon:Nj,CircleCheck:la,CircleCheckBig:xi,CircleCheckBigIcon:xi,CircleCheckIcon:la,CircleChevronDown:kj,CircleChevronDownIcon:kj,CircleChevronLeft:Sj,CircleChevronLeftIcon:Sj,CircleChevronRight:Cj,CircleChevronRightIcon:Cj,CircleChevronUp:Mj,CircleChevronUpIcon:Mj,CircleDashed:XU,CircleDashedIcon:XU,CircleDivide:Tj,CircleDivideIcon:Tj,CircleDollarSign:QU,CircleDollarSignIcon:QU,CircleDot:eV,CircleDotDashed:JU,CircleDotDashedIcon:JU,CircleDotIcon:eV,CircleEllipsis:tV,CircleEllipsisIcon:tV,CircleEqual:sV,CircleEqualIcon:sV,CircleFadingArrowUp:rV,CircleFadingArrowUpIcon:rV,CircleFadingPlus:nV,CircleFadingPlusIcon:nV,CircleGauge:Aj,CircleGaugeIcon:Aj,CircleHelp:Lv,CircleHelpIcon:Lv,CircleIcon:vd,CircleMinus:Ej,CircleMinusIcon:Ej,CircleOff:aV,CircleOffIcon:aV,CircleParking:Ij,CircleParkingIcon:Ij,CircleParkingOff:Pj,CircleParkingOffIcon:Pj,CirclePause:Lj,CirclePauseIcon:Lj,CirclePercent:Dj,CirclePercentIcon:Dj,CirclePlay:mp,CirclePlayIcon:mp,CirclePlus:Oj,CirclePlusIcon:Oj,CirclePower:Rj,CirclePowerIcon:Rj,CircleSlash:iV,CircleSlash2:Fj,CircleSlash2Icon:Fj,CircleSlashIcon:iV,CircleSlashed:Fj,CircleSlashedIcon:Fj,CircleStop:zj,CircleStopIcon:zj,CircleUser:$j,CircleUserIcon:$j,CircleUserRound:Bj,CircleUserRoundIcon:Bj,CircleX:xc,CircleXIcon:xc,CircuitBoard:oV,CircuitBoardIcon:oV,Citrus:lV,CitrusIcon:lV,Clapperboard:cV,ClapperboardIcon:cV,Clipboard:xV,ClipboardCheck:wM,ClipboardCheckIcon:wM,ClipboardCopy:dV,ClipboardCopyIcon:dV,ClipboardEdit:Uj,ClipboardEditIcon:Uj,ClipboardIcon:xV,ClipboardList:O_,ClipboardListIcon:O_,ClipboardMinus:uV,ClipboardMinusIcon:uV,ClipboardPaste:hV,ClipboardPasteIcon:hV,ClipboardPen:Uj,ClipboardPenIcon:Uj,ClipboardPenLine:qj,ClipboardPenLineIcon:qj,ClipboardPlus:mV,ClipboardPlusIcon:mV,ClipboardSignature:qj,ClipboardSignatureIcon:qj,ClipboardType:pV,ClipboardTypeIcon:pV,ClipboardX:fV,ClipboardXIcon:fV,Clock:mn,Clock1:gV,Clock10:yV,Clock10Icon:yV,Clock11:vV,Clock11Icon:vV,Clock12:bV,Clock12Icon:bV,Clock1Icon:gV,Clock2:_V,Clock2Icon:_V,Clock3:wV,Clock3Icon:wV,Clock4:jV,Clock4Icon:jV,Clock5:NV,Clock5Icon:NV,Clock6:kV,Clock6Icon:kV,Clock7:SV,Clock7Icon:SV,Clock8:CV,Clock8Icon:CV,Clock9:MV,Clock9Icon:MV,ClockAlert:TV,ClockAlertIcon:TV,ClockArrowDown:AV,ClockArrowDownIcon:AV,ClockArrowUp:EV,ClockArrowUpIcon:EV,ClockIcon:mn,Cloud:WV,CloudAlert:PV,CloudAlertIcon:PV,CloudCog:IV,CloudCogIcon:IV,CloudDownload:Vj,CloudDownloadIcon:Vj,CloudDrizzle:LV,CloudDrizzleIcon:LV,CloudFog:DV,CloudFogIcon:DV,CloudHail:OV,CloudHailIcon:OV,CloudIcon:WV,CloudLightning:RV,CloudLightningIcon:RV,CloudMoon:zV,CloudMoonIcon:zV,CloudMoonRain:FV,CloudMoonRainIcon:FV,CloudOff:BV,CloudOffIcon:BV,CloudRain:qV,CloudRainIcon:qV,CloudRainWind:$V,CloudRainWindIcon:$V,CloudSnow:UV,CloudSnowIcon:UV,CloudSun:HV,CloudSunIcon:HV,CloudSunRain:VV,CloudSunRainIcon:VV,CloudUpload:Hj,CloudUploadIcon:Hj,Cloudy:GV,CloudyIcon:GV,Clover:Gv,CloverIcon:Gv,Club:KV,ClubIcon:KV,Code:K4,Code2:Wj,Code2Icon:Wj,CodeIcon:K4,CodeSquare:ik,CodeSquareIcon:ik,CodeXml:Wj,CodeXmlIcon:Wj,Codepen:ZV,CodepenIcon:ZV,Codesandbox:YV,CodesandboxIcon:YV,Coffee:Z4,CoffeeIcon:Z4,Cog:XV,CogIcon:XV,Coins:JI,CoinsIcon:JI,Columns:Gj,Columns2:Gj,Columns2Icon:Gj,Columns3:Kj,Columns3Icon:Kj,Columns4:QV,Columns4Icon:QV,ColumnsIcon:Gj,Combine:JV,CombineIcon:JV,Command:eH,CommandIcon:eH,Compass:tH,CompassIcon:tH,Component:sH,ComponentIcon:sH,Computer:rH,ComputerIcon:rH,ConciergeBell:nH,ConciergeBellIcon:nH,Cone:aH,ConeIcon:aH,Construction:iH,ConstructionIcon:iH,Contact:Y4,Contact2:Zj,Contact2Icon:Zj,ContactIcon:Y4,ContactRound:Zj,ContactRoundIcon:Zj,Container:oH,ContainerIcon:oH,Contrast:lH,ContrastIcon:lH,Cookie:cH,CookieIcon:cH,CookingPot:dH,CookingPotIcon:dH,Copy:gi,CopyCheck:uH,CopyCheckIcon:uH,CopyIcon:gi,CopyMinus:hH,CopyMinusIcon:hH,CopyPlus:mH,CopyPlusIcon:mH,CopySlash:pH,CopySlashIcon:pH,CopyX:fH,CopyXIcon:fH,Copyleft:xH,CopyleftIcon:xH,Copyright:gH,CopyrightIcon:gH,CornerDownLeft:yH,CornerDownLeftIcon:yH,CornerDownRight:vH,CornerDownRightIcon:vH,CornerLeftDown:bH,CornerLeftDownIcon:bH,CornerLeftUp:_H,CornerLeftUpIcon:_H,CornerRightDown:wH,CornerRightDownIcon:wH,CornerRightUp:jH,CornerRightUpIcon:jH,CornerUpLeft:NH,CornerUpLeftIcon:NH,CornerUpRight:kH,CornerUpRightIcon:kH,Cpu:SH,CpuIcon:SH,CreativeCommons:CH,CreativeCommonsIcon:CH,CreditCard:Cx,CreditCardIcon:Cx,Croissant:MH,CroissantIcon:MH,Crop:TH,CropIcon:TH,Cross:AH,CrossIcon:AH,Crosshair:EH,CrosshairIcon:EH,Crown:Im,CrownIcon:Im,Cuboid:PH,CuboidIcon:PH,CupSoda:IH,CupSodaIcon:IH,CurlyBraces:rj,CurlyBracesIcon:rj,Currency:LH,CurrencyIcon:LH,Cylinder:DH,CylinderIcon:DH,Dam:OH,DamIcon:OH,Database:eL,DatabaseBackup:RH,DatabaseBackupIcon:RH,DatabaseIcon:eL,DatabaseZap:FH,DatabaseZapIcon:FH,Delete:zH,DeleteIcon:zH,Dessert:BH,DessertIcon:BH,Diameter:$H,DiameterIcon:$H,Diamond:VH,DiamondIcon:VH,DiamondMinus:qH,DiamondMinusIcon:qH,DiamondPercent:Yj,DiamondPercentIcon:Yj,DiamondPlus:UH,DiamondPlusIcon:UH,Dice1:HH,Dice1Icon:HH,Dice2:WH,Dice2Icon:WH,Dice3:GH,Dice3Icon:GH,Dice4:KH,Dice4Icon:KH,Dice5:ZH,Dice5Icon:ZH,Dice6:YH,Dice6Icon:YH,Dices:XH,DicesIcon:XH,Diff:QH,DiffIcon:QH,Disc:sW,Disc2:JH,Disc2Icon:JH,Disc3:eW,Disc3Icon:eW,DiscAlbum:tW,DiscAlbumIcon:tW,DiscIcon:sW,Divide:rW,DivideCircle:Tj,DivideCircleIcon:Tj,DivideIcon:rW,DivideSquare:dk,DivideSquareIcon:dk,Dna:aW,DnaIcon:aW,DnaOff:nW,DnaOffIcon:nW,Dock:iW,DockIcon:iW,Dog:oW,DogIcon:oW,DollarSign:wc,DollarSignIcon:wc,Donut:lW,DonutIcon:lW,DoorClosed:cW,DoorClosedIcon:cW,DoorOpen:t1,DoorOpenIcon:t1,Dot:dW,DotIcon:dW,DotSquare:uk,DotSquareIcon:uk,Download:Ci,DownloadCloud:Vj,DownloadCloudIcon:Vj,DownloadIcon:Ci,DraftingCompass:uW,DraftingCompassIcon:uW,Drama:hW,DramaIcon:hW,Dribbble:mW,DribbbleIcon:mW,Drill:pW,DrillIcon:pW,Droplet:fW,DropletIcon:fW,Droplets:Zg,DropletsIcon:Zg,Drum:xW,DrumIcon:xW,Drumstick:gW,DrumstickIcon:gW,Dumbbell:yW,DumbbellIcon:yW,Ear:bW,EarIcon:bW,EarOff:vW,EarOffIcon:vW,Earth:Xj,EarthIcon:Xj,EarthLock:_W,EarthLockIcon:_W,Eclipse:wW,EclipseIcon:wW,Edit:dd,Edit2:Qy,Edit2Icon:Qy,Edit3:Rv,Edit3Icon:Rv,EditIcon:dd,Egg:jM,EggFried:jW,EggFriedIcon:jW,EggIcon:jM,EggOff:NW,EggOffIcon:NW,Ellipsis:px,EllipsisIcon:px,EllipsisVertical:mx,EllipsisVerticalIcon:mx,Equal:CW,EqualApproximately:kW,EqualApproximatelyIcon:kW,EqualIcon:CW,EqualNot:SW,EqualNotIcon:SW,EqualSquare:hk,EqualSquareIcon:hk,Eraser:MW,EraserIcon:MW,EthernetPort:TW,EthernetPortIcon:TW,Euro:AW,EuroIcon:AW,Expand:tL,ExpandIcon:tL,ExternalLink:an,ExternalLinkIcon:an,Eye:qn,EyeClosed:EW,EyeClosedIcon:EW,EyeIcon:qn,EyeOff:kp,EyeOffIcon:kp,Facebook:ku,FacebookIcon:ku,Factory:PW,FactoryIcon:PW,Fan:IW,FanIcon:IW,FastForward:LW,FastForwardIcon:LW,Feather:DW,FeatherIcon:DW,Fence:OW,FenceIcon:OW,FerrisWheel:RW,FerrisWheelIcon:RW,Figma:FW,FigmaIcon:FW,File:NM,FileArchive:zW,FileArchiveIcon:zW,FileAudio:$W,FileAudio2:BW,FileAudio2Icon:BW,FileAudioIcon:$W,FileAxis3D:Qj,FileAxis3DIcon:Qj,FileAxis3d:Qj,FileAxis3dIcon:Qj,FileBadge:UW,FileBadge2:qW,FileBadge2Icon:qW,FileBadgeIcon:UW,FileBarChart:Jj,FileBarChart2:eN,FileBarChart2Icon:eN,FileBarChartIcon:Jj,FileBox:VW,FileBoxIcon:VW,FileChartColumn:eN,FileChartColumnIcon:eN,FileChartColumnIncreasing:Jj,FileChartColumnIncreasingIcon:Jj,FileChartLine:tN,FileChartLineIcon:tN,FileChartPie:sN,FileChartPieIcon:sN,FileCheck:WW,FileCheck2:HW,FileCheck2Icon:HW,FileCheckIcon:WW,FileClock:GW,FileClockIcon:GW,FileCode:ZW,FileCode2:KW,FileCode2Icon:KW,FileCodeIcon:ZW,FileCog:rN,FileCog2:rN,FileCog2Icon:rN,FileCogIcon:rN,FileDiff:YW,FileDiffIcon:YW,FileDigit:XW,FileDigitIcon:XW,FileDown:QW,FileDownIcon:QW,FileEdit:aN,FileEditIcon:aN,FileHeart:JW,FileHeartIcon:JW,FileIcon:NM,FileImage:R_,FileImageIcon:R_,FileInput:eG,FileInputIcon:eG,FileJson:sG,FileJson2:tG,FileJson2Icon:tG,FileJsonIcon:sG,FileKey:nG,FileKey2:rG,FileKey2Icon:rG,FileKeyIcon:nG,FileLineChart:tN,FileLineChartIcon:tN,FileLock:iG,FileLock2:aG,FileLock2Icon:aG,FileLockIcon:iG,FileMinus:lG,FileMinus2:oG,FileMinus2Icon:oG,FileMinusIcon:lG,FileMusic:cG,FileMusicIcon:cG,FileOutput:dG,FileOutputIcon:dG,FilePen:aN,FilePenIcon:aN,FilePenLine:nN,FilePenLineIcon:nN,FilePieChart:sN,FilePieChartIcon:sN,FilePlus:hG,FilePlus2:uG,FilePlus2Icon:uG,FilePlusIcon:hG,FileQuestion:mG,FileQuestionIcon:mG,FileScan:pG,FileScanIcon:pG,FileSearch:xG,FileSearch2:fG,FileSearch2Icon:fG,FileSearchIcon:xG,FileSignature:nN,FileSignatureIcon:nN,FileSliders:gG,FileSlidersIcon:gG,FileSpreadsheet:s1,FileSpreadsheetIcon:s1,FileStack:sL,FileStackIcon:sL,FileSymlink:yG,FileSymlinkIcon:yG,FileTerminal:vG,FileTerminalIcon:vG,FileText:En,FileTextIcon:En,FileType:_G,FileType2:bG,FileType2Icon:bG,FileTypeIcon:_G,FileUp:wG,FileUpIcon:wG,FileUser:jG,FileUserIcon:jG,FileVideo:kG,FileVideo2:NG,FileVideo2Icon:NG,FileVideoIcon:kG,FileVolume:CG,FileVolume2:SG,FileVolume2Icon:SG,FileVolumeIcon:CG,FileWarning:MG,FileWarningIcon:MG,FileX:AG,FileX2:TG,FileX2Icon:TG,FileXIcon:AG,Files:EG,FilesIcon:EG,Film:xu,FilmIcon:xu,Filter:Yg,FilterIcon:Yg,FilterX:PG,FilterXIcon:PG,Fingerprint:IG,FingerprintIcon:IG,FireExtinguisher:LG,FireExtinguisherIcon:LG,Fish:RG,FishIcon:RG,FishOff:DG,FishOffIcon:DG,FishSymbol:OG,FishSymbolIcon:OG,Flag:r1,FlagIcon:r1,FlagOff:FG,FlagOffIcon:FG,FlagTriangleLeft:zG,FlagTriangleLeftIcon:zG,FlagTriangleRight:BG,FlagTriangleRightIcon:BG,Flame:Qu,FlameIcon:Qu,FlameKindling:$G,FlameKindlingIcon:$G,Flashlight:UG,FlashlightIcon:UG,FlashlightOff:qG,FlashlightOffIcon:qG,FlaskConical:F_,FlaskConicalIcon:F_,FlaskConicalOff:VG,FlaskConicalOffIcon:VG,FlaskRound:HG,FlaskRoundIcon:HG,FlipHorizontal:rL,FlipHorizontal2:WG,FlipHorizontal2Icon:WG,FlipHorizontalIcon:rL,FlipVertical:KG,FlipVertical2:GG,FlipVertical2Icon:GG,FlipVerticalIcon:KG,Flower:ZG,Flower2:Vg,Flower2Icon:Vg,FlowerIcon:ZG,Focus:YG,FocusIcon:YG,FoldHorizontal:XG,FoldHorizontalIcon:XG,FoldVertical:QG,FoldVerticalIcon:QG,Folder:kK,FolderArchive:JG,FolderArchiveIcon:JG,FolderCheck:eK,FolderCheckIcon:eK,FolderClock:tK,FolderClockIcon:tK,FolderClosed:sK,FolderClosedIcon:sK,FolderCode:rK,FolderCodeIcon:rK,FolderCog:iN,FolderCog2:iN,FolderCog2Icon:iN,FolderCogIcon:iN,FolderDot:nK,FolderDotIcon:nK,FolderDown:aK,FolderDownIcon:aK,FolderEdit:oN,FolderEditIcon:oN,FolderGit:oK,FolderGit2:iK,FolderGit2Icon:iK,FolderGitIcon:oK,FolderHeart:lK,FolderHeartIcon:lK,FolderIcon:kK,FolderInput:cK,FolderInputIcon:cK,FolderKanban:dK,FolderKanbanIcon:dK,FolderKey:uK,FolderKeyIcon:uK,FolderLock:hK,FolderLockIcon:hK,FolderMinus:mK,FolderMinusIcon:mK,FolderOpen:Lm,FolderOpenDot:pK,FolderOpenDotIcon:pK,FolderOpenIcon:Lm,FolderOutput:fK,FolderOutputIcon:fK,FolderPen:oN,FolderPenIcon:oN,FolderPlus:xK,FolderPlusIcon:xK,FolderRoot:gK,FolderRootIcon:gK,FolderSearch:vK,FolderSearch2:yK,FolderSearch2Icon:yK,FolderSearchIcon:vK,FolderSymlink:bK,FolderSymlinkIcon:bK,FolderSync:_K,FolderSyncIcon:_K,FolderTree:wK,FolderTreeIcon:wK,FolderUp:jK,FolderUpIcon:jK,FolderX:NK,FolderXIcon:NK,Folders:SK,FoldersIcon:SK,Footprints:CK,FootprintsIcon:CK,ForkKnife:Xk,ForkKnifeCrossed:Yk,ForkKnifeCrossedIcon:Yk,ForkKnifeIcon:Xk,Forklift:MK,ForkliftIcon:MK,FormInput:PN,FormInputIcon:PN,Forward:TK,ForwardIcon:TK,Frame:AK,FrameIcon:AK,Framer:EK,FramerIcon:EK,Frown:PK,FrownIcon:PK,Fuel:IK,FuelIcon:IK,Fullscreen:LK,FullscreenIcon:LK,FunctionSquare:mk,FunctionSquareIcon:mk,GalleryHorizontal:OK,GalleryHorizontalEnd:DK,GalleryHorizontalEndIcon:DK,GalleryHorizontalIcon:OK,GalleryThumbnails:RK,GalleryThumbnailsIcon:RK,GalleryVertical:zK,GalleryVerticalEnd:FK,GalleryVerticalEndIcon:FK,GalleryVerticalIcon:zK,Gamepad:$K,Gamepad2:BK,Gamepad2Icon:BK,GamepadIcon:$K,GanttChart:pj,GanttChartIcon:pj,GanttChartSquare:qy,GanttChartSquareIcon:qy,Gauge:qK,GaugeCircle:Aj,GaugeCircleIcon:Aj,GaugeIcon:qK,Gavel:UK,GavelIcon:UK,Gem:VK,GemIcon:VK,Ghost:X4,GhostIcon:X4,Gift:No,GiftIcon:No,GitBranch:WK,GitBranchIcon:WK,GitBranchPlus:HK,GitBranchPlusIcon:HK,GitCommit:lN,GitCommitHorizontal:lN,GitCommitHorizontalIcon:lN,GitCommitIcon:lN,GitCommitVertical:GK,GitCommitVerticalIcon:GK,GitCompare:ZK,GitCompareArrows:KK,GitCompareArrowsIcon:KK,GitCompareIcon:ZK,GitFork:YK,GitForkIcon:YK,GitGraph:XK,GitGraphIcon:XK,GitMerge:QK,GitMergeIcon:QK,GitPullRequest:nZ,GitPullRequestArrow:JK,GitPullRequestArrowIcon:JK,GitPullRequestClosed:eZ,GitPullRequestClosedIcon:eZ,GitPullRequestCreate:sZ,GitPullRequestCreateArrow:tZ,GitPullRequestCreateArrowIcon:tZ,GitPullRequestCreateIcon:sZ,GitPullRequestDraft:rZ,GitPullRequestDraftIcon:rZ,GitPullRequestIcon:nZ,Github:aZ,GithubIcon:aZ,Gitlab:iZ,GitlabIcon:iZ,GlassWater:oZ,GlassWaterIcon:oZ,Glasses:lZ,GlassesIcon:lZ,Globe:Su,Globe2:Xj,Globe2Icon:Xj,GlobeIcon:Su,GlobeLock:cZ,GlobeLockIcon:cZ,Goal:dZ,GoalIcon:dZ,Grab:uZ,GrabIcon:uZ,GraduationCap:Gh,GraduationCapIcon:Gh,Grape:hZ,GrapeIcon:hZ,Grid:nx,Grid2X2:dN,Grid2X2Icon:dN,Grid2X2Plus:cN,Grid2X2PlusIcon:cN,Grid2x2:dN,Grid2x2Check:mZ,Grid2x2CheckIcon:mZ,Grid2x2Icon:dN,Grid2x2Plus:cN,Grid2x2PlusIcon:cN,Grid2x2X:pZ,Grid2x2XIcon:pZ,Grid3X3:nx,Grid3X3Icon:nx,Grid3x3:nx,Grid3x3Icon:nx,GridIcon:nx,Grip:xZ,GripHorizontal:fZ,GripHorizontalIcon:fZ,GripIcon:xZ,GripVertical:Ju,GripVerticalIcon:Ju,Group:gZ,GroupIcon:gZ,Guitar:yZ,GuitarIcon:yZ,Ham:vZ,HamIcon:vZ,Hammer:bZ,HammerIcon:bZ,Hand:nL,HandCoins:_Z,HandCoinsIcon:_Z,HandHeart:wZ,HandHeartIcon:wZ,HandHelping:uN,HandHelpingIcon:uN,HandIcon:nL,HandMetal:jZ,HandMetalIcon:jZ,HandPlatter:NZ,HandPlatterIcon:NZ,Handshake:aL,HandshakeIcon:aL,HardDrive:iL,HardDriveDownload:kZ,HardDriveDownloadIcon:kZ,HardDriveIcon:iL,HardDriveUpload:SZ,HardDriveUploadIcon:SZ,HardHat:CZ,HardHatIcon:CZ,Hash:z_,HashIcon:z_,Haze:MZ,HazeIcon:MZ,HdmiPort:TZ,HdmiPortIcon:TZ,Heading:IZ,Heading1:kM,Heading1Icon:kM,Heading2:SM,Heading2Icon:SM,Heading3:oL,Heading3Icon:oL,Heading4:AZ,Heading4Icon:AZ,Heading5:EZ,Heading5Icon:EZ,Heading6:PZ,Heading6Icon:PZ,HeadingIcon:IZ,HeadphoneOff:LZ,HeadphoneOffIcon:LZ,Headphones:DZ,HeadphonesIcon:DZ,Headset:OZ,HeadsetIcon:OZ,Heart:ii,HeartCrack:RZ,HeartCrackIcon:RZ,HeartHandshake:FZ,HeartHandshakeIcon:FZ,HeartIcon:ii,HeartOff:zZ,HeartOffIcon:zZ,HeartPulse:BZ,HeartPulseIcon:BZ,Heater:$Z,HeaterIcon:$Z,HelpCircle:Lv,HelpCircleIcon:Lv,HelpingHand:uN,HelpingHandIcon:uN,Hexagon:qZ,HexagonIcon:qZ,Highlighter:UZ,HighlighterIcon:UZ,History:CM,HistoryIcon:CM,Home:Sn,HomeIcon:Sn,Hop:HZ,HopIcon:HZ,HopOff:VZ,HopOffIcon:VZ,Hospital:WZ,HospitalIcon:WZ,Hotel:GZ,HotelIcon:GZ,Hourglass:KZ,HourglassIcon:KZ,House:Sn,HouseIcon:Sn,HousePlug:ZZ,HousePlugIcon:ZZ,HousePlus:YZ,HousePlusIcon:YZ,IceCream:mN,IceCream2:hN,IceCream2Icon:hN,IceCreamBowl:hN,IceCreamBowlIcon:hN,IceCreamCone:mN,IceCreamConeIcon:mN,IceCreamIcon:mN,Icon:tqe,IdCard:XZ,IdCardIcon:XZ,Image:fl,ImageDown:QZ,ImageDownIcon:QZ,ImageIcon:fl,ImageMinus:JZ,ImageMinusIcon:JZ,ImageOff:eY,ImageOffIcon:eY,ImagePlay:tY,ImagePlayIcon:tY,ImagePlus:n1,ImagePlusIcon:n1,ImageUp:sY,ImageUpIcon:sY,ImageUpscale:rY,ImageUpscaleIcon:rY,Images:nY,ImagesIcon:nY,Import:aY,ImportIcon:aY,Inbox:iY,InboxIcon:iY,Indent:fN,IndentDecrease:pN,IndentDecreaseIcon:pN,IndentIcon:fN,IndentIncrease:fN,IndentIncreaseIcon:fN,IndianRupee:oY,IndianRupeeIcon:oY,Infinity:lY,InfinityIcon:lY,Info:lL,InfoIcon:lL,Inspect:vk,InspectIcon:vk,InspectionPanel:cY,InspectionPanelIcon:cY,Instagram:Cu,InstagramIcon:Cu,Italic:Q4,ItalicIcon:Q4,IterationCcw:dY,IterationCcwIcon:dY,IterationCw:uY,IterationCwIcon:uY,JapaneseYen:hY,JapaneseYenIcon:hY,Joystick:mY,JoystickIcon:mY,Kanban:u0,KanbanIcon:u0,KanbanSquare:pk,KanbanSquareDashed:ok,KanbanSquareDashedIcon:ok,KanbanSquareIcon:pk,Key:Sp,KeyIcon:Sp,KeyRound:J4,KeyRoundIcon:J4,KeySquare:pY,KeySquareIcon:pY,Keyboard:gY,KeyboardIcon:gY,KeyboardMusic:fY,KeyboardMusicIcon:fY,KeyboardOff:xY,KeyboardOffIcon:xY,Lamp:jY,LampCeiling:yY,LampCeilingIcon:yY,LampDesk:vY,LampDeskIcon:vY,LampFloor:bY,LampFloorIcon:bY,LampIcon:jY,LampWallDown:_Y,LampWallDownIcon:_Y,LampWallUp:wY,LampWallUpIcon:wY,LandPlot:NY,LandPlotIcon:NY,Landmark:kY,LandmarkIcon:kY,Languages:SY,LanguagesIcon:SY,Laptop:MY,Laptop2:xN,Laptop2Icon:xN,LaptopIcon:MY,LaptopMinimal:xN,LaptopMinimalCheck:CY,LaptopMinimalCheckIcon:CY,LaptopMinimalIcon:xN,Lasso:AY,LassoIcon:AY,LassoSelect:TY,LassoSelectIcon:TY,Laugh:EY,LaughIcon:EY,Layers:MM,Layers2:PY,Layers2Icon:PY,Layers3:IY,Layers3Icon:IY,LayersIcon:MM,Layout:Ov,LayoutDashboard:eS,LayoutDashboardIcon:eS,LayoutGrid:Cp,LayoutGridIcon:Cp,LayoutIcon:Ov,LayoutList:LY,LayoutListIcon:LY,LayoutPanelLeft:DY,LayoutPanelLeftIcon:DY,LayoutPanelTop:OY,LayoutPanelTopIcon:OY,LayoutTemplate:tS,LayoutTemplateIcon:tS,Leaf:RY,LeafIcon:RY,LeafyGreen:FY,LeafyGreenIcon:FY,Lectern:zY,LecternIcon:zY,LetterText:BY,LetterTextIcon:BY,Library:TM,LibraryBig:$Y,LibraryBigIcon:$Y,LibraryIcon:TM,LibrarySquare:fk,LibrarySquareIcon:fk,LifeBuoy:AM,LifeBuoyIcon:AM,Ligature:qY,LigatureIcon:qY,Lightbulb:B_,LightbulbIcon:B_,LightbulbOff:UY,LightbulbOffIcon:UY,LineChart:uj,LineChartIcon:uj,Link:zo,Link2:cl,Link2Icon:cl,Link2Off:VY,Link2OffIcon:VY,LinkIcon:zo,Linkedin:Mp,LinkedinIcon:Mp,List:Ch,ListCheck:HY,ListCheckIcon:HY,ListChecks:WY,ListChecksIcon:WY,ListCollapse:GY,ListCollapseIcon:GY,ListEnd:KY,ListEndIcon:KY,ListFilter:ZY,ListFilterIcon:ZY,ListIcon:Ch,ListMinus:YY,ListMinusIcon:YY,ListMusic:XY,ListMusicIcon:XY,ListOrdered:h0,ListOrderedIcon:h0,ListPlus:QY,ListPlusIcon:QY,ListRestart:JY,ListRestartIcon:JY,ListStart:eX,ListStartIcon:eX,ListTodo:tX,ListTodoIcon:tX,ListTree:sX,ListTreeIcon:sX,ListVideo:rX,ListVideoIcon:rX,ListX:nX,ListXIcon:nX,Loader:iX,Loader2:ws,Loader2Icon:ws,LoaderCircle:ws,LoaderCircleIcon:ws,LoaderIcon:iX,LoaderPinwheel:aX,LoaderPinwheelIcon:aX,Locate:cX,LocateFixed:oX,LocateFixedIcon:oX,LocateIcon:cX,LocateOff:lX,LocateOffIcon:lX,Lock:Mh,LockIcon:Mh,LockKeyhole:dX,LockKeyholeIcon:dX,LockKeyholeOpen:gN,LockKeyholeOpenIcon:gN,LockOpen:yN,LockOpenIcon:yN,LogIn:EM,LogInIcon:EM,LogOut:sS,LogOutIcon:sS,Logs:uX,LogsIcon:uX,Lollipop:hX,LollipopIcon:hX,LucideAArrowDown:g9,LucideAArrowUp:y9,LucideALargeSmall:v9,LucideAccessibility:b9,LucideActivity:jh,LucideActivitySquare:BN,LucideAirVent:_9,LucideAirplay:w9,LucideAlarmCheck:U2,LucideAlarmClock:N9,LucideAlarmClockCheck:U2,LucideAlarmClockMinus:V2,LucideAlarmClockOff:j9,LucideAlarmClockPlus:H2,LucideAlarmMinus:V2,LucideAlarmPlus:H2,LucideAlarmSmoke:k9,LucideAlbum:S9,LucideAlertCircle:Nl,LucideAlertOctagon:Dv,LucideAlertTriangle:Gu,LucideAlignCenter:q4,LucideAlignCenterHorizontal:C9,LucideAlignCenterVertical:M9,LucideAlignEndHorizontal:T9,LucideAlignEndVertical:A9,LucideAlignHorizontalDistributeCenter:E9,LucideAlignHorizontalDistributeEnd:P9,LucideAlignHorizontalDistributeStart:I9,LucideAlignHorizontalJustifyCenter:L9,LucideAlignHorizontalJustifyEnd:D9,LucideAlignHorizontalJustifyStart:O9,LucideAlignHorizontalSpaceAround:R9,LucideAlignHorizontalSpaceBetween:F9,LucideAlignJustify:z9,LucideAlignLeft:U4,LucideAlignRight:V4,LucideAlignStartHorizontal:B9,LucideAlignStartVertical:$9,LucideAlignVerticalDistributeCenter:q9,LucideAlignVerticalDistributeEnd:U9,LucideAlignVerticalDistributeStart:V9,LucideAlignVerticalJustifyCenter:H9,LucideAlignVerticalJustifyEnd:W9,LucideAlignVerticalJustifyStart:G9,LucideAlignVerticalSpaceAround:K9,LucideAlignVerticalSpaceBetween:Z9,LucideAmbulance:Y9,LucideAmpersand:X9,LucideAmpersands:Q9,LucideAmphora:J9,LucideAnchor:eB,LucideAngry:tB,LucideAnnoyed:sB,LucideAntenna:rB,LucideAnvil:nB,LucideAperture:aB,LucideAppWindow:qI,LucideAppWindowMac:iB,LucideApple:oB,LucideArchive:vM,LucideArchiveRestore:UI,LucideArchiveX:lB,LucideAreaChart:aj,LucideArmchair:cB,LucideArrowBigDown:uB,LucideArrowBigDownDash:dB,LucideArrowBigLeft:mB,LucideArrowBigLeftDash:hB,LucideArrowBigRight:fB,LucideArrowBigRightDash:pB,LucideArrowBigUp:gB,LucideArrowBigUpDash:xB,LucideArrowDown:Hh,LucideArrowDown01:yB,LucideArrowDown10:vB,LucideArrowDownAZ:W2,LucideArrowDownAz:W2,LucideArrowDownCircle:gj,LucideArrowDownFromLine:bB,LucideArrowDownLeft:_B,LucideArrowDownLeftFromCircle:vj,LucideArrowDownLeftFromSquare:HN,LucideArrowDownLeftSquare:$N,LucideArrowDownNarrowWide:wB,LucideArrowDownRight:VI,LucideArrowDownRightFromCircle:bj,LucideArrowDownRightFromSquare:WN,LucideArrowDownRightSquare:qN,LucideArrowDownSquare:UN,LucideArrowDownToDot:jB,LucideArrowDownToLine:NB,LucideArrowDownUp:kB,LucideArrowDownWideNarrow:G2,LucideArrowDownZA:K2,LucideArrowDownZa:K2,LucideArrowLeft:ri,LucideArrowLeftCircle:yj,LucideArrowLeftFromLine:SB,LucideArrowLeftRight:CB,LucideArrowLeftSquare:VN,LucideArrowLeftToLine:MB,LucideArrowRight:fi,LucideArrowRightCircle:jj,LucideArrowRightFromLine:TB,LucideArrowRightLeft:Jv,LucideArrowRightSquare:ZN,LucideArrowRightToLine:AB,LucideArrowUp:Nu,LucideArrowUp01:EB,LucideArrowUp10:PB,LucideArrowUpAZ:Z2,LucideArrowUpAz:Z2,LucideArrowUpCircle:Nj,LucideArrowUpDown:yd,LucideArrowUpFromDot:IB,LucideArrowUpFromLine:LB,LucideArrowUpLeft:DB,LucideArrowUpLeftFromCircle:_j,LucideArrowUpLeftFromSquare:GN,LucideArrowUpLeftSquare:YN,LucideArrowUpNarrowWide:Y2,LucideArrowUpRight:HI,LucideArrowUpRightFromCircle:wj,LucideArrowUpRightFromSquare:KN,LucideArrowUpRightSquare:XN,LucideArrowUpSquare:QN,LucideArrowUpToLine:OB,LucideArrowUpWideNarrow:RB,LucideArrowUpZA:X2,LucideArrowUpZa:X2,LucideArrowsUpFromLine:FB,LucideAsterisk:zB,LucideAsteriskSquare:JN,LucideAtSign:BB,LucideAtom:$B,LucideAudioLines:qB,LucideAudioWaveform:UB,LucideAward:bc,LucideAxe:VB,LucideAxis3D:Q2,LucideAxis3d:Q2,LucideBaby:HB,LucideBackpack:WB,LucideBadge:l$,LucideBadgeAlert:GB,LucideBadgeCent:KB,LucideBadgeCheck:J2,LucideBadgeDollarSign:ZB,LucideBadgeEuro:YB,LucideBadgeHelp:XB,LucideBadgeIndianRupee:QB,LucideBadgeInfo:JB,LucideBadgeJapaneseYen:e$,LucideBadgeMinus:t$,LucideBadgePercent:s$,LucideBadgePlus:r$,LucideBadgePoundSterling:n$,LucideBadgeRussianRuble:a$,LucideBadgeSwissFranc:i$,LucideBadgeX:o$,LucideBaggageClaim:c$,LucideBan:WI,LucideBanana:d$,LucideBandage:u$,LucideBanknote:h$,LucideBarChart:hj,LucideBarChart2:mj,LucideBarChart3:Ro,LucideBarChart4:dj,LucideBarChartBig:cj,LucideBarChartHorizontal:oj,LucideBarChartHorizontalBig:ij,LucideBarcode:m$,LucideBaseline:p$,LucideBath:Nh,LucideBattery:b$,LucideBatteryCharging:f$,LucideBatteryFull:x$,LucideBatteryLow:g$,LucideBatteryMedium:y$,LucideBatteryWarning:v$,LucideBeaker:_$,LucideBean:j$,LucideBeanOff:w$,LucideBed:Np,LucideBedDouble:H4,LucideBedSingle:N$,LucideBeef:k$,LucideBeer:C$,LucideBeerOff:S$,LucideBell:Pm,LucideBellDot:M$,LucideBellElectric:T$,LucideBellMinus:A$,LucideBellOff:e1,LucideBellPlus:E$,LucideBellRing:P$,LucideBetweenHorizonalEnd:ej,LucideBetweenHorizonalStart:tj,LucideBetweenHorizontalEnd:ej,LucideBetweenHorizontalStart:tj,LucideBetweenVerticalEnd:I$,LucideBetweenVerticalStart:L$,LucideBicepsFlexed:D$,LucideBike:O$,LucideBinary:R$,LucideBinoculars:F$,LucideBiohazard:z$,LucideBird:B$,LucideBitcoin:$$,LucideBlend:q$,LucideBlinds:U$,LucideBlocks:V$,LucideBluetooth:K$,LucideBluetoothConnected:H$,LucideBluetoothOff:W$,LucideBluetoothSearching:G$,LucideBold:W4,LucideBolt:Z$,LucideBomb:Y$,LucideBone:X$,LucideBook:vq,LucideBookA:Q$,LucideBookAudio:J$,LucideBookCheck:eq,LucideBookCopy:tq,LucideBookDashed:sj,LucideBookDown:sq,LucideBookHeadphones:rq,LucideBookHeart:nq,LucideBookImage:aq,LucideBookKey:iq,LucideBookLock:oq,LucideBookMarked:lq,LucideBookMinus:cq,LucideBookOpen:kh,LucideBookOpenCheck:dq,LucideBookOpenText:uq,LucideBookPlus:hq,LucideBookTemplate:sj,LucideBookText:mq,LucideBookType:pq,LucideBookUp:xq,LucideBookUp2:fq,LucideBookUser:gq,LucideBookX:yq,LucideBookmark:Nx,LucideBookmarkCheck:bq,LucideBookmarkMinus:_q,LucideBookmarkPlus:GI,LucideBookmarkX:wq,LucideBoomBox:jq,LucideBot:bM,LucideBotMessageSquare:Nq,LucideBotOff:kq,LucideBox:Sq,LucideBoxSelect:ck,LucideBoxes:Cq,LucideBraces:rj,LucideBrackets:Mq,LucideBrain:KI,LucideBrainCircuit:Tq,LucideBrainCog:Aq,LucideBrickWall:Eq,LucideBriefcase:Wh,LucideBriefcaseBusiness:Pq,LucideBriefcaseConveyorBelt:Iq,LucideBriefcaseMedical:Lq,LucideBringToFront:Dq,LucideBrush:Oq,LucideBug:zq,LucideBugOff:Rq,LucideBugPlay:Fq,LucideBuilding:G4,LucideBuilding2:wa,LucideBus:$q,LucideBusFront:Bq,LucideCable:Uq,LucideCableCar:qq,LucideCake:Sh,LucideCakeSlice:Vq,LucideCalculator:ZI,LucideCalendar:cn,LucideCalendar1:Hq,LucideCalendarArrowDown:Wq,LucideCalendarArrowUp:Gq,LucideCalendarCheck:YI,LucideCalendarCheck2:Kq,LucideCalendarClock:XI,LucideCalendarCog:Zq,LucideCalendarDays:Dd,LucideCalendarFold:Yq,LucideCalendarHeart:Xq,LucideCalendarMinus:Jq,LucideCalendarMinus2:Qq,LucideCalendarOff:QI,LucideCalendarPlus:D_,LucideCalendarPlus2:eU,LucideCalendarRange:tU,LucideCalendarSearch:sU,LucideCalendarSync:rU,LucideCalendarX:aU,LucideCalendarX2:nU,LucideCamera:kx,LucideCameraOff:iU,LucideCandlestickChart:lj,LucideCandy:cU,LucideCandyCane:oU,LucideCandyOff:lU,LucideCannabis:dU,LucideCaptions:nj,LucideCaptionsOff:uU,LucideCar:_M,LucideCarFront:hU,LucideCarTaxiFront:mU,LucideCaravan:pU,LucideCarrot:fU,LucideCaseLower:xU,LucideCaseSensitive:gU,LucideCaseUpper:yU,LucideCassetteTape:vU,LucideCast:bU,LucideCastle:_U,LucideCat:wU,LucideCctv:jU,LucideChartArea:aj,LucideChartBar:oj,LucideChartBarBig:ij,LucideChartBarDecreasing:NU,LucideChartBarIncreasing:kU,LucideChartBarStacked:SU,LucideChartCandlestick:lj,LucideChartColumn:Ro,LucideChartColumnBig:cj,LucideChartColumnDecreasing:CU,LucideChartColumnIncreasing:dj,LucideChartColumnStacked:MU,LucideChartGantt:TU,LucideChartLine:uj,LucideChartNetwork:AU,LucideChartNoAxesColumn:mj,LucideChartNoAxesColumnDecreasing:EU,LucideChartNoAxesColumnIncreasing:hj,LucideChartNoAxesCombined:PU,LucideChartNoAxesGantt:pj,LucideChartPie:fj,LucideChartScatter:xj,LucideChartSpline:IU,LucideCheck:fa,LucideCheckCheck:LU,LucideCheckCircle:xi,LucideCheckCircle2:la,LucideCheckSquare:Fv,LucideCheckSquare2:tk,LucideChefHat:DU,LucideCherry:OU,LucideChevronDown:To,LucideChevronDownCircle:kj,LucideChevronDownSquare:sk,LucideChevronFirst:RU,LucideChevronLast:FU,LucideChevronLeft:ll,LucideChevronLeftCircle:Sj,LucideChevronLeftSquare:rk,LucideChevronRight:xa,LucideChevronRightCircle:Cj,LucideChevronRightSquare:nk,LucideChevronUp:pf,LucideChevronUpCircle:Mj,LucideChevronUpSquare:ak,LucideChevronsDown:BU,LucideChevronsDownUp:zU,LucideChevronsLeft:UU,LucideChevronsLeftRight:qU,LucideChevronsLeftRightEllipsis:$U,LucideChevronsRight:HU,LucideChevronsRightLeft:VU,LucideChevronsUp:WU,LucideChevronsUpDown:Sx,LucideChrome:GU,LucideChurch:KU,LucideCigarette:YU,LucideCigaretteOff:ZU,LucideCircle:vd,LucideCircleAlert:Nl,LucideCircleArrowDown:gj,LucideCircleArrowLeft:yj,LucideCircleArrowOutDownLeft:vj,LucideCircleArrowOutDownRight:bj,LucideCircleArrowOutUpLeft:_j,LucideCircleArrowOutUpRight:wj,LucideCircleArrowRight:jj,LucideCircleArrowUp:Nj,LucideCircleCheck:la,LucideCircleCheckBig:xi,LucideCircleChevronDown:kj,LucideCircleChevronLeft:Sj,LucideCircleChevronRight:Cj,LucideCircleChevronUp:Mj,LucideCircleDashed:XU,LucideCircleDivide:Tj,LucideCircleDollarSign:QU,LucideCircleDot:eV,LucideCircleDotDashed:JU,LucideCircleEllipsis:tV,LucideCircleEqual:sV,LucideCircleFadingArrowUp:rV,LucideCircleFadingPlus:nV,LucideCircleGauge:Aj,LucideCircleHelp:Lv,LucideCircleMinus:Ej,LucideCircleOff:aV,LucideCircleParking:Ij,LucideCircleParkingOff:Pj,LucideCirclePause:Lj,LucideCirclePercent:Dj,LucideCirclePlay:mp,LucideCirclePlus:Oj,LucideCirclePower:Rj,LucideCircleSlash:iV,LucideCircleSlash2:Fj,LucideCircleSlashed:Fj,LucideCircleStop:zj,LucideCircleUser:$j,LucideCircleUserRound:Bj,LucideCircleX:xc,LucideCircuitBoard:oV,LucideCitrus:lV,LucideClapperboard:cV,LucideClipboard:xV,LucideClipboardCheck:wM,LucideClipboardCopy:dV,LucideClipboardEdit:Uj,LucideClipboardList:O_,LucideClipboardMinus:uV,LucideClipboardPaste:hV,LucideClipboardPen:Uj,LucideClipboardPenLine:qj,LucideClipboardPlus:mV,LucideClipboardSignature:qj,LucideClipboardType:pV,LucideClipboardX:fV,LucideClock:mn,LucideClock1:gV,LucideClock10:yV,LucideClock11:vV,LucideClock12:bV,LucideClock2:_V,LucideClock3:wV,LucideClock4:jV,LucideClock5:NV,LucideClock6:kV,LucideClock7:SV,LucideClock8:CV,LucideClock9:MV,LucideClockAlert:TV,LucideClockArrowDown:AV,LucideClockArrowUp:EV,LucideCloud:WV,LucideCloudAlert:PV,LucideCloudCog:IV,LucideCloudDownload:Vj,LucideCloudDrizzle:LV,LucideCloudFog:DV,LucideCloudHail:OV,LucideCloudLightning:RV,LucideCloudMoon:zV,LucideCloudMoonRain:FV,LucideCloudOff:BV,LucideCloudRain:qV,LucideCloudRainWind:$V,LucideCloudSnow:UV,LucideCloudSun:HV,LucideCloudSunRain:VV,LucideCloudUpload:Hj,LucideCloudy:GV,LucideClover:Gv,LucideClub:KV,LucideCode:K4,LucideCode2:Wj,LucideCodeSquare:ik,LucideCodeXml:Wj,LucideCodepen:ZV,LucideCodesandbox:YV,LucideCoffee:Z4,LucideCog:XV,LucideCoins:JI,LucideColumns:Gj,LucideColumns2:Gj,LucideColumns3:Kj,LucideColumns4:QV,LucideCombine:JV,LucideCommand:eH,LucideCompass:tH,LucideComponent:sH,LucideComputer:rH,LucideConciergeBell:nH,LucideCone:aH,LucideConstruction:iH,LucideContact:Y4,LucideContact2:Zj,LucideContactRound:Zj,LucideContainer:oH,LucideContrast:lH,LucideCookie:cH,LucideCookingPot:dH,LucideCopy:gi,LucideCopyCheck:uH,LucideCopyMinus:hH,LucideCopyPlus:mH,LucideCopySlash:pH,LucideCopyX:fH,LucideCopyleft:xH,LucideCopyright:gH,LucideCornerDownLeft:yH,LucideCornerDownRight:vH,LucideCornerLeftDown:bH,LucideCornerLeftUp:_H,LucideCornerRightDown:wH,LucideCornerRightUp:jH,LucideCornerUpLeft:NH,LucideCornerUpRight:kH,LucideCpu:SH,LucideCreativeCommons:CH,LucideCreditCard:Cx,LucideCroissant:MH,LucideCrop:TH,LucideCross:AH,LucideCrosshair:EH,LucideCrown:Im,LucideCuboid:PH,LucideCupSoda:IH,LucideCurlyBraces:rj,LucideCurrency:LH,LucideCylinder:DH,LucideDam:OH,LucideDatabase:eL,LucideDatabaseBackup:RH,LucideDatabaseZap:FH,LucideDelete:zH,LucideDessert:BH,LucideDiameter:$H,LucideDiamond:VH,LucideDiamondMinus:qH,LucideDiamondPercent:Yj,LucideDiamondPlus:UH,LucideDice1:HH,LucideDice2:WH,LucideDice3:GH,LucideDice4:KH,LucideDice5:ZH,LucideDice6:YH,LucideDices:XH,LucideDiff:QH,LucideDisc:sW,LucideDisc2:JH,LucideDisc3:eW,LucideDiscAlbum:tW,LucideDivide:rW,LucideDivideCircle:Tj,LucideDivideSquare:dk,LucideDna:aW,LucideDnaOff:nW,LucideDock:iW,LucideDog:oW,LucideDollarSign:wc,LucideDonut:lW,LucideDoorClosed:cW,LucideDoorOpen:t1,LucideDot:dW,LucideDotSquare:uk,LucideDownload:Ci,LucideDownloadCloud:Vj,LucideDraftingCompass:uW,LucideDrama:hW,LucideDribbble:mW,LucideDrill:pW,LucideDroplet:fW,LucideDroplets:Zg,LucideDrum:xW,LucideDrumstick:gW,LucideDumbbell:yW,LucideEar:bW,LucideEarOff:vW,LucideEarth:Xj,LucideEarthLock:_W,LucideEclipse:wW,LucideEdit:dd,LucideEdit2:Qy,LucideEdit3:Rv,LucideEgg:jM,LucideEggFried:jW,LucideEggOff:NW,LucideEllipsis:px,LucideEllipsisVertical:mx,LucideEqual:CW,LucideEqualApproximately:kW,LucideEqualNot:SW,LucideEqualSquare:hk,LucideEraser:MW,LucideEthernetPort:TW,LucideEuro:AW,LucideExpand:tL,LucideExternalLink:an,LucideEye:qn,LucideEyeClosed:EW,LucideEyeOff:kp,LucideFacebook:ku,LucideFactory:PW,LucideFan:IW,LucideFastForward:LW,LucideFeather:DW,LucideFence:OW,LucideFerrisWheel:RW,LucideFigma:FW,LucideFile:NM,LucideFileArchive:zW,LucideFileAudio:$W,LucideFileAudio2:BW,LucideFileAxis3D:Qj,LucideFileAxis3d:Qj,LucideFileBadge:UW,LucideFileBadge2:qW,LucideFileBarChart:Jj,LucideFileBarChart2:eN,LucideFileBox:VW,LucideFileChartColumn:eN,LucideFileChartColumnIncreasing:Jj,LucideFileChartLine:tN,LucideFileChartPie:sN,LucideFileCheck:WW,LucideFileCheck2:HW,LucideFileClock:GW,LucideFileCode:ZW,LucideFileCode2:KW,LucideFileCog:rN,LucideFileCog2:rN,LucideFileDiff:YW,LucideFileDigit:XW,LucideFileDown:QW,LucideFileEdit:aN,LucideFileHeart:JW,LucideFileImage:R_,LucideFileInput:eG,LucideFileJson:sG,LucideFileJson2:tG,LucideFileKey:nG,LucideFileKey2:rG,LucideFileLineChart:tN,LucideFileLock:iG,LucideFileLock2:aG,LucideFileMinus:lG,LucideFileMinus2:oG,LucideFileMusic:cG,LucideFileOutput:dG,LucideFilePen:aN,LucideFilePenLine:nN,LucideFilePieChart:sN,LucideFilePlus:hG,LucideFilePlus2:uG,LucideFileQuestion:mG,LucideFileScan:pG,LucideFileSearch:xG,LucideFileSearch2:fG,LucideFileSignature:nN,LucideFileSliders:gG,LucideFileSpreadsheet:s1,LucideFileStack:sL,LucideFileSymlink:yG,LucideFileTerminal:vG,LucideFileText:En,LucideFileType:_G,LucideFileType2:bG,LucideFileUp:wG,LucideFileUser:jG,LucideFileVideo:kG,LucideFileVideo2:NG,LucideFileVolume:CG,LucideFileVolume2:SG,LucideFileWarning:MG,LucideFileX:AG,LucideFileX2:TG,LucideFiles:EG,LucideFilm:xu,LucideFilter:Yg,LucideFilterX:PG,LucideFingerprint:IG,LucideFireExtinguisher:LG,LucideFish:RG,LucideFishOff:DG,LucideFishSymbol:OG,LucideFlag:r1,LucideFlagOff:FG,LucideFlagTriangleLeft:zG,LucideFlagTriangleRight:BG,LucideFlame:Qu,LucideFlameKindling:$G,LucideFlashlight:UG,LucideFlashlightOff:qG,LucideFlaskConical:F_,LucideFlaskConicalOff:VG,LucideFlaskRound:HG,LucideFlipHorizontal:rL,LucideFlipHorizontal2:WG,LucideFlipVertical:KG,LucideFlipVertical2:GG,LucideFlower:ZG,LucideFlower2:Vg,LucideFocus:YG,LucideFoldHorizontal:XG,LucideFoldVertical:QG,LucideFolder:kK,LucideFolderArchive:JG,LucideFolderCheck:eK,LucideFolderClock:tK,LucideFolderClosed:sK,LucideFolderCode:rK,LucideFolderCog:iN,LucideFolderCog2:iN,LucideFolderDot:nK,LucideFolderDown:aK,LucideFolderEdit:oN,LucideFolderGit:oK,LucideFolderGit2:iK,LucideFolderHeart:lK,LucideFolderInput:cK,LucideFolderKanban:dK,LucideFolderKey:uK,LucideFolderLock:hK,LucideFolderMinus:mK,LucideFolderOpen:Lm,LucideFolderOpenDot:pK,LucideFolderOutput:fK,LucideFolderPen:oN,LucideFolderPlus:xK,LucideFolderRoot:gK,LucideFolderSearch:vK,LucideFolderSearch2:yK,LucideFolderSymlink:bK,LucideFolderSync:_K,LucideFolderTree:wK,LucideFolderUp:jK,LucideFolderX:NK,LucideFolders:SK,LucideFootprints:CK,LucideForkKnife:Xk,LucideForkKnifeCrossed:Yk,LucideForklift:MK,LucideFormInput:PN,LucideForward:TK,LucideFrame:AK,LucideFramer:EK,LucideFrown:PK,LucideFuel:IK,LucideFullscreen:LK,LucideFunctionSquare:mk,LucideGalleryHorizontal:OK,LucideGalleryHorizontalEnd:DK,LucideGalleryThumbnails:RK,LucideGalleryVertical:zK,LucideGalleryVerticalEnd:FK,LucideGamepad:$K,LucideGamepad2:BK,LucideGanttChart:pj,LucideGanttChartSquare:qy,LucideGauge:qK,LucideGaugeCircle:Aj,LucideGavel:UK,LucideGem:VK,LucideGhost:X4,LucideGift:No,LucideGitBranch:WK,LucideGitBranchPlus:HK,LucideGitCommit:lN,LucideGitCommitHorizontal:lN,LucideGitCommitVertical:GK,LucideGitCompare:ZK,LucideGitCompareArrows:KK,LucideGitFork:YK,LucideGitGraph:XK,LucideGitMerge:QK,LucideGitPullRequest:nZ,LucideGitPullRequestArrow:JK,LucideGitPullRequestClosed:eZ,LucideGitPullRequestCreate:sZ,LucideGitPullRequestCreateArrow:tZ,LucideGitPullRequestDraft:rZ,LucideGithub:aZ,LucideGitlab:iZ,LucideGlassWater:oZ,LucideGlasses:lZ,LucideGlobe:Su,LucideGlobe2:Xj,LucideGlobeLock:cZ,LucideGoal:dZ,LucideGrab:uZ,LucideGraduationCap:Gh,LucideGrape:hZ,LucideGrid:nx,LucideGrid2X2:dN,LucideGrid2X2Plus:cN,LucideGrid2x2:dN,LucideGrid2x2Check:mZ,LucideGrid2x2Plus:cN,LucideGrid2x2X:pZ,LucideGrid3X3:nx,LucideGrid3x3:nx,LucideGrip:xZ,LucideGripHorizontal:fZ,LucideGripVertical:Ju,LucideGroup:gZ,LucideGuitar:yZ,LucideHam:vZ,LucideHammer:bZ,LucideHand:nL,LucideHandCoins:_Z,LucideHandHeart:wZ,LucideHandHelping:uN,LucideHandMetal:jZ,LucideHandPlatter:NZ,LucideHandshake:aL,LucideHardDrive:iL,LucideHardDriveDownload:kZ,LucideHardDriveUpload:SZ,LucideHardHat:CZ,LucideHash:z_,LucideHaze:MZ,LucideHdmiPort:TZ,LucideHeading:IZ,LucideHeading1:kM,LucideHeading2:SM,LucideHeading3:oL,LucideHeading4:AZ,LucideHeading5:EZ,LucideHeading6:PZ,LucideHeadphoneOff:LZ,LucideHeadphones:DZ,LucideHeadset:OZ,LucideHeart:ii,LucideHeartCrack:RZ,LucideHeartHandshake:FZ,LucideHeartOff:zZ,LucideHeartPulse:BZ,LucideHeater:$Z,LucideHelpCircle:Lv,LucideHelpingHand:uN,LucideHexagon:qZ,LucideHighlighter:UZ,LucideHistory:CM,LucideHome:Sn,LucideHop:HZ,LucideHopOff:VZ,LucideHospital:WZ,LucideHotel:GZ,LucideHourglass:KZ,LucideHouse:Sn,LucideHousePlug:ZZ,LucideHousePlus:YZ,LucideIceCream:mN,LucideIceCream2:hN,LucideIceCreamBowl:hN,LucideIceCreamCone:mN,LucideIdCard:XZ,LucideImage:fl,LucideImageDown:QZ,LucideImageMinus:JZ,LucideImageOff:eY,LucideImagePlay:tY,LucideImagePlus:n1,LucideImageUp:sY,LucideImageUpscale:rY,LucideImages:nY,LucideImport:aY,LucideInbox:iY,LucideIndent:fN,LucideIndentDecrease:pN,LucideIndentIncrease:fN,LucideIndianRupee:oY,LucideInfinity:lY,LucideInfo:lL,LucideInspect:vk,LucideInspectionPanel:cY,LucideInstagram:Cu,LucideItalic:Q4,LucideIterationCcw:dY,LucideIterationCw:uY,LucideJapaneseYen:hY,LucideJoystick:mY,LucideKanban:u0,LucideKanbanSquare:pk,LucideKanbanSquareDashed:ok,LucideKey:Sp,LucideKeyRound:J4,LucideKeySquare:pY,LucideKeyboard:gY,LucideKeyboardMusic:fY,LucideKeyboardOff:xY,LucideLamp:jY,LucideLampCeiling:yY,LucideLampDesk:vY,LucideLampFloor:bY,LucideLampWallDown:_Y,LucideLampWallUp:wY,LucideLandPlot:NY,LucideLandmark:kY,LucideLanguages:SY,LucideLaptop:MY,LucideLaptop2:xN,LucideLaptopMinimal:xN,LucideLaptopMinimalCheck:CY,LucideLasso:AY,LucideLassoSelect:TY,LucideLaugh:EY,LucideLayers:MM,LucideLayers2:PY,LucideLayers3:IY,LucideLayout:Ov,LucideLayoutDashboard:eS,LucideLayoutGrid:Cp,LucideLayoutList:LY,LucideLayoutPanelLeft:DY,LucideLayoutPanelTop:OY,LucideLayoutTemplate:tS,LucideLeaf:RY,LucideLeafyGreen:FY,LucideLectern:zY,LucideLetterText:BY,LucideLibrary:TM,LucideLibraryBig:$Y,LucideLibrarySquare:fk,LucideLifeBuoy:AM,LucideLigature:qY,LucideLightbulb:B_,LucideLightbulbOff:UY,LucideLineChart:uj,LucideLink:zo,LucideLink2:cl,LucideLink2Off:VY,LucideLinkedin:Mp,LucideList:Ch,LucideListCheck:HY,LucideListChecks:WY,LucideListCollapse:GY,LucideListEnd:KY,LucideListFilter:ZY,LucideListMinus:YY,LucideListMusic:XY,LucideListOrdered:h0,LucideListPlus:QY,LucideListRestart:JY,LucideListStart:eX,LucideListTodo:tX,LucideListTree:sX,LucideListVideo:rX,LucideListX:nX,LucideLoader:iX,LucideLoader2:ws,LucideLoaderCircle:ws,LucideLoaderPinwheel:aX,LucideLocate:cX,LucideLocateFixed:oX,LucideLocateOff:lX,LucideLock:Mh,LucideLockKeyhole:dX,LucideLockKeyholeOpen:gN,LucideLockOpen:yN,LucideLogIn:EM,LucideLogOut:sS,LucideLogs:uX,LucideLollipop:hX,LucideLuggage:mX,LucideMSquare:xk,LucideMagnet:pX,LucideMail:dr,LucideMailCheck:fX,LucideMailMinus:xX,LucideMailOpen:gX,LucideMailPlus:cL,LucideMailQuestion:yX,LucideMailSearch:vX,LucideMailWarning:bX,LucideMailX:dL,LucideMailbox:_X,LucideMails:wX,LucideMap:PM,LucideMapPin:Ba,LucideMapPinCheck:NX,LucideMapPinCheckInside:jX,LucideMapPinHouse:kX,LucideMapPinMinus:CX,LucideMapPinMinusInside:SX,LucideMapPinOff:MX,LucideMapPinPlus:AX,LucideMapPinPlusInside:TX,LucideMapPinX:PX,LucideMapPinXInside:EX,LucideMapPinned:IX,LucideMartini:LX,LucideMaximize:rS,LucideMaximize2:DX,LucideMedal:a1,LucideMegaphone:Kh,LucideMegaphoneOff:OX,LucideMeh:RX,LucideMemoryStick:FX,LucideMenu:IM,LucideMenuSquare:gk,LucideMerge:zX,LucideMessageCircle:zc,LucideMessageCircleCode:BX,LucideMessageCircleDashed:$X,LucideMessageCircleHeart:LM,LucideMessageCircleMore:qX,LucideMessageCircleOff:UX,LucideMessageCirclePlus:VX,LucideMessageCircleQuestion:uL,LucideMessageCircleReply:HX,LucideMessageCircleWarning:WX,LucideMessageCircleX:GX,LucideMessageSquare:io,LucideMessageSquareCode:KX,LucideMessageSquareDashed:ZX,LucideMessageSquareDiff:YX,LucideMessageSquareDot:XX,LucideMessageSquareHeart:QX,LucideMessageSquareLock:JX,LucideMessageSquareMore:hL,LucideMessageSquareOff:eQ,LucideMessageSquarePlus:DM,LucideMessageSquareQuote:mL,LucideMessageSquareReply:tQ,LucideMessageSquareShare:sQ,LucideMessageSquareText:rQ,LucideMessageSquareWarning:nQ,LucideMessageSquareX:aQ,LucideMessagesSquare:iQ,LucideMic:pL,LucideMic2:vN,LucideMicOff:oQ,LucideMicVocal:vN,LucideMicrochip:lQ,LucideMicroscope:cQ,LucideMicrowave:dQ,LucideMilestone:uQ,LucideMilk:mQ,LucideMilkOff:hQ,LucideMinimize:fQ,LucideMinimize2:pQ,LucideMinus:m0,LucideMinusCircle:Ej,LucideMinusSquare:yk,LucideMonitor:aS,LucideMonitorCheck:xQ,LucideMonitorCog:gQ,LucideMonitorDot:yQ,LucideMonitorDown:vQ,LucideMonitorOff:bQ,LucideMonitorPause:_Q,LucideMonitorPlay:wQ,LucideMonitorSmartphone:jQ,LucideMonitorSpeaker:NQ,LucideMonitorStop:kQ,LucideMonitorUp:nS,LucideMonitorX:SQ,LucideMoon:MQ,LucideMoonStar:CQ,LucideMoreHorizontal:px,LucideMoreVertical:mx,LucideMountain:AQ,LucideMountainSnow:TQ,LucideMouse:LQ,LucideMouseOff:EQ,LucideMousePointer:bh,LucideMousePointer2:PQ,LucideMousePointerBan:IQ,LucideMousePointerClick:Xg,LucideMousePointerSquareDashed:lk,LucideMove:GQ,LucideMove3D:bN,LucideMove3d:bN,LucideMoveDiagonal:OQ,LucideMoveDiagonal2:DQ,LucideMoveDown:zQ,LucideMoveDownLeft:RQ,LucideMoveDownRight:FQ,LucideMoveHorizontal:BQ,LucideMoveLeft:$Q,LucideMoveRight:qQ,LucideMoveUp:HQ,LucideMoveUpLeft:UQ,LucideMoveUpRight:VQ,LucideMoveVertical:WQ,LucideMusic:XQ,LucideMusic2:KQ,LucideMusic3:ZQ,LucideMusic4:YQ,LucideNavigation:tJ,LucideNavigation2:JQ,LucideNavigation2Off:QQ,LucideNavigationOff:eJ,LucideNetwork:sJ,LucideNewspaper:i1,LucideNfc:rJ,LucideNotebook:oJ,LucideNotebookPen:nJ,LucideNotebookTabs:aJ,LucideNotebookText:iJ,LucideNotepadText:cJ,LucideNotepadTextDashed:lJ,LucideNut:uJ,LucideNutOff:dJ,LucideOctagon:mJ,LucideOctagonAlert:Dv,LucideOctagonMinus:hJ,LucideOctagonPause:_N,LucideOctagonX:wN,LucideOmega:pJ,LucideOption:fJ,LucideOrbit:xJ,LucideOrigami:gJ,LucideOutdent:pN,LucidePackage:Cl,LucidePackage2:yJ,LucidePackageCheck:vJ,LucidePackageMinus:bJ,LucidePackageOpen:_J,LucidePackagePlus:wJ,LucidePackageSearch:jJ,LucidePackageX:NJ,LucidePaintBucket:kJ,LucidePaintRoller:SJ,LucidePaintbrush:CJ,LucidePaintbrush2:jN,LucidePaintbrushVertical:jN,LucidePalette:sc,LucidePalmtree:Bk,LucidePanelBottom:AJ,LucidePanelBottomClose:MJ,LucidePanelBottomDashed:NN,LucidePanelBottomInactive:NN,LucidePanelBottomOpen:TJ,LucidePanelLeft:MN,LucidePanelLeftClose:kN,LucidePanelLeftDashed:SN,LucidePanelLeftInactive:SN,LucidePanelLeftOpen:CN,LucidePanelRight:IJ,LucidePanelRightClose:EJ,LucidePanelRightDashed:TN,LucidePanelRightInactive:TN,LucidePanelRightOpen:PJ,LucidePanelTop:OJ,LucidePanelTopClose:LJ,LucidePanelTopDashed:AN,LucidePanelTopInactive:AN,LucidePanelTopOpen:DJ,LucidePanelsLeftBottom:RJ,LucidePanelsLeftRight:Kj,LucidePanelsRightBottom:FJ,LucidePanelsTopBottom:DN,LucidePanelsTopLeft:Ov,LucidePaperclip:iS,LucideParentheses:zJ,LucideParkingCircle:Ij,LucideParkingCircleOff:Pj,LucideParkingMeter:BJ,LucideParkingSquare:_k,LucideParkingSquareOff:bk,LucidePartyPopper:tu,LucidePause:Dm,LucidePauseCircle:Lj,LucidePauseOctagon:_N,LucidePawPrint:$J,LucidePcCase:qJ,LucidePen:Qy,LucidePenBox:dd,LucidePenLine:Rv,LucidePenOff:UJ,LucidePenSquare:dd,LucidePenTool:$_,LucidePencil:Da,LucidePencilLine:VJ,LucidePencilOff:HJ,LucidePencilRuler:WJ,LucidePentagon:GJ,LucidePercent:OM,LucidePercentCircle:Dj,LucidePercentDiamond:Yj,LucidePercentSquare:wk,LucidePersonStanding:KJ,LucidePhilippinePeso:ZJ,LucidePhone:Un,LucidePhoneCall:YJ,LucidePhoneForwarded:XJ,LucidePhoneIncoming:QJ,LucidePhoneMissed:JJ,LucidePhoneOff:eee,LucidePhoneOutgoing:tee,LucidePi:see,LucidePiSquare:jk,LucidePiano:ree,LucidePickaxe:nee,LucidePictureInPicture:iee,LucidePictureInPicture2:aee,LucidePieChart:fj,LucidePiggyBank:oee,LucidePilcrow:dee,LucidePilcrowLeft:lee,LucidePilcrowRight:cee,LucidePilcrowSquare:Nk,LucidePill:hee,LucidePillBottle:uee,LucidePin:q_,LucidePinOff:fL,LucidePipette:mee,LucidePizza:pee,LucidePlane:gee,LucidePlaneLanding:fee,LucidePlaneTakeoff:xee,LucidePlay:rl,LucidePlayCircle:mp,LucidePlaySquare:kk,LucidePlug:xL,LucidePlug2:yee,LucidePlugZap:EN,LucidePlugZap2:EN,LucidePlus:qs,LucidePlusCircle:Oj,LucidePlusSquare:Sk,LucidePocket:bee,LucidePocketKnife:vee,LucidePodcast:_ee,LucidePointer:jee,LucidePointerOff:wee,LucidePopcorn:Nee,LucidePopsicle:kee,LucidePoundSterling:See,LucidePower:gL,LucidePowerCircle:Rj,LucidePowerOff:Cee,LucidePowerSquare:Ck,LucidePresentation:Qg,LucidePrinter:yL,LucidePrinterCheck:Mee,LucideProjector:Tee,LucideProportions:Aee,LucidePuzzle:Eee,LucidePyramid:Pee,LucideQrCode:o1,LucideQuote:U_,LucideRabbit:Iee,LucideRadar:Lee,LucideRadiation:Dee,LucideRadical:Oee,LucideRadio:l1,LucideRadioReceiver:Ree,LucideRadioTower:Fee,LucideRadius:zee,LucideRailSymbol:Bee,LucideRainbow:$ee,LucideRat:qee,LucideRatio:Uee,LucideReceipt:Qee,LucideReceiptCent:Vee,LucideReceiptEuro:Hee,LucideReceiptIndianRupee:Wee,LucideReceiptJapaneseYen:Gee,LucideReceiptPoundSterling:Kee,LucideReceiptRussianRuble:Zee,LucideReceiptSwissFranc:Yee,LucideReceiptText:Xee,LucideRectangleEllipsis:PN,LucideRectangleHorizontal:Jee,LucideRectangleVertical:ete,LucideRecycle:tte,LucideRedo:oS,LucideRedo2:ste,LucideRedoDot:rte,LucideRefreshCcw:RM,LucideRefreshCcwDot:nte,LucideRefreshCw:Wo,LucideRefreshCwOff:ate,LucideRefrigerator:ite,LucideRegex:ote,LucideRemoveFormatting:lte,LucideRepeat:vL,LucideRepeat1:cte,LucideRepeat2:dte,LucideReplace:hte,LucideReplaceAll:ute,LucideReply:bL,LucideReplyAll:mte,LucideRewind:pte,LucideRibbon:fte,LucideRocket:p0,LucideRockingChair:xte,LucideRollerCoaster:gte,LucideRotate3D:IN,LucideRotate3d:IN,LucideRotateCcw:c1,LucideRotateCcwSquare:yte,LucideRotateCw:_L,LucideRotateCwSquare:vte,LucideRoute:_te,LucideRouteOff:bte,LucideRouter:wte,LucideRows:LN,LucideRows2:LN,LucideRows3:DN,LucideRows4:jte,LucideRss:Nte,LucideRuler:d1,LucideRussianRuble:kte,LucideSailboat:Ste,LucideSalad:Cte,LucideSandwich:Mte,LucideSatellite:Ate,LucideSatelliteDish:Tte,LucideSave:ed,LucideSaveAll:Ete,LucideSaveOff:Pte,LucideScale:wL,LucideScale3D:ON,LucideScale3d:ON,LucideScaling:Ite,LucideScan:$te,LucideScanBarcode:Lte,LucideScanEye:Dte,LucideScanFace:Ote,LucideScanLine:Rte,LucideScanQrCode:Fte,LucideScanSearch:zte,LucideScanText:Bte,LucideScatterChart:xj,LucideSchool:qte,LucideSchool2:qk,LucideScissors:Vte,LucideScissorsLineDashed:Ute,LucideScissorsSquare:Mk,LucideScissorsSquareDashedBottom:ek,LucideScreenShare:Wte,LucideScreenShareOff:Hte,LucideScroll:Kte,LucideScrollText:Gte,LucideSearch:hn,LucideSearchCheck:Zte,LucideSearchCode:Yte,LucideSearchSlash:Xte,LucideSearchX:jL,LucideSection:Qte,LucideSend:Rn,LucideSendHorizonal:RN,LucideSendHorizontal:RN,LucideSendToBack:Jte,LucideSeparatorHorizontal:ese,LucideSeparatorVertical:tse,LucideServer:ase,LucideServerCog:sse,LucideServerCrash:rse,LucideServerOff:nse,LucideSettings:Yo,LucideSettings2:NL,LucideShapes:ise,LucideShare:kL,LucideShare2:bd,LucideSheet:ose,LucideShell:lse,LucideShield:Th,LucideShieldAlert:cse,LucideShieldBan:dse,LucideShieldCheck:SL,LucideShieldClose:FN,LucideShieldEllipsis:use,LucideShieldHalf:hse,LucideShieldMinus:mse,LucideShieldOff:pse,LucideShieldPlus:fse,LucideShieldQuestion:xse,LucideShieldX:FN,LucideShip:yse,LucideShipWheel:gse,LucideShirt:vse,LucideShoppingBag:f0,LucideShoppingBasket:bse,LucideShoppingCart:yp,LucideShovel:_se,LucideShowerHead:wse,LucideShrink:jse,LucideShrub:Nse,LucideShuffle:lS,LucideSidebar:MN,LucideSidebarClose:kN,LucideSidebarOpen:CN,LucideSigma:kse,LucideSigmaSquare:Tk,LucideSignal:Ase,LucideSignalHigh:Sse,LucideSignalLow:Cse,LucideSignalMedium:Mse,LucideSignalZero:Tse,LucideSignature:Ese,LucideSignpost:Ise,LucideSignpostBig:Pse,LucideSiren:Lse,LucideSkipBack:Dse,LucideSkipForward:Ose,LucideSkull:Rse,LucideSlack:Fse,LucideSlash:zse,LucideSlashSquare:Ak,LucideSlice:Bse,LucideSliders:zN,LucideSlidersHorizontal:FM,LucideSlidersVertical:zN,LucideSmartphone:u1,LucideSmartphoneCharging:$se,LucideSmartphoneNfc:qse,LucideSmile:Vse,LucideSmilePlus:Use,LucideSnail:Hse,LucideSnowflake:r0,LucideSofa:Wse,LucideSortAsc:Y2,LucideSortDesc:G2,LucideSoup:Gse,LucideSpace:Kse,LucideSpade:Zse,LucideSparkle:Yse,LucideSparkles:un,LucideSpeaker:Xse,LucideSpeech:Qse,LucideSpellCheck:ere,LucideSpellCheck2:Jse,LucideSpline:tre,LucideSplit:sre,LucideSplitSquareHorizontal:Ek,LucideSplitSquareVertical:Pk,LucideSprayCan:rre,LucideSprout:nre,LucideSquare:x0,LucideSquareActivity:BN,LucideSquareArrowDown:UN,LucideSquareArrowDownLeft:$N,LucideSquareArrowDownRight:qN,LucideSquareArrowLeft:VN,LucideSquareArrowOutDownLeft:HN,LucideSquareArrowOutDownRight:WN,LucideSquareArrowOutUpLeft:GN,LucideSquareArrowOutUpRight:KN,LucideSquareArrowRight:ZN,LucideSquareArrowUp:QN,LucideSquareArrowUpLeft:YN,LucideSquareArrowUpRight:XN,LucideSquareAsterisk:JN,LucideSquareBottomDashedScissors:ek,LucideSquareChartGantt:qy,LucideSquareCheck:tk,LucideSquareCheckBig:Fv,LucideSquareChevronDown:sk,LucideSquareChevronLeft:rk,LucideSquareChevronRight:nk,LucideSquareChevronUp:ak,LucideSquareCode:ik,LucideSquareDashed:ck,LucideSquareDashedBottom:ire,LucideSquareDashedBottomCode:are,LucideSquareDashedKanban:ok,LucideSquareDashedMousePointer:lk,LucideSquareDivide:dk,LucideSquareDot:uk,LucideSquareEqual:hk,LucideSquareFunction:mk,LucideSquareGanttChart:qy,LucideSquareKanban:pk,LucideSquareLibrary:fk,LucideSquareM:xk,LucideSquareMenu:gk,LucideSquareMinus:yk,LucideSquareMousePointer:vk,LucideSquareParking:_k,LucideSquareParkingOff:bk,LucideSquarePen:dd,LucideSquarePercent:wk,LucideSquarePi:jk,LucideSquarePilcrow:Nk,LucideSquarePlay:kk,LucideSquarePlus:Sk,LucideSquarePower:Ck,LucideSquareRadical:ore,LucideSquareScissors:Mk,LucideSquareSigma:Tk,LucideSquareSlash:Ak,LucideSquareSplitHorizontal:Ek,LucideSquareSplitVertical:Pk,LucideSquareSquare:lre,LucideSquareStack:cre,LucideSquareTerminal:Ik,LucideSquareUser:Dk,LucideSquareUserRound:Lk,LucideSquareX:Ok,LucideSquircle:dre,LucideSquirrel:ure,LucideStamp:hre,LucideStar:Jn,LucideStarHalf:mre,LucideStarOff:pre,LucideStars:un,LucideStepBack:fre,LucideStepForward:xre,LucideStethoscope:gre,LucideSticker:yre,LucideStickyNote:vre,LucideStopCircle:zj,LucideStore:zM,LucideStretchHorizontal:bre,LucideStretchVertical:_re,LucideStrikethrough:CL,LucideSubscript:wre,LucideSubtitles:nj,LucideSun:h1,LucideSunDim:jre,LucideSunMedium:Nre,LucideSunMoon:kre,LucideSunSnow:Sre,LucideSunrise:Cre,LucideSunset:Mre,LucideSuperscript:Tre,LucideSwatchBook:Are,LucideSwissFranc:Ere,LucideSwitchCamera:Pre,LucideSword:Ire,LucideSwords:Lre,LucideSyringe:Dre,LucideTable:$M,LucideTable2:BM,LucideTableCellsMerge:Ore,LucideTableCellsSplit:Rre,LucideTableColumnsSplit:Fre,LucideTableOfContents:zre,LucideTableProperties:Bre,LucideTableRowsSplit:$re,LucideTablet:Ure,LucideTabletSmartphone:qre,LucideTablets:Vre,LucideTag:Om,LucideTags:Hre,LucideTally1:Wre,LucideTally2:Gre,LucideTally3:Kre,LucideTally4:Zre,LucideTally5:Yre,LucideTangent:Xre,LucideTarget:Rm,LucideTelescope:Qre,LucideTent:ene,LucideTentTree:Jre,LucideTerminal:tne,LucideTerminalSquare:Ik,LucideTestTube:sne,LucideTestTube2:Rk,LucideTestTubeDiagonal:Rk,LucideTestTubes:rne,LucideText:lne,LucideTextCursor:ane,LucideTextCursorInput:nne,LucideTextQuote:ine,LucideTextSearch:one,LucideTextSelect:Fk,LucideTextSelection:Fk,LucideTheater:cne,LucideThermometer:ML,LucideThermometerSnowflake:dne,LucideThermometerSun:une,LucideThumbsDown:TL,LucideThumbsUp:eh,LucideTicket:AL,LucideTicketCheck:hne,LucideTicketMinus:mne,LucideTicketPercent:pne,LucideTicketPlus:fne,LucideTicketSlash:xne,LucideTicketX:gne,LucideTickets:vne,LucideTicketsPlane:yne,LucideTimer:wne,LucideTimerOff:bne,LucideTimerReset:_ne,LucideToggleLeft:jne,LucideToggleRight:Nne,LucideToilet:kne,LucideTornado:Sne,LucideTorus:Cne,LucideTouchpad:Tne,LucideTouchpadOff:Mne,LucideTowerControl:Ane,LucideToyBrick:Ene,LucideTractor:Pne,LucideTrafficCone:Ine,LucideTrain:zk,LucideTrainFront:Dne,LucideTrainFrontTunnel:Lne,LucideTrainTrack:One,LucideTramFront:zk,LucideTrash:Rne,LucideTrash2:Nr,LucideTreeDeciduous:Fne,LucideTreePalm:Bk,LucideTreePine:m1,LucideTrees:zne,LucideTrello:Bne,LucideTrendingDown:cS,LucideTrendingUp:Ol,LucideTrendingUpDown:$ne,LucideTriangle:Une,LucideTriangleAlert:Gu,LucideTriangleRight:qne,LucideTrophy:xo,LucideTruck:EL,LucideTurtle:Vne,LucideTv:Wne,LucideTv2:$k,LucideTvMinimal:$k,LucideTvMinimalPlay:Hne,LucideTwitch:Gne,LucideTwitter:Kne,LucideType:Yne,LucideTypeOutline:Zne,LucideUmbrella:Qne,LucideUmbrellaOff:Xne,LucideUnderline:PL,LucideUndo:dS,LucideUndo2:Jne,LucideUndoDot:eae,LucideUnfoldHorizontal:tae,LucideUnfoldVertical:sae,LucideUngroup:rae,LucideUniversity:qk,LucideUnlink:uS,LucideUnlink2:nae,LucideUnlock:yN,LucideUnlockKeyhole:gN,LucideUnplug:aae,LucideUpload:oi,LucideUploadCloud:Hj,LucideUsb:iae,LucideUser:to,LucideUser2:Kk,LucideUserCheck:V_,LucideUserCheck2:Uk,LucideUserCircle:$j,LucideUserCircle2:Bj,LucideUserCog:IL,LucideUserCog2:Vk,LucideUserMinus:LL,LucideUserMinus2:Hk,LucideUserPen:oae,LucideUserPlus:rc,LucideUserPlus2:Wk,LucideUserRound:Kk,LucideUserRoundCheck:Uk,LucideUserRoundCog:Vk,LucideUserRoundMinus:Hk,LucideUserRoundPen:lae,LucideUserRoundPlus:Wk,LucideUserRoundSearch:cae,LucideUserRoundX:Gk,LucideUserSearch:dae,LucideUserSquare:Dk,LucideUserSquare2:Lk,LucideUserX:uae,LucideUserX2:Gk,LucideUsers:mr,LucideUsers2:Zk,LucideUsersRound:Zk,LucideUtensils:Xk,LucideUtensilsCrossed:Yk,LucideUtilityPole:hae,LucideVariable:qM,LucideVault:mae,LucideVegan:pae,LucideVenetianMask:fae,LucideVerified:J2,LucideVibrate:gae,LucideVibrateOff:xae,LucideVideo:Cn,LucideVideoOff:yae,LucideVideotape:vae,LucideView:bae,LucideVoicemail:_ae,LucideVolleyball:wae,LucideVolume:Cae,LucideVolume1:jae,LucideVolume2:Nae,LucideVolumeOff:kae,LucideVolumeX:Sae,LucideVote:Mae,LucideWallet:DL,LucideWallet2:Qk,LucideWalletCards:Tae,LucideWalletMinimal:Qk,LucideWallpaper:Aae,LucideWand:Eae,LucideWand2:zv,LucideWandSparkles:zv,LucideWarehouse:Pae,LucideWashingMachine:Iae,LucideWatch:Lae,LucideWaves:OL,LucideWaypoints:Dae,LucideWebcam:Oae,LucideWebhook:Fae,LucideWebhookOff:Rae,LucideWeight:zae,LucideWheat:$ae,LucideWheatOff:Bae,LucideWholeWord:qae,LucideWifi:Gae,LucideWifiHigh:Uae,LucideWifiLow:Vae,LucideWifiOff:Hae,LucideWifiZero:Wae,LucideWind:Zae,LucideWindArrowDown:Kae,LucideWine:Xae,LucideWineOff:Yae,LucideWorkflow:Qae,LucideWorm:Jae,LucideWrapText:eie,LucideWrench:Jg,LucideX:Or,LucideXCircle:xc,LucideXOctagon:wN,LucideXSquare:Ok,LucideYoutube:tie,LucideZap:Fm,LucideZapOff:sie,LucideZoomIn:H_,LucideZoomOut:UM,Luggage:mX,LuggageIcon:mX,MSquare:xk,MSquareIcon:xk,Magnet:pX,MagnetIcon:pX,Mail:dr,MailCheck:fX,MailCheckIcon:fX,MailIcon:dr,MailMinus:xX,MailMinusIcon:xX,MailOpen:gX,MailOpenIcon:gX,MailPlus:cL,MailPlusIcon:cL,MailQuestion:yX,MailQuestionIcon:yX,MailSearch:vX,MailSearchIcon:vX,MailWarning:bX,MailWarningIcon:bX,MailX:dL,MailXIcon:dL,Mailbox:_X,MailboxIcon:_X,Mails:wX,MailsIcon:wX,Map:PM,MapIcon:PM,MapPin:Ba,MapPinCheck:NX,MapPinCheckIcon:NX,MapPinCheckInside:jX,MapPinCheckInsideIcon:jX,MapPinHouse:kX,MapPinHouseIcon:kX,MapPinIcon:Ba,MapPinMinus:CX,MapPinMinusIcon:CX,MapPinMinusInside:SX,MapPinMinusInsideIcon:SX,MapPinOff:MX,MapPinOffIcon:MX,MapPinPlus:AX,MapPinPlusIcon:AX,MapPinPlusInside:TX,MapPinPlusInsideIcon:TX,MapPinX:PX,MapPinXIcon:PX,MapPinXInside:EX,MapPinXInsideIcon:EX,MapPinned:IX,MapPinnedIcon:IX,Martini:LX,MartiniIcon:LX,Maximize:rS,Maximize2:DX,Maximize2Icon:DX,MaximizeIcon:rS,Medal:a1,MedalIcon:a1,Megaphone:Kh,MegaphoneIcon:Kh,MegaphoneOff:OX,MegaphoneOffIcon:OX,Meh:RX,MehIcon:RX,MemoryStick:FX,MemoryStickIcon:FX,Menu:IM,MenuIcon:IM,MenuSquare:gk,MenuSquareIcon:gk,Merge:zX,MergeIcon:zX,MessageCircle:zc,MessageCircleCode:BX,MessageCircleCodeIcon:BX,MessageCircleDashed:$X,MessageCircleDashedIcon:$X,MessageCircleHeart:LM,MessageCircleHeartIcon:LM,MessageCircleIcon:zc,MessageCircleMore:qX,MessageCircleMoreIcon:qX,MessageCircleOff:UX,MessageCircleOffIcon:UX,MessageCirclePlus:VX,MessageCirclePlusIcon:VX,MessageCircleQuestion:uL,MessageCircleQuestionIcon:uL,MessageCircleReply:HX,MessageCircleReplyIcon:HX,MessageCircleWarning:WX,MessageCircleWarningIcon:WX,MessageCircleX:GX,MessageCircleXIcon:GX,MessageSquare:io,MessageSquareCode:KX,MessageSquareCodeIcon:KX,MessageSquareDashed:ZX,MessageSquareDashedIcon:ZX,MessageSquareDiff:YX,MessageSquareDiffIcon:YX,MessageSquareDot:XX,MessageSquareDotIcon:XX,MessageSquareHeart:QX,MessageSquareHeartIcon:QX,MessageSquareIcon:io,MessageSquareLock:JX,MessageSquareLockIcon:JX,MessageSquareMore:hL,MessageSquareMoreIcon:hL,MessageSquareOff:eQ,MessageSquareOffIcon:eQ,MessageSquarePlus:DM,MessageSquarePlusIcon:DM,MessageSquareQuote:mL,MessageSquareQuoteIcon:mL,MessageSquareReply:tQ,MessageSquareReplyIcon:tQ,MessageSquareShare:sQ,MessageSquareShareIcon:sQ,MessageSquareText:rQ,MessageSquareTextIcon:rQ,MessageSquareWarning:nQ,MessageSquareWarningIcon:nQ,MessageSquareX:aQ,MessageSquareXIcon:aQ,MessagesSquare:iQ,MessagesSquareIcon:iQ,Mic:pL,Mic2:vN,Mic2Icon:vN,MicIcon:pL,MicOff:oQ,MicOffIcon:oQ,MicVocal:vN,MicVocalIcon:vN,Microchip:lQ,MicrochipIcon:lQ,Microscope:cQ,MicroscopeIcon:cQ,Microwave:dQ,MicrowaveIcon:dQ,Milestone:uQ,MilestoneIcon:uQ,Milk:mQ,MilkIcon:mQ,MilkOff:hQ,MilkOffIcon:hQ,Minimize:fQ,Minimize2:pQ,Minimize2Icon:pQ,MinimizeIcon:fQ,Minus:m0,MinusCircle:Ej,MinusCircleIcon:Ej,MinusIcon:m0,MinusSquare:yk,MinusSquareIcon:yk,Monitor:aS,MonitorCheck:xQ,MonitorCheckIcon:xQ,MonitorCog:gQ,MonitorCogIcon:gQ,MonitorDot:yQ,MonitorDotIcon:yQ,MonitorDown:vQ,MonitorDownIcon:vQ,MonitorIcon:aS,MonitorOff:bQ,MonitorOffIcon:bQ,MonitorPause:_Q,MonitorPauseIcon:_Q,MonitorPlay:wQ,MonitorPlayIcon:wQ,MonitorSmartphone:jQ,MonitorSmartphoneIcon:jQ,MonitorSpeaker:NQ,MonitorSpeakerIcon:NQ,MonitorStop:kQ,MonitorStopIcon:kQ,MonitorUp:nS,MonitorUpIcon:nS,MonitorX:SQ,MonitorXIcon:SQ,Moon:MQ,MoonIcon:MQ,MoonStar:CQ,MoonStarIcon:CQ,MoreHorizontal:px,MoreHorizontalIcon:px,MoreVertical:mx,MoreVerticalIcon:mx,Mountain:AQ,MountainIcon:AQ,MountainSnow:TQ,MountainSnowIcon:TQ,Mouse:LQ,MouseIcon:LQ,MouseOff:EQ,MouseOffIcon:EQ,MousePointer:bh,MousePointer2:PQ,MousePointer2Icon:PQ,MousePointerBan:IQ,MousePointerBanIcon:IQ,MousePointerClick:Xg,MousePointerClickIcon:Xg,MousePointerIcon:bh,MousePointerSquareDashed:lk,MousePointerSquareDashedIcon:lk,Move:GQ,Move3D:bN,Move3DIcon:bN,Move3d:bN,Move3dIcon:bN,MoveDiagonal:OQ,MoveDiagonal2:DQ,MoveDiagonal2Icon:DQ,MoveDiagonalIcon:OQ,MoveDown:zQ,MoveDownIcon:zQ,MoveDownLeft:RQ,MoveDownLeftIcon:RQ,MoveDownRight:FQ,MoveDownRightIcon:FQ,MoveHorizontal:BQ,MoveHorizontalIcon:BQ,MoveIcon:GQ,MoveLeft:$Q,MoveLeftIcon:$Q,MoveRight:qQ,MoveRightIcon:qQ,MoveUp:HQ,MoveUpIcon:HQ,MoveUpLeft:UQ,MoveUpLeftIcon:UQ,MoveUpRight:VQ,MoveUpRightIcon:VQ,MoveVertical:WQ,MoveVerticalIcon:WQ,Music:XQ,Music2:KQ,Music2Icon:KQ,Music3:ZQ,Music3Icon:ZQ,Music4:YQ,Music4Icon:YQ,MusicIcon:XQ,Navigation:tJ,Navigation2:JQ,Navigation2Icon:JQ,Navigation2Off:QQ,Navigation2OffIcon:QQ,NavigationIcon:tJ,NavigationOff:eJ,NavigationOffIcon:eJ,Network:sJ,NetworkIcon:sJ,Newspaper:i1,NewspaperIcon:i1,Nfc:rJ,NfcIcon:rJ,Notebook:oJ,NotebookIcon:oJ,NotebookPen:nJ,NotebookPenIcon:nJ,NotebookTabs:aJ,NotebookTabsIcon:aJ,NotebookText:iJ,NotebookTextIcon:iJ,NotepadText:cJ,NotepadTextDashed:lJ,NotepadTextDashedIcon:lJ,NotepadTextIcon:cJ,Nut:uJ,NutIcon:uJ,NutOff:dJ,NutOffIcon:dJ,Octagon:mJ,OctagonAlert:Dv,OctagonAlertIcon:Dv,OctagonIcon:mJ,OctagonMinus:hJ,OctagonMinusIcon:hJ,OctagonPause:_N,OctagonPauseIcon:_N,OctagonX:wN,OctagonXIcon:wN,Omega:pJ,OmegaIcon:pJ,Option:fJ,OptionIcon:fJ,Orbit:xJ,OrbitIcon:xJ,Origami:gJ,OrigamiIcon:gJ,Outdent:pN,OutdentIcon:pN,Package:Cl,Package2:yJ,Package2Icon:yJ,PackageCheck:vJ,PackageCheckIcon:vJ,PackageIcon:Cl,PackageMinus:bJ,PackageMinusIcon:bJ,PackageOpen:_J,PackageOpenIcon:_J,PackagePlus:wJ,PackagePlusIcon:wJ,PackageSearch:jJ,PackageSearchIcon:jJ,PackageX:NJ,PackageXIcon:NJ,PaintBucket:kJ,PaintBucketIcon:kJ,PaintRoller:SJ,PaintRollerIcon:SJ,Paintbrush:CJ,Paintbrush2:jN,Paintbrush2Icon:jN,PaintbrushIcon:CJ,PaintbrushVertical:jN,PaintbrushVerticalIcon:jN,Palette:sc,PaletteIcon:sc,Palmtree:Bk,PalmtreeIcon:Bk,PanelBottom:AJ,PanelBottomClose:MJ,PanelBottomCloseIcon:MJ,PanelBottomDashed:NN,PanelBottomDashedIcon:NN,PanelBottomIcon:AJ,PanelBottomInactive:NN,PanelBottomInactiveIcon:NN,PanelBottomOpen:TJ,PanelBottomOpenIcon:TJ,PanelLeft:MN,PanelLeftClose:kN,PanelLeftCloseIcon:kN,PanelLeftDashed:SN,PanelLeftDashedIcon:SN,PanelLeftIcon:MN,PanelLeftInactive:SN,PanelLeftInactiveIcon:SN,PanelLeftOpen:CN,PanelLeftOpenIcon:CN,PanelRight:IJ,PanelRightClose:EJ,PanelRightCloseIcon:EJ,PanelRightDashed:TN,PanelRightDashedIcon:TN,PanelRightIcon:IJ,PanelRightInactive:TN,PanelRightInactiveIcon:TN,PanelRightOpen:PJ,PanelRightOpenIcon:PJ,PanelTop:OJ,PanelTopClose:LJ,PanelTopCloseIcon:LJ,PanelTopDashed:AN,PanelTopDashedIcon:AN,PanelTopIcon:OJ,PanelTopInactive:AN,PanelTopInactiveIcon:AN,PanelTopOpen:DJ,PanelTopOpenIcon:DJ,PanelsLeftBottom:RJ,PanelsLeftBottomIcon:RJ,PanelsLeftRight:Kj,PanelsLeftRightIcon:Kj,PanelsRightBottom:FJ,PanelsRightBottomIcon:FJ,PanelsTopBottom:DN,PanelsTopBottomIcon:DN,PanelsTopLeft:Ov,PanelsTopLeftIcon:Ov,Paperclip:iS,PaperclipIcon:iS,Parentheses:zJ,ParenthesesIcon:zJ,ParkingCircle:Ij,ParkingCircleIcon:Ij,ParkingCircleOff:Pj,ParkingCircleOffIcon:Pj,ParkingMeter:BJ,ParkingMeterIcon:BJ,ParkingSquare:_k,ParkingSquareIcon:_k,ParkingSquareOff:bk,ParkingSquareOffIcon:bk,PartyPopper:tu,PartyPopperIcon:tu,Pause:Dm,PauseCircle:Lj,PauseCircleIcon:Lj,PauseIcon:Dm,PauseOctagon:_N,PauseOctagonIcon:_N,PawPrint:$J,PawPrintIcon:$J,PcCase:qJ,PcCaseIcon:qJ,Pen:Qy,PenBox:dd,PenBoxIcon:dd,PenIcon:Qy,PenLine:Rv,PenLineIcon:Rv,PenOff:UJ,PenOffIcon:UJ,PenSquare:dd,PenSquareIcon:dd,PenTool:$_,PenToolIcon:$_,Pencil:Da,PencilIcon:Da,PencilLine:VJ,PencilLineIcon:VJ,PencilOff:HJ,PencilOffIcon:HJ,PencilRuler:WJ,PencilRulerIcon:WJ,Pentagon:GJ,PentagonIcon:GJ,Percent:OM,PercentCircle:Dj,PercentCircleIcon:Dj,PercentDiamond:Yj,PercentDiamondIcon:Yj,PercentIcon:OM,PercentSquare:wk,PercentSquareIcon:wk,PersonStanding:KJ,PersonStandingIcon:KJ,PhilippinePeso:ZJ,PhilippinePesoIcon:ZJ,Phone:Un,PhoneCall:YJ,PhoneCallIcon:YJ,PhoneForwarded:XJ,PhoneForwardedIcon:XJ,PhoneIcon:Un,PhoneIncoming:QJ,PhoneIncomingIcon:QJ,PhoneMissed:JJ,PhoneMissedIcon:JJ,PhoneOff:eee,PhoneOffIcon:eee,PhoneOutgoing:tee,PhoneOutgoingIcon:tee,Pi:see,PiIcon:see,PiSquare:jk,PiSquareIcon:jk,Piano:ree,PianoIcon:ree,Pickaxe:nee,PickaxeIcon:nee,PictureInPicture:iee,PictureInPicture2:aee,PictureInPicture2Icon:aee,PictureInPictureIcon:iee,PieChart:fj,PieChartIcon:fj,PiggyBank:oee,PiggyBankIcon:oee,Pilcrow:dee,PilcrowIcon:dee,PilcrowLeft:lee,PilcrowLeftIcon:lee,PilcrowRight:cee,PilcrowRightIcon:cee,PilcrowSquare:Nk,PilcrowSquareIcon:Nk,Pill:hee,PillBottle:uee,PillBottleIcon:uee,PillIcon:hee,Pin:q_,PinIcon:q_,PinOff:fL,PinOffIcon:fL,Pipette:mee,PipetteIcon:mee,Pizza:pee,PizzaIcon:pee,Plane:gee,PlaneIcon:gee,PlaneLanding:fee,PlaneLandingIcon:fee,PlaneTakeoff:xee,PlaneTakeoffIcon:xee,Play:rl,PlayCircle:mp,PlayCircleIcon:mp,PlayIcon:rl,PlaySquare:kk,PlaySquareIcon:kk,Plug:xL,Plug2:yee,Plug2Icon:yee,PlugIcon:xL,PlugZap:EN,PlugZap2:EN,PlugZap2Icon:EN,PlugZapIcon:EN,Plus:qs,PlusCircle:Oj,PlusCircleIcon:Oj,PlusIcon:qs,PlusSquare:Sk,PlusSquareIcon:Sk,Pocket:bee,PocketIcon:bee,PocketKnife:vee,PocketKnifeIcon:vee,Podcast:_ee,PodcastIcon:_ee,Pointer:jee,PointerIcon:jee,PointerOff:wee,PointerOffIcon:wee,Popcorn:Nee,PopcornIcon:Nee,Popsicle:kee,PopsicleIcon:kee,PoundSterling:See,PoundSterlingIcon:See,Power:gL,PowerCircle:Rj,PowerCircleIcon:Rj,PowerIcon:gL,PowerOff:Cee,PowerOffIcon:Cee,PowerSquare:Ck,PowerSquareIcon:Ck,Presentation:Qg,PresentationIcon:Qg,Printer:yL,PrinterCheck:Mee,PrinterCheckIcon:Mee,PrinterIcon:yL,Projector:Tee,ProjectorIcon:Tee,Proportions:Aee,ProportionsIcon:Aee,Puzzle:Eee,PuzzleIcon:Eee,Pyramid:Pee,PyramidIcon:Pee,QrCode:o1,QrCodeIcon:o1,Quote:U_,QuoteIcon:U_,Rabbit:Iee,RabbitIcon:Iee,Radar:Lee,RadarIcon:Lee,Radiation:Dee,RadiationIcon:Dee,Radical:Oee,RadicalIcon:Oee,Radio:l1,RadioIcon:l1,RadioReceiver:Ree,RadioReceiverIcon:Ree,RadioTower:Fee,RadioTowerIcon:Fee,Radius:zee,RadiusIcon:zee,RailSymbol:Bee,RailSymbolIcon:Bee,Rainbow:$ee,RainbowIcon:$ee,Rat:qee,RatIcon:qee,Ratio:Uee,RatioIcon:Uee,Receipt:Qee,ReceiptCent:Vee,ReceiptCentIcon:Vee,ReceiptEuro:Hee,ReceiptEuroIcon:Hee,ReceiptIcon:Qee,ReceiptIndianRupee:Wee,ReceiptIndianRupeeIcon:Wee,ReceiptJapaneseYen:Gee,ReceiptJapaneseYenIcon:Gee,ReceiptPoundSterling:Kee,ReceiptPoundSterlingIcon:Kee,ReceiptRussianRuble:Zee,ReceiptRussianRubleIcon:Zee,ReceiptSwissFranc:Yee,ReceiptSwissFrancIcon:Yee,ReceiptText:Xee,ReceiptTextIcon:Xee,RectangleEllipsis:PN,RectangleEllipsisIcon:PN,RectangleHorizontal:Jee,RectangleHorizontalIcon:Jee,RectangleVertical:ete,RectangleVerticalIcon:ete,Recycle:tte,RecycleIcon:tte,Redo:oS,Redo2:ste,Redo2Icon:ste,RedoDot:rte,RedoDotIcon:rte,RedoIcon:oS,RefreshCcw:RM,RefreshCcwDot:nte,RefreshCcwDotIcon:nte,RefreshCcwIcon:RM,RefreshCw:Wo,RefreshCwIcon:Wo,RefreshCwOff:ate,RefreshCwOffIcon:ate,Refrigerator:ite,RefrigeratorIcon:ite,Regex:ote,RegexIcon:ote,RemoveFormatting:lte,RemoveFormattingIcon:lte,Repeat:vL,Repeat1:cte,Repeat1Icon:cte,Repeat2:dte,Repeat2Icon:dte,RepeatIcon:vL,Replace:hte,ReplaceAll:ute,ReplaceAllIcon:ute,ReplaceIcon:hte,Reply:bL,ReplyAll:mte,ReplyAllIcon:mte,ReplyIcon:bL,Rewind:pte,RewindIcon:pte,Ribbon:fte,RibbonIcon:fte,Rocket:p0,RocketIcon:p0,RockingChair:xte,RockingChairIcon:xte,RollerCoaster:gte,RollerCoasterIcon:gte,Rotate3D:IN,Rotate3DIcon:IN,Rotate3d:IN,Rotate3dIcon:IN,RotateCcw:c1,RotateCcwIcon:c1,RotateCcwSquare:yte,RotateCcwSquareIcon:yte,RotateCw:_L,RotateCwIcon:_L,RotateCwSquare:vte,RotateCwSquareIcon:vte,Route:_te,RouteIcon:_te,RouteOff:bte,RouteOffIcon:bte,Router:wte,RouterIcon:wte,Rows:LN,Rows2:LN,Rows2Icon:LN,Rows3:DN,Rows3Icon:DN,Rows4:jte,Rows4Icon:jte,RowsIcon:LN,Rss:Nte,RssIcon:Nte,Ruler:d1,RulerIcon:d1,RussianRuble:kte,RussianRubleIcon:kte,Sailboat:Ste,SailboatIcon:Ste,Salad:Cte,SaladIcon:Cte,Sandwich:Mte,SandwichIcon:Mte,Satellite:Ate,SatelliteDish:Tte,SatelliteDishIcon:Tte,SatelliteIcon:Ate,Save:ed,SaveAll:Ete,SaveAllIcon:Ete,SaveIcon:ed,SaveOff:Pte,SaveOffIcon:Pte,Scale:wL,Scale3D:ON,Scale3DIcon:ON,Scale3d:ON,Scale3dIcon:ON,ScaleIcon:wL,Scaling:Ite,ScalingIcon:Ite,Scan:$te,ScanBarcode:Lte,ScanBarcodeIcon:Lte,ScanEye:Dte,ScanEyeIcon:Dte,ScanFace:Ote,ScanFaceIcon:Ote,ScanIcon:$te,ScanLine:Rte,ScanLineIcon:Rte,ScanQrCode:Fte,ScanQrCodeIcon:Fte,ScanSearch:zte,ScanSearchIcon:zte,ScanText:Bte,ScanTextIcon:Bte,ScatterChart:xj,ScatterChartIcon:xj,School:qte,School2:qk,School2Icon:qk,SchoolIcon:qte,Scissors:Vte,ScissorsIcon:Vte,ScissorsLineDashed:Ute,ScissorsLineDashedIcon:Ute,ScissorsSquare:Mk,ScissorsSquareDashedBottom:ek,ScissorsSquareDashedBottomIcon:ek,ScissorsSquareIcon:Mk,ScreenShare:Wte,ScreenShareIcon:Wte,ScreenShareOff:Hte,ScreenShareOffIcon:Hte,Scroll:Kte,ScrollIcon:Kte,ScrollText:Gte,ScrollTextIcon:Gte,Search:hn,SearchCheck:Zte,SearchCheckIcon:Zte,SearchCode:Yte,SearchCodeIcon:Yte,SearchIcon:hn,SearchSlash:Xte,SearchSlashIcon:Xte,SearchX:jL,SearchXIcon:jL,Section:Qte,SectionIcon:Qte,Send:Rn,SendHorizonal:RN,SendHorizonalIcon:RN,SendHorizontal:RN,SendHorizontalIcon:RN,SendIcon:Rn,SendToBack:Jte,SendToBackIcon:Jte,SeparatorHorizontal:ese,SeparatorHorizontalIcon:ese,SeparatorVertical:tse,SeparatorVerticalIcon:tse,Server:ase,ServerCog:sse,ServerCogIcon:sse,ServerCrash:rse,ServerCrashIcon:rse,ServerIcon:ase,ServerOff:nse,ServerOffIcon:nse,Settings:Yo,Settings2:NL,Settings2Icon:NL,SettingsIcon:Yo,Shapes:ise,ShapesIcon:ise,Share:kL,Share2:bd,Share2Icon:bd,ShareIcon:kL,Sheet:ose,SheetIcon:ose,Shell:lse,ShellIcon:lse,Shield:Th,ShieldAlert:cse,ShieldAlertIcon:cse,ShieldBan:dse,ShieldBanIcon:dse,ShieldCheck:SL,ShieldCheckIcon:SL,ShieldClose:FN,ShieldCloseIcon:FN,ShieldEllipsis:use,ShieldEllipsisIcon:use,ShieldHalf:hse,ShieldHalfIcon:hse,ShieldIcon:Th,ShieldMinus:mse,ShieldMinusIcon:mse,ShieldOff:pse,ShieldOffIcon:pse,ShieldPlus:fse,ShieldPlusIcon:fse,ShieldQuestion:xse,ShieldQuestionIcon:xse,ShieldX:FN,ShieldXIcon:FN,Ship:yse,ShipIcon:yse,ShipWheel:gse,ShipWheelIcon:gse,Shirt:vse,ShirtIcon:vse,ShoppingBag:f0,ShoppingBagIcon:f0,ShoppingBasket:bse,ShoppingBasketIcon:bse,ShoppingCart:yp,ShoppingCartIcon:yp,Shovel:_se,ShovelIcon:_se,ShowerHead:wse,ShowerHeadIcon:wse,Shrink:jse,ShrinkIcon:jse,Shrub:Nse,ShrubIcon:Nse,Shuffle:lS,ShuffleIcon:lS,Sidebar:MN,SidebarClose:kN,SidebarCloseIcon:kN,SidebarIcon:MN,SidebarOpen:CN,SidebarOpenIcon:CN,Sigma:kse,SigmaIcon:kse,SigmaSquare:Tk,SigmaSquareIcon:Tk,Signal:Ase,SignalHigh:Sse,SignalHighIcon:Sse,SignalIcon:Ase,SignalLow:Cse,SignalLowIcon:Cse,SignalMedium:Mse,SignalMediumIcon:Mse,SignalZero:Tse,SignalZeroIcon:Tse,Signature:Ese,SignatureIcon:Ese,Signpost:Ise,SignpostBig:Pse,SignpostBigIcon:Pse,SignpostIcon:Ise,Siren:Lse,SirenIcon:Lse,SkipBack:Dse,SkipBackIcon:Dse,SkipForward:Ose,SkipForwardIcon:Ose,Skull:Rse,SkullIcon:Rse,Slack:Fse,SlackIcon:Fse,Slash:zse,SlashIcon:zse,SlashSquare:Ak,SlashSquareIcon:Ak,Slice:Bse,SliceIcon:Bse,Sliders:zN,SlidersHorizontal:FM,SlidersHorizontalIcon:FM,SlidersIcon:zN,SlidersVertical:zN,SlidersVerticalIcon:zN,Smartphone:u1,SmartphoneCharging:$se,SmartphoneChargingIcon:$se,SmartphoneIcon:u1,SmartphoneNfc:qse,SmartphoneNfcIcon:qse,Smile:Vse,SmileIcon:Vse,SmilePlus:Use,SmilePlusIcon:Use,Snail:Hse,SnailIcon:Hse,Snowflake:r0,SnowflakeIcon:r0,Sofa:Wse,SofaIcon:Wse,SortAsc:Y2,SortAscIcon:Y2,SortDesc:G2,SortDescIcon:G2,Soup:Gse,SoupIcon:Gse,Space:Kse,SpaceIcon:Kse,Spade:Zse,SpadeIcon:Zse,Sparkle:Yse,SparkleIcon:Yse,Sparkles:un,SparklesIcon:un,Speaker:Xse,SpeakerIcon:Xse,Speech:Qse,SpeechIcon:Qse,SpellCheck:ere,SpellCheck2:Jse,SpellCheck2Icon:Jse,SpellCheckIcon:ere,Spline:tre,SplineIcon:tre,Split:sre,SplitIcon:sre,SplitSquareHorizontal:Ek,SplitSquareHorizontalIcon:Ek,SplitSquareVertical:Pk,SplitSquareVerticalIcon:Pk,SprayCan:rre,SprayCanIcon:rre,Sprout:nre,SproutIcon:nre,Square:x0,SquareActivity:BN,SquareActivityIcon:BN,SquareArrowDown:UN,SquareArrowDownIcon:UN,SquareArrowDownLeft:$N,SquareArrowDownLeftIcon:$N,SquareArrowDownRight:qN,SquareArrowDownRightIcon:qN,SquareArrowLeft:VN,SquareArrowLeftIcon:VN,SquareArrowOutDownLeft:HN,SquareArrowOutDownLeftIcon:HN,SquareArrowOutDownRight:WN,SquareArrowOutDownRightIcon:WN,SquareArrowOutUpLeft:GN,SquareArrowOutUpLeftIcon:GN,SquareArrowOutUpRight:KN,SquareArrowOutUpRightIcon:KN,SquareArrowRight:ZN,SquareArrowRightIcon:ZN,SquareArrowUp:QN,SquareArrowUpIcon:QN,SquareArrowUpLeft:YN,SquareArrowUpLeftIcon:YN,SquareArrowUpRight:XN,SquareArrowUpRightIcon:XN,SquareAsterisk:JN,SquareAsteriskIcon:JN,SquareBottomDashedScissors:ek,SquareBottomDashedScissorsIcon:ek,SquareChartGantt:qy,SquareChartGanttIcon:qy,SquareCheck:tk,SquareCheckBig:Fv,SquareCheckBigIcon:Fv,SquareCheckIcon:tk,SquareChevronDown:sk,SquareChevronDownIcon:sk,SquareChevronLeft:rk,SquareChevronLeftIcon:rk,SquareChevronRight:nk,SquareChevronRightIcon:nk,SquareChevronUp:ak,SquareChevronUpIcon:ak,SquareCode:ik,SquareCodeIcon:ik,SquareDashed:ck,SquareDashedBottom:ire,SquareDashedBottomCode:are,SquareDashedBottomCodeIcon:are,SquareDashedBottomIcon:ire,SquareDashedIcon:ck,SquareDashedKanban:ok,SquareDashedKanbanIcon:ok,SquareDashedMousePointer:lk,SquareDashedMousePointerIcon:lk,SquareDivide:dk,SquareDivideIcon:dk,SquareDot:uk,SquareDotIcon:uk,SquareEqual:hk,SquareEqualIcon:hk,SquareFunction:mk,SquareFunctionIcon:mk,SquareGanttChart:qy,SquareGanttChartIcon:qy,SquareIcon:x0,SquareKanban:pk,SquareKanbanIcon:pk,SquareLibrary:fk,SquareLibraryIcon:fk,SquareM:xk,SquareMIcon:xk,SquareMenu:gk,SquareMenuIcon:gk,SquareMinus:yk,SquareMinusIcon:yk,SquareMousePointer:vk,SquareMousePointerIcon:vk,SquareParking:_k,SquareParkingIcon:_k,SquareParkingOff:bk,SquareParkingOffIcon:bk,SquarePen:dd,SquarePenIcon:dd,SquarePercent:wk,SquarePercentIcon:wk,SquarePi:jk,SquarePiIcon:jk,SquarePilcrow:Nk,SquarePilcrowIcon:Nk,SquarePlay:kk,SquarePlayIcon:kk,SquarePlus:Sk,SquarePlusIcon:Sk,SquarePower:Ck,SquarePowerIcon:Ck,SquareRadical:ore,SquareRadicalIcon:ore,SquareScissors:Mk,SquareScissorsIcon:Mk,SquareSigma:Tk,SquareSigmaIcon:Tk,SquareSlash:Ak,SquareSlashIcon:Ak,SquareSplitHorizontal:Ek,SquareSplitHorizontalIcon:Ek,SquareSplitVertical:Pk,SquareSplitVerticalIcon:Pk,SquareSquare:lre,SquareSquareIcon:lre,SquareStack:cre,SquareStackIcon:cre,SquareTerminal:Ik,SquareTerminalIcon:Ik,SquareUser:Dk,SquareUserIcon:Dk,SquareUserRound:Lk,SquareUserRoundIcon:Lk,SquareX:Ok,SquareXIcon:Ok,Squircle:dre,SquircleIcon:dre,Squirrel:ure,SquirrelIcon:ure,Stamp:hre,StampIcon:hre,Star:Jn,StarHalf:mre,StarHalfIcon:mre,StarIcon:Jn,StarOff:pre,StarOffIcon:pre,Stars:un,StarsIcon:un,StepBack:fre,StepBackIcon:fre,StepForward:xre,StepForwardIcon:xre,Stethoscope:gre,StethoscopeIcon:gre,Sticker:yre,StickerIcon:yre,StickyNote:vre,StickyNoteIcon:vre,StopCircle:zj,StopCircleIcon:zj,Store:zM,StoreIcon:zM,StretchHorizontal:bre,StretchHorizontalIcon:bre,StretchVertical:_re,StretchVerticalIcon:_re,Strikethrough:CL,StrikethroughIcon:CL,Subscript:wre,SubscriptIcon:wre,Subtitles:nj,SubtitlesIcon:nj,Sun:h1,SunDim:jre,SunDimIcon:jre,SunIcon:h1,SunMedium:Nre,SunMediumIcon:Nre,SunMoon:kre,SunMoonIcon:kre,SunSnow:Sre,SunSnowIcon:Sre,Sunrise:Cre,SunriseIcon:Cre,Sunset:Mre,SunsetIcon:Mre,Superscript:Tre,SuperscriptIcon:Tre,SwatchBook:Are,SwatchBookIcon:Are,SwissFranc:Ere,SwissFrancIcon:Ere,SwitchCamera:Pre,SwitchCameraIcon:Pre,Sword:Ire,SwordIcon:Ire,Swords:Lre,SwordsIcon:Lre,Syringe:Dre,SyringeIcon:Dre,Table:$M,Table2:BM,Table2Icon:BM,TableCellsMerge:Ore,TableCellsMergeIcon:Ore,TableCellsSplit:Rre,TableCellsSplitIcon:Rre,TableColumnsSplit:Fre,TableColumnsSplitIcon:Fre,TableIcon:$M,TableOfContents:zre,TableOfContentsIcon:zre,TableProperties:Bre,TablePropertiesIcon:Bre,TableRowsSplit:$re,TableRowsSplitIcon:$re,Tablet:Ure,TabletIcon:Ure,TabletSmartphone:qre,TabletSmartphoneIcon:qre,Tablets:Vre,TabletsIcon:Vre,Tag:Om,TagIcon:Om,Tags:Hre,TagsIcon:Hre,Tally1:Wre,Tally1Icon:Wre,Tally2:Gre,Tally2Icon:Gre,Tally3:Kre,Tally3Icon:Kre,Tally4:Zre,Tally4Icon:Zre,Tally5:Yre,Tally5Icon:Yre,Tangent:Xre,TangentIcon:Xre,Target:Rm,TargetIcon:Rm,Telescope:Qre,TelescopeIcon:Qre,Tent:ene,TentIcon:ene,TentTree:Jre,TentTreeIcon:Jre,Terminal:tne,TerminalIcon:tne,TerminalSquare:Ik,TerminalSquareIcon:Ik,TestTube:sne,TestTube2:Rk,TestTube2Icon:Rk,TestTubeDiagonal:Rk,TestTubeDiagonalIcon:Rk,TestTubeIcon:sne,TestTubes:rne,TestTubesIcon:rne,Text:lne,TextCursor:ane,TextCursorIcon:ane,TextCursorInput:nne,TextCursorInputIcon:nne,TextIcon:lne,TextQuote:ine,TextQuoteIcon:ine,TextSearch:one,TextSearchIcon:one,TextSelect:Fk,TextSelectIcon:Fk,TextSelection:Fk,TextSelectionIcon:Fk,Theater:cne,TheaterIcon:cne,Thermometer:ML,ThermometerIcon:ML,ThermometerSnowflake:dne,ThermometerSnowflakeIcon:dne,ThermometerSun:une,ThermometerSunIcon:une,ThumbsDown:TL,ThumbsDownIcon:TL,ThumbsUp:eh,ThumbsUpIcon:eh,Ticket:AL,TicketCheck:hne,TicketCheckIcon:hne,TicketIcon:AL,TicketMinus:mne,TicketMinusIcon:mne,TicketPercent:pne,TicketPercentIcon:pne,TicketPlus:fne,TicketPlusIcon:fne,TicketSlash:xne,TicketSlashIcon:xne,TicketX:gne,TicketXIcon:gne,Tickets:vne,TicketsIcon:vne,TicketsPlane:yne,TicketsPlaneIcon:yne,Timer:wne,TimerIcon:wne,TimerOff:bne,TimerOffIcon:bne,TimerReset:_ne,TimerResetIcon:_ne,ToggleLeft:jne,ToggleLeftIcon:jne,ToggleRight:Nne,ToggleRightIcon:Nne,Toilet:kne,ToiletIcon:kne,Tornado:Sne,TornadoIcon:Sne,Torus:Cne,TorusIcon:Cne,Touchpad:Tne,TouchpadIcon:Tne,TouchpadOff:Mne,TouchpadOffIcon:Mne,TowerControl:Ane,TowerControlIcon:Ane,ToyBrick:Ene,ToyBrickIcon:Ene,Tractor:Pne,TractorIcon:Pne,TrafficCone:Ine,TrafficConeIcon:Ine,Train:zk,TrainFront:Dne,TrainFrontIcon:Dne,TrainFrontTunnel:Lne,TrainFrontTunnelIcon:Lne,TrainIcon:zk,TrainTrack:One,TrainTrackIcon:One,TramFront:zk,TramFrontIcon:zk,Trash:Rne,Trash2:Nr,Trash2Icon:Nr,TrashIcon:Rne,TreeDeciduous:Fne,TreeDeciduousIcon:Fne,TreePalm:Bk,TreePalmIcon:Bk,TreePine:m1,TreePineIcon:m1,Trees:zne,TreesIcon:zne,Trello:Bne,TrelloIcon:Bne,TrendingDown:cS,TrendingDownIcon:cS,TrendingUp:Ol,TrendingUpDown:$ne,TrendingUpDownIcon:$ne,TrendingUpIcon:Ol,Triangle:Une,TriangleAlert:Gu,TriangleAlertIcon:Gu,TriangleIcon:Une,TriangleRight:qne,TriangleRightIcon:qne,Trophy:xo,TrophyIcon:xo,Truck:EL,TruckIcon:EL,Turtle:Vne,TurtleIcon:Vne,Tv:Wne,Tv2:$k,Tv2Icon:$k,TvIcon:Wne,TvMinimal:$k,TvMinimalIcon:$k,TvMinimalPlay:Hne,TvMinimalPlayIcon:Hne,Twitch:Gne,TwitchIcon:Gne,Twitter:Kne,TwitterIcon:Kne,Type:Yne,TypeIcon:Yne,TypeOutline:Zne,TypeOutlineIcon:Zne,Umbrella:Qne,UmbrellaIcon:Qne,UmbrellaOff:Xne,UmbrellaOffIcon:Xne,Underline:PL,UnderlineIcon:PL,Undo:dS,Undo2:Jne,Undo2Icon:Jne,UndoDot:eae,UndoDotIcon:eae,UndoIcon:dS,UnfoldHorizontal:tae,UnfoldHorizontalIcon:tae,UnfoldVertical:sae,UnfoldVerticalIcon:sae,Ungroup:rae,UngroupIcon:rae,University:qk,UniversityIcon:qk,Unlink:uS,Unlink2:nae,Unlink2Icon:nae,UnlinkIcon:uS,Unlock:yN,UnlockIcon:yN,UnlockKeyhole:gN,UnlockKeyholeIcon:gN,Unplug:aae,UnplugIcon:aae,Upload:oi,UploadCloud:Hj,UploadCloudIcon:Hj,UploadIcon:oi,Usb:iae,UsbIcon:iae,User:to,User2:Kk,User2Icon:Kk,UserCheck:V_,UserCheck2:Uk,UserCheck2Icon:Uk,UserCheckIcon:V_,UserCircle:$j,UserCircle2:Bj,UserCircle2Icon:Bj,UserCircleIcon:$j,UserCog:IL,UserCog2:Vk,UserCog2Icon:Vk,UserCogIcon:IL,UserIcon:to,UserMinus:LL,UserMinus2:Hk,UserMinus2Icon:Hk,UserMinusIcon:LL,UserPen:oae,UserPenIcon:oae,UserPlus:rc,UserPlus2:Wk,UserPlus2Icon:Wk,UserPlusIcon:rc,UserRound:Kk,UserRoundCheck:Uk,UserRoundCheckIcon:Uk,UserRoundCog:Vk,UserRoundCogIcon:Vk,UserRoundIcon:Kk,UserRoundMinus:Hk,UserRoundMinusIcon:Hk,UserRoundPen:lae,UserRoundPenIcon:lae,UserRoundPlus:Wk,UserRoundPlusIcon:Wk,UserRoundSearch:cae,UserRoundSearchIcon:cae,UserRoundX:Gk,UserRoundXIcon:Gk,UserSearch:dae,UserSearchIcon:dae,UserSquare:Dk,UserSquare2:Lk,UserSquare2Icon:Lk,UserSquareIcon:Dk,UserX:uae,UserX2:Gk,UserX2Icon:Gk,UserXIcon:uae,Users:mr,Users2:Zk,Users2Icon:Zk,UsersIcon:mr,UsersRound:Zk,UsersRoundIcon:Zk,Utensils:Xk,UtensilsCrossed:Yk,UtensilsCrossedIcon:Yk,UtensilsIcon:Xk,UtilityPole:hae,UtilityPoleIcon:hae,Variable:qM,VariableIcon:qM,Vault:mae,VaultIcon:mae,Vegan:pae,VeganIcon:pae,VenetianMask:fae,VenetianMaskIcon:fae,Verified:J2,VerifiedIcon:J2,Vibrate:gae,VibrateIcon:gae,VibrateOff:xae,VibrateOffIcon:xae,Video:Cn,VideoIcon:Cn,VideoOff:yae,VideoOffIcon:yae,Videotape:vae,VideotapeIcon:vae,View:bae,ViewIcon:bae,Voicemail:_ae,VoicemailIcon:_ae,Volleyball:wae,VolleyballIcon:wae,Volume:Cae,Volume1:jae,Volume1Icon:jae,Volume2:Nae,Volume2Icon:Nae,VolumeIcon:Cae,VolumeOff:kae,VolumeOffIcon:kae,VolumeX:Sae,VolumeXIcon:Sae,Vote:Mae,VoteIcon:Mae,Wallet:DL,Wallet2:Qk,Wallet2Icon:Qk,WalletCards:Tae,WalletCardsIcon:Tae,WalletIcon:DL,WalletMinimal:Qk,WalletMinimalIcon:Qk,Wallpaper:Aae,WallpaperIcon:Aae,Wand:Eae,Wand2:zv,Wand2Icon:zv,WandIcon:Eae,WandSparkles:zv,WandSparklesIcon:zv,Warehouse:Pae,WarehouseIcon:Pae,WashingMachine:Iae,WashingMachineIcon:Iae,Watch:Lae,WatchIcon:Lae,Waves:OL,WavesIcon:OL,Waypoints:Dae,WaypointsIcon:Dae,Webcam:Oae,WebcamIcon:Oae,Webhook:Fae,WebhookIcon:Fae,WebhookOff:Rae,WebhookOffIcon:Rae,Weight:zae,WeightIcon:zae,Wheat:$ae,WheatIcon:$ae,WheatOff:Bae,WheatOffIcon:Bae,WholeWord:qae,WholeWordIcon:qae,Wifi:Gae,WifiHigh:Uae,WifiHighIcon:Uae,WifiIcon:Gae,WifiLow:Vae,WifiLowIcon:Vae,WifiOff:Hae,WifiOffIcon:Hae,WifiZero:Wae,WifiZeroIcon:Wae,Wind:Zae,WindArrowDown:Kae,WindArrowDownIcon:Kae,WindIcon:Zae,Wine:Xae,WineIcon:Xae,WineOff:Yae,WineOffIcon:Yae,Workflow:Qae,WorkflowIcon:Qae,Worm:Jae,WormIcon:Jae,WrapText:eie,WrapTextIcon:eie,Wrench:Jg,WrenchIcon:Jg,X:Or,XCircle:xc,XCircleIcon:xc,XIcon:Or,XOctagon:wN,XOctagonIcon:wN,XSquare:Ok,XSquareIcon:Ok,Youtube:tie,YoutubeIcon:tie,Zap:Fm,ZapIcon:Fm,ZapOff:sie,ZapOffIcon:sie,ZoomIn:H_,ZoomInIcon:H_,ZoomOut:UM,ZoomOutIcon:UM,createLucideIcon:Z,icons:Ixt},Symbol.toStringTag,{value:"Module"})),m2e="-",Lxt=t=>{const s=Oxt(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:l=>{const i=l.split(m2e);return i[0]===""&&i.length!==1&&i.shift(),sqe(i,s)||Dxt(l)},getConflictingClassGroupIds:(l,i)=>{const c=r[l]||[];return i&&n[l]?[...c,...n[l]]:c}}},sqe=(t,s)=>{var l;if(t.length===0)return s.classGroupId;const r=t[0],n=s.nextPart.get(r),a=n?sqe(t.slice(1),n):void 0;if(a)return a;if(s.validators.length===0)return;const o=t.join(m2e);return(l=s.validators.find(({validator:i})=>i(o)))==null?void 0:l.classGroupId},MAe=/^\[(.+)\]$/,Dxt=t=>{if(MAe.test(t)){const s=MAe.exec(t)[1],r=s==null?void 0:s.substring(0,s.indexOf(":"));if(r)return"arbitrary.."+r}},Oxt=t=>{const{theme:s,prefix:r}=t,n={nextPart:new Map,validators:[]};return Fxt(Object.entries(t.classGroups),r).forEach(([o,l])=>{A0e(l,n,o,s)}),n},A0e=(t,s,r,n)=>{t.forEach(a=>{if(typeof a=="string"){const o=a===""?s:TAe(s,a);o.classGroupId=r;return}if(typeof a=="function"){if(Rxt(a)){A0e(a(n),s,r,n);return}s.validators.push({validator:a,classGroupId:r});return}Object.entries(a).forEach(([o,l])=>{A0e(l,TAe(s,o),r,n)})})},TAe=(t,s)=>{let r=t;return s.split(m2e).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},Rxt=t=>t.isThemeGetter,Fxt=(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,zxt=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)}}},rqe="!",Bxt=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 w=0;wp?f-p:void 0;return{modifiers:c,hasImportantModifier:b,baseClassName:_,maybePostfixModifierPosition:j}};return r?i=>r({className:i,parseClassName:l}):l},$xt=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},qxt=t=>({cache:zxt(t.cacheSize),parseClassName:Bxt(t),...Lxt(t)}),Uxt=/\s+/,Vxt=(t,s)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:a}=s,o=[],l=t.trim().split(Uxt);let i="";for(let c=l.length-1;c>=0;c-=1){const u=l[c],{modifiers:p,hasImportantModifier:f,baseClassName:g,maybePostfixModifierPosition:b}=r(u);let _=!!b,j=n(_?g.substring(0,b):g);if(!j){if(!_){i=u+(i.length>0?" "+i:i);continue}if(j=n(g),!j){i=u+(i.length>0?" "+i:i);continue}_=!1}const w=$xt(p).join(":"),N=f?w+rqe:w,C=N+j;if(o.includes(C))continue;o.push(C);const M=a(j,_);for(let I=0;I0?" "+i:i)}return i};function Hxt(){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=qxt(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=Vxt(c,r);return a(c,p),p}return function(){return o(Hxt.apply(null,arguments))}}const cc=t=>{const s=r=>r[t]||[];return s.isThemeGetter=!0,s},aqe=/^\[(?:([a-z-]+):)?(.+)\]$/i,Gxt=/^\d+\/\d+$/,Kxt=new Set(["px","full","screen"]),Zxt=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Yxt=/\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$/,Xxt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,Qxt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Jxt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,yv=t=>VM(t)||Kxt.has(t)||Gxt.test(t),Mb=t=>RA(t,"length",ogt),VM=t=>!!t&&!Number.isNaN(Number(t)),Kfe=t=>RA(t,"number",VM),OP=t=>!!t&&Number.isInteger(Number(t)),egt=t=>t.endsWith("%")&&VM(t.slice(0,-1)),Yi=t=>aqe.test(t),Tb=t=>Zxt.test(t),tgt=new Set(["length","size","percentage"]),sgt=t=>RA(t,tgt,iqe),rgt=t=>RA(t,"position",iqe),ngt=new Set(["image","url"]),agt=t=>RA(t,ngt,cgt),igt=t=>RA(t,"",lgt),RP=()=>!0,RA=(t,s,r)=>{const n=aqe.exec(t);return n?n[1]?typeof s=="string"?n[1]===s:s.has(n[1]):r(n[2]):!1},ogt=t=>Yxt.test(t)&&!Xxt.test(t),iqe=()=>!1,lgt=t=>Qxt.test(t),cgt=t=>Jxt.test(t),dgt=()=>{const t=cc("colors"),s=cc("spacing"),r=cc("blur"),n=cc("brightness"),a=cc("borderColor"),o=cc("borderRadius"),l=cc("borderSpacing"),i=cc("borderWidth"),c=cc("contrast"),u=cc("grayscale"),p=cc("hueRotate"),f=cc("invert"),g=cc("gap"),b=cc("gradientColorStops"),_=cc("gradientColorStopPositions"),j=cc("inset"),w=cc("margin"),N=cc("opacity"),C=cc("padding"),M=cc("saturate"),I=cc("scale"),L=cc("sepia"),R=cc("skew"),q=cc("space"),U=cc("translate"),B=()=>["auto","contain","none"],V=()=>["auto","hidden","clip","visible","scroll"],Y=()=>["auto",Yi,s],J=()=>[Yi,s],te=()=>["",yv,Mb],X=()=>["auto",VM,Yi],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"],le=()=>["start","end","center","between","around","evenly","stretch"],pe=()=>["","0",Yi],xe=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_e=()=>[VM,Yi];return{cacheSize:500,separator:":",theme:{colors:[RP],spacing:[yv,Mb],blur:["none","",Tb,Yi],brightness:_e(),borderColor:[t],borderRadius:["none","","full",Tb,Yi],borderSpacing:J(),borderWidth:te(),contrast:_e(),grayscale:pe(),hueRotate:_e(),invert:pe(),gap:J(),gradientColorStops:[t],gradientColorStopPositions:[egt,Mb],inset:Y(),margin:Y(),opacity:_e(),padding:J(),saturate:_e(),scale:_e(),sepia:pe(),skew:_e(),space:J(),translate:J()},classGroups:{aspect:[{aspect:["auto","square","video",Yi]}],container:["container"],columns:[{columns:[Tb]}],"break-after":[{"break-after":xe()}],"break-before":[{"break-before":xe()}],"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(),Yi]}],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:[j]}],"inset-x":[{"inset-x":[j]}],"inset-y":[{"inset-y":[j]}],start:[{start:[j]}],end:[{end:[j]}],top:[{top:[j]}],right:[{right:[j]}],bottom:[{bottom:[j]}],left:[{left:[j]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",OP,Yi]}],basis:[{basis:Y()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",Yi]}],grow:[{grow:pe()}],shrink:[{shrink:pe()}],order:[{order:["first","last","none",OP,Yi]}],"grid-cols":[{"grid-cols":[RP]}],"col-start-end":[{col:["auto",{span:["full",OP,Yi]},Yi]}],"col-start":[{"col-start":X()}],"col-end":[{"col-end":X()}],"grid-rows":[{"grid-rows":[RP]}],"row-start-end":[{row:["auto",{span:[OP,Yi]},Yi]}],"row-start":[{"row-start":X()}],"row-end":[{"row-end":X()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",Yi]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",Yi]}],gap:[{gap:[g]}],"gap-x":[{"gap-x":[g]}],"gap-y":[{"gap-y":[g]}],"justify-content":[{justify:["normal",...le()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...le(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...le(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[C]}],px:[{px:[C]}],py:[{py:[C]}],ps:[{ps:[C]}],pe:[{pe:[C]}],pt:[{pt:[C]}],pr:[{pr:[C]}],pb:[{pb:[C]}],pl:[{pl:[C]}],m:[{m:[w]}],mx:[{mx:[w]}],my:[{my:[w]}],ms:[{ms:[w]}],me:[{me:[w]}],mt:[{mt:[w]}],mr:[{mr:[w]}],mb:[{mb:[w]}],ml:[{ml:[w]}],"space-x":[{"space-x":[q]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[q]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",Yi,s]}],"min-w":[{"min-w":[Yi,s,"min","max","fit"]}],"max-w":[{"max-w":[Yi,s,"none","full","min","max","fit","prose",{screen:[Tb]},Tb]}],h:[{h:[Yi,s,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[Yi,s,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[Yi,s,"auto","min","max","fit"]}],"font-size":[{text:["base",Tb,Mb]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",Kfe]}],"font-family":[{font:[RP]}],"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",Yi]}],"line-clamp":[{"line-clamp":["none",VM,Kfe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",yv,Yi]}],"list-image":[{"list-image":["none",Yi]}],"list-style-type":[{list:["none","disc","decimal",Yi]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[N]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[N]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",yv,Mb]}],"underline-offset":[{"underline-offset":["auto",yv,Yi]}],"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:J()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Yi]}],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",Yi]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[N]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...ce(),rgt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",sgt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},agt]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[_]}],"gradient-via-pos":[{via:[_]}],"gradient-to-pos":[{to:[_]}],"gradient-from":[{from:[b]}],"gradient-via":[{via:[b]}],"gradient-to":[{to:[b]}],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":[N]}],"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":[N]}],"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":[yv,Yi]}],"outline-w":[{outline:[yv,Mb]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[N]}],"ring-offset-w":[{"ring-offset":[yv,Mb]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Tb,igt]}],"shadow-color":[{shadow:[RP]}],opacity:[{opacity:[N]}],"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",Tb,Yi]}],grayscale:[{grayscale:[u]}],"hue-rotate":[{"hue-rotate":[p]}],invert:[{invert:[f]}],saturate:[{saturate:[M]}],sepia:[{sepia:[L]}],"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":[N]}],"backdrop-saturate":[{"backdrop-saturate":[M]}],"backdrop-sepia":[{"backdrop-sepia":[L]}],"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",Yi]}],duration:[{duration:_e()}],ease:[{ease:["linear","in","out","in-out",Yi]}],delay:[{delay:_e()}],animate:[{animate:["none","spin","ping","pulse","bounce",Yi]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[I]}],"scale-x":[{"scale-x":[I]}],"scale-y":[{"scale-y":[I]}],rotate:[{rotate:[OP,Yi]}],"translate-x":[{"translate-x":[U]}],"translate-y":[{"translate-y":[U]}],"skew-x":[{"skew-x":[R]}],"skew-y":[{"skew-y":[R]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",Yi]}],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",Yi]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":J()}],"scroll-mx":[{"scroll-mx":J()}],"scroll-my":[{"scroll-my":J()}],"scroll-ms":[{"scroll-ms":J()}],"scroll-me":[{"scroll-me":J()}],"scroll-mt":[{"scroll-mt":J()}],"scroll-mr":[{"scroll-mr":J()}],"scroll-mb":[{"scroll-mb":J()}],"scroll-ml":[{"scroll-ml":J()}],"scroll-p":[{"scroll-p":J()}],"scroll-px":[{"scroll-px":J()}],"scroll-py":[{"scroll-py":J()}],"scroll-ps":[{"scroll-ps":J()}],"scroll-pe":[{"scroll-pe":J()}],"scroll-pt":[{"scroll-pt":J()}],"scroll-pr":[{"scroll-pr":J()}],"scroll-pb":[{"scroll-pb":J()}],"scroll-pl":[{"scroll-pl":J()}],"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",Yi]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[yv,Mb,Kfe]}],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"]}}},ugt=Wxt(dgt);function Pt(...t){return ugt(Vi(t))}function Gl(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 AAe(t){const s=new Date(t);return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric"}).format(s)}function bde(t){return t?t.replace(/<[^>]*>/g,""):""}const hgt=Axt,oqe=k.forwardRef(({className:t,...s},r)=>e.jsx(G$e,{ref:r,className:Pt("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}));oqe.displayName=G$e.displayName;const mgt=lC("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"}}),lqe=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx(K$e,{ref:n,className:Pt(mgt({variant:s}),t),...r}));lqe.displayName=K$e.displayName;const pgt=k.forwardRef(({className:t,...s},r)=>e.jsx(X$e,{ref:r,className:Pt("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}));pgt.displayName=X$e.displayName;const cqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Q$e,{ref:r,className:Pt("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(Or,{className:"h-4 w-4"})}));cqe.displayName=Q$e.displayName;const dqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Z$e,{ref:r,className:Pt("text-sm font-semibold",t),...s}));dqe.displayName=Z$e.displayName;const uqe=k.forwardRef(({className:t,...s},r)=>e.jsx(Y$e,{ref:r,className:Pt("text-sm opacity-90",t),...s}));uqe.displayName=Y$e.displayName;function fgt(){const{toasts:t}=qa();return e.jsxs(hgt,{children:[t.map(function({id:s,title:r,description:n,action:a,...o}){return e.jsxs(lqe,{...o,children:[e.jsxs("div",{className:"grid gap-1",children:[r&&e.jsx(dqe,{children:r}),n&&e.jsx(uqe,{children:n})]}),a,e.jsx(cqe,{})]},s)}),e.jsx(oqe,{})]})}var EAe=["light","dark"],xgt="(prefers-color-scheme: dark)",ggt=k.createContext(void 0),ygt={setTheme:t=>{},themes:[]},vgt=()=>{var t;return(t=k.useContext(ggt))!=null?t:ygt};k.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?EAe.includes(o)&&o?`if(e==='light'||e==='dark'||!e)d.style.colorScheme=e||'${o}'`:"if(e==='light'||e==='dark')d.style.colorScheme=e":"",g=(_,j=!1,w=!0)=>{let N=l?l[_]:_,C=j?_+"|| ''":`'${N}'`,M="";return a&&w&&!j&&EAe.includes(_)&&(M+=`d.style.colorScheme = '${_}';`),r==="class"?j||N?M+=`c.add(${C})`:M+="null":N&&(M+=`d[s](n,${C})`),M},b=t?`!function(){${p}${g(t)}}()`:n?`!function(){try{${p}var e=localStorage.getItem('${s}');if('system'===e||(!e&&${u})){var t='${xgt}',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 k.createElement("script",{nonce:c,dangerouslySetInnerHTML:{__html:b}})});var bgt=t=>{switch(t){case"success":return jgt;case"info":return kgt;case"warning":return Ngt;case"error":return Sgt;default:return null}},_gt=Array(12).fill(0),wgt=({visible:t,className:s})=>ht.createElement("div",{className:["sonner-loading-wrapper",s].filter(Boolean).join(" "),"data-visible":t},ht.createElement("div",{className:"sonner-spinner"},_gt.map((r,n)=>ht.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${n}`})))),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:"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"})),Ngt=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"})),kgt=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"})),Sgt=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"})),Cgt=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"})),Mgt=()=>{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},E0e=1,Tgt=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:E0e++,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(Egt(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)||E0e++;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}},dp=new Tgt,Agt=(t,s)=>{let r=(s==null?void 0:s.id)||E0e++;return dp.addToast({title:t,...s,id:r}),r},Egt=t=>t&&typeof t=="object"&&"ok"in t&&typeof t.ok=="boolean"&&"status"in t&&typeof t.status=="number",Pgt=Agt,Igt=()=>dp.toasts,Lgt=()=>dp.getActiveToasts(),he=Object.assign(Pgt,{success:dp.success,info:dp.info,warning:dp.warning,error:dp.error,custom:dp.custom,message:dp.message,promise:dp.promise,dismiss:dp.dismiss,loading:dp.loading},{getHistory:Igt,getToasts:Lgt});function Dgt(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))}Dgt(`: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 L7(t){return t.label!==void 0}var Ogt=3,Rgt="32px",Fgt="16px",PAe=4e3,zgt=356,Bgt=14,$gt=20,qgt=200;function wg(...t){return t.filter(Boolean).join(" ")}function Ugt(t){let[s,r]=t.split("-"),n=[];return s&&n.push(s),r&&n.push(r),n}var Vgt=t=>{var s,r,n,a,o,l,i,c,u,p,f;let{invert:g,toast:b,unstyled:_,interacting:j,setHeights:w,visibleToasts:N,heights:C,index:M,toasts:I,expanded:L,removeToast:R,defaultRichColors:q,closeButton:U,style:B,cancelButtonStyle:V,actionButtonStyle:Y,className:J="",descriptionClassName:te="",duration:X,position:ce,gap:ne,loadingIcon:re,expandByDefault:le,classNames:pe,icons:xe,closeButtonAriaLabel:_e="Close toast",pauseWhenPageIsHidden:fe}=t,[we,Ie]=ht.useState(null),[Ne,Ae]=ht.useState(null),[Fe,Ce]=ht.useState(!1),[Me,$e]=ht.useState(!1),[ct,Te]=ht.useState(!1),[ft,me]=ht.useState(!1),[Ve,nt]=ht.useState(!1),[et,Se]=ht.useState(0),[rt,Ge]=ht.useState(0),lt=ht.useRef(b.duration||X||PAe),qe=ht.useRef(null),Ze=ht.useRef(null),Je=M===0,He=M+1<=N,Qe=b.type,at=b.dismissible!==!1,It=b.className||"",Ut=b.descriptionClassName||"",hs=ht.useMemo(()=>C.findIndex(Hr=>Hr.toastId===b.id)||0,[C,b.id]),Yt=ht.useMemo(()=>{var Hr;return(Hr=b.closeButton)!=null?Hr:U},[b.closeButton,U]),ts=ht.useMemo(()=>b.duration||X||PAe,[b.duration,X]),Ds=ht.useRef(0),vr=ht.useRef(0),Ct=ht.useRef(0),As=ht.useRef(null),[Us,kr]=ce.split("-"),ta=ht.useMemo(()=>C.reduce((Hr,ln,Zr)=>Zr>=hs?Hr:Hr+ln.height,0),[C,hs]),ka=Mgt(),Li=b.invert||g,Wa=Qe==="loading";vr.current=ht.useMemo(()=>hs*ne+ta,[hs,ta]),ht.useEffect(()=>{lt.current=ts},[ts]),ht.useEffect(()=>{Ce(!0)},[]),ht.useEffect(()=>{let Hr=Ze.current;if(Hr){let ln=Hr.getBoundingClientRect().height;return Ge(ln),w(Zr=>[{toastId:b.id,height:ln,position:b.position},...Zr]),()=>w(Zr=>Zr.filter(yi=>yi.toastId!==b.id))}},[w,b.id]),ht.useLayoutEffect(()=>{if(!Fe)return;let Hr=Ze.current,ln=Hr.style.height;Hr.style.height="auto";let Zr=Hr.getBoundingClientRect().height;Hr.style.height=ln,Ge(Zr),w(yi=>yi.find(pt=>pt.toastId===b.id)?yi.map(pt=>pt.toastId===b.id?{...pt,height:Zr}:pt):[{toastId:b.id,height:Zr,position:b.position},...yi])},[Fe,b.title,b.description,w,b.id]);let cr=ht.useCallback(()=>{$e(!0),Se(vr.current),w(Hr=>Hr.filter(ln=>ln.toastId!==b.id)),setTimeout(()=>{R(b)},qgt)},[b,R,w,vr]);ht.useEffect(()=>{if(b.promise&&Qe==="loading"||b.duration===1/0||b.type==="loading")return;let Hr;return L||j||fe&&ka?(()=>{if(Ct.current{var ln;(ln=b.onAutoClose)==null||ln.call(b,b),cr()},lt.current)),()=>clearTimeout(Hr)},[L,j,b,Qe,fe,ka,cr]),ht.useEffect(()=>{b.delete&&cr()},[cr,b.delete]);function Qr(){var Hr,ln,Zr;return xe!=null&&xe.loading?ht.createElement("div",{className:wg(pe==null?void 0:pe.loader,(Hr=b==null?void 0:b.classNames)==null?void 0:Hr.loader,"sonner-loader"),"data-visible":Qe==="loading"},xe.loading):re?ht.createElement("div",{className:wg(pe==null?void 0:pe.loader,(ln=b==null?void 0:b.classNames)==null?void 0:ln.loader,"sonner-loader"),"data-visible":Qe==="loading"},re):ht.createElement(wgt,{className:wg(pe==null?void 0:pe.loader,(Zr=b==null?void 0:b.classNames)==null?void 0:Zr.loader),visible:Qe==="loading"})}return ht.createElement("li",{tabIndex:0,ref:Ze,className:wg(J,It,pe==null?void 0:pe.toast,(s=b==null?void 0:b.classNames)==null?void 0:s.toast,pe==null?void 0:pe.default,pe==null?void 0:pe[Qe],(r=b==null?void 0:b.classNames)==null?void 0:r[Qe]),"data-sonner-toast":"","data-rich-colors":(n=b.richColors)!=null?n:q,"data-styled":!(b.jsx||b.unstyled||_),"data-mounted":Fe,"data-promise":!!b.promise,"data-swiped":Ve,"data-removed":Me,"data-visible":He,"data-y-position":Us,"data-x-position":kr,"data-index":M,"data-front":Je,"data-swiping":ct,"data-dismissible":at,"data-type":Qe,"data-invert":Li,"data-swipe-out":ft,"data-swipe-direction":Ne,"data-expanded":!!(L||le&&Fe),style:{"--index":M,"--toasts-before":M,"--z-index":I.length-M,"--offset":`${Me?et:vr.current}px`,"--initial-height":le?"auto":`${rt}px`,...B,...b.style},onDragEnd:()=>{Te(!1),Ie(null),As.current=null},onPointerDown:Hr=>{Wa||!at||(qe.current=new Date,Se(vr.current),Hr.target.setPointerCapture(Hr.pointerId),Hr.target.tagName!=="BUTTON"&&(Te(!0),As.current={x:Hr.clientX,y:Hr.clientY}))},onPointerUp:()=>{var Hr,ln,Zr,yi;if(ft||!at)return;As.current=null;let pt=Number(((Hr=Ze.current)==null?void 0:Hr.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),ir=Number(((ln=Ze.current)==null?void 0:ln.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Bn=new Date().getTime()-((Zr=qe.current)==null?void 0:Zr.getTime()),Cr=we==="x"?pt:ir,jr=Math.abs(Cr)/Bn;if(Math.abs(Cr)>=$gt||jr>.11){Se(vr.current),(yi=b.onDismiss)==null||yi.call(b,b),Ae(we==="x"?pt>0?"right":"left":ir>0?"down":"up"),cr(),me(!0),nt(!1);return}Te(!1),Ie(null)},onPointerMove:Hr=>{var ln,Zr,yi,pt;if(!As.current||!at||((ln=window.getSelection())==null?void 0:ln.toString().length)>0)return;let ir=Hr.clientY-As.current.y,Bn=Hr.clientX-As.current.x,Cr=(Zr=t.swipeDirections)!=null?Zr:Ugt(ce);!we&&(Math.abs(Bn)>1||Math.abs(ir)>1)&&Ie(Math.abs(Bn)>Math.abs(ir)?"x":"y");let jr={x:0,y:0};we==="y"?(Cr.includes("top")||Cr.includes("bottom"))&&(Cr.includes("top")&&ir<0||Cr.includes("bottom")&&ir>0)&&(jr.y=ir):we==="x"&&(Cr.includes("left")||Cr.includes("right"))&&(Cr.includes("left")&&Bn<0||Cr.includes("right")&&Bn>0)&&(jr.x=Bn),(Math.abs(jr.x)>0||Math.abs(jr.y)>0)&&nt(!0),(yi=Ze.current)==null||yi.style.setProperty("--swipe-amount-x",`${jr.x}px`),(pt=Ze.current)==null||pt.style.setProperty("--swipe-amount-y",`${jr.y}px`)}},Yt&&!b.jsx?ht.createElement("button",{"aria-label":_e,"data-disabled":Wa,"data-close-button":!0,onClick:Wa||!at?()=>{}:()=>{var Hr;cr(),(Hr=b.onDismiss)==null||Hr.call(b,b)},className:wg(pe==null?void 0:pe.closeButton,(a=b==null?void 0:b.classNames)==null?void 0:a.closeButton)},(o=xe==null?void 0:xe.close)!=null?o:Cgt):null,b.jsx||k.isValidElement(b.title)?b.jsx?b.jsx:typeof b.title=="function"?b.title():b.title:ht.createElement(ht.Fragment,null,Qe||b.icon||b.promise?ht.createElement("div",{"data-icon":"",className:wg(pe==null?void 0:pe.icon,(l=b==null?void 0:b.classNames)==null?void 0:l.icon)},b.promise||b.type==="loading"&&!b.icon?b.icon||Qr():null,b.type!=="loading"?b.icon||(xe==null?void 0:xe[Qe])||bgt(Qe):null):null,ht.createElement("div",{"data-content":"",className:wg(pe==null?void 0:pe.content,(i=b==null?void 0:b.classNames)==null?void 0:i.content)},ht.createElement("div",{"data-title":"",className:wg(pe==null?void 0:pe.title,(c=b==null?void 0:b.classNames)==null?void 0:c.title)},typeof b.title=="function"?b.title():b.title),b.description?ht.createElement("div",{"data-description":"",className:wg(te,Ut,pe==null?void 0:pe.description,(u=b==null?void 0:b.classNames)==null?void 0:u.description)},typeof b.description=="function"?b.description():b.description):null),k.isValidElement(b.cancel)?b.cancel:b.cancel&&L7(b.cancel)?ht.createElement("button",{"data-button":!0,"data-cancel":!0,style:b.cancelButtonStyle||V,onClick:Hr=>{var ln,Zr;L7(b.cancel)&&at&&((Zr=(ln=b.cancel).onClick)==null||Zr.call(ln,Hr),cr())},className:wg(pe==null?void 0:pe.cancelButton,(p=b==null?void 0:b.classNames)==null?void 0:p.cancelButton)},b.cancel.label):null,k.isValidElement(b.action)?b.action:b.action&&L7(b.action)?ht.createElement("button",{"data-button":!0,"data-action":!0,style:b.actionButtonStyle||Y,onClick:Hr=>{var ln,Zr;L7(b.action)&&((Zr=(ln=b.action).onClick)==null||Zr.call(ln,Hr),!Hr.defaultPrevented&&cr())},className:wg(pe==null?void 0:pe.actionButton,(f=b==null?void 0:b.classNames)==null?void 0:f.actionButton)},b.action.label):null))};function IAe(){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 Hgt(t,s){let r={};return[t,s].forEach((n,a)=>{let o=a===1,l=o?"--mobile-offset":"--offset",i=o?Fgt:Rgt;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 Wgt=k.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:b,visibleToasts:_=Ogt,toastOptions:j,dir:w=IAe(),gap:N=Bgt,loadingIcon:C,icons:M,containerAriaLabel:I="Notifications",pauseWhenPageIsHidden:L}=t,[R,q]=ht.useState([]),U=ht.useMemo(()=>Array.from(new Set([n].concat(R.filter(fe=>fe.position).map(fe=>fe.position)))),[R,n]),[B,V]=ht.useState([]),[Y,J]=ht.useState(!1),[te,X]=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),le=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),pe=ht.useRef(null),xe=ht.useRef(!1),_e=ht.useCallback(fe=>{q(we=>{var Ie;return(Ie=we.find(Ne=>Ne.id===fe.id))!=null&&Ie.delete||dp.dismiss(fe.id),we.filter(({id:Ne})=>Ne!==fe.id)})},[]);return ht.useEffect(()=>dp.subscribe(fe=>{if(fe.dismiss){q(we=>we.map(Ie=>Ie.id===fe.id?{...Ie,delete:!0}:Ie));return}setTimeout(()=>{i2e.flushSync(()=>{q(we=>{let Ie=we.findIndex(Ne=>Ne.id===fe.id);return Ie!==-1?[...we.slice(0,Ie),{...we[Ie],...fe},...we.slice(Ie+1)]:[fe,...we]})})})}),[]),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 fe=window.matchMedia("(prefers-color-scheme: dark)");try{fe.addEventListener("change",({matches:we})=>{ne(we?"dark":"light")})}catch{fe.addListener(({matches:Ie})=>{try{ne(Ie?"dark":"light")}catch(Ne){console.error(Ne)}})}},[p]),ht.useEffect(()=>{R.length<=1&&J(!1)},[R]),ht.useEffect(()=>{let fe=we=>{var Ie,Ne;a.every(Ae=>we[Ae]||we.code===Ae)&&(J(!0),(Ie=re.current)==null||Ie.focus()),we.code==="Escape"&&(document.activeElement===re.current||(Ne=re.current)!=null&&Ne.contains(document.activeElement))&&J(!1)};return document.addEventListener("keydown",fe),()=>document.removeEventListener("keydown",fe)},[a]),ht.useEffect(()=>{if(re.current)return()=>{pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null,xe.current=!1)}},[re.current]),ht.createElement("section",{ref:s,"aria-label":`${I} ${le}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},U.map((fe,we)=>{var Ie;let[Ne,Ae]=fe.split("-");return R.length?ht.createElement("ol",{key:fe,dir:w==="auto"?IAe():w,tabIndex:-1,ref:re,className:i,"data-sonner-toaster":!0,"data-theme":ce,"data-y-position":Ne,"data-lifted":Y&&R.length>1&&!o,"data-x-position":Ae,style:{"--front-toast-height":`${((Ie=B[0])==null?void 0:Ie.height)||0}px`,"--width":`${zgt}px`,"--gap":`${N}px`,...b,...Hgt(c,u)},onBlur:Fe=>{xe.current&&!Fe.currentTarget.contains(Fe.relatedTarget)&&(xe.current=!1,pe.current&&(pe.current.focus({preventScroll:!0}),pe.current=null))},onFocus:Fe=>{Fe.target instanceof HTMLElement&&Fe.target.dataset.dismissible==="false"||xe.current||(xe.current=!0,pe.current=Fe.relatedTarget)},onMouseEnter:()=>J(!0),onMouseMove:()=>J(!0),onMouseLeave:()=>{te||J(!1)},onDragEnd:()=>J(!1),onPointerDown:Fe=>{Fe.target instanceof HTMLElement&&Fe.target.dataset.dismissible==="false"||X(!0)},onPointerUp:()=>X(!1)},R.filter(Fe=>!Fe.position&&we===0||Fe.position===fe).map((Fe,Ce)=>{var Me,$e;return ht.createElement(Vgt,{key:Fe.id,icons:M,index:Ce,toast:Fe,defaultRichColors:f,duration:(Me=j==null?void 0:j.duration)!=null?Me:g,className:j==null?void 0:j.className,descriptionClassName:j==null?void 0:j.descriptionClassName,invert:r,visibleToasts:_,closeButton:($e=j==null?void 0:j.closeButton)!=null?$e:l,interacting:te,position:fe,style:j==null?void 0:j.style,unstyled:j==null?void 0:j.unstyled,classNames:j==null?void 0:j.classNames,cancelButtonStyle:j==null?void 0:j.cancelButtonStyle,actionButtonStyle:j==null?void 0:j.actionButtonStyle,removeToast:_e,toasts:R.filter(ct=>ct.position==Fe.position),heights:B.filter(ct=>ct.position==Fe.position),setHeights:V,expandByDefault:o,gap:N,loadingIcon:C,expanded:Y,pauseWhenPageIsHidden:L,swipeDirections:t.swipeDirections})})):null}))});const Ggt=({...t})=>{const{theme:s="system"}=vgt();return e.jsx(Wgt,{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 Kgt=fwe[" useId ".trim().toString()]||(()=>{}),Zgt=0;function Mu(t){const[s,r]=k.useState(Kgt());return wd(()=>{r(n=>n??String(Zgt++))},[t]),s?`radix-${s}`:""}const Ygt=["top","right","bottom","left"],iw=Math.min,rf=Math.max,noe=Math.round,D7=Math.floor,g0=t=>({x:t,y:t}),Xgt={left:"right",right:"left",bottom:"top",top:"bottom"},Qgt={start:"end",end:"start"};function P0e(t,s,r){return rf(t,iw(s,r))}function S1(t,s){return typeof t=="function"?t(s):t}function C1(t){return t.split("-")[0]}function FA(t){return t.split("-")[1]}function p2e(t){return t==="x"?"y":"x"}function f2e(t){return t==="y"?"height":"width"}const Jgt=new Set(["top","bottom"]);function n0(t){return Jgt.has(C1(t))?"y":"x"}function x2e(t){return p2e(n0(t))}function eyt(t,s,r){r===void 0&&(r=!1);const n=FA(t),a=x2e(t),o=f2e(a);let l=a==="x"?n===(r?"end":"start")?"right":"left":n==="start"?"bottom":"top";return s.reference[o]>s.floating[o]&&(l=aoe(l)),[l,aoe(l)]}function tyt(t){const s=aoe(t);return[I0e(t),s,I0e(s)]}function I0e(t){return t.replace(/start|end/g,s=>Qgt[s])}const LAe=["left","right"],DAe=["right","left"],syt=["top","bottom"],ryt=["bottom","top"];function nyt(t,s,r){switch(t){case"top":case"bottom":return r?s?DAe:LAe:s?LAe:DAe;case"left":case"right":return s?syt:ryt;default:return[]}}function ayt(t,s,r,n){const a=FA(t);let o=nyt(C1(t),r==="start",n);return a&&(o=o.map(l=>l+"-"+a),s&&(o=o.concat(o.map(I0e)))),o}function aoe(t){return t.replace(/left|right|bottom|top/g,s=>Xgt[s])}function iyt(t){return{top:0,right:0,bottom:0,left:0,...t}}function hqe(t){return typeof t!="number"?iyt(t):{top:t,right:t,bottom:t,left:t}}function ioe(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 OAe(t,s,r){let{reference:n,floating:a}=t;const o=n0(s),l=x2e(s),i=f2e(l),c=C1(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 b;switch(c){case"top":b={x:p,y:n.y-a.height};break;case"bottom":b={x:p,y:n.y+n.height};break;case"right":b={x:n.x+n.width,y:f};break;case"left":b={x:n.x-a.width,y:f};break;default:b={x:n.x,y:n.y}}switch(FA(s)){case"start":b[l]-=g*(r&&u?-1:1);break;case"end":b[l]+=g*(r&&u?-1:1);break}return b}const oyt=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}=OAe(u,n,c),g=n,b={},_=0;for(let j=0;j({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}=S1(t,s)||{};if(u==null)return{};const f=hqe(p),g={x:r,y:n},b=x2e(a),_=f2e(b),j=await l.getDimensions(u),w=b==="y",N=w?"top":"left",C=w?"bottom":"right",M=w?"clientHeight":"clientWidth",I=o.reference[_]+o.reference[b]-g[b]-o.floating[_],L=g[b]-o.reference[b],R=await(l.getOffsetParent==null?void 0:l.getOffsetParent(u));let q=R?R[M]:0;(!q||!await(l.isElement==null?void 0:l.isElement(R)))&&(q=i.floating[M]||o.floating[_]);const U=I/2-L/2,B=q/2-j[_]/2-1,V=iw(f[N],B),Y=iw(f[C],B),J=V,te=q-j[_]-Y,X=q/2-j[_]/2+U,ce=P0e(J,X,te),ne=!c.arrow&&FA(a)!=null&&X!==ce&&o.reference[_]/2-(XX<=0)){var Y,J;const X=(((Y=o.flip)==null?void 0:Y.index)||0)+1,ce=q[X];if(ce&&(!(f==="alignment"?C!==n0(ce):!1)||V.every(le=>le.overflows[0]>0&&n0(le.placement)===C)))return{data:{index:X,overflows:V},reset:{placement:ce}};let ne=(J=V.filter(re=>re.overflows[0]<=0).sort((re,le)=>re.overflows[1]-le.overflows[1])[0])==null?void 0:J.placement;if(!ne)switch(b){case"bestFit":{var te;const re=(te=V.filter(le=>{if(R){const pe=n0(le.placement);return pe===C||pe==="y"}return!0}).map(le=>[le.placement,le.overflows.filter(pe=>pe>0).reduce((pe,xe)=>pe+xe,0)]).sort((le,pe)=>le[1]-pe[1])[0])==null?void 0:te[0];re&&(ne=re);break}case"initialPlacement":ne=i;break}if(a!==ne)return{reset:{placement:ne}}}return{}}}};function RAe(t,s){return{top:t.top-s.height,right:t.right-s.width,bottom:t.bottom-s.height,left:t.left-s.width}}function FAe(t){return Ygt.some(s=>t[s]>=0)}const dyt=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(s){const{rects:r}=s,{strategy:n="referenceHidden",...a}=S1(t,s);switch(n){case"referenceHidden":{const o=await F8(s,{...a,elementContext:"reference"}),l=RAe(o,r.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:FAe(l)}}}case"escaped":{const o=await F8(s,{...a,altBoundary:!0}),l=RAe(o,r.floating);return{data:{escapedOffsets:l,escaped:FAe(l)}}}default:return{}}}}},mqe=new Set(["left","top"]);async function uyt(t,s){const{placement:r,platform:n,elements:a}=t,o=await(n.isRTL==null?void 0:n.isRTL(a.floating)),l=C1(r),i=FA(r),c=n0(r)==="y",u=mqe.has(l)?-1:1,p=o&&c?-1:1,f=S1(s,t);let{mainAxis:g,crossAxis:b,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"&&(b=i==="end"?_*-1:_),c?{x:b*p,y:g*u}:{x:g*u,y:b*p}}const hyt=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 uyt(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}}}}},myt=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:w=>{let{x:N,y:C}=w;return{x:N,y:C}}},...c}=S1(t,s),u={x:r,y:n},p=await F8(s,c),f=n0(C1(a)),g=p2e(f);let b=u[g],_=u[f];if(o){const w=g==="y"?"top":"left",N=g==="y"?"bottom":"right",C=b+p[w],M=b-p[N];b=P0e(C,b,M)}if(l){const w=f==="y"?"top":"left",N=f==="y"?"bottom":"right",C=_+p[w],M=_-p[N];_=P0e(C,_,M)}const j=i.fn({...s,[g]:b,[f]:_});return{...j,data:{x:j.x-r,y:j.y-n,enabled:{[g]:o,[f]:l}}}}}},pyt=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}=S1(t,s),p={x:r,y:n},f=n0(a),g=p2e(f);let b=p[g],_=p[f];const j=S1(i,s),w=typeof j=="number"?{mainAxis:j,crossAxis:0}:{mainAxis:0,crossAxis:0,...j};if(c){const M=g==="y"?"height":"width",I=o.reference[g]-o.floating[M]+w.mainAxis,L=o.reference[g]+o.reference[M]-w.mainAxis;bL&&(b=L)}if(u){var N,C;const M=g==="y"?"width":"height",I=mqe.has(C1(a)),L=o.reference[f]-o.floating[M]+(I&&((N=l.offset)==null?void 0:N[f])||0)+(I?0:w.crossAxis),R=o.reference[f]+o.reference[M]+(I?0:((C=l.offset)==null?void 0:C[f])||0)-(I?w.crossAxis:0);_R&&(_=R)}return{[g]:b,[f]:_}}}},fyt=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}=S1(t,s),p=await F8(s,u),f=C1(a),g=FA(a),b=n0(a)==="y",{width:_,height:j}=o.floating;let w,N;f==="top"||f==="bottom"?(w=f,N=g===(await(l.isRTL==null?void 0:l.isRTL(i.floating))?"start":"end")?"left":"right"):(N=f,w=g==="end"?"top":"bottom");const C=j-p.top-p.bottom,M=_-p.left-p.right,I=iw(j-p[w],C),L=iw(_-p[N],M),R=!s.middlewareData.shift;let q=I,U=L;if((r=s.middlewareData.shift)!=null&&r.enabled.x&&(U=M),(n=s.middlewareData.shift)!=null&&n.enabled.y&&(q=C),R&&!g){const V=rf(p.left,0),Y=rf(p.right,0),J=rf(p.top,0),te=rf(p.bottom,0);b?U=_-2*(V!==0||Y!==0?V+Y:rf(p.left,p.right)):q=j-2*(J!==0||te!==0?J+te:rf(p.top,p.bottom))}await c({...s,availableWidth:U,availableHeight:q});const B=await l.getDimensions(i.floating);return _!==B.width||j!==B.height?{reset:{rects:!0}}:{}}}};function _de(){return typeof window<"u"}function zA(t){return pqe(t)?(t.nodeName||"").toLowerCase():"#document"}function ff(t){var s;return(t==null||(s=t.ownerDocument)==null?void 0:s.defaultView)||window}function I0(t){var s;return(s=(pqe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:s.documentElement}function pqe(t){return _de()?t instanceof Node||t instanceof ff(t).Node:!1}function ny(t){return _de()?t instanceof Element||t instanceof ff(t).Element:!1}function N0(t){return _de()?t instanceof HTMLElement||t instanceof ff(t).HTMLElement:!1}function zAe(t){return!_de()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof ff(t).ShadowRoot}const xyt=new Set(["inline","contents"]);function xO(t){const{overflow:s,overflowX:r,overflowY:n,display:a}=ay(t);return/auto|scroll|overlay|hidden|clip/.test(s+n+r)&&!xyt.has(a)}const gyt=new Set(["table","td","th"]);function yyt(t){return gyt.has(zA(t))}const vyt=[":popover-open",":modal"];function wde(t){return vyt.some(s=>{try{return t.matches(s)}catch{return!1}})}const byt=["transform","translate","scale","rotate","perspective"],_yt=["transform","translate","scale","rotate","perspective","filter"],wyt=["paint","layout","strict","content"];function g2e(t){const s=y2e(),r=ny(t)?ay(t):t;return byt.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)||_yt.some(n=>(r.willChange||"").includes(n))||wyt.some(n=>(r.contain||"").includes(n))}function jyt(t){let s=ow(t);for(;N0(s)&&!TT(s);){if(g2e(s))return s;if(wde(s))return null;s=ow(s)}return null}function y2e(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Nyt=new Set(["html","body","#document"]);function TT(t){return Nyt.has(zA(t))}function ay(t){return ff(t).getComputedStyle(t)}function jde(t){return ny(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function ow(t){if(zA(t)==="html")return t;const s=t.assignedSlot||t.parentNode||zAe(t)&&t.host||I0(t);return zAe(s)?s.host:s}function fqe(t){const s=ow(t);return TT(s)?t.ownerDocument?t.ownerDocument.body:t.body:N0(s)&&xO(s)?s:fqe(s)}function z8(t,s,r){var n;s===void 0&&(s=[]),r===void 0&&(r=!0);const a=fqe(t),o=a===((n=t.ownerDocument)==null?void 0:n.body),l=ff(a);if(o){const i=L0e(l);return s.concat(l,l.visualViewport||[],xO(a)?a:[],i&&r?z8(i):[])}return s.concat(a,z8(a,[],r))}function L0e(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function xqe(t){const s=ay(t);let r=parseFloat(s.width)||0,n=parseFloat(s.height)||0;const a=N0(t),o=a?t.offsetWidth:r,l=a?t.offsetHeight:n,i=noe(r)!==o||noe(n)!==l;return i&&(r=o,n=l),{width:r,height:n,$:i}}function v2e(t){return ny(t)?t:t.contextElement}function HM(t){const s=v2e(t);if(!N0(s))return g0(1);const r=s.getBoundingClientRect(),{width:n,height:a,$:o}=xqe(s);let l=(o?noe(r.width):r.width)/n,i=(o?noe(r.height):r.height)/a;return(!l||!Number.isFinite(l))&&(l=1),(!i||!Number.isFinite(i))&&(i=1),{x:l,y:i}}const kyt=g0(0);function gqe(t){const s=ff(t);return!y2e()||!s.visualViewport?kyt:{x:s.visualViewport.offsetLeft,y:s.visualViewport.offsetTop}}function Syt(t,s,r){return s===void 0&&(s=!1),!r||s&&r!==ff(t)?!1:s}function ES(t,s,r,n){s===void 0&&(s=!1),r===void 0&&(r=!1);const a=t.getBoundingClientRect(),o=v2e(t);let l=g0(1);s&&(n?ny(n)&&(l=HM(n)):l=HM(t));const i=Syt(o,r,n)?gqe(o):g0(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=ff(o),b=n&&ny(n)?ff(n):n;let _=g,j=L0e(_);for(;j&&n&&b!==_;){const w=HM(j),N=j.getBoundingClientRect(),C=ay(j),M=N.left+(j.clientLeft+parseFloat(C.paddingLeft))*w.x,I=N.top+(j.clientTop+parseFloat(C.paddingTop))*w.y;c*=w.x,u*=w.y,p*=w.x,f*=w.y,c+=M,u+=I,_=ff(j),j=L0e(_)}}return ioe({width:p,height:f,x:c,y:u})}function b2e(t,s){const r=jde(t).scrollLeft;return s?s.left+r:ES(I0(t)).left+r}function yqe(t,s,r){r===void 0&&(r=!1);const n=t.getBoundingClientRect(),a=n.left+s.scrollLeft-(r?0:b2e(t,n)),o=n.top+s.scrollTop;return{x:a,y:o}}function Cyt(t){let{elements:s,rect:r,offsetParent:n,strategy:a}=t;const o=a==="fixed",l=I0(n),i=s?wde(s.floating):!1;if(n===l||i&&o)return r;let c={scrollLeft:0,scrollTop:0},u=g0(1);const p=g0(0),f=N0(n);if((f||!f&&!o)&&((zA(n)!=="body"||xO(l))&&(c=jde(n)),N0(n))){const b=ES(n);u=HM(n),p.x=b.x+n.clientLeft,p.y=b.y+n.clientTop}const g=l&&!f&&!o?yqe(l,c,!0):g0(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 Myt(t){return Array.from(t.getClientRects())}function Tyt(t){const s=I0(t),r=jde(t),n=t.ownerDocument.body,a=rf(s.scrollWidth,s.clientWidth,n.scrollWidth,n.clientWidth),o=rf(s.scrollHeight,s.clientHeight,n.scrollHeight,n.clientHeight);let l=-r.scrollLeft+b2e(t);const i=-r.scrollTop;return ay(n).direction==="rtl"&&(l+=rf(s.clientWidth,n.clientWidth)-a),{width:a,height:o,x:l,y:i}}function Ayt(t,s){const r=ff(t),n=I0(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=y2e();(!u||u&&s==="fixed")&&(i=a.offsetLeft,c=a.offsetTop)}return{width:o,height:l,x:i,y:c}}const Eyt=new Set(["absolute","fixed"]);function Pyt(t,s){const r=ES(t,!0,s==="fixed"),n=r.top+t.clientTop,a=r.left+t.clientLeft,o=N0(t)?HM(t):g0(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 BAe(t,s,r){let n;if(s==="viewport")n=Ayt(t,r);else if(s==="document")n=Tyt(I0(t));else if(ny(s))n=Pyt(s,r);else{const a=gqe(t);n={x:s.x-a.x,y:s.y-a.y,width:s.width,height:s.height}}return ioe(n)}function vqe(t,s){const r=ow(t);return r===s||!ny(r)||TT(r)?!1:ay(r).position==="fixed"||vqe(r,s)}function Iyt(t,s){const r=s.get(t);if(r)return r;let n=z8(t,[],!1).filter(i=>ny(i)&&zA(i)!=="body"),a=null;const o=ay(t).position==="fixed";let l=o?ow(t):t;for(;ny(l)&&!TT(l);){const i=ay(l),c=g2e(l);!c&&i.position==="fixed"&&(a=null),(o?!c&&!a:!c&&i.position==="static"&&!!a&&Eyt.has(a.position)||xO(l)&&!c&&vqe(t,l))?n=n.filter(p=>p!==l):a=i,l=ow(l)}return s.set(t,n),n}function Lyt(t){let{element:s,boundary:r,rootBoundary:n,strategy:a}=t;const l=[...r==="clippingAncestors"?wde(s)?[]:Iyt(s,this._c):[].concat(r),n],i=l[0],c=l.reduce((u,p)=>{const f=BAe(s,p,a);return u.top=rf(f.top,u.top),u.right=iw(f.right,u.right),u.bottom=iw(f.bottom,u.bottom),u.left=rf(f.left,u.left),u},BAe(s,i,a));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Dyt(t){const{width:s,height:r}=xqe(t);return{width:s,height:r}}function Oyt(t,s,r){const n=N0(s),a=I0(s),o=r==="fixed",l=ES(t,!0,o,s);let i={scrollLeft:0,scrollTop:0};const c=g0(0);function u(){c.x=b2e(a)}if(n||!n&&!o)if((zA(s)!=="body"||xO(a))&&(i=jde(s)),n){const b=ES(s,!0,o,s);c.x=b.x+s.clientLeft,c.y=b.y+s.clientTop}else a&&u();o&&!n&&a&&u();const p=a&&!n&&!o?yqe(a,i):g0(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 Zfe(t){return ay(t).position==="static"}function $Ae(t,s){if(!N0(t)||ay(t).position==="fixed")return null;if(s)return s(t);let r=t.offsetParent;return I0(t)===r&&(r=r.ownerDocument.body),r}function bqe(t,s){const r=ff(t);if(wde(t))return r;if(!N0(t)){let a=ow(t);for(;a&&!TT(a);){if(ny(a)&&!Zfe(a))return a;a=ow(a)}return r}let n=$Ae(t,s);for(;n&&yyt(n)&&Zfe(n);)n=$Ae(n,s);return n&&TT(n)&&Zfe(n)&&!g2e(n)?r:n||jyt(t)||r}const Ryt=async function(t){const s=this.getOffsetParent||bqe,r=this.getDimensions,n=await r(t.floating);return{reference:Oyt(t.reference,await s(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Fyt(t){return ay(t).direction==="rtl"}const zyt={convertOffsetParentRelativeRectToViewportRelativeRect:Cyt,getDocumentElement:I0,getClippingRect:Lyt,getOffsetParent:bqe,getElementRects:Ryt,getClientRects:Myt,getDimensions:Dyt,getScale:HM,isElement:ny,isRTL:Fyt};function _qe(t,s){return t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height}function Byt(t,s){let r=null,n;const a=I0(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:b}=u;if(i||s(),!g||!b)return;const _=D7(f),j=D7(a.clientWidth-(p+g)),w=D7(a.clientHeight-(f+b)),N=D7(p),M={rootMargin:-_+"px "+-j+"px "+-w+"px "+-N+"px",threshold:rf(0,iw(1,c))||1};let I=!0;function L(R){const q=R[0].intersectionRatio;if(q!==c){if(!I)return l();q?l(!1,q):n=setTimeout(()=>{l(!1,1e-7)},1e3)}q===1&&!_qe(u,t.getBoundingClientRect())&&l(),I=!1}try{r=new IntersectionObserver(L,{...M,root:a.ownerDocument})}catch{r=new IntersectionObserver(L,M)}r.observe(t)}return l(!0),o}function $yt(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=v2e(t),p=a||o?[...u?z8(u):[],...z8(s)]:[];p.forEach(N=>{a&&N.addEventListener("scroll",r,{passive:!0}),o&&N.addEventListener("resize",r)});const f=u&&i?Byt(u,r):null;let g=-1,b=null;l&&(b=new ResizeObserver(N=>{let[C]=N;C&&C.target===u&&b&&(b.unobserve(s),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var M;(M=b)==null||M.observe(s)})),r()}),u&&!c&&b.observe(u),b.observe(s));let _,j=c?ES(t):null;c&&w();function w(){const N=ES(t);j&&!_qe(j,N)&&r(),j=N,_=requestAnimationFrame(w)}return r(),()=>{var N;p.forEach(C=>{a&&C.removeEventListener("scroll",r),o&&C.removeEventListener("resize",r)}),f==null||f(),(N=b)==null||N.disconnect(),b=null,c&&cancelAnimationFrame(_)}}const qyt=hyt,Uyt=myt,Vyt=cyt,Hyt=fyt,Wyt=dyt,qAe=lyt,Gyt=pyt,Kyt=(t,s,r)=>{const n=new Map,a={platform:zyt,...r},o={...a.platform,_c:n};return oyt(t,s,{...a,platform:o})};var Zyt=typeof document<"u",Yyt=function(){},rie=Zyt?k.useLayoutEffect:Yyt;function ooe(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(!ooe(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)&&!ooe(t[o],s[o]))return!1}return!0}return t!==t&&s!==s}function wqe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function UAe(t,s){const r=wqe(t);return Math.round(s*r)/r}function Yfe(t){const s=k.useRef(t);return rie(()=>{s.current=t}),s}function Xyt(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]=k.useState({x:0,y:0,strategy:r,placement:s,middlewareData:{},isPositioned:!1}),[g,b]=k.useState(n);ooe(g,n)||b(n);const[_,j]=k.useState(null),[w,N]=k.useState(null),C=k.useCallback(le=>{le!==R.current&&(R.current=le,j(le))},[]),M=k.useCallback(le=>{le!==q.current&&(q.current=le,N(le))},[]),I=o||_,L=l||w,R=k.useRef(null),q=k.useRef(null),U=k.useRef(p),B=c!=null,V=Yfe(c),Y=Yfe(a),J=Yfe(u),te=k.useCallback(()=>{if(!R.current||!q.current)return;const le={placement:s,strategy:r,middleware:g};Y.current&&(le.platform=Y.current),Kyt(R.current,q.current,le).then(pe=>{const xe={...pe,isPositioned:J.current!==!1};X.current&&!ooe(U.current,xe)&&(U.current=xe,gp.flushSync(()=>{f(xe)}))})},[g,s,r,Y,J]);rie(()=>{u===!1&&U.current.isPositioned&&(U.current.isPositioned=!1,f(le=>({...le,isPositioned:!1})))},[u]);const X=k.useRef(!1);rie(()=>(X.current=!0,()=>{X.current=!1}),[]),rie(()=>{if(I&&(R.current=I),L&&(q.current=L),I&&L){if(V.current)return V.current(I,L,te);te()}},[I,L,te,V,B]);const ce=k.useMemo(()=>({reference:R,floating:q,setReference:C,setFloating:M}),[C,M]),ne=k.useMemo(()=>({reference:I,floating:L}),[I,L]),re=k.useMemo(()=>{const le={position:r,left:0,top:0};if(!ne.floating)return le;const pe=UAe(ne.floating,p.x),xe=UAe(ne.floating,p.y);return i?{...le,transform:"translate("+pe+"px, "+xe+"px)",...wqe(ne.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:pe,top:xe}},[r,i,ne.floating,p.x,p.y]);return k.useMemo(()=>({...p,update:te,refs:ce,elements:ne,floatingStyles:re}),[p,te,ce,ne,re])}const Qyt=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?qAe({element:n.current,padding:a}).fn(r):{}:n?qAe({element:n,padding:a}).fn(r):{}}}},Jyt=(t,s)=>({...qyt(t),options:[t,s]}),e0t=(t,s)=>({...Uyt(t),options:[t,s]}),t0t=(t,s)=>({...Gyt(t),options:[t,s]}),s0t=(t,s)=>({...Vyt(t),options:[t,s]}),r0t=(t,s)=>({...Hyt(t),options:[t,s]}),n0t=(t,s)=>({...Wyt(t),options:[t,s]}),a0t=(t,s)=>({...Qyt(t),options:[t,s]});var i0t="Arrow",jqe=k.forwardRef((t,s)=>{const{children:r,width:n=10,height:a=5,...o}=t;return e.jsx(sn.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"})})});jqe.displayName=i0t;var o0t=jqe;function gO(t){const[s,r]=k.useState(void 0);return wd(()=>{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 _2e="Popper",[Nqe,L0]=nd(_2e),[l0t,kqe]=Nqe(_2e),Sqe=t=>{const{__scopePopper:s,children:r}=t,[n,a]=k.useState(null);return e.jsx(l0t,{scope:s,anchor:n,onAnchorChange:a,children:r})};Sqe.displayName=_2e;var Cqe="PopperAnchor",Mqe=k.forwardRef((t,s)=>{const{__scopePopper:r,virtualRef:n,...a}=t,o=kqe(Cqe,r),l=k.useRef(null),i=$a(s,l);return k.useEffect(()=>{o.onAnchorChange((n==null?void 0:n.current)||l.current)}),n?null:e.jsx(sn.div,{...a,ref:i})});Mqe.displayName=Cqe;var w2e="PopperContent",[c0t,d0t]=Nqe(w2e),Tqe=k.forwardRef((t,s)=>{var Fe,Ce,Me,$e,ct,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:b="optimized",onPlaced:_,...j}=t,w=kqe(w2e,r),[N,C]=k.useState(null),M=$a(s,ft=>C(ft)),[I,L]=k.useState(null),R=gO(I),q=(R==null?void 0:R.width)??0,U=(R==null?void 0:R.height)??0,B=n+(o!=="center"?"-"+o:""),V=typeof p=="number"?p:{top:0,right:0,bottom:0,left:0,...p},Y=Array.isArray(u)?u:[u],J=Y.length>0,te={padding:V,boundary:Y.filter(h0t),altBoundary:J},{refs:X,floatingStyles:ce,placement:ne,isPositioned:re,middlewareData:le}=Xyt({strategy:"fixed",placement:B,whileElementsMounted:(...ft)=>$yt(...ft,{animationFrame:b==="always"}),elements:{reference:w.anchor},middleware:[Jyt({mainAxis:a+U,alignmentAxis:l}),c&&e0t({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?t0t():void 0,...te}),c&&s0t({...te}),r0t({...te,apply:({elements:ft,rects:me,availableWidth:Ve,availableHeight:nt})=>{const{width:et,height:Se}=me.reference,rt=ft.floating.style;rt.setProperty("--radix-popper-available-width",`${Ve}px`),rt.setProperty("--radix-popper-available-height",`${nt}px`),rt.setProperty("--radix-popper-anchor-width",`${et}px`),rt.setProperty("--radix-popper-anchor-height",`${Se}px`)}}),I&&a0t({element:I,padding:i}),m0t({arrowWidth:q,arrowHeight:U}),g&&n0t({strategy:"referenceHidden",...te})]}),[pe,xe]=Pqe(ne),_e=gd(_);wd(()=>{re&&(_e==null||_e())},[re,_e]);const fe=(Fe=le.arrow)==null?void 0:Fe.x,we=(Ce=le.arrow)==null?void 0:Ce.y,Ie=((Me=le.arrow)==null?void 0:Me.centerOffset)!==0,[Ne,Ae]=k.useState();return wd(()=>{N&&Ae(window.getComputedStyle(N).zIndex)},[N]),e.jsx("div",{ref:X.setFloating,"data-radix-popper-content-wrapper":"",style:{...ce,transform:re?ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Ne,"--radix-popper-transform-origin":[($e=le.transformOrigin)==null?void 0:$e.x,(ct=le.transformOrigin)==null?void 0:ct.y].join(" "),...((Te=le.hide)==null?void 0:Te.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:e.jsx(c0t,{scope:r,placedSide:pe,onArrowChange:L,arrowX:fe,arrowY:we,shouldHideArrow:Ie,children:e.jsx(sn.div,{"data-side":pe,"data-align":xe,...j,ref:M,style:{...j.style,animation:re?void 0:"none"}})})})});Tqe.displayName=w2e;var Aqe="PopperArrow",u0t={top:"bottom",right:"left",bottom:"top",left:"right"},Eqe=k.forwardRef(function(s,r){const{__scopePopper:n,...a}=s,o=d0t(Aqe,n),l=u0t[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(o0t,{...a,ref:r,style:{...a.style,display:"block"}})})});Eqe.displayName=Aqe;function h0t(t){return t!==null}var m0t=t=>({name:"transformOrigin",options:t,fn(s){var w,N,C;const{placement:r,rects:n,middlewareData:a}=s,l=((w=a.arrow)==null?void 0:w.centerOffset)!==0,i=l?0:t.arrowWidth,c=l?0:t.arrowHeight,[u,p]=Pqe(r),f={start:"0%",center:"50%",end:"100%"}[p],g=(((N=a.arrow)==null?void 0:N.x)??0)+i/2,b=(((C=a.arrow)==null?void 0:C.y)??0)+c/2;let _="",j="";return u==="bottom"?(_=l?f:`${g}px`,j=`${-c}px`):u==="top"?(_=l?f:`${g}px`,j=`${n.floating.height+c}px`):u==="right"?(_=`${-c}px`,j=l?f:`${b}px`):u==="left"&&(_=`${n.floating.width+c}px`,j=l?f:`${b}px`),{data:{x:_,y:j}}}});function Pqe(t){const[s,r="center"]=t.split("-");return[s,r]}var yO=Sqe,BA=Mqe,vO=Tqe,bO=Eqe,[Nde]=nd("Tooltip",[L0]),kde=L0(),Iqe="TooltipProvider",p0t=700,D0e="tooltip.open",[f0t,j2e]=Nde(Iqe),Lqe=t=>{const{__scopeTooltip:s,delayDuration:r=p0t,skipDelayDuration:n=300,disableHoverableContent:a=!1,children:o}=t,l=k.useRef(!0),i=k.useRef(!1),c=k.useRef(0);return k.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),e.jsx(f0t,{scope:s,isOpenDelayedRef:l,delayDuration:r,onOpen:k.useCallback(()=>{window.clearTimeout(c.current),l.current=!1},[]),onClose:k.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>l.current=!0,n)},[n]),isPointerInTransitRef:i,onPointerInTransitChange:k.useCallback(u=>{i.current=u},[]),disableHoverableContent:a,children:o})};Lqe.displayName=Iqe;var B8="Tooltip",[x0t,Sde]=Nde(B8),Dqe=t=>{const{__scopeTooltip:s,children:r,open:n,defaultOpen:a,onOpenChange:o,disableHoverableContent:l,delayDuration:i}=t,c=j2e(B8,t.__scopeTooltip),u=kde(s),[p,f]=k.useState(null),g=Mu(),b=k.useRef(0),_=l??c.disableHoverableContent,j=i??c.delayDuration,w=k.useRef(!1),[N,C]=rh({prop:n,defaultProp:a??!1,onChange:q=>{q?(c.onOpen(),document.dispatchEvent(new CustomEvent(D0e))):c.onClose(),o==null||o(q)},caller:B8}),M=k.useMemo(()=>N?w.current?"delayed-open":"instant-open":"closed",[N]),I=k.useCallback(()=>{window.clearTimeout(b.current),b.current=0,w.current=!1,C(!0)},[C]),L=k.useCallback(()=>{window.clearTimeout(b.current),b.current=0,C(!1)},[C]),R=k.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{w.current=!0,C(!0),b.current=0},j)},[j,C]);return k.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),e.jsx(yO,{...u,children:e.jsx(x0t,{scope:s,contentId:g,open:N,stateAttribute:M,trigger:p,onTriggerChange:f,onTriggerEnter:k.useCallback(()=>{c.isOpenDelayedRef.current?R():I()},[c.isOpenDelayedRef,R,I]),onTriggerLeave:k.useCallback(()=>{_?L():(window.clearTimeout(b.current),b.current=0)},[L,_]),onOpen:I,onClose:L,disableHoverableContent:_,children:r})})};Dqe.displayName=B8;var O0e="TooltipTrigger",Oqe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=Sde(O0e,r),o=j2e(O0e,r),l=kde(r),i=k.useRef(null),c=$a(s,i,a.onTriggerChange),u=k.useRef(!1),p=k.useRef(!1),f=k.useCallback(()=>u.current=!1,[]);return k.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),e.jsx(BA,{asChild:!0,...l,children:e.jsx(sn.button,{"aria-describedby":a.open?a.contentId:void 0,"data-state":a.stateAttribute,...n,ref:c,onPointerMove:Ir(t.onPointerMove,g=>{g.pointerType!=="touch"&&!p.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),p.current=!0)}),onPointerLeave:Ir(t.onPointerLeave,()=>{a.onTriggerLeave(),p.current=!1}),onPointerDown:Ir(t.onPointerDown,()=>{a.open&&a.onClose(),u.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ir(t.onFocus,()=>{u.current||a.onOpen()}),onBlur:Ir(t.onBlur,a.onClose),onClick:Ir(t.onClick,a.onClose)})})});Oqe.displayName=O0e;var g0t="TooltipPortal",[iMs,y0t]=Nde(g0t,{forceMount:void 0}),AT="TooltipContent",Rqe=k.forwardRef((t,s)=>{const r=y0t(AT,t.__scopeTooltip),{forceMount:n=r.forceMount,side:a="top",...o}=t,l=Sde(AT,t.__scopeTooltip);return e.jsx(Fd,{present:n||l.open,children:l.disableHoverableContent?e.jsx(Fqe,{side:a,...o,ref:s}):e.jsx(v0t,{side:a,...o,ref:s})})}),v0t=k.forwardRef((t,s)=>{const r=Sde(AT,t.__scopeTooltip),n=j2e(AT,t.__scopeTooltip),a=k.useRef(null),o=$a(s,a),[l,i]=k.useState(null),{trigger:c,onClose:u}=r,p=a.current,{onPointerInTransitChange:f}=n,g=k.useCallback(()=>{i(null),f(!1)},[f]),b=k.useCallback((_,j)=>{const w=_.currentTarget,N={x:_.clientX,y:_.clientY},C=N0t(N,w.getBoundingClientRect()),M=k0t(N,C),I=S0t(j.getBoundingClientRect()),L=M0t([...M,...I]);i(L),f(!0)},[f]);return k.useEffect(()=>()=>g(),[g]),k.useEffect(()=>{if(c&&p){const _=w=>b(w,p),j=w=>b(w,c);return c.addEventListener("pointerleave",_),p.addEventListener("pointerleave",j),()=>{c.removeEventListener("pointerleave",_),p.removeEventListener("pointerleave",j)}}},[c,p,b,g]),k.useEffect(()=>{if(l){const _=j=>{const w=j.target,N={x:j.clientX,y:j.clientY},C=(c==null?void 0:c.contains(w))||(p==null?void 0:p.contains(w)),M=!C0t(N,l);C?g():M&&(g(),u())};return document.addEventListener("pointermove",_),()=>document.removeEventListener("pointermove",_)}},[c,p,l,u,g]),e.jsx(Fqe,{...t,ref:o})}),[b0t,_0t]=Nde(B8,{isInside:!1}),w0t=T$e("TooltipContent"),Fqe=k.forwardRef((t,s)=>{const{__scopeTooltip:r,children:n,"aria-label":a,onEscapeKeyDown:o,onPointerDownOutside:l,...i}=t,c=Sde(AT,r),u=kde(r),{onClose:p}=c;return k.useEffect(()=>(document.addEventListener(D0e,p),()=>document.removeEventListener(D0e,p)),[p]),k.useEffect(()=>{if(c.trigger){const f=g=>{const b=g.target;b!=null&&b.contains(c.trigger)&&p()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,p]),e.jsx(ww,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:f=>f.preventDefault(),onDismiss:p,children:e.jsxs(vO,{"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(w0t,{children:n}),e.jsx(b0t,{scope:r,isInside:!0,children:e.jsx(hxt,{id:c.contentId,role:"tooltip",children:a||n})})]})})});Rqe.displayName=AT;var zqe="TooltipArrow",j0t=k.forwardRef((t,s)=>{const{__scopeTooltip:r,...n}=t,a=kde(r);return _0t(zqe,r).isInside?null:e.jsx(bO,{...a,...n,ref:s})});j0t.displayName=zqe;function N0t(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 k0t(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 S0t(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 C0t(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 M0t(t){const s=t.slice();return s.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),T0t(s)}function T0t(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 A0t=Lqe,E0t=Dqe,P0t=Oqe,Bqe=Rqe;const F1=A0t,Oc=E0t,Rc=P0t,gc=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Bqe,{ref:n,sideOffset:s,className:Pt("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}));gc.displayName=Bqe.displayName;var $A=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(){}},PS=typeof window>"u"||"Deno"in globalThis;function bm(){}function I0t(t,s){return typeof t=="function"?t(s):t}function R0e(t){return typeof t=="number"&&t>=0&&t!==1/0}function $qe(t,s){return Math.max(t+(s||0)-Date.now(),0)}function W_(t,s){return typeof t=="function"?t(s):t}function ox(t,s){return typeof t=="function"?t(s):t}function VAe(t,s){const{type:r="all",exact:n,fetchStatus:a,predicate:o,queryKey:l,stale:i}=t;if(l){if(n){if(s.queryHash!==N2e(l,s.options))return!1}else if(!$8(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 HAe(t,s){const{exact:r,status:n,predicate:a,mutationKey:o}=t;if(o){if(!s.options.mutationKey)return!1;if(r){if(IS(s.options.mutationKey)!==IS(o))return!1}else if(!$8(s.options.mutationKey,o))return!1}return!(n&&s.state.status!==n||a&&!a(s))}function N2e(t,s){return((s==null?void 0:s.queryKeyHashFn)||IS)(t)}function IS(t){return JSON.stringify(t,(s,r)=>F0e(r)?Object.keys(r).sort().reduce((n,a)=>(n[a]=r[a],n),{}):r)}function $8(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"&&typeof s=="object"?Object.keys(s).every(r=>$8(t[r],s[r])):!1}function qqe(t,s){if(t===s)return t;const r=WAe(t)&&WAe(s);if(r||F0e(t)&&F0e(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 z0e(t,s,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,s):r.structuralSharing!==!1?qqe(t,s):s}function D0t(t,s,r=0){const n=[...t,s];return r&&n.length>r?n.slice(1):n}function O0t(t,s,r=0){const n=[s,...t];return r&&n.length>r?n.slice(0,-1):n}var k2e=Symbol();function Uqe(t,s){return!t.queryFn&&(s!=null&&s.initialPromise)?()=>s.initialPromise:!t.queryFn||t.queryFn===k2e?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function Vqe(t,s){return typeof t=="function"?t(...s):!!t}var A4,l_,dT,n9e,R0t=(n9e=class extends $A{constructor(){super();Xa(this,A4);Xa(this,l_);Xa(this,dT);Kn(this,dT,s=>{if(!PS&&window.addEventListener){const r=()=>s();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){ls(this,l_)||this.setEventListener(ls(this,dT))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,l_))==null||s.call(this),Kn(this,l_,void 0))}setEventListener(s){var r;Kn(this,dT,s),(r=ls(this,l_))==null||r.call(this),Kn(this,l_,s(n=>{typeof n=="boolean"?this.setFocused(n):this.onFocus()}))}setFocused(s){ls(this,A4)!==s&&(Kn(this,A4,s),this.onFocus())}onFocus(){const s=this.isFocused();this.listeners.forEach(r=>{r(s)})}isFocused(){var s;return typeof ls(this,A4)=="boolean"?ls(this,A4):((s=globalThis.document)==null?void 0:s.visibilityState)!=="hidden"}},A4=new WeakMap,l_=new WeakMap,dT=new WeakMap,n9e),S2e=new R0t,uT,c_,hT,a9e,F0t=(a9e=class extends $A{constructor(){super();Xa(this,uT,!0);Xa(this,c_);Xa(this,hT);Kn(this,hT,s=>{if(!PS&&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(){ls(this,c_)||this.setEventListener(ls(this,hT))}onUnsubscribe(){var s;this.hasListeners()||((s=ls(this,c_))==null||s.call(this),Kn(this,c_,void 0))}setEventListener(s){var r;Kn(this,hT,s),(r=ls(this,c_))==null||r.call(this),Kn(this,c_,s(this.setOnline.bind(this)))}setOnline(s){ls(this,uT)!==s&&(Kn(this,uT,s),this.listeners.forEach(n=>{n(s)}))}isOnline(){return ls(this,uT)}},uT=new WeakMap,c_=new WeakMap,hT=new WeakMap,a9e),coe=new F0t;function B0e(){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 z0t(t){return Math.min(1e3*2**t,3e4)}function Hqe(t){return(t??"online")==="online"?coe.isOnline():!0}var Wqe=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function Xfe(t){return t instanceof Wqe}function Gqe(t){let s=!1,r=0,n=!1,a;const o=B0e(),l=j=>{var w;n||(g(new Wqe(j)),(w=t.abort)==null||w.call(t))},i=()=>{s=!0},c=()=>{s=!1},u=()=>S2e.isFocused()&&(t.networkMode==="always"||coe.isOnline())&&t.canRun(),p=()=>Hqe(t.networkMode)&&t.canRun(),f=j=>{var w;n||(n=!0,(w=t.onSuccess)==null||w.call(t,j),a==null||a(),o.resolve(j))},g=j=>{var w;n||(n=!0,(w=t.onError)==null||w.call(t,j),a==null||a(),o.reject(j))},b=()=>new Promise(j=>{var w;a=N=>{(n||u())&&j(N)},(w=t.onPause)==null||w.call(t)}).then(()=>{var j;a=void 0,n||(j=t.onContinue)==null||j.call(t)}),_=()=>{if(n)return;let j;const w=r===0?t.initialPromise:void 0;try{j=w??t.fn()}catch(N){j=Promise.reject(N)}Promise.resolve(j).then(f).catch(N=>{var R;if(n)return;const C=t.retry??(PS?0:3),M=t.retryDelay??z0t,I=typeof M=="function"?M(r,N):M,L=C===!0||typeof C=="number"&&ru()?void 0:b()).then(()=>{s?g(N):_()})})};return{promise:o,cancel:l,continue:()=>(a==null||a(),o),cancelRetry:i,continueRetry:c,canStart:p,start:()=>(p()?_():b().then(_),o)}}var B0t=t=>setTimeout(t,0);function $0t(){let t=[],s=0,r=i=>{i()},n=i=>{i()},a=B0t;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 yu=$0t(),E4,i9e,Kqe=(i9e=class{constructor(){Xa(this,E4)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),R0e(this.gcTime)&&Kn(this,E4,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(PS?1/0:5*60*1e3))}clearGcTimeout(){ls(this,E4)&&(clearTimeout(ls(this,E4)),Kn(this,E4,void 0))}},E4=new WeakMap,i9e),mT,P4,ix,I4,Fh,aO,L4,Pg,Sv,o9e,q0t=(o9e=class extends Kqe{constructor(s){super();Xa(this,Pg);Xa(this,mT);Xa(this,P4);Xa(this,ix);Xa(this,I4);Xa(this,Fh);Xa(this,aO);Xa(this,L4);Kn(this,L4,!1),Kn(this,aO,s.defaultOptions),this.setOptions(s.options),this.observers=[],Kn(this,I4,s.client),Kn(this,ix,ls(this,I4).getQueryCache()),this.queryKey=s.queryKey,this.queryHash=s.queryHash,Kn(this,mT,U0t(this.options)),this.state=s.state??ls(this,mT),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var s;return(s=ls(this,Fh))==null?void 0:s.promise}setOptions(s){this.options={...ls(this,aO),...s},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&ls(this,ix).remove(this)}setData(s,r){const n=z0e(this.state.data,s,this.options);return Qi(this,Pg,Sv).call(this,{data:n,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),n}setState(s,r){Qi(this,Pg,Sv).call(this,{type:"setState",state:s,setStateOptions:r})}cancel(s){var n,a;const r=(n=ls(this,Fh))==null?void 0:n.promise;return(a=ls(this,Fh))==null||a.cancel(s),r?r.then(bm).catch(bm):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(ls(this,mT))}isActive(){return this.observers.some(s=>ox(s.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===k2e||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(s=>W_(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:!$qe(this.state.dataUpdatedAt,s)}onFocus(){var r;const s=this.observers.find(n=>n.shouldFetchOnWindowFocus());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Fh))==null||r.continue()}onOnline(){var r;const s=this.observers.find(n=>n.shouldFetchOnReconnect());s==null||s.refetch({cancelRefetch:!1}),(r=ls(this,Fh))==null||r.continue()}addObserver(s){this.observers.includes(s)||(this.observers.push(s),this.clearGcTimeout(),ls(this,ix).notify({type:"observerAdded",query:this,observer:s}))}removeObserver(s){this.observers.includes(s)&&(this.observers=this.observers.filter(r=>r!==s),this.observers.length||(ls(this,Fh)&&(ls(this,L4)?ls(this,Fh).cancel({revert:!0}):ls(this,Fh).cancelRetry()),this.scheduleGc()),ls(this,ix).notify({type:"observerRemoved",query:this,observer:s}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Qi(this,Pg,Sv).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(ls(this,Fh))return ls(this,Fh).continueRetry(),ls(this,Fh).promise}if(s&&this.setOptions(s),!this.options.queryFn){const g=this.observers.find(b=>b.options.queryFn);g&&this.setOptions(g.options)}const n=new AbortController,a=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(Kn(this,L4,!0),n.signal)})},o=()=>{const g=Uqe(this.options,r),_=(()=>{const j={client:ls(this,I4),queryKey:this.queryKey,meta:this.meta};return a(j),j})();return Kn(this,L4,!1),this.options.persister?this.options.persister(g,_,this):g(_)},i=(()=>{const g={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:ls(this,I4),state:this.state,fetchFn:o};return a(g),g})();(u=this.options.behavior)==null||u.onFetch(i,this),Kn(this,P4,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((p=i.fetchOptions)==null?void 0:p.meta))&&Qi(this,Pg,Sv).call(this,{type:"fetch",meta:(f=i.fetchOptions)==null?void 0:f.meta});const c=g=>{var b,_,j,w;Xfe(g)&&g.silent||Qi(this,Pg,Sv).call(this,{type:"error",error:g}),Xfe(g)||((_=(b=ls(this,ix).config).onError)==null||_.call(b,g,this),(w=(j=ls(this,ix).config).onSettled)==null||w.call(j,this.state.data,g,this)),this.scheduleGc()};return Kn(this,Fh,Gqe({initialPromise:r==null?void 0:r.initialPromise,fn:i.fetchFn,abort:n.abort.bind(n),onSuccess:g=>{var b,_,j,w;if(g===void 0){c(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(g)}catch(N){c(N);return}(_=(b=ls(this,ix).config).onSuccess)==null||_.call(b,g,this),(w=(j=ls(this,ix).config).onSettled)==null||w.call(j,g,this.state.error,this),this.scheduleGc()},onError:c,onFail:(g,b)=>{Qi(this,Pg,Sv).call(this,{type:"failed",failureCount:g,error:b})},onPause:()=>{Qi(this,Pg,Sv).call(this,{type:"pause"})},onContinue:()=>{Qi(this,Pg,Sv).call(this,{type:"continue"})},retry:i.options.retry,retryDelay:i.options.retryDelay,networkMode:i.options.networkMode,canRun:()=>!0})),ls(this,Fh).start()}},mT=new WeakMap,P4=new WeakMap,ix=new WeakMap,I4=new WeakMap,Fh=new WeakMap,aO=new WeakMap,L4=new WeakMap,Pg=new WeakSet,Sv=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,...Zqe(n.data,this.options),fetchMeta:s.meta??null};case"success":return Kn(this,P4,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 Xfe(a)&&a.revert&&ls(this,P4)?{...ls(this,P4),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),yu.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),ls(this,ix).notify({query:this,type:"updated",action:s})})},o9e);function Zqe(t,s){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Hqe(s.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function U0t(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 Zy,l9e,V0t=(l9e=class extends $A{constructor(s={}){super();Xa(this,Zy);this.config=s,Kn(this,Zy,new Map)}build(s,r,n){const a=r.queryKey,o=r.queryHash??N2e(a,r);let l=this.get(o);return l||(l=new q0t({client:s,queryKey:a,queryHash:o,options:s.defaultQueryOptions(r),state:n,defaultOptions:s.getQueryDefaults(a)}),this.add(l)),l}add(s){ls(this,Zy).has(s.queryHash)||(ls(this,Zy).set(s.queryHash,s),this.notify({type:"added",query:s}))}remove(s){const r=ls(this,Zy).get(s.queryHash);r&&(s.destroy(),r===s&&ls(this,Zy).delete(s.queryHash),this.notify({type:"removed",query:s}))}clear(){yu.batch(()=>{this.getAll().forEach(s=>{this.remove(s)})})}get(s){return ls(this,Zy).get(s)}getAll(){return[...ls(this,Zy).values()]}find(s){const r={exact:!0,...s};return this.getAll().find(n=>VAe(r,n))}findAll(s={}){const r=this.getAll();return Object.keys(s).length>0?r.filter(n=>VAe(s,n)):r}notify(s){yu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}onFocus(){yu.batch(()=>{this.getAll().forEach(s=>{s.onFocus()})})}onOnline(){yu.batch(()=>{this.getAll().forEach(s=>{s.onOnline()})})}},Zy=new WeakMap,l9e),Yy,gm,D4,Xy,Rb,c9e,H0t=(c9e=class extends Kqe{constructor(s){super();Xa(this,Xy);Xa(this,Yy);Xa(this,gm);Xa(this,D4);this.mutationId=s.mutationId,Kn(this,gm,s.mutationCache),Kn(this,Yy,[]),this.state=s.state||Yqe(),this.setOptions(s.options),this.scheduleGc()}setOptions(s){this.options=s,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(s){ls(this,Yy).includes(s)||(ls(this,Yy).push(s),this.clearGcTimeout(),ls(this,gm).notify({type:"observerAdded",mutation:this,observer:s}))}removeObserver(s){Kn(this,Yy,ls(this,Yy).filter(r=>r!==s)),this.scheduleGc(),ls(this,gm).notify({type:"observerRemoved",mutation:this,observer:s})}optionalRemove(){ls(this,Yy).length||(this.state.status==="pending"?this.scheduleGc():ls(this,gm).remove(this))}continue(){var s;return((s=ls(this,D4))==null?void 0:s.continue())??this.execute(this.state.variables)}async execute(s){var o,l,i,c,u,p,f,g,b,_,j,w,N,C,M,I,L,R,q,U;const r=()=>{Qi(this,Xy,Rb).call(this,{type:"continue"})};Kn(this,D4,Gqe({fn:()=>this.options.mutationFn?this.options.mutationFn(s):Promise.reject(new Error("No mutationFn found")),onFail:(B,V)=>{Qi(this,Xy,Rb).call(this,{type:"failed",failureCount:B,error:V})},onPause:()=>{Qi(this,Xy,Rb).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>ls(this,gm).canRun(this)}));const n=this.state.status==="pending",a=!ls(this,D4).canStart();try{if(n)r();else{Qi(this,Xy,Rb).call(this,{type:"pending",variables:s,isPaused:a}),await((l=(o=ls(this,gm).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&&Qi(this,Xy,Rb).call(this,{type:"pending",context:V,variables:s,isPaused:a})}const B=await ls(this,D4).start();return await((p=(u=ls(this,gm).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((_=(b=ls(this,gm).config).onSettled)==null?void 0:_.call(b,B,null,this.state.variables,this.state.context,this)),await((w=(j=this.options).onSettled)==null?void 0:w.call(j,B,null,s,this.state.context)),Qi(this,Xy,Rb).call(this,{type:"success",data:B}),B}catch(B){try{throw await((C=(N=ls(this,gm).config).onError)==null?void 0:C.call(N,B,s,this.state.context,this)),await((I=(M=this.options).onError)==null?void 0:I.call(M,B,s,this.state.context)),await((R=(L=ls(this,gm).config).onSettled)==null?void 0:R.call(L,void 0,B,this.state.variables,this.state.context,this)),await((U=(q=this.options).onSettled)==null?void 0:U.call(q,void 0,B,s,this.state.context)),B}finally{Qi(this,Xy,Rb).call(this,{type:"error",error:B})}}finally{ls(this,gm).runNext(this)}}},Yy=new WeakMap,gm=new WeakMap,D4=new WeakMap,Xy=new WeakSet,Rb=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),yu.batch(()=>{ls(this,Yy).forEach(n=>{n.onMutationUpdate(s)}),ls(this,gm).notify({mutation:this,type:"updated",action:s})})},c9e);function Yqe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Bv,Ig,iO,d9e,W0t=(d9e=class extends $A{constructor(s={}){super();Xa(this,Bv);Xa(this,Ig);Xa(this,iO);this.config=s,Kn(this,Bv,new Set),Kn(this,Ig,new Map),Kn(this,iO,0)}build(s,r,n){const a=new H0t({mutationCache:this,mutationId:++p7(this,iO)._,options:s.defaultMutationOptions(r),state:n});return this.add(a),a}add(s){ls(this,Bv).add(s);const r=O7(s);if(typeof r=="string"){const n=ls(this,Ig).get(r);n?n.push(s):ls(this,Ig).set(r,[s])}this.notify({type:"added",mutation:s})}remove(s){if(ls(this,Bv).delete(s)){const r=O7(s);if(typeof r=="string"){const n=ls(this,Ig).get(r);if(n)if(n.length>1){const a=n.indexOf(s);a!==-1&&n.splice(a,1)}else n[0]===s&&ls(this,Ig).delete(r)}}this.notify({type:"removed",mutation:s})}canRun(s){const r=O7(s);if(typeof r=="string"){const n=ls(this,Ig).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=O7(s);if(typeof r=="string"){const a=(n=ls(this,Ig).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(){yu.batch(()=>{ls(this,Bv).forEach(s=>{this.notify({type:"removed",mutation:s})}),ls(this,Bv).clear(),ls(this,Ig).clear()})}getAll(){return Array.from(ls(this,Bv))}find(s){const r={exact:!0,...s};return this.getAll().find(n=>HAe(r,n))}findAll(s={}){return this.getAll().filter(r=>HAe(s,r))}notify(s){yu.batch(()=>{this.listeners.forEach(r=>{r(s)})})}resumePausedMutations(){const s=this.getAll().filter(r=>r.state.isPaused);return yu.batch(()=>Promise.all(s.map(r=>r.continue().catch(bm))))}},Bv=new WeakMap,Ig=new WeakMap,iO=new WeakMap,d9e);function O7(t){var s;return(s=t.options.scope)==null?void 0:s.id}function doe(t){return{onFetch:(s,r)=>{var p,f,g,b,_;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=((b=s.state.data)==null?void 0:b.pages)||[],l=((_=s.state.data)==null?void 0:_.pageParams)||[];let i={pages:[],pageParams:[]},c=0;const u=async()=>{let j=!1;const w=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(s.signal.aborted?j=!0:s.signal.addEventListener("abort",()=>{j=!0}),s.signal)})},N=Uqe(s.options,s.fetchOptions),C=async(M,I,L)=>{if(j)return Promise.reject();if(I==null&&M.pages.length)return Promise.resolve(M);const q=(()=>{const Y={client:s.client,queryKey:s.queryKey,pageParam:I,direction:L?"backward":"forward",meta:s.options.meta};return w(Y),Y})(),U=await N(q),{maxPages:B}=s.options,V=L?O0t:D0t;return{pages:V(M.pages,U,B),pageParams:V(M.pageParams,I,B)}};if(a&&o.length){const M=a==="backward",I=M?Xqe:$0e,L={pages:o,pageParams:l},R=I(n,L);i=await C(L,R,M)}else{const M=t??o.length;do{const I=c===0?l[0]??n.initialPageParam:$0e(n,i);if(c>0&&I==null)break;i=await C(i,I),c++}while(c{var j,w;return(w=(j=s.options).persister)==null?void 0:w.call(j,u,{client:s.client,queryKey:s.queryKey,meta:s.options.meta,signal:s.signal},r)}:s.fetchFn=u}}}function $0e(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 Xqe(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 G0t(t,s){return s?$0e(t,s)!=null:!1}function K0t(t,s){return!s||!t.getPreviousPageParam?!1:Xqe(t,s)!=null}var cd,d_,u_,pT,fT,h_,xT,gT,u9e,Z0t=(u9e=class{constructor(t={}){Xa(this,cd);Xa(this,d_);Xa(this,u_);Xa(this,pT);Xa(this,fT);Xa(this,h_);Xa(this,xT);Xa(this,gT);Kn(this,cd,t.queryCache||new V0t),Kn(this,d_,t.mutationCache||new W0t),Kn(this,u_,t.defaultOptions||{}),Kn(this,pT,new Map),Kn(this,fT,new Map),Kn(this,h_,0)}mount(){p7(this,h_)._++,ls(this,h_)===1&&(Kn(this,xT,S2e.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,cd).onFocus())})),Kn(this,gT,coe.subscribe(async t=>{t&&(await this.resumePausedMutations(),ls(this,cd).onOnline())})))}unmount(){var t,s;p7(this,h_)._--,ls(this,h_)===0&&((t=ls(this,xT))==null||t.call(this),Kn(this,xT,void 0),(s=ls(this,gT))==null||s.call(this),Kn(this,gT,void 0))}isFetching(t){return ls(this,cd).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return ls(this,d_).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,cd).get(s.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const s=this.defaultQueryOptions(t),r=ls(this,cd).build(this,s),n=r.state.data;return n===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(W_(s.staleTime,r))&&this.prefetchQuery(s),Promise.resolve(n))}getQueriesData(t){return ls(this,cd).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=ls(this,cd).get(n.queryHash),o=a==null?void 0:a.state.data,l=I0t(s,o);if(l!==void 0)return ls(this,cd).build(this,n).setData(l,{...r,manual:!0})}setQueriesData(t,s,r){return yu.batch(()=>ls(this,cd).findAll(t).map(({queryKey:n})=>[n,this.setQueryData(n,s,r)]))}getQueryState(t){var r;const s=this.defaultQueryOptions({queryKey:t});return(r=ls(this,cd).get(s.queryHash))==null?void 0:r.state}removeQueries(t){const s=ls(this,cd);yu.batch(()=>{s.findAll(t).forEach(r=>{s.remove(r)})})}resetQueries(t,s){const r=ls(this,cd);return yu.batch(()=>(r.findAll(t).forEach(n=>{n.reset()}),this.refetchQueries({type:"active",...t},s)))}cancelQueries(t,s={}){const r={revert:!0,...s},n=yu.batch(()=>ls(this,cd).findAll(t).map(a=>a.cancel(r)));return Promise.all(n).then(bm).catch(bm)}invalidateQueries(t,s={}){return yu.batch(()=>(ls(this,cd).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=yu.batch(()=>ls(this,cd).findAll(t).filter(a=>!a.isDisabled()&&!a.isStatic()).map(a=>{let o=a.fetch(void 0,r);return r.throwOnError||(o=o.catch(bm)),a.state.fetchStatus==="paused"?Promise.resolve():o}));return Promise.all(n).then(bm)}fetchQuery(t){const s=this.defaultQueryOptions(t);s.retry===void 0&&(s.retry=!1);const r=ls(this,cd).build(this,s);return r.isStaleByTime(W_(s.staleTime,r))?r.fetch(s):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(bm).catch(bm)}fetchInfiniteQuery(t){return t.behavior=doe(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(bm).catch(bm)}ensureInfiniteQueryData(t){return t.behavior=doe(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return coe.isOnline()?ls(this,d_).resumePausedMutations():Promise.resolve()}getQueryCache(){return ls(this,cd)}getMutationCache(){return ls(this,d_)}getDefaultOptions(){return ls(this,u_)}setDefaultOptions(t){Kn(this,u_,t)}setQueryDefaults(t,s){ls(this,pT).set(IS(t),{queryKey:t,defaultOptions:s})}getQueryDefaults(t){const s=[...ls(this,pT).values()],r={};return s.forEach(n=>{$8(t,n.queryKey)&&Object.assign(r,n.defaultOptions)}),r}setMutationDefaults(t,s){ls(this,fT).set(IS(t),{mutationKey:t,defaultOptions:s})}getMutationDefaults(t){const s=[...ls(this,fT).values()],r={};return s.forEach(n=>{$8(t,n.mutationKey)&&Object.assign(r,n.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const s={...ls(this,u_).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return s.queryHash||(s.queryHash=N2e(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===k2e&&(s.enabled=!1),s}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...ls(this,u_).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){ls(this,cd).clear(),ls(this,d_).clear()}},cd=new WeakMap,d_=new WeakMap,u_=new WeakMap,pT=new WeakMap,fT=new WeakMap,h_=new WeakMap,xT=new WeakMap,gT=new WeakMap,u9e),op,Co,oO,ym,O4,yT,m_,p_,lO,vT,bT,R4,F4,f_,_T,ol,xI,q0e,U0e,V0e,H0e,W0e,G0e,K0e,Jqe,h9e,Qqe=(h9e=class extends $A{constructor(s,r){super();Xa(this,ol);Xa(this,op);Xa(this,Co);Xa(this,oO);Xa(this,ym);Xa(this,O4);Xa(this,yT);Xa(this,m_);Xa(this,p_);Xa(this,lO);Xa(this,vT);Xa(this,bT);Xa(this,R4);Xa(this,F4);Xa(this,f_);Xa(this,_T,new Set);this.options=r,Kn(this,op,s),Kn(this,p_,null),Kn(this,m_,B0e()),this.options.experimental_prefetchInRender||ls(this,m_).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&&(ls(this,Co).addObserver(this),KAe(ls(this,Co),this.options)?Qi(this,ol,xI).call(this):this.updateResult(),Qi(this,ol,H0e).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Z0e(ls(this,Co),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Z0e(ls(this,Co),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Qi(this,ol,W0e).call(this),Qi(this,ol,G0e).call(this),ls(this,Co).removeObserver(this)}setOptions(s){const r=this.options,n=ls(this,Co);if(this.options=ls(this,op).defaultQueryOptions(s),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof ox(this.options.enabled,ls(this,Co))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Qi(this,ol,K0e).call(this),ls(this,Co).setOptions(this.options),r._defaulted&&!loe(this.options,r)&&ls(this,op).getQueryCache().notify({type:"observerOptionsUpdated",query:ls(this,Co),observer:this});const a=this.hasListeners();a&&ZAe(ls(this,Co),n,this.options,r)&&Qi(this,ol,xI).call(this),this.updateResult(),a&&(ls(this,Co)!==n||ox(this.options.enabled,ls(this,Co))!==ox(r.enabled,ls(this,Co))||W_(this.options.staleTime,ls(this,Co))!==W_(r.staleTime,ls(this,Co)))&&Qi(this,ol,q0e).call(this);const o=Qi(this,ol,U0e).call(this);a&&(ls(this,Co)!==n||ox(this.options.enabled,ls(this,Co))!==ox(r.enabled,ls(this,Co))||o!==ls(this,f_))&&Qi(this,ol,V0e).call(this,o)}getOptimisticResult(s){const r=ls(this,op).getQueryCache().build(ls(this,op),s),n=this.createResult(r,s);return X0t(this,n)&&(Kn(this,ym,n),Kn(this,yT,this.options),Kn(this,O4,ls(this,Co).state)),n}getCurrentResult(){return ls(this,ym)}trackResult(s,r){return new Proxy(s,{get:(n,a)=>(this.trackProp(a),r==null||r(a),Reflect.get(n,a))})}trackProp(s){ls(this,_T).add(s)}getCurrentQuery(){return ls(this,Co)}refetch({...s}={}){return this.fetch({...s})}fetchOptimistic(s){const r=ls(this,op).defaultQueryOptions(s),n=ls(this,op).getQueryCache().build(ls(this,op),r);return n.fetch().then(()=>this.createResult(n,r))}fetch(s){return Qi(this,ol,xI).call(this,{...s,cancelRefetch:s.cancelRefetch??!0}).then(()=>(this.updateResult(),ls(this,ym)))}createResult(s,r){var B;const n=ls(this,Co),a=this.options,o=ls(this,ym),l=ls(this,O4),i=ls(this,yT),u=s!==n?s.state:ls(this,oO),{state:p}=s;let f={...p},g=!1,b;if(r._optimisticResults){const V=this.hasListeners(),Y=!V&&KAe(s,r),J=V&&ZAe(s,n,r,a);(Y||J)&&(f={...f,...Zqe(p.data,s.options)}),r._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:_,errorUpdatedAt:j,status:w}=f;b=f.data;let N=!1;if(r.placeholderData!==void 0&&b===void 0&&w==="pending"){let V;o!=null&&o.isPlaceholderData&&r.placeholderData===(i==null?void 0:i.placeholderData)?(V=o.data,N=!0):V=typeof r.placeholderData=="function"?r.placeholderData((B=ls(this,bT))==null?void 0:B.state.data,ls(this,bT)):r.placeholderData,V!==void 0&&(w="success",b=z0e(o==null?void 0:o.data,V,r),g=!0)}if(r.select&&b!==void 0&&!N)if(o&&b===(l==null?void 0:l.data)&&r.select===ls(this,lO))b=ls(this,vT);else try{Kn(this,lO,r.select),b=r.select(b),b=z0e(o==null?void 0:o.data,b,r),Kn(this,vT,b),Kn(this,p_,null)}catch(V){Kn(this,p_,V)}ls(this,p_)&&(_=ls(this,p_),b=ls(this,vT),j=Date.now(),w="error");const C=f.fetchStatus==="fetching",M=w==="pending",I=w==="error",L=M&&C,R=b!==void 0,U={status:w,fetchStatus:f.fetchStatus,isPending:M,isSuccess:w==="success",isError:I,isInitialLoading:L,isLoading:L,data:b,dataUpdatedAt:f.dataUpdatedAt,error:_,errorUpdatedAt:j,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:C,isRefetching:C&&!M,isLoadingError:I&&!R,isPaused:f.fetchStatus==="paused",isPlaceholderData:g,isRefetchError:I&&R,isStale:C2e(s,r),refetch:this.refetch,promise:ls(this,m_),isEnabled:ox(r.enabled,s)!==!1};if(this.options.experimental_prefetchInRender){const V=te=>{U.status==="error"?te.reject(U.error):U.data!==void 0&&te.resolve(U.data)},Y=()=>{const te=Kn(this,m_,U.promise=B0e());V(te)},J=ls(this,m_);switch(J.status){case"pending":s.queryHash===n.queryHash&&V(J);break;case"fulfilled":(U.status==="error"||U.data!==J.value)&&Y();break;case"rejected":(U.status!=="error"||U.error!==J.reason)&&Y();break}}return U}updateResult(){const s=ls(this,ym),r=this.createResult(ls(this,Co),this.options);if(Kn(this,O4,ls(this,Co).state),Kn(this,yT,this.options),ls(this,O4).data!==void 0&&Kn(this,bT,ls(this,Co)),loe(r,s))return;Kn(this,ym,r);const n=()=>{if(!s)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!ls(this,_T).size)return!0;const l=new Set(o??ls(this,_T));return this.options.throwOnError&&l.add("error"),Object.keys(ls(this,ym)).some(i=>{const c=i;return ls(this,ym)[c]!==s[c]&&l.has(c)})};Qi(this,ol,Jqe).call(this,{listeners:n()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Qi(this,ol,H0e).call(this)}},op=new WeakMap,Co=new WeakMap,oO=new WeakMap,ym=new WeakMap,O4=new WeakMap,yT=new WeakMap,m_=new WeakMap,p_=new WeakMap,lO=new WeakMap,vT=new WeakMap,bT=new WeakMap,R4=new WeakMap,F4=new WeakMap,f_=new WeakMap,_T=new WeakMap,ol=new WeakSet,xI=function(s){Qi(this,ol,K0e).call(this);let r=ls(this,Co).fetch(this.options,s);return s!=null&&s.throwOnError||(r=r.catch(bm)),r},q0e=function(){Qi(this,ol,W0e).call(this);const s=W_(this.options.staleTime,ls(this,Co));if(PS||ls(this,ym).isStale||!R0e(s))return;const n=$qe(ls(this,ym).dataUpdatedAt,s)+1;Kn(this,R4,setTimeout(()=>{ls(this,ym).isStale||this.updateResult()},n))},U0e=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(ls(this,Co)):this.options.refetchInterval)??!1},V0e=function(s){Qi(this,ol,G0e).call(this),Kn(this,f_,s),!(PS||ox(this.options.enabled,ls(this,Co))===!1||!R0e(ls(this,f_))||ls(this,f_)===0)&&Kn(this,F4,setInterval(()=>{(this.options.refetchIntervalInBackground||S2e.isFocused())&&Qi(this,ol,xI).call(this)},ls(this,f_)))},H0e=function(){Qi(this,ol,q0e).call(this),Qi(this,ol,V0e).call(this,Qi(this,ol,U0e).call(this))},W0e=function(){ls(this,R4)&&(clearTimeout(ls(this,R4)),Kn(this,R4,void 0))},G0e=function(){ls(this,F4)&&(clearInterval(ls(this,F4)),Kn(this,F4,void 0))},K0e=function(){const s=ls(this,op).getQueryCache().build(ls(this,op),this.options);if(s===ls(this,Co))return;const r=ls(this,Co);Kn(this,Co,s),Kn(this,oO,s.state),this.hasListeners()&&(r==null||r.removeObserver(this),s.addObserver(this))},Jqe=function(s){yu.batch(()=>{s.listeners&&this.listeners.forEach(r=>{r(ls(this,ym))}),ls(this,op).getQueryCache().notify({query:ls(this,Co),type:"observerResultsUpdated"})})},h9e);function Y0t(t,s){return ox(s.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&s.retryOnMount===!1)}function KAe(t,s){return Y0t(t,s)||t.state.data!==void 0&&Z0e(t,s,s.refetchOnMount)}function Z0e(t,s,r){if(ox(s.enabled,t)!==!1&&W_(s.staleTime,t)!=="static"){const n=typeof r=="function"?r(t):r;return n==="always"||n!==!1&&C2e(t,s)}return!1}function ZAe(t,s,r,n){return(t!==s||ox(n.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&C2e(t,r)}function C2e(t,s){return ox(s.enabled,t)!==!1&&t.isStaleByTime(W_(s.staleTime,t))}function X0t(t,s){return!loe(t.getCurrentResult(),s)}var Q0t=class extends Qqe{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:doe()})}getOptimisticResult(t){return t.behavior=doe(),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 _,j;const{state:r}=t,n=super.createResult(t,s),{isFetching:a,isRefetching:o,isError:l,isRefetchError:i}=n,c=(j=(_=r.fetchMeta)==null?void 0:_.fetchMore)==null?void 0:j.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:G0t(s,r.data),hasPreviousPage:K0t(s,r.data),isFetchNextPageError:u,isFetchingNextPage:p,isFetchPreviousPageError:f,isFetchingPreviousPage:g,isRefetchError:i&&!u&&!f,isRefetching:o&&!p&&!g}}},x_,g_,lp,$v,b1,nie,Y0e,m9e,J0t=(m9e=class extends $A{constructor(r,n){super();Xa(this,b1);Xa(this,x_);Xa(this,g_);Xa(this,lp);Xa(this,$v);Kn(this,x_,r),this.setOptions(n),this.bindMethods(),Qi(this,b1,nie).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=ls(this,x_).defaultMutationOptions(r),loe(this.options,n)||ls(this,x_).getMutationCache().notify({type:"observerOptionsUpdated",mutation:ls(this,lp),observer:this}),n!=null&&n.mutationKey&&this.options.mutationKey&&IS(n.mutationKey)!==IS(this.options.mutationKey)?this.reset():((a=ls(this,lp))==null?void 0:a.state.status)==="pending"&&ls(this,lp).setOptions(this.options)}onUnsubscribe(){var r;this.hasListeners()||(r=ls(this,lp))==null||r.removeObserver(this)}onMutationUpdate(r){Qi(this,b1,nie).call(this),Qi(this,b1,Y0e).call(this,r)}getCurrentResult(){return ls(this,g_)}reset(){var r;(r=ls(this,lp))==null||r.removeObserver(this),Kn(this,lp,void 0),Qi(this,b1,nie).call(this),Qi(this,b1,Y0e).call(this)}mutate(r,n){var a;return Kn(this,$v,n),(a=ls(this,lp))==null||a.removeObserver(this),Kn(this,lp,ls(this,x_).getMutationCache().build(ls(this,x_),this.options)),ls(this,lp).addObserver(this),ls(this,lp).execute(r)}},x_=new WeakMap,g_=new WeakMap,lp=new WeakMap,$v=new WeakMap,b1=new WeakSet,nie=function(){var n;const r=((n=ls(this,lp))==null?void 0:n.state)??Yqe();Kn(this,g_,{...r,isPending:r.status==="pending",isSuccess:r.status==="success",isError:r.status==="error",isIdle:r.status==="idle",mutate:this.mutate,reset:this.reset})},Y0e=function(r){yu.batch(()=>{var n,a,o,l,i,c,u,p;if(ls(this,$v)&&this.hasListeners()){const f=ls(this,g_).variables,g=ls(this,g_).context;(r==null?void 0:r.type)==="success"?((a=(n=ls(this,$v)).onSuccess)==null||a.call(n,r.data,f,g),(l=(o=ls(this,$v)).onSettled)==null||l.call(o,r.data,null,f,g)):(r==null?void 0:r.type)==="error"&&((c=(i=ls(this,$v)).onError)==null||c.call(i,r.error,f,g),(p=(u=ls(this,$v)).onSettled)==null||p.call(u,void 0,r.error,f,g))}this.listeners.forEach(f=>{f(ls(this,g_))})})},m9e),eUe=k.createContext(void 0),es=t=>{const s=k.useContext(eUe);if(!s)throw new Error("No QueryClient set, use QueryClientProvider to set one");return s},evt=({client:t,children:s})=>(k.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),e.jsx(eUe.Provider,{value:t,children:s})),tUe=k.createContext(!1),tvt=()=>k.useContext(tUe);tUe.Provider;function svt(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var rvt=k.createContext(svt()),nvt=()=>k.useContext(rvt),avt=(t,s)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(s.isReset()||(t.retryOnMount=!1))},ivt=t=>{k.useEffect(()=>{t.clearReset()},[t])},ovt=({result:t,errorResetBoundary:s,throwOnError:r,query:n,suspense:a})=>t.isError&&!s.isReset()&&!t.isFetching&&n&&(a&&t.data===void 0||Vqe(r,[t.error,n])),lvt=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))}},cvt=(t,s)=>t.isLoading&&t.isFetching&&!s,dvt=(t,s)=>(t==null?void 0:t.suspense)&&s.isPending,YAe=(t,s,r)=>s.fetchOptimistic(t).catch(()=>{r.clearReset()});function sUe(t,s,r){var f,g,b,_,j;const n=tvt(),a=nvt(),o=es(),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",lvt(l),avt(l,a),ivt(a);const i=!o.getQueryCache().get(l.queryHash),[c]=k.useState(()=>new s(o,l)),u=c.getOptimisticResult(l),p=!n&&t.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(w=>{const N=p?c.subscribe(yu.batchCalls(w)):bm;return c.updateResult(),N},[c,p]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setOptions(l)},[l,c]),dvt(l,u))throw YAe(l,c,a);if(ovt({result:u,errorResetBoundary:a,throwOnError:l.throwOnError,query:o.getQueryCache().get(l.queryHash),suspense:l.suspense}))throw u.error;if((_=(b=o.getDefaultOptions().queries)==null?void 0:b._experimental_afterQuery)==null||_.call(b,l,u),l.experimental_prefetchInRender&&!PS&&cvt(u,n)){const w=i?YAe(l,c,a):(j=o.getQueryCache().get(l.queryHash))==null?void 0:j.promise;w==null||w.catch(bm).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?u:c.trackResult(u)}function mt(t,s){return sUe(t,Qqe)}function Lt(t,s){const r=es(),[n]=k.useState(()=>new J0t(r,t));k.useEffect(()=>{n.setOptions(t)},[n,t]);const a=k.useSyncExternalStore(k.useCallback(l=>n.subscribe(yu.batchCalls(l)),[n]),()=>n.getCurrentResult(),()=>n.getCurrentResult()),o=k.useCallback((l,i)=>{n.mutate(l,i).catch(bm)},[n]);if(a.error&&Vqe(n.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function rUe(t,s){return sUe(t,Q0t)}/** * @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 q8(){return q8=Object.assign?Object.assign.bind():function(t){for(var s=1;s"u")throw new Error(s)}function nUe(t,s){if(!t){typeof console<"u"&&console.warn(s);try{throw new Error(s)}catch{}}}function hvt(){return Math.random().toString(36).substr(2,8)}function QAe(t,s){return{usr:t.state,key:t.key,idx:s}}function X0e(t,s,r,n){return r===void 0&&(r=null),q8({pathname:typeof t=="string"?t:t.pathname,search:"",hash:""},typeof s=="string"?qA(s):s,{state:r,key:s&&s.key||n||hvt()})}function uoe(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 qA(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 mvt(t,s,r,n){n===void 0&&(n={});let{window:a=document.defaultView,v5Compat:o=!1}=n,l=a.history,i=b_.Pop,c=null,u=p();u==null&&(u=0,l.replaceState(q8({},l.state,{idx:u}),""));function p(){return(l.state||{idx:null}).idx}function f(){i=b_.Pop;let w=p(),N=w==null?null:w-u;u=w,c&&c({action:i,location:j.location,delta:N})}function g(w,N){i=b_.Push;let C=X0e(j.location,w,N);u=p()+1;let M=QAe(C,u),I=j.createHref(C);try{l.pushState(M,"",I)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;a.location.assign(I)}o&&c&&c({action:i,location:j.location,delta:1})}function b(w,N){i=b_.Replace;let C=X0e(j.location,w,N);u=p();let M=QAe(C,u),I=j.createHref(C);l.replaceState(M,"",I),o&&c&&c({action:i,location:j.location,delta:0})}function _(w){let N=a.location.origin!=="null"?a.location.origin:a.location.href,C=typeof w=="string"?w:uoe(w);return C=C.replace(/ $/,"%20"),Od(N,"No window.location.(origin|href) available to create URL for href: "+C),new URL(C,N)}let j={get action(){return i},get location(){return t(a,l)},listen(w){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(XAe,f),c=w,()=>{a.removeEventListener(XAe,f),c=null}},createHref(w){return s(a,w)},createURL:_,encodeLocation(w){let N=_(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:g,replace:b,go(w){return l.go(w)}};return j}var JAe;(function(t){t.data="data",t.deferred="deferred",t.redirect="redirect",t.error="error"})(JAe||(JAe={}));function pvt(t,s,r){return r===void 0&&(r="/"),fvt(t,s,r)}function fvt(t,s,r,n){let a=typeof s=="string"?qA(s):s,o=M2e(a.pathname||"/",r);if(o==null)return null;let l=aUe(t);xvt(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("/")&&(Od(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=G_([n,c.relativePath]),p=r.concat(c);o.children&&o.children.length>0&&(Od(o.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),aUe(o.children,s,p,u)),!(o.path==null&&!o.index)&&s.push({path:u,score:jvt(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 iUe(o.path))a(o,l,c)}),s}function iUe(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=iUe(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 xvt(t){t.sort((s,r)=>s.score!==r.score?r.score-s.score:Nvt(s.routesMeta.map(n=>n.childrenIndex),r.routesMeta.map(n=>n.childrenIndex)))}const gvt=/^:[\w-]+$/,yvt=3,vvt=2,bvt=1,_vt=10,wvt=-2,eEe=t=>t==="*";function jvt(t,s){let r=t.split("/"),n=r.length;return r.some(eEe)&&(n+=wvt),s&&(n+=vvt),r.filter(a=>!eEe(a)).reduce((a,o)=>a+(gvt.test(o)?yvt:o===""?bvt:_vt),n)}function Nvt(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 kvt(t,s,r){let{routesMeta:n}=t,a={},o="/",l=[];for(let i=0;i{let{paramName:g,isOptional:b}=p;if(g==="*"){let j=i[f]||"";l=o.slice(0,o.length-j.length).replace(/(.)\/+$/,"$1")}const _=i[f];return b&&!_?u[g]=void 0:u[g]=(_||"").replace(/%2F/g,"/"),u},{}),pathname:o,pathnameBase:l,pattern:t}}function Cvt(t,s,r){s===void 0&&(s=!1),r===void 0&&(r=!0),nUe(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 Mvt(t){try{return t.split("/").map(s=>decodeURIComponent(s).replace(/\//g,"%2F")).join("/")}catch(s){return nUe(!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 M2e(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 Tvt(t,s){s===void 0&&(s="/");let{pathname:r,search:n="",hash:a=""}=typeof t=="string"?qA(t):t;return{pathname:r?r.startsWith("/")?r:Avt(r,s):s,search:Ivt(n),hash:Lvt(a)}}function Avt(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 Qfe(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 Evt(t){return t.filter((s,r)=>r===0||s.route.path&&s.route.path.length>0)}function T2e(t,s){let r=Evt(t);return s?r.map((n,a)=>a===r.length-1?n.pathname:n.pathnameBase):r.map(n=>n.pathnameBase)}function A2e(t,s,r,n){n===void 0&&(n=!1);let a;typeof t=="string"?a=qA(t):(a=q8({},t),Od(!a.pathname||!a.pathname.includes("?"),Qfe("?","pathname","search",a)),Od(!a.pathname||!a.pathname.includes("#"),Qfe("#","pathname","hash",a)),Od(!a.search||!a.search.includes("#"),Qfe("#","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=Tvt(a,i),u=l&&l!=="/"&&l.endsWith("/"),p=(o||l===".")&&r.endsWith("/");return!c.pathname.endsWith("/")&&(u||p)&&(c.pathname+="/"),c}const G_=t=>t.join("/").replace(/\/\/+/g,"/"),Pvt=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),Ivt=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Lvt=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t;function Dvt(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}const oUe=["post","put","patch","delete"];new Set(oUe);const Ovt=["get",...oUe];new Set(Ovt);/** * 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 U8(){return U8=Object.assign?Object.assign.bind():function(t){for(var s=1;s{i.current=!0}),k.useCallback(function(u,p){if(p===void 0&&(p={}),!i.current)return;if(typeof u=="number"){n.go(u);return}let f=A2e(u,JSON.parse(l),o,p.relative==="path");t==null&&s!=="/"&&(f.pathname=f.pathname==="/"?s:G_([s,f.pathname])),(p.replace?n.replace:n.push)(f,p.state,p)},[s,n,l,o,t])}const Bvt=k.createContext(null);function $vt(t){let s=k.useContext(D0).outlet;return s&&k.createElement(Bvt.Provider,{value:t},s)}function yo(){let{matches:t}=k.useContext(D0),s=t[t.length-1];return s?s.params:{}}function dUe(t,s){let{relative:r}=s===void 0?{}:s,{future:n}=k.useContext(jw),{matches:a}=k.useContext(D0),{pathname:o}=nu(),l=JSON.stringify(T2e(a,n.v7_relativeSplatPath));return k.useMemo(()=>A2e(t,JSON.parse(l),o,r==="path"),[t,l,o,r])}function qvt(t,s){return Uvt(t,s)}function Uvt(t,s,r,n){UA()||Od(!1);let{navigator:a}=k.useContext(jw),{matches:o}=k.useContext(D0),l=o[o.length-1],i=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=nu(),p;if(s){var f;let w=typeof s=="string"?qA(s):s;c==="/"||(f=w.pathname)!=null&&f.startsWith(c)||Od(!1),p=w}else p=u;let g=p.pathname||"/",b=g;if(c!=="/"){let w=c.replace(/^\//,"").split("/");b="/"+g.replace(/^\//,"").split("/").slice(w.length).join("/")}let _=pvt(t,{pathname:b}),j=Kvt(_&&_.map(w=>Object.assign({},w,{params:Object.assign({},i,w.params),pathname:G_([c,a.encodeLocation?a.encodeLocation(w.pathname).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?c:G_([c,a.encodeLocation?a.encodeLocation(w.pathnameBase).pathname:w.pathnameBase])})),o,r,n);return s&&j?k.createElement(Cde.Provider,{value:{location:U8({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:b_.Pop}},j):j}function Vvt(){let t=Qvt(),s=Dvt(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 k.createElement(k.Fragment,null,k.createElement("h2",null,"Unexpected Application Error!"),k.createElement("h3",{style:{fontStyle:"italic"}},s),r?k.createElement("pre",{style:a},r):null,null)}const Hvt=k.createElement(Vvt,null);class Wvt extends k.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?k.createElement(D0.Provider,{value:this.props.routeContext},k.createElement(lUe.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Gvt(t){let{routeContext:s,match:r,children:n}=t,a=k.useContext(E2e);return a&&a.static&&a.staticContext&&(r.route.errorElement||r.route.ErrorBoundary)&&(a.staticContext._deepestRenderedBoundaryId=r.route.id),k.createElement(D0.Provider,{value:s},n)}function Kvt(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||Od(!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 b,_=!1,j=null,w=null;r&&(b=i&&f.route.id?i[f.route.id]:void 0,j=f.route.errorElement||Hvt,c&&(u<0&&g===0?(e1t("route-fallback"),_=!0,w=null):u===g&&(_=!0,w=f.route.hydrateFallbackElement||null)));let N=s.concat(l.slice(0,g+1)),C=()=>{let M;return b?M=j:_?M=w:f.route.Component?M=k.createElement(f.route.Component,null):f.route.element?M=f.route.element:M=p,k.createElement(Gvt,{match:f,routeContext:{outlet:p,matches:N,isDataRoute:r!=null},children:M})};return r&&(f.route.ErrorBoundary||f.route.errorElement||g===0)?k.createElement(Wvt,{location:r.location,revalidation:r.revalidation,component:j,error:b,children:C(),routeContext:{outlet:null,matches:N,isDataRoute:!0}}):C()},null)}var uUe=function(t){return t.UseBlocker="useBlocker",t.UseRevalidator="useRevalidator",t.UseNavigateStable="useNavigate",t}(uUe||{}),hUe=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}(hUe||{});function Zvt(t){let s=k.useContext(E2e);return s||Od(!1),s}function Yvt(t){let s=k.useContext(Rvt);return s||Od(!1),s}function Xvt(t){let s=k.useContext(D0);return s||Od(!1),s}function mUe(t){let s=Xvt(),r=s.matches[s.matches.length-1];return r.route.id||Od(!1),r.route.id}function Qvt(){var t;let s=k.useContext(lUe),r=Yvt(),n=mUe();return s!==void 0?s:(t=r.errors)==null?void 0:t[n]}function Jvt(){let{router:t}=Zvt(uUe.UseNavigateStable),s=mUe(hUe.UseNavigateStable),r=k.useRef(!1);return cUe(()=>{r.current=!0}),k.useCallback(function(a,o){o===void 0&&(o={}),r.current&&(typeof a=="number"?t.navigate(a):t.navigate(a,U8({fromRouteId:s},o)))},[t,s])}const tEe={};function e1t(t,s,r){tEe[t]||(tEe[t]=!0)}function t1t(t,s){t==null||t.v7_startTransition,t==null||t.v7_relativeSplatPath}function Jfe(t){let{to:s,replace:r,state:n,relative:a}=t;UA()||Od(!1);let{future:o,static:l}=k.useContext(jw),{matches:i}=k.useContext(D0),{pathname:c}=nu(),u=pr(),p=A2e(s,T2e(i,o.v7_relativeSplatPath),c,a==="path"),f=JSON.stringify(p);return k.useEffect(()=>u(JSON.parse(f),{replace:r,state:n,relative:a}),[u,f,a,r,n]),null}function s1t(t){return $vt(t.context)}function Cs(t){Od(!1)}function r1t(t){let{basename:s="/",children:r=null,location:n,navigationType:a=b_.Pop,navigator:o,static:l=!1,future:i}=t;UA()&&Od(!1);let c=s.replace(/^\/*/,"/"),u=k.useMemo(()=>({basename:c,navigator:o,static:l,future:U8({v7_relativeSplatPath:!1},i)}),[c,i,o,l]);typeof n=="string"&&(n=qA(n));let{pathname:p="/",search:f="",hash:g="",state:b=null,key:_="default"}=n,j=k.useMemo(()=>{let w=M2e(p,c);return w==null?null:{location:{pathname:w,search:f,hash:g,state:b,key:_},navigationType:a}},[c,p,f,g,b,_,a]);return j==null?null:k.createElement(jw.Provider,{value:u},k.createElement(Cde.Provider,{children:r,value:j}))}function P2e(t){let{children:s,location:r}=t;return qvt(Q0e(s),r)}new Promise(()=>{});function Q0e(t,s){s===void 0&&(s=[]);let r=[];return k.Children.forEach(t,(n,a)=>{if(!k.isValidElement(n))return;let o=[...s,a];if(n.type===k.Fragment){r.push.apply(r,Q0e(n.props.children,o));return}n.type!==Cs&&Od(!1),!n.props.index||!n.props.children||Od(!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=Q0e(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 J0e(){return J0e=Object.assign?Object.assign.bind():function(t){for(var s=1;s=0)&&(r[a]=t[a]);return r}function a1t(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function i1t(t,s){return t.button===0&&(!s||s==="_self")&&!a1t(t)}function eve(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 o1t(t,s){let r=eve(t);return s&&s.forEach((n,a)=>{r.has(a)||s.getAll(a).forEach(o=>{r.append(a,o)})}),r}const l1t=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],c1t="6";try{window.__reactRouterVersion=c1t}catch{}const d1t="startTransition",sEe=fwe[d1t];function u1t(t){let{basename:s,children:r,future:n,window:a}=t,o=k.useRef();o.current==null&&(o.current=uvt({window:a,v5Compat:!0}));let l=o.current,[i,c]=k.useState({action:l.action,location:l.location}),{v7_startTransition:u}=n||{},p=k.useCallback(f=>{u&&sEe?sEe(()=>c(f)):c(f)},[c,u]);return k.useLayoutEffect(()=>l.listen(p),[l,p]),k.useEffect(()=>t1t(n),[n]),k.createElement(r1t,{basename:s,children:r,location:i.location,navigationType:i.action,navigator:l,future:n})}const h1t=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",m1t=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ei=k.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=n1t(s,l1t),{basename:b}=k.useContext(jw),_,j=!1;if(typeof u=="string"&&m1t.test(u)&&(_=u,h1t))try{let M=new URL(window.location.href),I=u.startsWith("//")?new URL(M.protocol+u):new URL(u),L=M2e(I.pathname,b);I.origin===M.origin&&L!=null?u=L+I.search+I.hash:j=!0}catch{}let w=Fvt(u,{relative:a}),N=p1t(u,{replace:l,state:i,target:c,preventScrollReset:p,relative:a,viewTransition:f});function C(M){n&&n(M),M.defaultPrevented||N(M)}return k.createElement("a",J0e({},g,{href:_||w,onClick:j||o?n:C,ref:r,target:c}))});var rEe;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(rEe||(rEe={}));var nEe;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(nEe||(nEe={}));function p1t(t,s){let{target:r,replace:n,state:a,preventScrollReset:o,relative:l,viewTransition:i}=s===void 0?{}:s,c=pr(),u=nu(),p=dUe(t,{relative:l});return k.useCallback(f=>{if(i1t(f,r)){f.preventDefault();let g=n!==void 0?n:uoe(u)===uoe(p);c(t,{replace:g,state:a,preventScrollReset:o,relative:l,viewTransition:i})}},[u,c,p,n,a,r,t,o,l,i])}function qc(t){let s=k.useRef(eve(t)),r=k.useRef(!1),n=nu(),a=k.useMemo(()=>o1t(n.search,r.current?null:s.current),[n.search]),o=pr(),l=k.useCallback((i,c)=>{const u=eve(typeof i=="function"?i(a):i);r.current=!0,o("?"+u,c)},[o,a]);return[a,l]}var f1t=typeof Element<"u",x1t=typeof Map=="function",g1t=typeof Set=="function",y1t=typeof ArrayBuffer=="function"&&!!ArrayBuffer.isView;function aie(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(!aie(t[n],s[n]))return!1;return!0}var o;if(x1t&&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(!aie(n.value[1],s.get(n.value[0])))return!1;return!0}if(g1t&&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(y1t&&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(f1t&&t instanceof Element)return!1;for(n=r;n--!==0;)if(!((a[n]==="_owner"||a[n]==="__v"||a[n]==="__o")&&t.$$typeof)&&!aie(t[a[n]],s[a[n]]))return!1;return!0}return t!==t&&s!==s}var v1t=function(s,r){try{return aie(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 b1t=Ao(v1t);var _1t=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}},w1t=_1t;const aEe=Ao(w1t);var j1t=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))(pUe||{}),exe={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"]}},iEe=Object.values(pUe),I2e={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},k1t=Object.entries(I2e).reduce((t,[s,r])=>(t[r]=s,t),{}),Hg="data-rh",WM={DEFAULT_TITLE:"defaultTitle",DEFER:"defer",ENCODE_SPECIAL_CHARACTERS:"encodeSpecialCharacters",ON_CHANGE_CLIENT_STATE:"onChangeClientState",TITLE_TEMPLATE:"titleTemplate",PRIORITIZE_SEO_TAGS:"prioritizeSeoTags"},GM=(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},S1t=t=>{let s=GM(t,"title");const r=GM(t,WM.TITLE_TEMPLATE);if(Array.isArray(s)&&(s=s.join("")),r&&s)return r.replace(/%s/g,()=>s);const n=GM(t,WM.DEFAULT_TITLE);return s||n||void 0},C1t=t=>GM(t,WM.ON_CHANGE_CLIENT_STATE)||(()=>{}),txe=(t,s)=>s.filter(r=>typeof r[t]<"u").map(r=>r[t]).reduce((r,n)=>({...r,...n}),{}),M1t=(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),FP=(t,s,r)=>{const n={};return r.filter(a=>Array.isArray(a[t])?!0:(typeof a[t]<"u"&&T1t(`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:M1t(["href"],t),bodyAttributes:txe("bodyAttributes",t),defer:GM(t,WM.DEFER),encode:GM(t,WM.ENCODE_SPECIAL_CHARACTERS),htmlAttributes:txe("htmlAttributes",t),linkTags:FP("link",["rel","href"],t),metaTags:FP("meta",["name","charset","http-equiv","property","itemprop"],t),noscriptTags:FP("noscript",["innerHTML"],t),onChangeClientState:C1t(t),scriptTags:FP("script",["src","innerHTML"],t),styleTags:FP("style",["cssText"],t),title:S1t(t),titleAttributes:txe("titleAttributes",t),prioritizeSeoTags:A1t(t,WM.PRIORITIZE_SEO_TAGS)}),fUe=t=>Array.isArray(t)?t.join(""):t,P1t=(t,s)=>{const r=Object.keys(t);for(let n=0;nArray.isArray(t)?t.reduce((r,n)=>(P1t(n,s)?r.priority.push(n):r.default.push(n),r),{priority:[],default:[]}):{default:t,priority:[]},oEe=(t,s)=>({...t,[s]:void 0}),I1t=["noscript","script","style"],tve=(t,s=!0)=>s===!1?String(t):String(t).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'"),xUe=t=>Object.keys(t).reduce((s,r)=>{const n=typeof t[r]<"u"?`${r}="${t[r]}"`:`${r}`;return s?`${s} ${n}`:n},""),L1t=(t,s,r,n)=>{const a=xUe(r),o=fUe(s);return a?`<${t} ${Hg}="true" ${a}>${tve(o,n)}`:`<${t} ${Hg}="true">${tve(o,n)}`},D1t=(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}="${tve(o[p],r)}"`;return u?`${u} ${f}`:f},""),i=o.innerHTML||o.cssText||"",c=I1t.indexOf(t)===-1;return`${n}<${t} ${Hg}="true" ${l}${c?"/>":`>${i}`}`},""),gUe=(t,s={})=>Object.keys(t).reduce((r,n)=>{const a=I2e[n];return r[a||n]=t[n],r},s),O1t=(t,s,r)=>{const n={key:s,[Hg]:!0},a=gUe(r,n);return[ht.createElement("title",a,s)]},iie=(t,s)=>s.map((r,n)=>{const a={key:n,[Hg]:!0};return Object.keys(r).forEach(o=>{const i=I2e[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)}),ax=(t,s,r=!0)=>{switch(t){case"title":return{toComponent:()=>O1t(t,s.title,s.titleAttributes),toString:()=>L1t(t,s.title,s.titleAttributes,r)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>gUe(s),toString:()=>xUe(s)};default:return{toComponent:()=>iie(t,s),toString:()=>D1t(t,s,r)}}},R1t=({metaTags:t,linkTags:s,scriptTags:r,encode:n})=>{const a=sxe(t,exe.meta),o=sxe(s,exe.link),l=sxe(r,exe.script);return{priorityMethods:{toComponent:()=>[...iie("meta",a.priority),...iie("link",o.priority),...iie("script",l.priority)],toString:()=>`${ax("meta",a.priority,n)} ${ax("link",o.priority,n)} ${ax("script",l.priority,n)}`},metaTags:a.default,linkTags:o.default,scriptTags:l.default}},F1t=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,b={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:b,linkTags:p,metaTags:f,scriptTags:g}=R1t(t)),{priority:b,base:ax("base",s,n),bodyAttributes:ax("bodyAttributes",r,n),htmlAttributes:ax("htmlAttributes",a,n),link:ax("link",p,n),meta:ax("meta",f,n),noscript:ax("noscript",o,n),script:ax("script",g,n),style:ax("style",l,n),title:ax("title",{title:i,titleAttributes:c},n)}},sve=F1t,R7=[],yUe=!!(typeof window<"u"&&window.document&&window.document.createElement),rve=class{constructor(t,s){Nn(this,"instances",[]);Nn(this,"canUseDOM",yUe);Nn(this,"context");Nn(this,"value",{setHelmet:t=>{this.context.helmet=t},helmetInstances:{get:()=>this.canUseDOM?R7:this.instances,add:t=>{(this.canUseDOM?R7:this.instances).push(t)},remove:t=>{const s=(this.canUseDOM?R7:this.instances).indexOf(t);(this.canUseDOM?R7:this.instances).splice(s,1)}}});this.context=t,this.canUseDOM=s||!1,s||(t.helmet=sve({baseTag:[],bodyAttributes:{},htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}},z1t={},vUe=ht.createContext(z1t),z4,bUe=(z4=class extends k.Component{constructor(r){super(r);Nn(this,"helmetData");this.helmetData=new rve(this.props.context||{},z4.canUseDOM)}render(){return ht.createElement(vUe.Provider,{value:this.helmetData.value},this.props.children)}},Nn(z4,"canUseDOM",yUe),z4),a5=(t,s)=>{const r=document.head||document.querySelector("head"),n=r.querySelectorAll(`${t}[${Hg}]`),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(Hg,"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}},nve=(t,s)=>{const r=document.getElementsByTagName(t)[0];if(!r)return;const n=r.getAttribute(Hg),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(Hg):r.getAttribute(Hg)!==l.join(",")&&r.setAttribute(Hg,l.join(","))},B1t=(t,s)=>{typeof t<"u"&&document.title!==t&&(document.title=fUe(t)),nve("title",s)},lEe=(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;nve("body",n),nve("html",a),B1t(f,g);const b={baseTag:a5("base",r),linkTags:a5("link",o),metaTags:a5("meta",l),noscriptTags:a5("noscript",i),scriptTags:a5("script",u),styleTags:a5("style",p)},_={},j={};Object.keys(b).forEach(w=>{const{newTags:N,oldTags:C}=b[w];N.length&&(_[w]=N),C.length&&(j[w]=b[w].oldTags)}),s&&s(),c(t,_,j)},zP=null,$1t=t=>{zP&&cancelAnimationFrame(zP),t.defer?zP=requestAnimationFrame(()=>{lEe(t,()=>{zP=null})}):(lEe(t),zP=null)},q1t=$1t,cEe=class extends k.Component{constructor(){super(...arguments);Nn(this,"rendered",!1)}shouldComponentUpdate(s){return!N1t(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=E1t(s.get().map(o=>{const l={...o.props};return delete l.context,l}));bUe.canUseDOM?q1t(a):sve&&(n=sve(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}},Iye,rd=(Iye=class extends k.Component{shouldComponentUpdate(t){return!b1t(oEe(this.props,"helmetData"),oEe(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 aEe(iEe.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 ${iEe.join(", ")} are allowed. Helmet does not support rendering <${t.type}> elements. Refer to our API for more information.`),aEe(!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[k1t[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 rve)){const a=n;n=new rve(a.context,!0),delete r.helmetData}return n?ht.createElement(cEe,{...r,context:n.value}):ht.createElement(vUe.Consumer,null,a=>ht.createElement(cEe,{...r,context:a}))}},Nn(Iye,"defaultProps",{defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1}),Iye),ave=function(t,s){return ave=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])},ave(t,s)};function _Ue(t,s){if(typeof s!="function"&&s!==null)throw new TypeError("Class extends value "+String(s)+" is not a constructor or null");ave(t,s);function r(){this.constructor=t}t.prototype=s===null?Object.create(s):(r.prototype=s.prototype,new r)}var fx=function(){return fx=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 jUe(t,s){return function(r,n){s(r,n,t)}}function NUe(t,s,r,n,a,o){function l(N){if(N!==void 0&&typeof N!="function")throw new TypeError("Function expected");return N}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,b=r.length-1;b>=0;b--){var _={};for(var j in n)_[j]=j==="access"?{}:n[j];for(var j in n.access)_.access[j]=n.access[j];_.addInitializer=function(N){if(g)throw new TypeError("Cannot add initializers after decoration has completed");o.push(l(N||null))};var w=(0,r[b])(i==="accessor"?{get:p.get,set:p.set}:p[c],_);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(f=l(w.get))&&(p.get=f),(f=l(w.set))&&(p.set=f),(f=l(w.init))&&a.unshift(f)}else(f=l(w))&&(i==="field"?a.unshift(f):p[c]=f)}u&&Object.defineProperty(u,n.name,p),g=!0}function kUe(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 L2e(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 EUe(){for(var t=[],s=0;s1||c(b,j)})},_&&(a[b]=_(a[b])))}function c(b,_){try{u(n[b](_))}catch(j){g(o[0][3],j)}}function u(b){b.value instanceof ET?Promise.resolve(b.value.v).then(p,f):g(o[0][2],b)}function p(b){c("next",b)}function f(b){c("throw",b)}function g(b,_){b(_),o.shift(),o.length&&c(o[0][0],o[0][1])}}function LUe(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:ET(t[a](l)),done:!1}:o?o(l):l}:o}}function DUe(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 hoe=="function"?hoe(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 OUe(t,s){return Object.defineProperty?Object.defineProperty(t,"raw",{value:s}):t.raw=s,t}var U1t=Object.create?function(t,s){Object.defineProperty(t,"default",{enumerable:!0,value:s})}:function(t,s){t.default=s},ive=function(t){return ive=Object.getOwnPropertyNames||function(s){var r=[];for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[r.length]=n);return r},ive(t)};function RUe(t){if(t&&t.__esModule)return t;var s={};if(t!=null)for(var r=ive(t),n=0;n{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>jc(async()=>{const{default:n}=await Promise.resolve().then(()=>cC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)};class O2e extends Error{constructor(s,r="FunctionsError",n){super(s),this.name=r,this.context=n}}class dEe extends O2e{constructor(s){super("Failed to send a request to the Edge Function","FunctionsFetchError",s)}}class uEe extends O2e{constructor(s){super("Relay Error invoking the Edge Function","FunctionsRelayError",s)}}class hEe extends O2e{constructor(s){super("Edge Function returned a non-2xx status code","FunctionsHttpError",s)}}var ove;(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"})(ove||(ove={}));class K1t{constructor(s,{headers:r={},customFetch:n,region:a=ove.Any}={}){this.url=s,this.headers=r,this.region=a,this.fetch=G1t(n)}setAuth(s){this.headers.Authorization=`Bearer ${s}`}invoke(s){return pa(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 b=yield this.fetch(f.toString(),{method:l||"POST",headers:Object.assign(Object.assign(Object.assign({},u),this.headers),o),body:g,signal:c}).catch(N=>{throw N.name==="AbortError"?N:new dEe(N)}),_=b.headers.get("x-relay-error");if(_&&_==="true")throw new uEe(b);if(!b.ok)throw new hEe(b);let j=((a=b.headers.get("Content-Type"))!==null&&a!==void 0?a:"text/plain").split(";")[0].trim(),w;return j==="application/json"?w=yield b.json():j==="application/octet-stream"||j==="application/pdf"?w=yield b.blob():j==="text/event-stream"?w=b:j==="multipart/form-data"?w=yield b.formData():w=yield b.text(),{data:w,error:null,response:b}}catch(o){return o instanceof Error&&o.name==="AbortError"?{data:null,error:new dEe(o)}:{data:null,error:o,response:o instanceof hEe||o instanceof uEe?o.context:void 0}}})}}var pp={};const VA=p9e(W1t);var F7={},z7={},B7={},$7={},q7={},Z1t=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")},PT=Z1t();const Y1t=PT.fetch,HUe=PT.fetch.bind(PT),WUe=PT.Headers,X1t=PT.Request,Q1t=PT.Response,cC=Object.freeze(Object.defineProperty({__proto__:null,Headers:WUe,Request:X1t,Response:Q1t,default:HUe,fetch:Y1t},Symbol.toStringTag,{value:"Module"})),J1t=p9e(cC);var U7={},mEe;function GUe(){if(mEe)return U7;mEe=1,Object.defineProperty(U7,"__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 U7.default=t,U7}var pEe;function KUe(){if(pEe)return q7;pEe=1,Object.defineProperty(q7,"__esModule",{value:!0});const t=VA,s=t.__importDefault(J1t),r=t.__importDefault(GUe());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,b;let _=null,j=null,w=null,N=u.status,C=u.statusText;if(u.ok){if(this.method!=="HEAD"){const R=await u.text();R===""||(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"))?j=R:j=JSON.parse(R))}const I=(f=this.headers.get("Prefer"))===null||f===void 0?void 0:f.match(/count=(exact|planned|estimated)/),L=(g=u.headers.get("content-range"))===null||g===void 0?void 0:g.split("/");I&&L&&L.length>1&&(w=parseInt(L[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(j)&&(j.length>1?(_={code:"PGRST116",details:`Results contain ${j.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},j=null,w=null,N=406,C="Not Acceptable"):j.length===1?j=j[0]:j=null)}else{const I=await u.text();try{_=JSON.parse(I),Array.isArray(_)&&u.status===404&&(j=[],_=null,N=200,C="OK")}catch{u.status===404&&I===""?(N=204,C="No Content"):_={message:I}}if(_&&this.isMaybeSingle&&(!((b=_==null?void 0:_.details)===null||b===void 0)&&b.includes("0 rows"))&&(_=null,N=200,C="OK"),_&&this.shouldThrowOnError)throw new r.default(_)}return{error:_,data:j,count:w,status:N,statusText:C}});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 q7.default=n,q7}var fEe;function ZUe(){if(fEe)return $7;fEe=1,Object.defineProperty($7,"__esModule",{value:!0});const s=VA.__importDefault(KUe());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 $7.default=r,$7}var xEe;function R2e(){if(xEe)return B7;xEe=1,Object.defineProperty(B7,"__esModule",{value:!0});const s=VA.__importDefault(ZUe()),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 B7.default=n,B7}var gEe;function YUe(){if(gEe)return z7;gEe=1,Object.defineProperty(z7,"__esModule",{value:!0});const s=VA.__importDefault(R2e());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,b)=>g.concat(Object.keys(b)),[]);if(f.length>0){const g=[...new Set(f)].map(b=>`"${b}"`);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 z7.default=r,z7}var yEe;function ebt(){if(yEe)return F7;yEe=1,Object.defineProperty(F7,"__esModule",{value:!0});const t=VA,s=t.__importDefault(YUe()),r=t.__importDefault(R2e());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 b;i||c?(f=i?"HEAD":"GET",Object.entries(l).filter(([j,w])=>w!==void 0).map(([j,w])=>[j,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([j,w])=>{g.searchParams.append(j,w)})):(f="POST",b=l);const _=new Headers(this.headers);return u&&_.set("Prefer",`count=${u}`),new r.default({method:f,url:g,headers:_,schema:this.schemaName,body:b,fetch:(p=this.fetch)!==null&&p!==void 0?p:fetch})}}return F7.default=n,F7}Object.defineProperty(pp,"__esModule",{value:!0});var XUe=pp.PostgrestError=oVe=pp.PostgrestBuilder=aVe=pp.PostgrestTransformBuilder=rVe=pp.PostgrestFilterBuilder=tVe=pp.PostgrestQueryBuilder=JUe=pp.PostgrestClient=void 0;const HA=VA,QUe=HA.__importDefault(ebt());var JUe=pp.PostgrestClient=QUe.default;const eVe=HA.__importDefault(YUe());var tVe=pp.PostgrestQueryBuilder=eVe.default;const sVe=HA.__importDefault(R2e());var rVe=pp.PostgrestFilterBuilder=sVe.default;const nVe=HA.__importDefault(ZUe());var aVe=pp.PostgrestTransformBuilder=nVe.default;const iVe=HA.__importDefault(KUe());var oVe=pp.PostgrestBuilder=iVe.default;const lVe=HA.__importDefault(GUe());XUe=pp.PostgrestError=lVe.default;var cVe=pp.default={PostgrestClient:QUe.default,PostgrestQueryBuilder:eVe.default,PostgrestFilterBuilder:sVe.default,PostgrestTransformBuilder:nVe.default,PostgrestBuilder:iVe.default,PostgrestError:lVe.default};const tbt=Object.freeze(Object.defineProperty({__proto__:null,get PostgrestBuilder(){return oVe},get PostgrestClient(){return JUe},get PostgrestError(){return XUe},get PostgrestFilterBuilder(){return rVe},get PostgrestQueryBuilder(){return tVe},get PostgrestTransformBuilder(){return aVe},default:cVe},Symbol.toStringTag,{value:"Module"})),{PostgrestClient:sbt,PostgrestQueryBuilder:lMs,PostgrestFilterBuilder:cMs,PostgrestTransformBuilder:dMs,PostgrestBuilder:uMs,PostgrestError:hMs}=cVe||tbt;class rbt{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 nbt="2.78.0",abt=`realtime-js/${nbt}`,ibt="1.0.0",lve=1e4,obt=1e3,lbt=100;var RL;(function(t){t[t.connecting=0]="connecting",t[t.open=1]="open",t[t.closing=2]="closing",t[t.closed=3]="closed"})(RL||(RL={}));var hu;(function(t){t.closed="closed",t.errored="errored",t.joined="joined",t.joining="joining",t.leaving="leaving"})(hu||(hu={}));var Dg;(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"})(Dg||(Dg={}));var cve;(function(t){t.websocket="websocket"})(cve||(cve={}));var a4;(function(t){t.Connecting="connecting",t.Open="open",t.Closing="closing",t.Closed="closed"})(a4||(a4={}));class cbt{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 dVe{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 Vl;(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"})(Vl||(Vl={}));const vEe=(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]=dbt(l,t,s,a),o),{}):{}},dbt=(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)?uVe(o,l):dve(l)},uVe=(t,s)=>{if(t.charAt(0)==="_"){const r=t.slice(1,t.length);return pbt(s,r)}switch(t){case Vl.bool:return ubt(s);case Vl.float4:case Vl.float8:case Vl.int2:case Vl.int4:case Vl.int8:case Vl.numeric:case Vl.oid:return hbt(s);case Vl.json:case Vl.jsonb:return mbt(s);case Vl.timestamp:return fbt(s);case Vl.abstime:case Vl.date:case Vl.daterange:case Vl.int4range:case Vl.int8range:case Vl.money:case Vl.reltime:case Vl.text:case Vl.time:case Vl.timestamptz:case Vl.timetz:case Vl.tsrange:case Vl.tstzrange:return dve(s);default:return dve(s)}},dve=t=>t,ubt=t=>{switch(t){case"t":return!0;case"f":return!1;default:return t}},hbt=t=>{if(typeof t=="string"){const s=parseFloat(t);if(!Number.isNaN(s))return s}return t},mbt=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch(s){return console.log(`JSON parse error: ${s}`),t}return t},pbt=(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=>uVe(s,i))}return t},fbt=t=>typeof t=="string"?t.replace(" ","T"):t,hVe=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 rxe{constructor(s,r,n={},a=lve){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 bEe;(function(t){t.SYNC="sync",t.JOIN="join",t.LEAVE="leave"})(bEe||(bEe={}));class FL{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=FL.syncState(this.state,a,o,l),this.pendingDiffs.forEach(c=>{this.state=FL.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=FL.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(w=>w.presence_ref),b=f.map(w=>w.presence_ref),_=p.filter(w=>b.indexOf(w.presence_ref)<0),j=f.filter(w=>g.indexOf(w.presence_ref)<0);_.length>0&&(i[u]=_),j.length>0&&(c[u]=j)}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(b=>b.presence_ref),g=p.filter(b=>f.indexOf(b.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 _Ee;(function(t){t.ALL="*",t.INSERT="INSERT",t.UPDATE="UPDATE",t.DELETE="DELETE"})(_Ee||(_Ee={}));var zL;(function(t){t.BROADCAST="broadcast",t.PRESENCE="presence",t.POSTGRES_CHANGES="postgres_changes",t.SYSTEM="system"})(zL||(zL={}));var Av;(function(t){t.SUBSCRIBED="SUBSCRIBED",t.TIMED_OUT="TIMED_OUT",t.CLOSED="CLOSED",t.CHANNEL_ERROR="CHANNEL_ERROR"})(Av||(Av={}));class F2e{constructor(s,r={config:{}},n){var a,o;if(this.topic=s,this.params=r,this.socket=n,this.bindings={},this.state=hu.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 rxe(this,Dg.join,this.params,this.timeout),this.rejoinTimer=new dVe(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=hu.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=hu.closed,this.socket._remove(this)}),this._onError(l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=hu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=hu.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",l=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,l),this.state=hu.errored,this.rejoinTimer.scheduleTimeout())}),this._on(Dg.reply,{},(l,i)=>{this._trigger(this._replyEventName(i),l)}),this.presence=new FL(this),this.broadcastEndpointURL=hVe(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==hu.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(b=>b.filter))!==null&&a!==void 0?a:[],p=!!this.bindings[zL.PRESENCE]&&this.bindings[zL.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(b=>s==null?void 0:s(Av.CHANNEL_ERROR,b)),this._onClose(()=>s==null?void 0:s(Av.CLOSED)),this.updateJoinPayload(Object.assign({config:g},f)),this.joinedOnce=!0,this._rejoin(r),this.joinPush.receive("ok",async({postgres_changes:b})=>{var _;if(this.socket.setAuth(),b===void 0){s==null||s(Av.SUBSCRIBED);return}else{const j=this.bindings.postgres_changes,w=(_=j==null?void 0:j.length)!==null&&_!==void 0?_:0,N=[];for(let C=0;C{this.state=hu.errored,s==null||s(Av.CHANNEL_ERROR,new Error(JSON.stringify(Object.values(b).join(", ")||"error")))}).receive("timeout",()=>{s==null||s(Av.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===hu.joined&&s===zL.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=hu.leaving;const r=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(Dg.close,"leave",this._joinRef())};this.joinPush.destroy();let n=null;return new Promise(a=>{n=new rxe(this,Dg.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=hu.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 rxe(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>lbt){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}=Dg;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(b=>{var _,j,w;return((_=b.filter)===null||_===void 0?void 0:_.event)==="*"||((w=(j=b.filter)===null||j===void 0?void 0:j.event)===null||w===void 0?void 0:w.toLocaleLowerCase())===l}).map(b=>b.callback(g,n)):(o=this.bindings[l])===null||o===void 0||o.filter(b=>{var _,j,w,N,C,M;if(["broadcast","presence","postgres_changes"].includes(l))if("id"in b){const I=b.id,L=(_=b.filter)===null||_===void 0?void 0:_.event;return I&&((j=r.ids)===null||j===void 0?void 0:j.includes(I))&&(L==="*"||(L==null?void 0:L.toLocaleLowerCase())===((w=r.data)===null||w===void 0?void 0:w.type.toLocaleLowerCase()))}else{const I=(C=(N=b==null?void 0:b.filter)===null||N===void 0?void 0:N.event)===null||C===void 0?void 0:C.toLocaleLowerCase();return I==="*"||I===((M=r==null?void 0:r.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return b.type.toLocaleLowerCase()===l}).map(b=>{if(typeof g=="object"&&"ids"in g){const _=g.data,{schema:j,table:w,commit_timestamp:N,type:C,errors:M}=_;g=Object.assign(Object.assign({},{schema:j,table:w,commit_timestamp:N,eventType:C,new:{},old:{},errors:M}),this._getPayloadRecords(_))}b.callback(g,n)})}_isClosed(){return this.state===hu.closed}_isJoined(){return this.state===hu.joined}_isJoining(){return this.state===hu.joining}_isLeaving(){return this.state===hu.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&&F2e.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(Dg.close,{},s)}_onError(s){this._on(Dg.error,{},r=>s(r))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(s=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=hu.joining,this.joinPush.resend(s))}_getPayloadRecords(s){const r={new:{},old:{}};return(s.type==="INSERT"||s.type==="UPDATE")&&(r.new=vEe(s.columns,s.record)),(s.type==="UPDATE"||s.type==="DELETE")&&(r.old=vEe(s.columns,s.old_record)),r}}const nxe=()=>{},V7={HEARTBEAT_INTERVAL:25e3,RECONNECT_DELAY:10,HEARTBEAT_TIMEOUT_FALLBACK:100},xbt=[1e3,2e3,5e3,1e4],gbt=1e4,ybt=` addEventListener("message", (e) => { if (e.data.event === "start") { setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); } });`;class vbt{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=lve,this.transport=null,this.heartbeatIntervalMs=V7.HEARTBEAT_INTERVAL,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=nxe,this.ref=0,this.reconnectTimer=null,this.logger=nxe,this.conn=null,this.sendBuffer=[],this.serializer=new cbt,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)=>jc(async()=>{const{default:i}=await Promise.resolve().then(()=>cC);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}/${cve.websocket}`,this.httpEndpoint=hVe(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=rbt.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:ibt}))}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 RL.connecting:return a4.Connecting;case RL.open:return a4.Open;case RL.closing:return a4.Closing;default:return a4.Closed}}isConnected(){return this.connectionState()===a4.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 F2e(`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(obt,"heartbeat timeout"),setTimeout(()=>{var r;this.isConnected()||(r=this.reconnectTimer)===null||r===void 0||r.scheduleTimeout()},V7.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(Dg.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([ybt],{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:abt};r&&n.updateJoinPayload(a),n.joinedOnce&&n._isJoined()&&n._push(Dg.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 dVe(async()=>{setTimeout(async()=>{await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()},V7.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:lve,this.heartbeatIntervalMs=(a=s==null?void 0:s.heartbeatIntervalMs)!==null&&a!==void 0?a:V7.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:nxe,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=>xbt[f-1]||gbt,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 z2e extends Error{constructor(s){super(s),this.__isStorageError=!0,this.name="StorageError"}}function Gc(t){return typeof t=="object"&&t!==null&&"__isStorageError"in t}class bbt extends z2e{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 uve extends z2e{constructor(s,r){super(s),this.name="StorageUnknownError",this.originalError=r}}const B2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>jc(async()=>{const{default:n}=await Promise.resolve().then(()=>cC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},_bt=()=>pa(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield jc(()=>Promise.resolve().then(()=>cC),void 0)).Response:Response}),hve=t=>{if(Array.isArray(t))return t.map(r=>hve(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]=hve(n)}),s},wbt=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)},axe=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)},jbt=(t,s,r)=>pa(void 0,void 0,void 0,function*(){const n=yield _bt();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 bbt(axe(a),o,l))}).catch(a=>{s(new uve(axe(a),a))}):s(new uve(axe(t),t))}),Nbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return t==="GET"||!n?a:(wbt(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 _O(t,s,r,n,a,o){return pa(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Nbt(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=>jbt(c,i,n))})})}function V8(t,s,r,n){return pa(this,void 0,void 0,function*(){return _O(t,"GET",s,r,n)})}function Eg(t,s,r,n,a){return pa(this,void 0,void 0,function*(){return _O(t,"POST",s,n,a,r)})}function mve(t,s,r,n,a){return pa(this,void 0,void 0,function*(){return _O(t,"PUT",s,n,a,r)})}function kbt(t,s,r,n){return pa(this,void 0,void 0,function*(){return _O(t,"HEAD",s,Object.assign(Object.assign({},r),{noResolveJson:!0}),n)})}function $2e(t,s,r,n,a){return pa(this,void 0,void 0,function*(){return _O(t,"DELETE",s,n,a,r)})}class Sbt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r}then(s,r){return this.execute().then(s,r)}execute(){return pa(this,void 0,void 0,function*(){try{return{data:(yield this.downloadFn()).body,error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Gc(s))return{data:null,error:s};throw s}})}}var mVe;class Cbt{constructor(s,r){this.downloadFn=s,this.shouldThrowOnError=r,this[mVe]="BlobDownloadBuilder",this.promise=null}asStream(){return new Sbt(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 pa(this,void 0,void 0,function*(){try{return{data:yield(yield this.downloadFn()).blob(),error:null}}catch(s){if(this.shouldThrowOnError)throw s;if(Gc(s))return{data:null,error:s};throw s}})}}mVe=Symbol.toStringTag;const Mbt={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},wEe={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class Tbt{constructor(s,r={},n,a){this.shouldThrowOnError=!1,this.url=s,this.headers=r,this.bucketId=n,this.fetch=B2e(a)}throwOnError(){return this.shouldThrowOnError=!0,this}uploadOrUpdate(s,r,n,a){return pa(this,void 0,void 0,function*(){try{let o;const l=Object.assign(Object.assign({},wEe),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"?mve:Eg)(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(Gc(o))return{data:null,error:o};throw o}})}upload(s,r,n){return pa(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",s,r,n)})}uploadToSignedUrl(s,r,n,a){return pa(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:wEe.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 mve(this.fetch,i.toString(),c,{headers:p});return{data:{path:o,fullPath:f.Key},error:null}}catch(c){if(this.shouldThrowOnError)throw c;if(Gc(c))return{data:null,error:c};throw c}})}createSignedUploadUrl(s,r){return pa(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 Eg(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 z2e("No token returned by API");return{data:{signedUrl:l.toString(),path:s,token:i},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Gc(n))return{data:null,error:n};throw n}})}update(s,r,n){return pa(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",s,r,n)})}move(s,r,n){return pa(this,void 0,void 0,function*(){try{return{data:yield Eg(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(Gc(a))return{data:null,error:a};throw a}})}copy(s,r,n){return pa(this,void 0,void 0,function*(){try{return{data:{path:(yield Eg(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(Gc(a))return{data:null,error:a};throw a}})}createSignedUrl(s,r,n){return pa(this,void 0,void 0,function*(){try{let a=this._getFinalPath(s),o=yield Eg(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(Gc(a))return{data:null,error:a};throw a}})}createSignedUrls(s,r,n){return pa(this,void 0,void 0,function*(){try{const a=yield Eg(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(Gc(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=()=>V8(this.fetch,`${this.url}/${a}/${i}${l}`,{headers:this.headers,noResolveJson:!0});return new Cbt(c,this.shouldThrowOnError)}info(s){return pa(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{const n=yield V8(this.fetch,`${this.url}/object/info/${r}`,{headers:this.headers});return{data:hve(n),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Gc(n))return{data:null,error:n};throw n}})}exists(s){return pa(this,void 0,void 0,function*(){const r=this._getFinalPath(s);try{return yield kbt(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Gc(n)&&n instanceof uve){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 pa(this,void 0,void 0,function*(){try{return{data:yield $2e(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}list(s,r,n){return pa(this,void 0,void 0,function*(){try{const a=Object.assign(Object.assign(Object.assign({},Mbt),r),{prefix:s||""});return{data:yield Eg(this.fetch,`${this.url}/object/list/${this.bucketId}`,a,{headers:this.headers},n),error:null}}catch(a){if(this.shouldThrowOnError)throw a;if(Gc(a))return{data:null,error:a};throw a}})}listV2(s,r){return pa(this,void 0,void 0,function*(){try{const n=Object.assign({},s);return{data:yield Eg(this.fetch,`${this.url}/object/list-v2/${this.bucketId}`,n,{headers:this.headers},r),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(Gc(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 pVe="2.78.0",fVe={"X-Client-Info":`storage-js/${pVe}`};class Abt{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({},fVe),r),this.fetch=B2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}listBuckets(s){return pa(this,void 0,void 0,function*(){try{const r=this.listBucketOptionsToQueryString(s);return{data:yield V8(this.fetch,`${this.url}/bucket${r}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}getBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield V8(this.fetch,`${this.url}/bucket/${s}`,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}createBucket(s){return pa(this,arguments,void 0,function*(r,n={public:!1}){try{return{data:yield Eg(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(Gc(a))return{data:null,error:a};throw a}})}updateBucket(s,r){return pa(this,void 0,void 0,function*(){try{return{data:yield mve(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(Gc(n))return{data:null,error:n};throw n}})}emptyBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield Eg(this.fetch,`${this.url}/bucket/${s}/empty`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield $2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(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 Ebt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},fVe),r),this.fetch=B2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield Eg(this.fetch,`${this.url}/bucket`,{name:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}listBuckets(s){return pa(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 V8(this.fetch,a,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}deleteBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield $2e(this.fetch,`${this.url}/bucket/${s}`,{},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(Gc(r))return{data:null,error:r};throw r}})}}const q2e={"X-Client-Info":`storage-js/${pVe}`,"Content-Type":"application/json"};class xVe extends Error{constructor(s){super(s),this.__isStorageVectorsError=!0,this.name="StorageVectorsError"}}function af(t){return typeof t=="object"&&t!==null&&"__isStorageVectorsError"in t}class ixe extends xVe{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 Pbt extends xVe{constructor(s,r){super(s),this.name="StorageVectorsUnknownError",this.originalError=r}}var jEe;(function(t){t.InternalError="InternalError",t.S3VectorConflictException="S3VectorConflictException",t.S3VectorNotFoundException="S3VectorNotFoundException",t.S3VectorBucketNotEmpty="S3VectorBucketNotEmpty",t.S3VectorMaxBucketsExceeded="S3VectorMaxBucketsExceeded",t.S3VectorMaxIndexesExceeded="S3VectorMaxIndexesExceeded"})(jEe||(jEe={}));const U2e=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>jc(async()=>{const{default:n}=await Promise.resolve().then(()=>cC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},Ibt=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)},NEe=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),Lbt=(t,s,r)=>pa(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 ixe(NEe(l),a,i))}).catch(()=>{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new ixe(i,a,l))});else{const l=a+"",i=o.statusText||`HTTP ${a} error`;s(new ixe(i,a,l))}}else s(new Pbt(NEe(t),t))}),Dbt=(t,s,r,n)=>{const a={method:t,headers:(s==null?void 0:s.headers)||{}};return n?(Ibt(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 Obt(t,s,r,n,a,o){return pa(this,void 0,void 0,function*(){return new Promise((l,i)=>{t(r,Dbt(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=>Lbt(c,i,n))})})}function of(t,s,r,n,a){return pa(this,void 0,void 0,function*(){return Obt(t,"POST",s,n,a,r)})}class Rbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},q2e),r),this.fetch=U2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createIndex(s){return pa(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/CreateIndex`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getIndex(s,r){return pa(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}),error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(af(n))return{data:null,error:n};throw n}})}listIndexes(s){return pa(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/ListIndexes`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteIndex(s,r){return pa(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/DeleteIndex`,{vectorBucketName:s,indexName:r},{headers:this.headers}))||{},error:null}}catch(n){if(this.shouldThrowOnError)throw n;if(af(n))return{data:null,error:n};throw n}})}}class Fbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},q2e),r),this.fetch=U2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}putVectors(s){return pa(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 of(this.fetch,`${this.url}/PutVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getVectors(s){return pa(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}listVectors(s){return pa(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 of(this.fetch,`${this.url}/ListVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}queryVectors(s){return pa(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/QueryVectors`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteVectors(s){return pa(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 of(this.fetch,`${this.url}/DeleteVectors`,s,{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}}class zbt{constructor(s,r={},n){this.shouldThrowOnError=!1,this.url=s.replace(/\/$/,""),this.headers=Object.assign(Object.assign({},q2e),r),this.fetch=U2e(n)}throwOnError(){return this.shouldThrowOnError=!0,this}createBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/CreateVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}getBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:yield of(this.fetch,`${this.url}/GetVectorBucket`,{vectorBucketName:s},{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}listBuckets(){return pa(this,arguments,void 0,function*(s={}){try{return{data:yield of(this.fetch,`${this.url}/ListVectorBuckets`,s,{headers:this.headers}),error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}deleteBucket(s){return pa(this,void 0,void 0,function*(){try{return{data:(yield of(this.fetch,`${this.url}/DeleteVectorBucket`,{vectorBucketName:s},{headers:this.headers}))||{},error:null}}catch(r){if(this.shouldThrowOnError)throw r;if(af(r))return{data:null,error:r};throw r}})}}class Bbt extends zbt{constructor(s,r={}){super(s,r.headers||{},r.fetch)}from(s){return new $bt(this.url,this.headers,s,this.fetch)}}class $bt extends Rbt{constructor(s,r,n,a){super(s,r,a),this.vectorBucketName=n}createIndex(s){const r=Object.create(null,{createIndex:{get:()=>super.createIndex}});return pa(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 pa(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 pa(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 pa(this,void 0,void 0,function*(){return r.deleteIndex.call(this,this.vectorBucketName,s)})}index(s){return new qbt(this.url,this.headers,this.vectorBucketName,s,this.fetch)}}class qbt extends Fbt{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 pa(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 pa(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 pa(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 pa(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 pa(this,void 0,void 0,function*(){return r.deleteVectors.call(this,Object.assign(Object.assign({},s),{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))})}}class Ubt extends Abt{constructor(s,r={},n,a){super(s,r,n,a)}from(s){return new Tbt(this.url,this.headers,s,this.fetch)}get vectors(){return new Bbt(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new Ebt(this.url+"/iceberg",this.headers,this.fetch)}}const Vbt="2.78.0";let gI="";typeof Deno<"u"?gI="deno":typeof document<"u"?gI="web":typeof navigator<"u"&&navigator.product==="ReactNative"?gI="react-native":gI="node";const Hbt={"X-Client-Info":`supabase-js-${gI}/${Vbt}`},Wbt={headers:Hbt},Gbt={schema:"public"},Kbt={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},Zbt={},Ybt=t=>{let s;return t?s=t:typeof fetch>"u"?s=HUe:s=fetch,(...r)=>s(...r)},Xbt=()=>typeof Headers>"u"?WUe:Headers,Qbt=(t,s,r)=>{const n=Ybt(r),a=Xbt();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 Jbt(t){return t.endsWith("/")?t:t+"/"}function e_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(Jbt(s))}catch{throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}const gVe="2.78.0",E5=30*1e3,pve=3,oxe=pve*E5,s_t="http://localhost:9999",r_t="supabase.auth.token",n_t={"X-Client-Info":`gotrue-js/${gVe}`},fve="X-Supabase-Api-Version",yVe={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},a_t=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,i_t=10*60*1e3;class H8 extends Error{constructor(s,r,n){super(s),this.__isAuthError=!0,this.name="AuthError",this.status=r,this.code=n}}function Fa(t){return typeof t=="object"&&t!==null&&"__isAuthError"in t}class o_t extends H8{constructor(s,r,n){super(s,r,n),this.name="AuthApiError",this.status=r,this.code=n}}function l_t(t){return Fa(t)&&t.name==="AuthApiError"}class i4 extends H8{constructor(s,r){super(s),this.name="AuthUnknownError",this.originalError=r}}class kw extends H8{constructor(s,r,n,a){super(s,n,a),this.name=r,this.status=n}}class kg extends kw{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function c_t(t){return Fa(t)&&t.name==="AuthSessionMissingError"}class i5 extends kw{constructor(){super("Auth session or user missing","AuthInvalidTokenResponseError",500,void 0)}}class H7 extends kw{constructor(s){super(s,"AuthInvalidCredentialsError",400,void 0)}}class W7 extends kw{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 d_t(t){return Fa(t)&&t.name==="AuthImplicitGrantRedirectError"}class kEe extends kw{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 xve extends kw{constructor(s,r){super(s,"AuthRetryableFetchError",r,void 0)}}function lxe(t){return Fa(t)&&t.name==="AuthRetryableFetchError"}class SEe extends kw{constructor(s,r,n){super(s,"AuthWeakPasswordError",r,"weak_password"),this.reasons=n}}class gve extends kw{constructor(s){super(s,"AuthInvalidJwtError",400,"invalid_jwt")}}const moe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),CEe=` \r=`.split(""),u_t=(()=>{const t=new Array(128);for(let s=0;s=6;){const n=s.queue>>s.queuedBits-6&63;r(moe[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(moe[n]),s.queuedBits-=6}}function vVe(t,s,r){const n=u_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 TEe(t){const s=[],r=l=>{s.push(String.fromCodePoint(l))},n={utf8seq:0,codepoint:0},a={queue:0,queuedBits:0},o=l=>{p_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 m_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}h_t(n,s)}}function p_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 KM(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};for(let a=0;as.push(r)),new Uint8Array(s)}function m4(t){const s=[],r={queue:0,queuedBits:0},n=a=>{s.push(a)};return t.forEach(a=>MEe(a,r,n)),MEe(null,r,n),s.join("")}function x_t(t){return Math.round(Date.now()/1e3)+t}function g_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 xm=()=>typeof window<"u"&&typeof document<"u",P2={tested:!1,writable:!1},bVe=()=>{if(!xm())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(P2.tested)return P2.writable;const t=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(t,t),globalThis.localStorage.removeItem(t),P2.tested=!0,P2.writable=!0}catch{P2.tested=!0,P2.writable=!1}return P2.writable};function y_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 _Ve=t=>{let s;return t?s=t:typeof fetch>"u"?s=(...r)=>jc(async()=>{const{default:n}=await Promise.resolve().then(()=>cC);return{default:n}},void 0).then(({default:n})=>n(...r)):s=fetch,(...r)=>s(...r)},v_t=t=>typeof t=="object"&&t!==null&&"status"in t&&"ok"in t&&"json"in t&&typeof t.json=="function",P5=async(t,s,r)=>{await t.setItem(s,JSON.stringify(r))},I2=async(t,s)=>{const r=await t.getItem(s);if(!r)return null;try{return JSON.parse(r)}catch{return r}},Ab=async(t,s)=>{await t.removeItem(s)};class Tde{constructor(){this.promise=new Tde.promiseConstructor((s,r)=>{this.resolve=s,this.reject=r})}}Tde.promiseConstructor=Promise;function cxe(t){const s=t.split(".");if(s.length!==3)throw new gve("Invalid JWT structure");for(let n=0;n{setTimeout(()=>s(null),t)})}function __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 w_t(t){return("0"+t.toString(16)).substr(-2)}function j_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,w_t).join("")}async function N_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 k_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 N_t(t);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function o5(t,s,r=!1){const n=j_t();let a=n;r&&(a+="/PASSWORD_RECOVERY"),await P5(t,`${s}-code-verifier`,a);const o=await k_t(n);return[o,n===o?"plain":"s256"]}const S_t=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function C_t(t){const s=t.headers.get(fve);if(!s||!s.match(S_t))return null;try{return new Date(`${s}T00:00:00.0Z`)}catch{return null}}function M_t(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 T_t(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 A_t=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function l5(t){if(!A_t.test(t))throw new Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function dxe(){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 E_t(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 AEe(t){return JSON.parse(JSON.stringify(t))}const Jk=t=>t.msg||t.message||t.error_description||t.error||JSON.stringify(t),P_t=[502,503,504];async function EEe(t){var s;if(!v_t(t))throw new xve(Jk(t),0);if(P_t.includes(t.status))throw new xve(Jk(t),t.status);let r;try{r=await t.json()}catch(o){throw new i4(Jk(o),o)}let n;const a=C_t(t);if(a&&a.getTime()>=yVe["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 SEe(Jk(r),t.status,((s=r.weak_password)===null||s===void 0?void 0:s.reasons)||[]);if(n==="session_not_found")throw new kg}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 SEe(Jk(r),t.status,r.weak_password.reasons);throw new o_t(Jk(r),t.status||500,n)}const I_t=(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 wi(t,s,r,n){var a;const o=Object.assign({},n==null?void 0:n.headers);o[fve]||(o[fve]=yVe["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 L_t(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 L_t(t,s,r,n,a,o){const l=I_t(s,n,a,o);let i;try{i=await t(r,Object.assign({},l))}catch(c){throw console.error(c),new xve(Jk(c),0)}if(i.ok||await EEe(i),n!=null&&n.noResolveJson)return i;try{return await i.json()}catch(c){await EEe(c)}}function Sg(t){var s;let r=null;R_t(t)&&(r=Object.assign({},t),t.expires_at||(r.expires_at=x_t(t.expires_in)));const n=(s=t.user)!==null&&s!==void 0?s:t;return{data:{session:r,user:n},error:null}}function PEe(t){const s=Sg(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 s_(t){var s;return{data:{user:(s=t.user)!==null&&s!==void 0?s:t},error:null}}function D_t(t){return{data:t,error:null}}function O_t(t){const{action_link:s,email_otp:r,hashed_token:n,redirect_to:a,verification_type:o}=t,l=Nw(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 IEe(t){return t}function R_t(t){return t.access_token&&t.refresh_token&&t.expires_in}const uxe=["global","local","others"];class F_t{constructor({url:s="",headers:r={},fetch:n}){this.url=s,this.headers=r,this.fetch=_Ve(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=uxe[0]){if(uxe.indexOf(r)<0)throw new Error(`@supabase/auth-js: Parameter scope must be one of ${uxe.join(", ")}`);try{return await wi(this.fetch,"POST",`${this.url}/logout?scope=${r}`,{headers:this.headers,jwt:s,noResolveJson:!0}),{data:null,error:null}}catch(n){if(Fa(n))return{data:null,error:n};throw n}}async inviteUserByEmail(s,r={}){try{return await wi(this.fetch,"POST",`${this.url}/invite`,{body:{email:s,data:r.data},headers:this.headers,redirectTo:r.redirectTo,xform:s_})}catch(n){if(Fa(n))return{data:{user:null},error:n};throw n}}async generateLink(s){try{const{options:r}=s,n=Nw(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 wi(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:a,headers:this.headers,xform:O_t,redirectTo:r==null?void 0:r.redirectTo})}catch(r){if(Fa(r))return{data:{properties:null,user:null},error:r};throw r}}async createUser(s){try{return await wi(this.fetch,"POST",`${this.url}/admin/users`,{body:s,headers:this.headers,xform:s_})}catch(r){if(Fa(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 wi(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:IEe});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,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Fa(u))return{data:{users:[]},error:u};throw u}}async getUserById(s){l5(s);try{return await wi(this.fetch,"GET",`${this.url}/admin/users/${s}`,{headers:this.headers,xform:s_})}catch(r){if(Fa(r))return{data:{user:null},error:r};throw r}}async updateUserById(s,r){l5(s);try{return await wi(this.fetch,"PUT",`${this.url}/admin/users/${s}`,{body:r,headers:this.headers,xform:s_})}catch(n){if(Fa(n))return{data:{user:null},error:n};throw n}}async deleteUser(s,r=!1){l5(s);try{return await wi(this.fetch,"DELETE",`${this.url}/admin/users/${s}`,{headers:this.headers,body:{should_soft_delete:r},xform:s_})}catch(n){if(Fa(n))return{data:{user:null},error:n};throw n}}async _listFactors(s){l5(s.userId);try{const{data:r,error:n}=await wi(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(Fa(r))return{data:null,error:r};throw r}}async _deleteFactor(s){l5(s.userId),l5(s.id);try{return{data:await wi(this.fetch,"DELETE",`${this.url}/admin/users/${s.userId}/factors/${s.id}`,{headers:this.headers}),error:null}}catch(r){if(Fa(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 wi(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:IEe});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,b=(c=(i=p.headers.get("link"))===null||i===void 0?void 0:i.split(","))!==null&&c!==void 0?c:[];return b.length>0&&(b.forEach(_=>{const j=parseInt(_.split(";")[0].split("=")[1].substring(0,1)),w=JSON.parse(_.split(";")[1].split("=")[1]);u[`${w}Page`]=j}),u.total=parseInt(g)),{data:Object.assign(Object.assign({},f),u),error:null}}catch(u){if(Fa(u))return{data:{clients:[]},error:u};throw u}}async _createOAuthClient(s){try{return await wi(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:s,headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Fa(r))return{data:null,error:r};throw r}}async _getOAuthClient(s){try{return await wi(this.fetch,"GET",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Fa(r))return{data:null,error:r};throw r}}async _updateOAuthClient(s,r){try{return await wi(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${s}`,{body:r,headers:this.headers,xform:n=>({data:n,error:null})})}catch(n){if(Fa(n))return{data:null,error:n};throw n}}async _deleteOAuthClient(s){try{return await wi(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${s}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(r){if(Fa(r))return{data:null,error:r};throw r}}async _regenerateOAuthClientSecret(s){try{return await wi(this.fetch,"POST",`${this.url}/admin/oauth/clients/${s}/regenerate_secret`,{headers:this.headers,xform:r=>({data:r,error:null})})}catch(r){if(Fa(r))return{data:null,error:r};throw r}}}function LEe(t={}){return{getItem:s=>t[s]||null,setItem:(s,r)=>{t[s]=r},removeItem:s=>{delete t[s]}}}const c5={debug:!!(globalThis&&bVe()&&globalThis.localStorage&&globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug")==="true")};class wVe extends Error{constructor(s){super(s),this.isAcquireTimeout=!0}}class z_t extends wVe{}async function B_t(t,s,r){c5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",t,s);const n=new globalThis.AbortController;return s>0&&setTimeout(()=>{n.abort(),c5.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){c5.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",t,a.name);try{return await r()}finally{c5.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",t,a.name)}}else{if(s===0)throw c5.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",t),new z_t(`Acquiring an exclusive Navigator LockManager lock "${t}" immediately failed`);if(c5.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 $_t(){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 jVe(t){if(!/^0x[a-fA-F0-9]{40}$/.test(t))throw new Error(`@supabase/auth-js: Address "${t}" is invalid.`);return t.toLowerCase()}function q_t(t){return parseInt(t,16)}function U_t(t){const s=new TextEncoder().encode(t);return"0x"+Array.from(s,n=>n.toString(16).padStart(2,"0")).join("")}function V_t(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 b=jVe(t.address),_=p?`${p}://${n}`:n,j=t.statement?`${t.statement} `:"",w=`${_} wants you to sign in with your Ethereum account: ${b} ${j}`;let N=`URI: ${f} Version: ${g} Chain ID: ${r}${l?` Nonce: ${l}`:""} Issued At: ${o.toISOString()}`;if(a&&(N+=` Expiration Time: ${a.toISOString()}`),i&&(N+=` Not Before: ${i.toISOString()}`),c&&(N+=` Request ID: ${c}`),u){let C=` 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}`);C+=` - ${M}`}N+=C}return`${w} ${N}`}class Kd 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 poe extends Kd{constructor(s,r){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:s}),this.name="WebAuthnUnknownError",this.originalError=r}}function H_t({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 Kd({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 Kd({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 Kd({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 Kd({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 Kd({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:t});if(t.name==="NotAllowedError")return new Kd({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 Kd({message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:t}):new Kd({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(NVe(l)){if(o.rp.id!==l)return new Kd({message:`The RP ID "${o.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Kd({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 Kd({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 Kd({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 Kd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}function W_t({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 Kd({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else{if(t.name==="NotAllowedError")return new Kd({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});if(t.name==="SecurityError"){const n=window.location.hostname;if(NVe(n)){if(r.rpId!==n)return new Kd({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:t})}else return new Kd({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:t})}else if(t.name==="UnknownError")return new Kd({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 Kd({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}class G_t{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 K_t=new G_t;function Z_t(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=Nw(t,["challenge","user","excludeCredentials"]),o=KM(s).buffer,l=Object.assign(Object.assign({},r),{id:KM(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]=foe(i,l):n[o]=foe(l)}else n[o]=l}return n}function rwt(t,s){return foe(twt,t,s||{})}function nwt(t,s){return foe(swt,t,s||{})}class awt{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??K_t.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=rwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.create),{data:p,error:f}=await J_t({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=nwt(l.webauthn.credential_options.publicKey,o==null?void 0:o.request),{data:p,error:f}=await ewt(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 Fa(l)?{data:null,error:l}:{data:null,error:new i4("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 H8("rpId is required for WebAuthn authentication")};try{if(!DEe())return{data:null,error:new i4("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 Fa(l)?{data:null,error:l}:{data:null,error:new i4("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 H8("rpId is required for WebAuthn registration")};try{if(!DEe())return{data:null,error:new i4("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 Fa(l)?{data:null,error:l}:{data:null,error:new i4("Unexpected error in register",l)}}}}$_t();const iwt={url:s_t,storageKey:r_t,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:n_t,flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1};async function OEe(t,s,r){return await r()}const d5={};class W8{get jwks(){var s,r;return(r=(s=d5[this.storageKey])===null||s===void 0?void 0:s.jwks)!==null&&r!==void 0?r:{keys:[]}}set jwks(s){d5[this.storageKey]=Object.assign(Object.assign({},d5[this.storageKey]),{jwks:s})}get jwks_cached_at(){var s,r;return(r=(s=d5[this.storageKey])===null||s===void 0?void 0:s.cachedAt)!==null&&r!==void 0?r:Number.MIN_SAFE_INTEGER}set jwks_cached_at(s){d5[this.storageKey]=Object.assign(Object.assign({},d5[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=W8.nextInstanceID,W8.nextInstanceID+=1,this.instanceID>0&&xm()&&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({},iwt),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 F_t({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=_Ve(a.fetch),this.lock=a.lock||OEe,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,a.lock?this.lock=a.lock:xm()&&(!((r=globalThis==null?void 0:globalThis.navigator)===null||r===void 0)&&r.locks)?this.lock=B_t:this.lock=OEe,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 awt(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:bVe()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=LEe(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=LEe(this.memoryStorage)),xm()&&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} (${gVe}) ${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=y_t(window.location.href);let n="none";if(this._isImplicitGrantCallback(r)?n="implicit":await this._isPKCECallback(r)&&(n="pkce"),xm()&&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),d_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 Fa(r)?{error:r}:{error:new i4("Unexpected error during initialization",r)}}finally{await this._handleVisibilityChange(),this._debug("#_initialize()","end")}}async signInAnonymously(s){var r,n,a;try{const o=await wi(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:Sg}),{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(Fa(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 b=null,_=null;this.flowType==="pkce"&&([b,_]=await o5(this.storage,this.storageKey)),o=await wi(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:b,code_challenge_method:_},xform:Sg})}else if("phone"in s){const{phone:p,password:f,options:g}=s;o=await wi(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:Sg})}else throw new H7("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(Fa(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 wi(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:PEe})}else if("phone"in s){const{phone:o,password:l,options:i}=s;r=await wi(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:PEe})}else throw new H7("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 i5}:(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(Fa(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 b,_;if("message"in s)b=s.message,_=s.signature;else{const{chain:j,wallet:w,statement:N,options:C}=s;let M;if(xm())if(typeof w=="object")M=w;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 w!="object"||!(C!=null&&C.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");M=w}const I=new URL((r=C==null?void 0:C.url)!==null&&r!==void 0?r:window.location.href),L=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(!L||L.length===0)throw new Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");const R=jVe(L[0]);let q=(n=C==null?void 0:C.signInWithEthereum)===null||n===void 0?void 0:n.chainId;if(!q){const B=await M.request({method:"eth_chainId"});q=q_t(B)}const U={domain:I.host,address:R,statement:N,uri:I.href,version:"1",chainId:q,nonce:(a=C==null?void 0:C.signInWithEthereum)===null||a===void 0?void 0:a.nonce,issuedAt:(l=(o=C==null?void 0:C.signInWithEthereum)===null||o===void 0?void 0:o.issuedAt)!==null&&l!==void 0?l:new Date,expirationTime:(i=C==null?void 0:C.signInWithEthereum)===null||i===void 0?void 0:i.expirationTime,notBefore:(c=C==null?void 0:C.signInWithEthereum)===null||c===void 0?void 0:c.notBefore,requestId:(u=C==null?void 0:C.signInWithEthereum)===null||u===void 0?void 0:u.requestId,resources:(p=C==null?void 0:C.signInWithEthereum)===null||p===void 0?void 0:p.resources};b=V_t(U),_=await M.request({method:"personal_sign",params:[U_t(b),R]})}try{const{data:j,error:w}=await wi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"ethereum",message:b,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:Sg});if(w)throw w;return!j||!j.session||!j.user?{data:{user:null,session:null},error:new i5}:(j.session&&(await this._saveSession(j.session),await this._notifyAllSubscribers("SIGNED_IN",j.session)),{data:Object.assign({},j),error:w})}catch(j){if(Fa(j))return{data:{user:null,session:null},error:j};throw j}}async signInWithSolana(s){var r,n,a,o,l,i,c,u,p,f,g,b;let _,j;if("message"in s)_=s.message,j=s.signature;else{const{chain:w,wallet:N,statement:C,options:M}=s;let I;if(xm())if(typeof N=="object")I=N;else{const R=window;if("solana"in R&&typeof R.solana=="object"&&("signIn"in R.solana&&typeof R.solana.signIn=="function"||"signMessage"in R.solana&&typeof R.solana.signMessage=="function"))I=R.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 N!="object"||!(M!=null&&M.url))throw new Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");I=N}const L=new URL((r=M==null?void 0:M.url)!==null&&r!==void 0?r:window.location.href);if("signIn"in I&&I.signIn){const R=await I.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},M==null?void 0:M.signInWithSolana),{version:"1",domain:L.host,uri:L.href}),C?{statement:C}:null));let q;if(Array.isArray(R)&&R[0]&&typeof R[0]=="object")q=R[0];else if(R&&typeof R=="object"&&"signedMessage"in R&&"signature"in R)q=R;else throw new Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in q&&"signature"in q&&(typeof q.signedMessage=="string"||q.signedMessage instanceof Uint8Array)&&q.signature instanceof Uint8Array)_=typeof q.signedMessage=="string"?q.signedMessage:new TextDecoder().decode(q.signedMessage),j=q.signature;else throw new Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields")}else{if(!("signMessage"in I)||typeof I.signMessage!="function"||!("publicKey"in I)||typeof I!="object"||!I.publicKey||!("toBase58"in I.publicKey)||typeof I.publicKey.toBase58!="function")throw new Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");_=[`${L.host} wants you to sign in with your Solana account:`,I.publicKey.toBase58(),...C?["",C,""]:[""],"Version: 1",`URI: ${L.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(q=>`- ${q}`)]:[]].join(` `);const R=await I.signMessage(new TextEncoder().encode(_),"utf8");if(!R||!(R instanceof Uint8Array))throw new Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");j=R}}try{const{data:w,error:N}=await wi(this.fetch,"POST",`${this.url}/token?grant_type=web3`,{headers:this.headers,body:Object.assign({chain:"solana",message:_,signature:m4(j)},!((g=s.options)===null||g===void 0)&&g.captchaToken?{gotrue_meta_security:{captcha_token:(b=s.options)===null||b===void 0?void 0:b.captchaToken}}:null),xform:Sg});if(N)throw N;return!w||!w.session||!w.user?{data:{user:null,session:null},error:new i5}:(w.session&&(await this._saveSession(w.session),await this._notifyAllSubscribers("SIGNED_IN",w.session)),{data:Object.assign({},w),error:N})}catch(w){if(Fa(w))return{data:{user:null,session:null},error:w};throw w}}async _exchangeCodeForSession(s){const r=await I2(this.storage,`${this.storageKey}-code-verifier`),[n,a]=(r??"").split("/");try{const{data:o,error:l}=await wi(this.fetch,"POST",`${this.url}/token?grant_type=pkce`,{headers:this.headers,body:{auth_code:s,code_verifier:n},xform:Sg});if(await Ab(this.storage,`${this.storageKey}-code-verifier`),l)throw l;return!o||!o.session||!o.user?{data:{user:null,session:null,redirectType:null},error:new i5}:(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(Fa(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 wi(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:Sg}),{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 i5}:(c.session&&(await this._saveSession(c.session),await this._notifyAllSubscribers("SIGNED_IN",c.session)),{data:c,error:u})}catch(r){if(Fa(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 o5(this.storage,this.storageKey));const{error:f}=await wi(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 wi(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 H7("You must provide either an email or phone number.")}catch(i){if(Fa(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 wi(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},s),{gotrue_meta_security:{captcha_token:o}}),redirectTo:a,xform:Sg});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(Fa(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 o5(this.storage,this.storageKey)),await wi(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:D_t})}catch(o){if(Fa(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 kg;const{error:a}=await wi(this.fetch,"GET",`${this.url}/reauthenticate`,{headers:this.headers,jwt:r.access_token});return{data:{user:null,session:null},error:a}})}catch(s){if(Fa(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 wi(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 wi(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 H7("You must provide either an email or phone number and a type")}catch(r){if(Fa(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 I2(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 wi(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:s,xform:s_}):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 kg}:await wi(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:s_})})}catch(r){if(Fa(r))return c_t(r)&&(await this._removeSession(),await Ab(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 kg;const l=a.session;let i=null,c=null;this.flowType==="pkce"&&s.email!=null&&([i,c]=await o5(this.storage,this.storageKey));const{data:u,error:p}=await wi(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:s_});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(Fa(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 kg;const r=Date.now()/1e3;let n=r,a=!0,o=null;const{payload:l}=cxe(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(Fa(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 kg;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(Fa(r))return{data:{user:null,session:null},error:r};throw r}}async _getSessionFromURL(s,r){try{if(!xm())throw new W7("No browser detected.");if(s.error||s.error_description||s.error_code)throw new W7(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 kEe("Not a valid PKCE flow url.");break;case"pkce":if(this.flowType==="implicit")throw new W7("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 kEe("No code detected.");const{data:C,error:M}=await this._exchangeCodeForSession(s.code);if(M)throw M;const I=new URL(window.location.href);return I.searchParams.delete("code"),window.history.replaceState(window.history.state,"",I.toString()),{data:{session:C.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 W7("No session defined in URL");const p=Math.round(Date.now()/1e3),f=parseInt(i);let g=p+f;c&&(g=parseInt(c));const b=g-p;b*1e3<=E5&&console.warn(`@supabase/gotrue-js: Session as retrieved from URL expires in ${b}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:j,error:w}=await this._getUser(o);if(w)throw w;const N={provider_token:n,provider_refresh_token:a,access_token:o,expires_in:f,expires_at:g,refresh_token:l,token_type:u,user:j.user};return window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),{data:{session:N,redirectType:s.type},error:null}}catch(n){if(Fa(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 I2(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&&!(l_t(i)&&(i.status===404||i.status===401||i.status===403)))return{error:i}}return s!=="others"&&(await this._removeSession(),await Ab(this.storage,`${this.storageKey}-code-verifier`)),{error:null}})}onAuthStateChange(s){const r=g_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 o5(this.storage,this.storageKey,!0));try{return await wi(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(Fa(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(Fa(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 b=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 wi(this.fetch,"GET",b,{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 xm()&&!(!((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(Fa(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 wi(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:Sg}),{data:g,error:b}=f;return b?{data:{user:null,session:null},error:b}:!g||!g.session||!g.user?{data:{user:null,session:null},error:new i5}:(g.session&&(await this._saveSession(g.session),await this._notifyAllSubscribers("USER_UPDATED",g.session)),{data:g,error:b})}catch(a){if(Fa(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 wi(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(Fa(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 __t(async a=>(a>0&&await b_t(200*Math.pow(2,a-1)),this._debug(r,"refreshing attempt",a),await wi(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:s},headers:this.headers,xform:Sg})),(a,o)=>{const l=200*Math.pow(2,a);return o&&lxe(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(),E5);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)/E5);this._debug("#_autoRefreshTokenTick()",`access token expires in ${a} ticks, a tick lasts ${E5}ms, refresh threshold is ${pve} ticks`),a<=pve&&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 wVe)this._debug("auto refresh token tick lock not available");else throw s}}async _handleVisibilityChange(){if(this._debug("#_handleVisibilityChange()"),!xm()||!(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 o5(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 wi(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(Fa(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 wi(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(Fa(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"?X_t(s.webauthn.credential_response):Q_t(s.webauthn.credential_response)})}:{code:s.code}),{data:i,error:c}=await wi(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(Fa(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 wi(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:Z_t(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:Y_t(i.webauthn.credential_options.publicKey)})})}),error:null}}})}catch(r){if(Fa(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}=cxe(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 wi(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 kg}})}catch(r){if(Fa(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 kg};const l=await wi(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&&xm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Fa(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 kg};const l=await wi(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&&xm()&&!(r!=null&&r.skipBrowserRedirect)&&window.location.assign(l.data.redirect_url),l})}catch(n){if(Fa(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+i_t>a)return n;const{data:o,error:l}=await wi(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:b,error:_}=await this.getSession();if(_||!b.session)return{data:null,error:_};n=b.session.access_token}const{header:a,payload:o,signature:l,raw:{header:i,payload:c}}=cxe(n);r!=null&&r.allowExpired||M_t(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:b}=await this.getUser(n);if(b)throw b;return{data:{claims:o,header:a,signature:l},error:null}}const p=T_t(a.alg),f=await crypto.subtle.importKey("jwk",u,p,!0,["verify"]);if(!await crypto.subtle.verify(p,f,l,f_t(`${i}.${c}`)))throw new gve("Invalid JWT signature");return{data:{claims:o,header:a,signature:l},error:null}}catch(n){if(Fa(n))return{data:null,error:n};throw n}}}W8.nextInstanceID=0;const owt=W8;class lwt extends owt{constructor(s){super(s)}}class cwt{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:Gbt,realtime:Zbt,auth:Object.assign(Object.assign({},Kbt),{storageKey:c}),global:Wbt},p=e_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=Qbt(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 sbt(new URL("rest/v1",i).href,{headers:this.headers,schema:p.db.schema,fetch:this.fetch}),this.storage=new Ubt(this.storageUrl.href,this.headers,this.fetch,n==null?void 0:n.storage),p.accessToken||this._listenForAuthEvents()}get functions(){return new K1t(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 lwt({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(b=>b.toLowerCase()==="authorization")})}_initRealtimeClient(s){return new vbt(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 dwt=(t,s,r)=>new cwt(t,s,r);function uwt(){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}uwt()&&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 hwt="https://relzejiswnotikjgvjhz.supabase.co",mwt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM",H=dwt(hwt,mwt,{auth:{storage:localStorage,persistSession:!0,autoRefreshToken:!0}}),kVe=k.createContext(void 0),pwt=({children:t})=>{const[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(null),[j,w]=k.useState([]),[N,C]=k.useState(null),M=pr(),I=()=>{p(!1),g(!1),_(null),w([]),C(null)},L=async B=>{c(!0);try{console.log("Checking roles via RPC for user:",B);const[{data:V,error:Y},{data:J,error:te}]=await Promise.all([H.rpc("has_role",{_user_id:B,_role:"admin"}),H.rpc("has_role",{_user_id:B,_role:"brokerage_manager"})]);if(Y||te)console.error("Role RPC errors:",{isAdminError:Y,isBrokerError:te}),p(!1),g(!1);else{const ne=!!V,re=!!J;console.log("RPC roles result:",{adminValue:ne,brokerValue:re}),p(ne),g(re)}const{data:X,error:ce}=await H.from("profiles").select("brokerage_id").eq("id",B).single();if(_(!ce&&X?X.brokerage_id:null),J){console.log("Fetching managed brokerages for user:",B);const{data:ne,error:re}=await H.from("brokerage_manager_assignments").select("brokerage_id").eq("user_id",B);if(console.log("Managed brokerage assignments result:",{assignments:ne,assignmentsError:re}),re||!ne){console.error("Error fetching managed brokerage assignments:",re),w([]);return}const le=Array.from(new Set(ne.map(fe=>fe.brokerage_id).filter(Boolean)));if(le.length===0){w([]);return}const{data:pe,error:xe}=await H.from("brokerages").select("id, name").in("id",le);if(console.log("Managed brokerages details result:",{brokeragesData:pe,brokeragesError:xe}),xe||!pe){console.error("Error fetching managed brokerages details:",xe),w([]);return}const _e=pe.map(fe=>({id:fe.id,name:fe.name})).sort((fe,we)=>le.indexOf(fe.id)-le.indexOf(we.id));console.log("Parsed managed brokerages:",_e),w(_e),_e.length>0&&C(fe=>fe??_e[0].id)}else console.log("User is not a brokerage manager, skipping managed brokerages fetch"),w([])}catch(V){console.error("Unexpected error in checkRoles:",V),I()}finally{c(!1)}};k.useEffect(()=>{let B=!0,V=!1;const Y=()=>{!B||V||(V=!0,l(!1))},{data:{subscription:J}}=H.auth.onAuthStateChange((ce,ne)=>{console.log("Auth event:",ce),B&&(a(ne),r((ne==null?void 0:ne.user)??null),Y(),ce==="PASSWORD_RECOVERY"&&(console.log("Password recovery detected, redirecting to profile"),setTimeout(()=>{M("/profile?reset=true")},100)),ne!=null&&ne.user?setTimeout(()=>{L(ne.user.id)},0):(I(),c(!1)))}),te=window.setTimeout(()=>{console.warn("Auth initialization timeout reached. Continuing without blocking UI."),Y()},4e3);return(async()=>{try{const{data:{session:ce}}=await H.auth.getSession();if(!B)return;a(ce),r((ce==null?void 0:ce.user)??null),ce!=null&&ce.user?await L(ce.user.id):I()}catch(ce){console.error("Error restoring auth session:",ce),B&&(a(null),r(null),I())}finally{Y()}})(),()=>{B=!1,window.clearTimeout(te),J.unsubscribe()}},[]);const R=async(B,V)=>{const{error:Y}=await H.auth.signInWithPassword({email:B,password:V});if(Y)throw he.error(Y.message),Y;he.success("Welcome back!"),M("/dashboard")},q=async(B,V,Y)=>{const J=`${window.location.origin}/dashboard`,{error:te}=await H.auth.signUp({email:B,password:V,options:{emailRedirectTo:J,data:{name:Y}}});if(te)throw he.error(te.message),te;he.success("Account created! Welcome to LevelUp."),M("/dashboard")},U=async()=>{try{const{data:{session:B}}=await H.auth.getSession();if(B){const{error:V}=await H.auth.signOut();V?V.message==="Auth session missing!"?console.warn("Sign out warning (ignored):",V.message):(console.error("Sign out error:",V),he.error(V.message)):he.success("Signed out successfully")}else console.log("No active session found, redirecting to auth");r(null),a(null),p(!1),g(!1),_(null),w([]),C(null),M("/auth")}catch(B){console.error("Unexpected sign out error:",B),M("/auth")}};return e.jsx(kVe.Provider,{value:{user:s,session:n,loading:o,rolesLoading:i,signIn:R,signUp:q,signOut:U,isAdmin:u,isBrokerageManager:f,brokerageId:b,managedBrokerages:j,selectedBrokerageId:N,setSelectedBrokerageId:C},children:t})},Rs=()=>{const t=k.useContext(kVe);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t},SVe=k.createContext(void 0),L2="levelup_admin_session",Eb="levelup_impersonation",fwt=({children:t})=>{const[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1);k.useEffect(()=>{const u=sessionStorage.getItem(Eb);if(u)try{const p=JSON.parse(u);r(!0),a(p)}catch{sessionStorage.removeItem(Eb)}},[]);const i=async u=>{l(!0);try{const{data:{session:p}}=await H.auth.getSession();if(!p)return he.error("No active session found"),!1;const f={access_token:p.access_token,refresh_token:p.refresh_token};sessionStorage.setItem(L2,JSON.stringify(f));const g=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/impersonate-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${p.access_token}`},body:JSON.stringify({targetUserId:u})}),b=await g.json();if(!g.ok)throw new Error(b.error||"Failed to impersonate user");const _={id:b.targetUser.id,name:b.targetUser.name,email:b.targetUser.email};if(sessionStorage.setItem(Eb,JSON.stringify(_)),b.method==="session"){const{error:j}=await H.auth.setSession({access_token:b.access_token,refresh_token:b.refresh_token});if(j)throw console.error("Set session error:",j),sessionStorage.removeItem(L2),sessionStorage.removeItem(Eb),new Error("Failed to establish impersonation session")}else{const j=b.type||"recovery",{error:w}=await H.auth.verifyOtp({token_hash:b.token_hash,type:j});if(w)throw console.error("Verify OTP error:",w),sessionStorage.removeItem(L2),sessionStorage.removeItem(Eb),new Error("Failed to establish impersonation session")}return r(!0),a(_),he.success(`Now viewing as ${_.name}`),window.location.href="/dashboard",!0}catch(p){return console.error("Impersonation error:",p),he.error(p.message||"Failed to impersonate user"),sessionStorage.removeItem(L2),sessionStorage.removeItem(Eb),!1}finally{l(!1)}},c=async()=>{l(!0);try{const u=sessionStorage.getItem(L2);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(L2),sessionStorage.removeItem(Eb),f){console.error("Failed to restore admin session:",f),he.error("Admin session expired, please sign in again"),window.location.href="/auth";return}r(!1),a(null),he.success("Returned to admin account"),window.location.href="/admin/members"}catch(u){console.error("Stop impersonation error:",u),he.error("Failed to restore admin session"),sessionStorage.removeItem(L2),sessionStorage.removeItem(Eb),window.location.href="/auth"}finally{l(!1)}};return e.jsx(SVe.Provider,{value:{isImpersonating:s,impersonatedUser:n,startImpersonation:i,stopImpersonation:c,isLoading:o},children:t})},V2e=()=>{const t=k.useContext(SVe);if(t===void 0)throw new Error("useImpersonation must be used within an ImpersonationProvider");return t},G8=lC("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=k.forwardRef(({className:t,variant:s,size:r,asChild:n=!1,...a},o)=>{const l=n?o2e:"button";return e.jsx(l,{className:Pt(G8({variant:s,size:r,className:t})),ref:o,...a})});K.displayName="Button";const xwt=()=>{const{isImpersonating:t,impersonatedUser:s,stopImpersonation:r,isLoading:n}=V2e();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(Gu,{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(ws,{className:"h-4 w-4 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Or,{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"})]})})]})})},CVe=k.createContext(void 0),u5="levelup_acting_as",G7="levelup_acting_as_self",gwt=({children:t})=>{const{user:s}=Rs(),[r,n]=k.useState(!1),[a,o]=k.useState([]),[l,i]=k.useState(null),[c,u]=k.useState({}),[p,f]=k.useState(!0),[g,b]=k.useState(()=>sessionStorage.getItem(G7)==="true");k.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:I,error:L}=await H.from("agent_assistant_assignments").select("agent_id, permissions").eq("assistant_id",s.id);if(L||!I||I.length===0){o([]),f(!1);return}const R=I.map(B=>B.agent_id),{data:q}=await H.from("profiles").select("id, name, email, avatar_url").in("id",R),U=(q||[]).map(B=>({id:B.id,name:B.name||B.email||"Unknown",email:B.email||"",avatar_url:B.avatar_url}));if(o(U),sessionStorage.getItem(G7)==="true")b(!0),i(null),u({});else{const B=sessionStorage.getItem(u5);if(B){const V=U.find(Y=>Y.id===B);if(V){i(V);const Y=I.find(J=>J.agent_id===B);u((Y==null?void 0:Y.permissions)||{})}else if(U.length>0){i(U[0]);const Y=I.find(J=>J.agent_id===U[0].id);u((Y==null?void 0:Y.permissions)||{}),sessionStorage.setItem(u5,U[0].id)}}else if(U.length>0){i(U[0]);const V=I.find(Y=>Y.agent_id===U[0].id);u((V==null?void 0:V.permissions)||{}),sessionStorage.setItem(u5,U[0].id)}}}catch(M){console.error("Error loading assistant data:",M)}finally{f(!1)}})()},[s==null?void 0:s.id]);const _=C=>{i(C),b(!1),sessionStorage.removeItem(G7),C?(sessionStorage.setItem(u5,C.id),H.from("agent_assistant_assignments").select("permissions").eq("assistant_id",(s==null?void 0:s.id)||"").eq("agent_id",C.id).single().then(({data:M})=>{u((M==null?void 0:M.permissions)||{})})):(sessionStorage.removeItem(u5),u({}))},j=()=>{b(!0),i(null),u({}),sessionStorage.setItem(G7,"true"),sessionStorage.removeItem(u5)},w=C=>!r||g?!0:c[C]===!0,N=r&&l&&!g?l.id:(s==null?void 0:s.id)||null;return e.jsx(CVe.Provider,{value:{isAssistant:r,assignedAgents:a,actingAsAgent:l,setActingAsAgent:_,effectiveUserId:N,permissions:c,hasPermission:w,isLoading:p,isActingAsSelf:g,setActingAsSelf:j},children:t})},H2e=()=>{const t=k.useContext(CVe);if(t===void 0)throw new Error("useActingAs must be used within an ActingAsProvider");return t},li=()=>{const{effectiveUserId:t}=H2e();return t};var MVe={exports:{}},TVe={};/** * @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 IT=k;function ywt(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var vwt=typeof Object.is=="function"?Object.is:ywt,bwt=IT.useState,_wt=IT.useEffect,wwt=IT.useLayoutEffect,jwt=IT.useDebugValue;function Nwt(t,s){var r=s(),n=bwt({inst:{value:r,getSnapshot:s}}),a=n[0].inst,o=n[1];return wwt(function(){a.value=r,a.getSnapshot=s,hxe(a)&&o({inst:a})},[t,r,s]),_wt(function(){return hxe(a)&&o({inst:a}),t(function(){hxe(a)&&o({inst:a})})},[t]),jwt(r),r}function hxe(t){var s=t.getSnapshot;t=t.value;try{var r=s();return!vwt(t,r)}catch{return!0}}function kwt(t,s){return s()}var Swt=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?kwt:Nwt;TVe.useSyncExternalStore=IT.useSyncExternalStore!==void 0?IT.useSyncExternalStore:Swt;MVe.exports=TVe;var Cwt=MVe.exports;function Mwt(){return Cwt.useSyncExternalStore(Twt,()=>!0,()=>!1)}function Twt(){return()=>{}}var W2e="Avatar",[Awt]=nd(W2e),[Ewt,AVe]=Awt(W2e),EVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,...n}=t,[a,o]=k.useState("idle");return e.jsx(Ewt,{scope:r,imageLoadingStatus:a,onImageLoadingStatusChange:o,children:e.jsx(sn.span,{...n,ref:s})})});EVe.displayName=W2e;var PVe="AvatarImage",IVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,src:n,onLoadingStatusChange:a=()=>{},...o}=t,l=AVe(PVe,r),i=Pwt(n,o),c=gd(u=>{a(u),l.onImageLoadingStatusChange(u)});return wd(()=>{i!=="idle"&&c(i)},[i,c]),i==="loaded"?e.jsx(sn.img,{...o,ref:s,src:n}):null});IVe.displayName=PVe;var LVe="AvatarFallback",DVe=k.forwardRef((t,s)=>{const{__scopeAvatar:r,delayMs:n,...a}=t,o=AVe(LVe,r),[l,i]=k.useState(n===void 0);return k.useEffect(()=>{if(n!==void 0){const c=window.setTimeout(()=>i(!0),n);return()=>window.clearTimeout(c)}},[n]),l&&o.imageLoadingStatus!=="loaded"?e.jsx(sn.span,{...a,ref:s}):null});DVe.displayName=LVe;function REe(t,s){return t?s?(t.src!==s&&(t.src=s),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Pwt(t,{referrerPolicy:s,crossOrigin:r}){const n=Mwt(),a=k.useRef(null),o=n?(a.current||(a.current=new window.Image),a.current):null,[l,i]=k.useState(()=>REe(o,t));return wd(()=>{i(REe(o,t))},[o,t]),wd(()=>{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 OVe=EVe,RVe=IVe,FVe=DVe;const _n=k.forwardRef(({className:t,...s},r)=>e.jsx(OVe,{ref:r,className:Pt("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...s}));_n.displayName=OVe.displayName;const za=k.forwardRef(({className:t,...s},r)=>e.jsx(RVe,{ref:r,className:Pt("aspect-square h-full w-full",t),...s}));za.displayName=RVe.displayName;const wn=k.forwardRef(({className:t,...s},r)=>e.jsx(FVe,{ref:r,className:Pt("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...s}));wn.displayName=FVe.displayName;const Iwt=lC("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 tt({className:t,variant:s,...r}){return e.jsx("div",{className:Pt(Iwt({variant:s}),t),...r})}var Lwt=k.createContext(void 0);function Sw(t){const s=k.useContext(Lwt);return t||s||"ltr"}var mxe=0;function Ade(){k.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??FEe()),document.body.insertAdjacentElement("beforeend",t[1]??FEe()),mxe++,()=>{mxe===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(s=>s.remove()),mxe--}},[])}function FEe(){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 pxe="focusScope.autoFocusOnMount",fxe="focusScope.autoFocusOnUnmount",zEe={bubbles:!1,cancelable:!0},Dwt="FocusScope",wO=k.forwardRef((t,s)=>{const{loop:r=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:o,...l}=t,[i,c]=k.useState(null),u=gd(a),p=gd(o),f=k.useRef(null),g=$a(s,j=>c(j)),b=k.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;k.useEffect(()=>{if(n){let j=function(M){if(b.paused||!i)return;const I=M.target;i.contains(I)?f.current=I:Fb(f.current,{select:!0})},w=function(M){if(b.paused||!i)return;const I=M.relatedTarget;I!==null&&(i.contains(I)||Fb(f.current,{select:!0}))},N=function(M){if(document.activeElement===document.body)for(const L of M)L.removedNodes.length>0&&Fb(i)};document.addEventListener("focusin",j),document.addEventListener("focusout",w);const C=new MutationObserver(N);return i&&C.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",w),C.disconnect()}}},[n,i,b.paused]),k.useEffect(()=>{if(i){$Ee.add(b);const j=document.activeElement;if(!i.contains(j)){const N=new CustomEvent(pxe,zEe);i.addEventListener(pxe,u),i.dispatchEvent(N),N.defaultPrevented||(Owt($wt(zVe(i)),{select:!0}),document.activeElement===j&&Fb(i))}return()=>{i.removeEventListener(pxe,u),setTimeout(()=>{const N=new CustomEvent(fxe,zEe);i.addEventListener(fxe,p),i.dispatchEvent(N),N.defaultPrevented||Fb(j??document.body,{select:!0}),i.removeEventListener(fxe,p),$Ee.remove(b)},0)}}},[i,u,p,b]);const _=k.useCallback(j=>{if(!r&&!n||b.paused)return;const w=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,N=document.activeElement;if(w&&N){const C=j.currentTarget,[M,I]=Rwt(C);M&&I?!j.shiftKey&&N===I?(j.preventDefault(),r&&Fb(M,{select:!0})):j.shiftKey&&N===M&&(j.preventDefault(),r&&Fb(I,{select:!0})):N===C&&j.preventDefault()}},[r,n,b.paused]);return e.jsx(sn.div,{tabIndex:-1,...l,ref:g,onKeyDown:_})});wO.displayName=Dwt;function Owt(t,{select:s=!1}={}){const r=document.activeElement;for(const n of t)if(Fb(n,{select:s}),document.activeElement!==r)return}function Rwt(t){const s=zVe(t),r=BEe(s,t),n=BEe(s.reverse(),t);return[r,n]}function zVe(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 BEe(t,s){for(const r of t)if(!Fwt(r,{upTo:s}))return r}function Fwt(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 zwt(t){return t instanceof HTMLInputElement&&"select"in t}function Fb(t,{select:s=!1}={}){if(t&&t.focus){const r=document.activeElement;t.focus({preventScroll:!0}),t!==r&&zwt(t)&&s&&t.select()}}var $Ee=Bwt();function Bwt(){let t=[];return{add(s){const r=t[0];s!==r&&(r==null||r.pause()),t=qEe(t,s),t.unshift(s)},remove(s){var r;t=qEe(t,s),(r=t[0])==null||r.resume()}}}function qEe(t,s){const r=[...t],n=r.indexOf(s);return n!==-1&&r.splice(n,1),r}function $wt(t){return t.filter(s=>s.tagName!=="A")}var xxe="rovingFocusGroup.onEntryFocus",qwt={bubbles:!1,cancelable:!0},jO="RovingFocusGroup",[yve,BVe,Uwt]=pO(jO),[Vwt,Cw]=nd(jO,[Uwt]),[Hwt,Wwt]=Vwt(jO),$Ve=k.forwardRef((t,s)=>e.jsx(yve.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(yve.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Gwt,{...t,ref:s})})}));$Ve.displayName=jO;var Gwt=k.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=k.useRef(null),b=$a(s,g),_=Sw(o),[j,w]=rh({prop:l,defaultProp:i??null,onChange:c,caller:jO}),[N,C]=k.useState(!1),M=gd(u),I=BVe(r),L=k.useRef(!1),[R,q]=k.useState(0);return k.useEffect(()=>{const U=g.current;if(U)return U.addEventListener(xxe,M),()=>U.removeEventListener(xxe,M)},[M]),e.jsx(Hwt,{scope:r,orientation:n,dir:_,loop:a,currentTabStopId:j,onItemFocus:k.useCallback(U=>w(U),[w]),onItemShiftTab:k.useCallback(()=>C(!0),[]),onFocusableItemAdd:k.useCallback(()=>q(U=>U+1),[]),onFocusableItemRemove:k.useCallback(()=>q(U=>U-1),[]),children:e.jsx(sn.div,{tabIndex:N||R===0?-1:0,"data-orientation":n,...f,ref:b,style:{outline:"none",...t.style},onMouseDown:Ir(t.onMouseDown,()=>{L.current=!0}),onFocus:Ir(t.onFocus,U=>{const B=!L.current;if(U.target===U.currentTarget&&B&&!N){const V=new CustomEvent(xxe,qwt);if(U.currentTarget.dispatchEvent(V),!V.defaultPrevented){const Y=I().filter(ne=>ne.focusable),J=Y.find(ne=>ne.active),te=Y.find(ne=>ne.id===j),ce=[J,te,...Y].filter(Boolean).map(ne=>ne.ref.current);VVe(ce,p)}}L.current=!1}),onBlur:Ir(t.onBlur,()=>C(!1))})})}),qVe="RovingFocusGroupItem",UVe=k.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:a=!1,tabStopId:o,children:l,...i}=t,c=Mu(),u=o||c,p=Wwt(qVe,r),f=p.currentTabStopId===u,g=BVe(r),{onFocusableItemAdd:b,onFocusableItemRemove:_,currentTabStopId:j}=p;return k.useEffect(()=>{if(n)return b(),()=>_()},[n,b,_]),e.jsx(yve.ItemSlot,{scope:r,id:u,focusable:n,active:a,children:e.jsx(sn.span,{tabIndex:f?0:-1,"data-orientation":p.orientation,...i,ref:s,onMouseDown:Ir(t.onMouseDown,w=>{n?p.onItemFocus(u):w.preventDefault()}),onFocus:Ir(t.onFocus,()=>p.onItemFocus(u)),onKeyDown:Ir(t.onKeyDown,w=>{if(w.key==="Tab"&&w.shiftKey){p.onItemShiftTab();return}if(w.target!==w.currentTarget)return;const N=Ywt(w,p.orientation,p.dir);if(N!==void 0){if(w.metaKey||w.ctrlKey||w.altKey||w.shiftKey)return;w.preventDefault();let M=g().filter(I=>I.focusable).map(I=>I.ref.current);if(N==="last")M.reverse();else if(N==="prev"||N==="next"){N==="prev"&&M.reverse();const I=M.indexOf(w.currentTarget);M=p.loop?Xwt(M,I+1):M.slice(I+1)}setTimeout(()=>VVe(M))}}),children:typeof l=="function"?l({isCurrentTabStop:f,hasTabStop:j!=null}):l})})});UVe.displayName=qVe;var Kwt={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Zwt(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Ywt(t,s,r){const n=Zwt(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Kwt[n]}function VVe(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function Xwt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var Ede=$Ve,Pde=UVe,Qwt=function(t){if(typeof document>"u")return null;var s=Array.isArray(t)?t[0]:t;return s.ownerDocument.body},h5=new WeakMap,K7=new WeakMap,Z7={},gxe=0,HVe=function(t){return t&&(t.host||HVe(t.parentNode))},Jwt=function(t,s){return s.map(function(r){if(t.contains(r))return r;var n=HVe(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})},e2t=function(t,s,r,n){var a=Jwt(s,Array.isArray(t)?t:[t]);Z7[r]||(Z7[r]=new WeakMap);var o=Z7[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 b=g.getAttribute(n),_=b!==null&&b!=="false",j=(h5.get(g)||0)+1,w=(o.get(g)||0)+1;h5.set(g,j),o.set(g,w),l.push(g),j===1&&_&&K7.set(g,!0),w===1&&g.setAttribute(r,"true"),_||g.setAttribute(n,"true")}catch(N){console.error("aria-hidden: cannot operate on ",g,N)}})};return p(s),i.clear(),gxe++,function(){l.forEach(function(f){var g=h5.get(f)-1,b=o.get(f)-1;h5.set(f,g),o.set(f,b),g||(K7.has(f)||f.removeAttribute(n),K7.delete(f)),b||f.removeAttribute(r)}),gxe--,gxe||(h5=new WeakMap,h5=new WeakMap,K7=new WeakMap,Z7={})}},Ide=function(t,s,r){r===void 0&&(r="data-aria-hidden");var n=Array.from(Array.isArray(t)?t:[t]),a=Qwt(t);return a?(n.push.apply(n,Array.from(a.querySelectorAll("[aria-live]"))),e2t(n,a,r,"aria-hidden")):function(){return null}},oie="right-scroll-bar-position",lie="width-before-scroll-bar",t2t="with-scroll-bars-hidden",s2t="--removed-body-scroll-bar-size";function yxe(t,s){return typeof t=="function"?t(s):t&&(t.current=s),t}function r2t(t,s){var r=k.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 n2t=typeof window<"u"?k.useLayoutEffect:k.useEffect,UEe=new WeakMap;function a2t(t,s){var r=r2t(null,function(n){return t.forEach(function(a){return yxe(a,n)})});return n2t(function(){var n=UEe.get(r);if(n){var a=new Set(n),o=new Set(t),l=r.current;a.forEach(function(i){o.has(i)||yxe(i,null)}),o.forEach(function(i){a.has(i)||yxe(i,l)})}UEe.set(r,t)},[t]),r}function i2t(t){return t}function o2t(t,s){s===void 0&&(s=i2t);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 l2t(t){t===void 0&&(t={});var s=o2t(null);return s.options=fx({async:!0,ssr:!1},t),s}var WVe=function(t){var s=t.sideCar,r=Nw(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 k.createElement(n,fx({},r))};WVe.isSideCarExport=!0;function c2t(t,s){return t.useMedium(s),WVe}var GVe=l2t(),vxe=function(){},Lde=k.forwardRef(function(t,s){var r=k.useRef(null),n=k.useState({onScrollCapture:vxe,onWheelCapture:vxe,onTouchMoveCapture:vxe}),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,b=t.noRelative,_=t.noIsolation,j=t.inert,w=t.allowPinchZoom,N=t.as,C=N===void 0?"div":N,M=t.gapMode,I=Nw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),L=g,R=a2t([r,s]),q=fx(fx({},I),a);return k.createElement(k.Fragment,null,p&&k.createElement(L,{sideCar:GVe,removeScrollBar:u,shards:f,noRelative:b,noIsolation:_,inert:j,setCallbacks:o,allowPinchZoom:!!w,lockRef:r,gapMode:M}),l?k.cloneElement(k.Children.only(i),fx(fx({},q),{ref:R})):k.createElement(C,fx({},q,{className:c,ref:R}),i))});Lde.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Lde.classNames={fullWidth:lie,zeroRight:oie};var d2t=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function u2t(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var s=d2t();return s&&t.setAttribute("nonce",s),t}function h2t(t,s){t.styleSheet?t.styleSheet.cssText=s:t.appendChild(document.createTextNode(s))}function m2t(t){var s=document.head||document.getElementsByTagName("head")[0];s.appendChild(t)}var p2t=function(){var t=0,s=null;return{add:function(r){t==0&&(s=u2t())&&(h2t(s,r),m2t(s)),t++},remove:function(){t--,!t&&s&&(s.parentNode&&s.parentNode.removeChild(s),s=null)}}},f2t=function(){var t=p2t();return function(s,r){k.useEffect(function(){return t.add(s),function(){t.remove()}},[s&&r])}},KVe=function(){var t=f2t(),s=function(r){var n=r.styles,a=r.dynamic;return t(n,a),null};return s},x2t={left:0,top:0,right:0,gap:0},bxe=function(t){return parseInt(t||"",10)||0},g2t=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[bxe(r),bxe(n),bxe(a)]},y2t=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return x2t;var s=g2t(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])}},v2t=KVe(),ZM="data-scroll-locked",b2t=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(ZM,`] { 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(oie,` { right: `).concat(i,"px ").concat(n,`; } .`).concat(lie,` { margin-right: `).concat(i,"px ").concat(n,`; } .`).concat(oie," .").concat(oie,` { right: 0 `).concat(n,`; } .`).concat(lie," .").concat(lie,` { margin-right: 0 `).concat(n,`; } body[`).concat(ZM,`] { `).concat(s2t,": ").concat(i,`px; } `)},VEe=function(){var t=parseInt(document.body.getAttribute(ZM)||"0",10);return isFinite(t)?t:0},_2t=function(){k.useEffect(function(){return document.body.setAttribute(ZM,(VEe()+1).toString()),function(){var t=VEe()-1;t<=0?document.body.removeAttribute(ZM):document.body.setAttribute(ZM,t.toString())}},[])},w2t=function(t){var s=t.noRelative,r=t.noImportant,n=t.gapMode,a=n===void 0?"margin":n;_2t();var o=k.useMemo(function(){return y2t(a)},[a]);return k.createElement(v2t,{styles:b2t(o,!s,a,r?"":"!important")})},vve=!1;if(typeof window<"u")try{var Y7=Object.defineProperty({},"passive",{get:function(){return vve=!0,!0}});window.addEventListener("test",Y7,Y7),window.removeEventListener("test",Y7,Y7)}catch{vve=!1}var m5=vve?{passive:!1}:!1,j2t=function(t){return t.tagName==="TEXTAREA"},ZVe=function(t,s){if(!(t instanceof Element))return!1;var r=window.getComputedStyle(t);return r[s]!=="hidden"&&!(r.overflowY===r.overflowX&&!j2t(t)&&r[s]==="visible")},N2t=function(t){return ZVe(t,"overflowY")},k2t=function(t){return ZVe(t,"overflowX")},HEe=function(t,s){var r=s.ownerDocument,n=s;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var a=YVe(t,n);if(a){var o=XVe(t,n),l=o[1],i=o[2];if(l>i)return!0}n=n.parentNode}while(n&&n!==r.body);return!1},S2t=function(t){var s=t.scrollTop,r=t.scrollHeight,n=t.clientHeight;return[s,r,n]},C2t=function(t){var s=t.scrollLeft,r=t.scrollWidth,n=t.clientWidth;return[s,r,n]},YVe=function(t,s){return t==="v"?N2t(s):k2t(s)},XVe=function(t,s){return t==="v"?S2t(s):C2t(s)},M2t=function(t,s){return t==="h"&&s==="rtl"?-1:1},T2t=function(t,s,r,n,a){var o=M2t(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 b=XVe(t,i),_=b[0],j=b[1],w=b[2],N=j-w-o*_;(_||N)&&YVe(t,i)&&(f+=N,g+=_);var C=i.parentNode;i=C&&C.nodeType===Node.DOCUMENT_FRAGMENT_NODE?C.host:C}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},X7=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},WEe=function(t){return[t.deltaX,t.deltaY]},GEe=function(t){return t&&"current"in t?t.current:t},A2t=function(t,s){return t[0]===s[0]&&t[1]===s[1]},E2t=function(t){return` .block-interactivity-`.concat(t,` {pointer-events: none;} .allow-interactivity-`).concat(t,` {pointer-events: all;} `)},P2t=0,p5=[];function I2t(t){var s=k.useRef([]),r=k.useRef([0,0]),n=k.useRef(),a=k.useState(P2t++)[0],o=k.useState(KVe)[0],l=k.useRef(t);k.useEffect(function(){l.current=t},[t]),k.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(a));var j=D2e([t.lockRef.current],(t.shards||[]).map(GEe),!0).filter(Boolean);return j.forEach(function(w){return w.classList.add("allow-interactivity-".concat(a))}),function(){document.body.classList.remove("block-interactivity-".concat(a)),j.forEach(function(w){return w.classList.remove("allow-interactivity-".concat(a))})}}},[t.inert,t.lockRef.current,t.shards]);var i=k.useCallback(function(j,w){if("touches"in j&&j.touches.length===2||j.type==="wheel"&&j.ctrlKey)return!l.current.allowPinchZoom;var N=X7(j),C=r.current,M="deltaX"in j?j.deltaX:C[0]-N[0],I="deltaY"in j?j.deltaY:C[1]-N[1],L,R=j.target,q=Math.abs(M)>Math.abs(I)?"h":"v";if("touches"in j&&q==="h"&&R.type==="range")return!1;var U=HEe(q,R);if(!U)return!0;if(U?L=q:(L=q==="v"?"h":"v",U=HEe(q,R)),!U)return!1;if(!n.current&&"changedTouches"in j&&(M||I)&&(n.current=L),!L)return!0;var B=n.current||L;return T2t(B,w,j,B==="h"?M:I)},[]),c=k.useCallback(function(j){var w=j;if(!(!p5.length||p5[p5.length-1]!==o)){var N="deltaY"in w?WEe(w):X7(w),C=s.current.filter(function(L){return L.name===w.type&&(L.target===w.target||w.target===L.shadowParent)&&A2t(L.delta,N)})[0];if(C&&C.should){w.cancelable&&w.preventDefault();return}if(!C){var M=(l.current.shards||[]).map(GEe).filter(Boolean).filter(function(L){return L.contains(w.target)}),I=M.length>0?i(w,M[0]):!l.current.noIsolation;I&&w.cancelable&&w.preventDefault()}}},[]),u=k.useCallback(function(j,w,N,C){var M={name:j,delta:w,target:N,should:C,shadowParent:L2t(N)};s.current.push(M),setTimeout(function(){s.current=s.current.filter(function(I){return I!==M})},1)},[]),p=k.useCallback(function(j){r.current=X7(j),n.current=void 0},[]),f=k.useCallback(function(j){u(j.type,WEe(j),j.target,i(j,t.lockRef.current))},[]),g=k.useCallback(function(j){u(j.type,X7(j),j.target,i(j,t.lockRef.current))},[]);k.useEffect(function(){return p5.push(o),t.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:g}),document.addEventListener("wheel",c,m5),document.addEventListener("touchmove",c,m5),document.addEventListener("touchstart",p,m5),function(){p5=p5.filter(function(j){return j!==o}),document.removeEventListener("wheel",c,m5),document.removeEventListener("touchmove",c,m5),document.removeEventListener("touchstart",p,m5)}},[]);var b=t.removeScrollBar,_=t.inert;return k.createElement(k.Fragment,null,_?k.createElement(o,{styles:E2t(a)}):null,b?k.createElement(w2t,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function L2t(t){for(var s=null;t!==null;)t instanceof ShadowRoot&&(s=t.host,t=t.host),t=t.parentNode;return s}const D2t=c2t(GVe,I2t);var NO=k.forwardRef(function(t,s){return k.createElement(Lde,fx({},t,{ref:s,sideCar:D2t}))});NO.classNames=Lde.classNames;var bve=["Enter"," "],O2t=["ArrowDown","PageUp","Home"],QVe=["ArrowUp","PageDown","End"],R2t=[...O2t,...QVe],F2t={ltr:[...bve,"ArrowRight"],rtl:[...bve,"ArrowLeft"]},z2t={ltr:["ArrowLeft"],rtl:["ArrowRight"]},kO="Menu",[K8,B2t,$2t]=pO(kO),[dC,JVe]=nd(kO,[$2t,L0,Cw]),Dde=L0(),eHe=Cw(),[q2t,uC]=dC(kO),[U2t,SO]=dC(kO),tHe=t=>{const{__scopeMenu:s,open:r=!1,children:n,dir:a,onOpenChange:o,modal:l=!0}=t,i=Dde(s),[c,u]=k.useState(null),p=k.useRef(!1),f=gd(o),g=Sw(a);return k.useEffect(()=>{const b=()=>{p.current=!0,document.addEventListener("pointerdown",_,{capture:!0,once:!0}),document.addEventListener("pointermove",_,{capture:!0,once:!0})},_=()=>p.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",_,{capture:!0}),document.removeEventListener("pointermove",_,{capture:!0})}},[]),e.jsx(yO,{...i,children:e.jsx(q2t,{scope:s,open:r,onOpenChange:f,content:c,onContentChange:u,children:e.jsx(U2t,{scope:s,onClose:k.useCallback(()=>f(!1),[f]),isUsingKeyboardRef:p,dir:g,modal:l,children:n})})})};tHe.displayName=kO;var V2t="MenuAnchor",G2e=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Dde(r);return e.jsx(BA,{...a,...n,ref:s})});G2e.displayName=V2t;var K2e="MenuPortal",[H2t,sHe]=dC(K2e,{forceMount:void 0}),rHe=t=>{const{__scopeMenu:s,forceMount:r,children:n,container:a}=t,o=uC(K2e,s);return e.jsx(H2t,{scope:s,forceMount:r,children:e.jsx(Fd,{present:r||o.open,children:e.jsx(OA,{asChild:!0,container:a,children:n})})})};rHe.displayName=K2e;var Mx="MenuContent",[W2t,Z2e]=dC(Mx),nHe=k.forwardRef((t,s)=>{const r=sHe(Mx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=uC(Mx,t.__scopeMenu),l=SO(Mx,t.__scopeMenu);return e.jsx(K8.Provider,{scope:t.__scopeMenu,children:e.jsx(Fd,{present:n||o.open,children:e.jsx(K8.Slot,{scope:t.__scopeMenu,children:l.modal?e.jsx(G2t,{...a,ref:s}):e.jsx(K2t,{...a,ref:s})})})})}),G2t=k.forwardRef((t,s)=>{const r=uC(Mx,t.__scopeMenu),n=k.useRef(null),a=$a(s,n);return k.useEffect(()=>{const o=n.current;if(o)return Ide(o)},[]),e.jsx(Y2e,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),K2t=k.forwardRef((t,s)=>{const r=uC(Mx,t.__scopeMenu);return e.jsx(Y2e,{...t,ref:s,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),Z2t=aw("MenuContent.ScrollLock"),Y2e=k.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:b,disableOutsideScroll:_,...j}=t,w=uC(Mx,r),N=SO(Mx,r),C=Dde(r),M=eHe(r),I=B2t(r),[L,R]=k.useState(null),q=k.useRef(null),U=$a(s,q,w.onContentChange),B=k.useRef(0),V=k.useRef(""),Y=k.useRef(0),J=k.useRef(null),te=k.useRef("right"),X=k.useRef(0),ce=_?NO:k.Fragment,ne=_?{as:Z2t,allowPinchZoom:!0}:void 0,re=pe=>{var Fe,Ce;const xe=V.current+pe,_e=I().filter(Me=>!Me.disabled),fe=document.activeElement,we=(Fe=_e.find(Me=>Me.ref.current===fe))==null?void 0:Fe.textValue,Ie=_e.map(Me=>Me.textValue),Ne=ojt(Ie,xe,we),Ae=(Ce=_e.find(Me=>Me.textValue===Ne))==null?void 0:Ce.ref.current;(function Me($e){V.current=$e,window.clearTimeout(B.current),$e!==""&&(B.current=window.setTimeout(()=>Me(""),1e3))})(xe),Ae&&setTimeout(()=>Ae.focus())};k.useEffect(()=>()=>window.clearTimeout(B.current),[]),Ade();const le=k.useCallback(pe=>{var _e,fe;return te.current===((_e=J.current)==null?void 0:_e.side)&&cjt(pe,(fe=J.current)==null?void 0:fe.area)},[]);return e.jsx(W2t,{scope:r,searchRef:V,onItemEnter:k.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),onItemLeave:k.useCallback(pe=>{var xe;le(pe)||((xe=q.current)==null||xe.focus(),R(null))},[le]),onTriggerLeave:k.useCallback(pe=>{le(pe)&&pe.preventDefault()},[le]),pointerGraceTimerRef:Y,onPointerGraceIntentChange:k.useCallback(pe=>{J.current=pe},[]),children:e.jsx(ce,{...ne,children:e.jsx(wO,{asChild:!0,trapped:a,onMountAutoFocus:Ir(o,pe=>{var xe;pe.preventDefault(),(xe=q.current)==null||xe.focus({preventScroll:!0})}),onUnmountAutoFocus:l,children:e.jsx(ww,{asChild:!0,disableOutsidePointerEvents:i,onEscapeKeyDown:u,onPointerDownOutside:p,onFocusOutside:f,onInteractOutside:g,onDismiss:b,children:e.jsx(Ede,{asChild:!0,...M,dir:N.dir,orientation:"vertical",loop:n,currentTabStopId:L,onCurrentTabStopIdChange:R,onEntryFocus:Ir(c,pe=>{N.isUsingKeyboardRef.current||pe.preventDefault()}),preventScrollOnEntryFocus:!0,children:e.jsx(vO,{role:"menu","aria-orientation":"vertical","data-state":bHe(w.open),"data-radix-menu-content":"",dir:N.dir,...C,...j,ref:U,style:{outline:"none",...j.style},onKeyDown:Ir(j.onKeyDown,pe=>{const _e=pe.target.closest("[data-radix-menu-content]")===pe.currentTarget,fe=pe.ctrlKey||pe.altKey||pe.metaKey,we=pe.key.length===1;_e&&(pe.key==="Tab"&&pe.preventDefault(),!fe&&we&&re(pe.key));const Ie=q.current;if(pe.target!==Ie||!R2t.includes(pe.key))return;pe.preventDefault();const Ae=I().filter(Fe=>!Fe.disabled).map(Fe=>Fe.ref.current);QVe.includes(pe.key)&&Ae.reverse(),ajt(Ae)}),onBlur:Ir(t.onBlur,pe=>{pe.currentTarget.contains(pe.target)||(window.clearTimeout(B.current),V.current="")}),onPointerMove:Ir(t.onPointerMove,Z8(pe=>{const xe=pe.target,_e=X.current!==pe.clientX;if(pe.currentTarget.contains(xe)&&_e){const fe=pe.clientX>X.current?"right":"left";te.current=fe,X.current=pe.clientX}}))})})})})})})});nHe.displayName=Mx;var Y2t="MenuGroup",X2e=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(sn.div,{role:"group",...n,ref:s})});X2e.displayName=Y2t;var X2t="MenuLabel",aHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(sn.div,{...n,ref:s})});aHe.displayName=X2t;var xoe="MenuItem",KEe="menu.itemSelect",Ode=k.forwardRef((t,s)=>{const{disabled:r=!1,onSelect:n,...a}=t,o=k.useRef(null),l=SO(xoe,t.__scopeMenu),i=Z2e(xoe,t.__scopeMenu),c=$a(s,o),u=k.useRef(!1),p=()=>{const f=o.current;if(!r&&f){const g=new CustomEvent(KEe,{bubbles:!0,cancelable:!0});f.addEventListener(KEe,b=>n==null?void 0:n(b),{once:!0}),l2e(f,g),g.defaultPrevented?u.current=!1:l.onClose()}};return e.jsx(iHe,{...a,ref:c,disabled:r,onClick:Ir(t.onClick,p),onPointerDown:f=>{var g;(g=t.onPointerDown)==null||g.call(t,f),u.current=!0},onPointerUp:Ir(t.onPointerUp,f=>{var g;u.current||(g=f.currentTarget)==null||g.click()}),onKeyDown:Ir(t.onKeyDown,f=>{const g=i.searchRef.current!=="";r||g&&f.key===" "||bve.includes(f.key)&&(f.currentTarget.click(),f.preventDefault())})})});Ode.displayName=xoe;var iHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,disabled:n=!1,textValue:a,...o}=t,l=Z2e(xoe,r),i=eHe(r),c=k.useRef(null),u=$a(s,c),[p,f]=k.useState(!1),[g,b]=k.useState("");return k.useEffect(()=>{const _=c.current;_&&b((_.textContent??"").trim())},[o.children]),e.jsx(K8.ItemSlot,{scope:r,disabled:n,textValue:a??g,children:e.jsx(Pde,{asChild:!0,...i,focusable:!n,children:e.jsx(sn.div,{role:"menuitem","data-highlighted":p?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...o,ref:u,onPointerMove:Ir(t.onPointerMove,Z8(_=>{n?l.onItemLeave(_):(l.onItemEnter(_),_.defaultPrevented||_.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ir(t.onPointerLeave,Z8(_=>l.onItemLeave(_))),onFocus:Ir(t.onFocus,()=>f(!0)),onBlur:Ir(t.onBlur,()=>f(!1))})})})}),Q2t="MenuCheckboxItem",oHe=k.forwardRef((t,s)=>{const{checked:r=!1,onCheckedChange:n,...a}=t;return e.jsx(hHe,{scope:t.__scopeMenu,checked:r,children:e.jsx(Ode,{role:"menuitemcheckbox","aria-checked":goe(r)?"mixed":r,...a,ref:s,"data-state":J2e(r),onSelect:Ir(a.onSelect,()=>n==null?void 0:n(goe(r)?!0:!r),{checkForDefaultPrevented:!1})})})});oHe.displayName=Q2t;var lHe="MenuRadioGroup",[J2t,ejt]=dC(lHe,{value:void 0,onValueChange:()=>{}}),cHe=k.forwardRef((t,s)=>{const{value:r,onValueChange:n,...a}=t,o=gd(n);return e.jsx(J2t,{scope:t.__scopeMenu,value:r,onValueChange:o,children:e.jsx(X2e,{...a,ref:s})})});cHe.displayName=lHe;var dHe="MenuRadioItem",uHe=k.forwardRef((t,s)=>{const{value:r,...n}=t,a=ejt(dHe,t.__scopeMenu),o=r===a.value;return e.jsx(hHe,{scope:t.__scopeMenu,checked:o,children:e.jsx(Ode,{role:"menuitemradio","aria-checked":o,...n,ref:s,"data-state":J2e(o),onSelect:Ir(n.onSelect,()=>{var l;return(l=a.onValueChange)==null?void 0:l.call(a,r)},{checkForDefaultPrevented:!1})})})});uHe.displayName=dHe;var Q2e="MenuItemIndicator",[hHe,tjt]=dC(Q2e,{checked:!1}),mHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,forceMount:n,...a}=t,o=tjt(Q2e,r);return e.jsx(Fd,{present:n||goe(o.checked)||o.checked===!0,children:e.jsx(sn.span,{...a,ref:s,"data-state":J2e(o.checked)})})});mHe.displayName=Q2e;var sjt="MenuSeparator",pHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t;return e.jsx(sn.div,{role:"separator","aria-orientation":"horizontal",...n,ref:s})});pHe.displayName=sjt;var rjt="MenuArrow",fHe=k.forwardRef((t,s)=>{const{__scopeMenu:r,...n}=t,a=Dde(r);return e.jsx(bO,{...a,...n,ref:s})});fHe.displayName=rjt;var njt="MenuSub",[mMs,xHe]=dC(njt),yI="MenuSubTrigger",gHe=k.forwardRef((t,s)=>{const r=uC(yI,t.__scopeMenu),n=SO(yI,t.__scopeMenu),a=xHe(yI,t.__scopeMenu),o=Z2e(yI,t.__scopeMenu),l=k.useRef(null),{pointerGraceTimerRef:i,onPointerGraceIntentChange:c}=o,u={__scopeMenu:t.__scopeMenu},p=k.useCallback(()=>{l.current&&window.clearTimeout(l.current),l.current=null},[]);return k.useEffect(()=>p,[p]),k.useEffect(()=>{const f=i.current;return()=>{window.clearTimeout(f),c(null)}},[i,c]),e.jsx(G2e,{asChild:!0,...u,children:e.jsx(iHe,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":a.contentId,"data-state":bHe(r.open),...t,ref:k1(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:Ir(t.onPointerMove,Z8(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:Ir(t.onPointerLeave,Z8(f=>{var b,_;p();const g=(b=r.content)==null?void 0:b.getBoundingClientRect();if(g){const j=(_=r.content)==null?void 0:_.dataset.side,w=j==="right",N=w?-5:5,C=g[w?"left":"right"],M=g[w?"right":"left"];o.onPointerGraceIntentChange({area:[{x:f.clientX+N,y:f.clientY},{x:C,y:g.top},{x:M,y:g.top},{x:M,y:g.bottom},{x:C,y:g.bottom}],side:j}),window.clearTimeout(i.current),i.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(f),f.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:Ir(t.onKeyDown,f=>{var b;const g=o.searchRef.current!=="";t.disabled||g&&f.key===" "||F2t[n.dir].includes(f.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),f.preventDefault())})})})});gHe.displayName=yI;var yHe="MenuSubContent",vHe=k.forwardRef((t,s)=>{const r=sHe(Mx,t.__scopeMenu),{forceMount:n=r.forceMount,...a}=t,o=uC(Mx,t.__scopeMenu),l=SO(Mx,t.__scopeMenu),i=xHe(yHe,t.__scopeMenu),c=k.useRef(null),u=$a(s,c);return e.jsx(K8.Provider,{scope:t.__scopeMenu,children:e.jsx(Fd,{present:n||o.open,children:e.jsx(K8.Slot,{scope:t.__scopeMenu,children:e.jsx(Y2e,{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:Ir(t.onFocusOutside,p=>{p.target!==i.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:Ir(t.onEscapeKeyDown,p=>{l.onClose(),p.preventDefault()}),onKeyDown:Ir(t.onKeyDown,p=>{var b;const f=p.currentTarget.contains(p.target),g=z2t[l.dir].includes(p.key);f&&g&&(o.onOpenChange(!1),(b=i.trigger)==null||b.focus(),p.preventDefault())})})})})})});vHe.displayName=yHe;function bHe(t){return t?"open":"closed"}function goe(t){return t==="indeterminate"}function J2e(t){return goe(t)?"indeterminate":t?"checked":"unchecked"}function ajt(t){const s=document.activeElement;for(const r of t)if(r===s||(r.focus(),document.activeElement!==s))return}function ijt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}function ojt(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=ijt(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 ljt(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 cjt(t,s){if(!s)return!1;const r={x:t.clientX,y:t.clientY};return ljt(r,s)}function Z8(t){return s=>s.pointerType==="mouse"?t(s):void 0}var djt=tHe,ujt=G2e,hjt=rHe,mjt=nHe,pjt=X2e,fjt=aHe,xjt=Ode,gjt=oHe,yjt=cHe,vjt=uHe,bjt=mHe,_jt=pHe,wjt=fHe,jjt=gHe,Njt=vHe,Rde="DropdownMenu",[kjt]=nd(Rde,[JVe]),Hm=JVe(),[Sjt,_He]=kjt(Rde),wHe=t=>{const{__scopeDropdownMenu:s,children:r,dir:n,open:a,defaultOpen:o,onOpenChange:l,modal:i=!0}=t,c=Hm(s),u=k.useRef(null),[p,f]=rh({prop:a,defaultProp:o??!1,onChange:l,caller:Rde});return e.jsx(Sjt,{scope:s,triggerId:Mu(),triggerRef:u,contentId:Mu(),open:p,onOpenChange:f,onOpenToggle:k.useCallback(()=>f(g=>!g),[f]),modal:i,children:e.jsx(djt,{...c,open:p,onOpenChange:f,dir:n,modal:i,children:r})})};wHe.displayName=Rde;var jHe="DropdownMenuTrigger",NHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,disabled:n=!1,...a}=t,o=_He(jHe,r),l=Hm(r);return e.jsx(ujt,{asChild:!0,...l,children:e.jsx(sn.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:k1(s,o.triggerRef),onPointerDown:Ir(t.onPointerDown,i=>{!n&&i.button===0&&i.ctrlKey===!1&&(o.onOpenToggle(),o.open||i.preventDefault())}),onKeyDown:Ir(t.onKeyDown,i=>{n||(["Enter"," "].includes(i.key)&&o.onOpenToggle(),i.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(i.key)&&i.preventDefault())})})})});NHe.displayName=jHe;var Cjt="DropdownMenuPortal",kHe=t=>{const{__scopeDropdownMenu:s,...r}=t,n=Hm(s);return e.jsx(hjt,{...n,...r})};kHe.displayName=Cjt;var SHe="DropdownMenuContent",CHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=_He(SHe,r),o=Hm(r),l=k.useRef(!1);return e.jsx(mjt,{id:a.contentId,"aria-labelledby":a.triggerId,...o,...n,ref:s,onCloseAutoFocus:Ir(t.onCloseAutoFocus,i=>{var c;l.current||(c=a.triggerRef.current)==null||c.focus(),l.current=!1,i.preventDefault()}),onInteractOutside:Ir(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)"}})});CHe.displayName=SHe;var Mjt="DropdownMenuGroup",Tjt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(pjt,{...a,...n,ref:s})});Tjt.displayName=Mjt;var Ajt="DropdownMenuLabel",MHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(fjt,{...a,...n,ref:s})});MHe.displayName=Ajt;var Ejt="DropdownMenuItem",THe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(xjt,{...a,...n,ref:s})});THe.displayName=Ejt;var Pjt="DropdownMenuCheckboxItem",AHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(gjt,{...a,...n,ref:s})});AHe.displayName=Pjt;var Ijt="DropdownMenuRadioGroup",Ljt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(yjt,{...a,...n,ref:s})});Ljt.displayName=Ijt;var Djt="DropdownMenuRadioItem",EHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(vjt,{...a,...n,ref:s})});EHe.displayName=Djt;var Ojt="DropdownMenuItemIndicator",PHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(bjt,{...a,...n,ref:s})});PHe.displayName=Ojt;var Rjt="DropdownMenuSeparator",IHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(_jt,{...a,...n,ref:s})});IHe.displayName=Rjt;var Fjt="DropdownMenuArrow",zjt=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(wjt,{...a,...n,ref:s})});zjt.displayName=Fjt;var Bjt="DropdownMenuSubTrigger",LHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(jjt,{...a,...n,ref:s})});LHe.displayName=Bjt;var $jt="DropdownMenuSubContent",DHe=k.forwardRef((t,s)=>{const{__scopeDropdownMenu:r,...n}=t,a=Hm(r);return e.jsx(Njt,{...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)"}})});DHe.displayName=$jt;var qjt=wHe,Ujt=NHe,Vjt=kHe,OHe=CHe,RHe=MHe,FHe=THe,zHe=AHe,BHe=EHe,$He=PHe,qHe=IHe,UHe=LHe,VHe=DHe;const au=qjt,iu=Ujt,Hjt=k.forwardRef(({className:t,inset:s,children:r,...n},a)=>e.jsxs(UHe,{ref:a,className:Pt("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(xa,{className:"ml-auto h-4 w-4"})]}));Hjt.displayName=UHe.displayName;const Wjt=k.forwardRef(({className:t,...s},r)=>e.jsx(VHe,{ref:r,className:Pt("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}));Wjt.displayName=VHe.displayName;const zd=k.forwardRef(({className:t,sideOffset:s=4,...r},n)=>e.jsx(Vjt,{children:e.jsx(OHe,{ref:n,sideOffset:s,className:Pt("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})}));zd.displayName=OHe.displayName;const Ca=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(FHe,{ref:n,className:Pt("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}));Ca.displayName=FHe.displayName;const Gjt=k.forwardRef(({className:t,children:s,checked:r,...n},a)=>e.jsxs(zHe,{ref:a,className:Pt("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($He,{children:e.jsx(fa,{className:"h-4 w-4"})})}),s]}));Gjt.displayName=zHe.displayName;const Kjt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(BHe,{ref:n,className:Pt("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($He,{children:e.jsx(vd,{className:"h-2 w-2 fill-current"})})}),s]}));Kjt.displayName=BHe.displayName;const _ve=k.forwardRef(({className:t,inset:s,...r},n)=>e.jsx(RHe,{ref:n,className:Pt("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...r}));_ve.displayName=RHe.displayName;const lw=k.forwardRef(({className:t,...s},r)=>e.jsx(qHe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));lw.displayName=qHe.displayName;const Zjt=()=>{const{isAssistant:t,actingAsAgent:s,assignedAgents:r,setActingAsAgent:n,isActingAsSelf:a,setActingAsSelf:o}=H2e();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(to,{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(mr,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"font-medium text-sm",children:"Acting as"})]}),e.jsxs(au,{children:[e.jsx(iu,{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(to,{className:"h-4 w-4"}),e.jsx("strong",{children:"My Account"})]}):s?e.jsxs(e.Fragment,{children:[e.jsxs(_n,{className:"h-5 w-5",children:[e.jsx(za,{src:s.avatar_url||void 0}),e.jsx(wn,{className:"text-[10px] bg-primary-foreground/30",children:l(s.name)})]}),e.jsx("strong",{children:s.name})]}):e.jsx("strong",{children:"Select..."}),e.jsx(To,{className:"h-3 w-3"})]})}),e.jsxs(zd,{align:"start",className:"z-[2147483647]",children:[e.jsxs(Ca,{onClick:o,className:"gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),e.jsx("span",{children:"My Account"}),a&&e.jsx(tt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]}),e.jsx(lw,{}),r.map(i=>e.jsxs(Ca,{onClick:()=>n(i),className:"gap-2",children:[e.jsxs(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:i.avatar_url||void 0}),e.jsx(wn,{className:"text-[10px]",children:l(i.name)})]}),e.jsx("span",{children:i.name}),!a&&i.id===(s==null?void 0:s.id)&&e.jsx(tt,{variant:"secondary",className:"ml-auto text-[10px]",children:"Current"})]},i.id))]})]})]}),e.jsx(tt,{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}=Rs();return a||(s||r)&&o?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..."})]})}):n?s&&!l?e.jsx(Jfe,{to:"/dashboard",replace:!0}):r&&!i&&!l?e.jsx(Jfe,{to:"/dashboard",replace:!0}):e.jsx(e.Fragment,{children:t}):e.jsx(Jfe,{to:"/auth",replace:!0})};var eje={};(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 xe=new OffscreenCanvas(1,1),_e=xe.getContext("2d");_e.fillRect(0,0,1,1);var fe=xe.transferToImageBitmap();_e.createPattern(fe,"no-repeat")}catch{return!1}return!0}();function c(){}function u(xe){var _e=r.exports.Promise,fe=_e!==void 0?_e:s.Promise;return typeof fe=="function"?new fe(xe):(xe(c,c),null)}var p=function(xe,_e){return{transform:function(fe){if(xe)return fe;if(_e.has(fe))return _e.get(fe);var we=new OffscreenCanvas(fe.width,fe.height),Ie=we.getContext("2d");return Ie.drawImage(fe,0,0),_e.set(fe,we),we},clear:function(){_e.clear()}}}(i,new Map),f=function(){var xe=Math.floor(16.666666666666668),_e,fe,we={},Ie=0;return typeof requestAnimationFrame=="function"&&typeof cancelAnimationFrame=="function"?(_e=function(Ne){var Ae=Math.random();return we[Ae]=requestAnimationFrame(function Fe(Ce){Ie===Ce||Ie+xe-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 Xjt(){const t=es();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 Qjt(){const t=es(),{user:s}=Rs();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 Fde="Dialog",[HHe,WHe]=nd(Fde),[Jjt,dy]=HHe(Fde),GHe=t=>{const{__scopeDialog:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!0}=t,i=k.useRef(null),c=k.useRef(null),[u,p]=rh({prop:n,defaultProp:a??!1,onChange:o,caller:Fde});return e.jsx(Jjt,{scope:s,triggerRef:i,contentRef:c,contentId:Mu(),titleId:Mu(),descriptionId:Mu(),open:u,onOpenChange:p,onOpenToggle:k.useCallback(()=>p(f=>!f),[p]),modal:l,children:r})};GHe.displayName=Fde;var KHe="DialogTrigger",ZHe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=dy(KHe,r),o=$a(s,a.triggerRef);return e.jsx(sn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":rje(a.open),...n,ref:o,onClick:Ir(t.onClick,a.onOpenToggle)})});ZHe.displayName=KHe;var tje="DialogPortal",[eNt,YHe]=HHe(tje,{forceMount:void 0}),XHe=t=>{const{__scopeDialog:s,forceMount:r,children:n,container:a}=t,o=dy(tje,s);return e.jsx(eNt,{scope:s,forceMount:r,children:k.Children.map(n,l=>e.jsx(Fd,{present:r||o.open,children:e.jsx(OA,{asChild:!0,container:a,children:l})}))})};XHe.displayName=tje;var yoe="DialogOverlay",QHe=k.forwardRef((t,s)=>{const r=YHe(yoe,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=dy(yoe,t.__scopeDialog);return o.modal?e.jsx(Fd,{present:n||o.open,children:e.jsx(sNt,{...a,ref:s})}):null});QHe.displayName=yoe;var tNt=aw("DialogOverlay.RemoveScroll"),sNt=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=dy(yoe,r);return e.jsx(NO,{as:tNt,allowPinchZoom:!0,shards:[a.contentRef],children:e.jsx(sn.div,{"data-state":rje(a.open),...n,ref:s,style:{pointerEvents:"auto",...n.style}})})}),LS="DialogContent",JHe=k.forwardRef((t,s)=>{const r=YHe(LS,t.__scopeDialog),{forceMount:n=r.forceMount,...a}=t,o=dy(LS,t.__scopeDialog);return e.jsx(Fd,{present:n||o.open,children:o.modal?e.jsx(rNt,{...a,ref:s}):e.jsx(nNt,{...a,ref:s})})});JHe.displayName=LS;var rNt=k.forwardRef((t,s)=>{const r=dy(LS,t.__scopeDialog),n=k.useRef(null),a=$a(s,r.contentRef,n);return k.useEffect(()=>{const o=n.current;if(o)return Ide(o)},[]),e.jsx(eWe,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),(l=r.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Ir(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,i=l.button===0&&l.ctrlKey===!0;(l.button===2||i)&&o.preventDefault()}),onFocusOutside:Ir(t.onFocusOutside,o=>o.preventDefault())})}),nNt=k.forwardRef((t,s)=>{const r=dy(LS,t.__scopeDialog),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(eWe,{...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()}})}),eWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:o,...l}=t,i=dy(LS,r),c=k.useRef(null),u=$a(s,c);return Ade(),e.jsxs(e.Fragment,{children:[e.jsx(wO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(ww,{role:"dialog",id:i.contentId,"aria-describedby":i.descriptionId,"aria-labelledby":i.titleId,"data-state":rje(i.open),...l,ref:u,onDismiss:()=>i.onOpenChange(!1)})}),e.jsxs(e.Fragment,{children:[e.jsx(iNt,{titleId:i.titleId}),e.jsx(lNt,{contentRef:c,descriptionId:i.descriptionId})]})]})}),sje="DialogTitle",tWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=dy(sje,r);return e.jsx(sn.h2,{id:a.titleId,...n,ref:s})});tWe.displayName=sje;var sWe="DialogDescription",rWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=dy(sWe,r);return e.jsx(sn.p,{id:a.descriptionId,...n,ref:s})});rWe.displayName=sWe;var nWe="DialogClose",aWe=k.forwardRef((t,s)=>{const{__scopeDialog:r,...n}=t,a=dy(nWe,r);return e.jsx(sn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});aWe.displayName=nWe;function rje(t){return t?"open":"closed"}var iWe="DialogTitleWarning",[aNt,oWe]=qft(iWe,{contentName:LS,titleName:sje,docsSlug:"dialog"}),iNt=({titleId:t})=>{const s=oWe(iWe),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 k.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},oNt="DialogDescriptionWarning",lNt=({contentRef:t,descriptionId:s})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${oWe(oNt).contentName}}.`;return k.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},zde=GHe,nje=ZHe,Bde=XHe,WA=QHe,GA=JHe,CO=tWe,MO=rWe,TO=aWe;const xs=zde,qi=nje,cNt=Bde,pMs=TO,lWe=k.forwardRef(({className:t,...s},r)=>e.jsx(WA,{ref:r,className:Pt("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}));lWe.displayName=WA.displayName;const fs=k.forwardRef(({className:t,children:s,overlayClassName:r,...n},a)=>e.jsxs(cNt,{children:[e.jsx(lWe,{className:r}),e.jsxs(GA,{ref:a,className:Pt("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(TO,{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(Or,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fs.displayName=GA.displayName;const _s=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-1.5 text-center sm:text-left",t),...s});_s.displayName="DialogHeader";const zn=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});zn.displayName="DialogFooter";const bs=k.forwardRef(({className:t,...s},r)=>e.jsx(CO,{ref:r,className:Pt("text-lg font-semibold leading-none tracking-tight",t),...s}));bs.displayName=CO.displayName;const Wr=k.forwardRef(({className:t,...s},r)=>e.jsx(MO,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Wr.displayName=MO.displayName;const dNt={points_earned:xo,listing_created:Sn,deal_closed:wc,custom:Jn},YEe={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"},XEe=()=>{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 uNt(){const{user:t}=Rs(),s=es(),{data:r}=Yjt(),n=Xjt(),[a,o]=k.useState(null),[l,i]=k.useState(!1),c=k.useCallback(()=>{const b=Date.now()+3e3,_={startVelocity:30,spread:360,ticks:60,zIndex:9999},j=(N,C)=>Math.random()*(C-N)+N,w=setInterval(()=>{const N=b-Date.now();if(N<=0){clearInterval(w);return}const C=50*(N/3e3);ZEe({..._,particleCount:C,origin:{x:j(.1,.3),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]}),ZEe({..._,particleCount:C,origin:{x:j(.7,.9),y:Math.random()-.2},colors:["#ff6b6b","#feca57","#48dbfb","#ff9ff3","#54a0ff","#5f27cd"]})},250)},[]);k.useEffect(()=>{XEe()||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],b=>(b==null?void 0:b.filter(_=>_.id!==g))??[]),await n.mutateAsync(g)}};if(XEe()||!a)return null;const p=dNt[a.celebration_type]||Jn,f=YEe[a.celebration_type]||YEe.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(un,{className:"w-5 h-5 text-yellow-500 animate-pulse"}),e.jsx(un,{className:"w-5 h-5 text-yellow-500 animate-pulse delay-75"}),e.jsx(un,{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 cWe="/assets/levelup-logo-horizontal-DEFNc0ms.png",aje="/assets/levelup-logo-white-C2RAgAoG.png",hNt="/assets/listings-hero-BI9Ki9Dq.jpg",ze=k.forwardRef(({className:t,type:s,...r},n)=>e.jsx("input",{type:s,className:Pt("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 dWe={exports:{}};(function(t,s){(function(r,n){t.exports=n()})(Vv,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],v=d[1],S=d[2],E=d[3],P=m*E-S*v;return P?(x[0]=E*(P=1/P),x[1]=-v*P,x[2]=-S*P,x[3]=m*P,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],v=d[1],S=d[2],E=d[3],P=d[4],O=d[5],$=d[6],G=d[7],ee=d[8];return x[0]=P*ee-O*G,x[1]=S*G-v*ee,x[2]=v*O-S*P,x[3]=O*$-E*ee,x[4]=m*ee-S*$,x[5]=S*E-m*O,x[6]=E*G-P*$,x[7]=v*$-m*G,x[8]=m*P-v*E,x}function b(x,d,m){var v=d[0],S=d[1],E=d[2],P=d[3],O=d[4],$=d[5],G=d[6],ee=d[7],se=d[8],ie=m[0],de=m[1],ue=m[2],ke=m[3],Oe=m[4],De=m[5],Ke=m[6],Xe=m[7],ot=m[8];return x[0]=ie*v+de*P+ue*G,x[1]=ie*S+de*O+ue*ee,x[2]=ie*E+de*$+ue*se,x[3]=ke*v+Oe*P+De*G,x[4]=ke*S+Oe*O+De*ee,x[5]=ke*E+Oe*$+De*se,x[6]=Ke*v+Xe*P+ot*G,x[7]=Ke*S+Xe*O+ot*ee,x[8]=Ke*E+Xe*$+ot*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 j(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 w(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 N(x,d){var m=d[0],v=d[1],S=d[2],E=d[3],P=d[4],O=d[5],$=d[6],G=d[7],ee=d[8],se=d[9],ie=d[10],de=d[11],ue=d[12],ke=d[13],Oe=d[14],De=d[15],Ke=m*O-v*P,Xe=m*$-S*P,ot=m*G-E*P,Nt=v*$-S*O,yt=v*G-E*O,At=S*G-E*$,Ft=ee*ke-se*ue,qt=ee*Oe-ie*ue,ns=ee*De-de*ue,Gt=se*Oe-ie*ke,ds=se*De-de*ke,js=ie*De-de*Oe,Ns=Ke*js-Xe*ds+ot*Gt+Nt*ns-yt*qt+At*Ft;return Ns?(x[0]=(O*js-$*ds+G*Gt)*(Ns=1/Ns),x[1]=(S*ds-v*js-E*Gt)*Ns,x[2]=(ke*At-Oe*yt+De*Nt)*Ns,x[3]=(ie*yt-se*At-de*Nt)*Ns,x[4]=($*ns-P*js-G*qt)*Ns,x[5]=(m*js-S*ns+E*qt)*Ns,x[6]=(Oe*ot-ue*At-De*Xe)*Ns,x[7]=(ee*At-ie*ot+de*Xe)*Ns,x[8]=(P*ds-O*ns+G*Ft)*Ns,x[9]=(v*ns-m*ds-E*Ft)*Ns,x[10]=(ue*yt-ke*ot+De*Ke)*Ns,x[11]=(se*ot-ee*yt-de*Ke)*Ns,x[12]=(O*qt-P*Gt-$*Ft)*Ns,x[13]=(m*Gt-v*qt+S*Ft)*Ns,x[14]=(ke*Xe-ue*Nt-Oe*Ke)*Ns,x[15]=(ee*Nt-se*Xe+ie*Ke)*Ns,x):null}function C(x,d,m){var v=d[0],S=d[1],E=d[2],P=d[3],O=d[4],$=d[5],G=d[6],ee=d[7],se=d[8],ie=d[9],de=d[10],ue=d[11],ke=d[12],Oe=d[13],De=d[14],Ke=d[15],Xe=m[0],ot=m[1],Nt=m[2],yt=m[3];return x[0]=Xe*v+ot*O+Nt*se+yt*ke,x[1]=Xe*S+ot*$+Nt*ie+yt*Oe,x[2]=Xe*E+ot*G+Nt*de+yt*De,x[3]=Xe*P+ot*ee+Nt*ue+yt*Ke,x[4]=(Xe=m[4])*v+(ot=m[5])*O+(Nt=m[6])*se+(yt=m[7])*ke,x[5]=Xe*S+ot*$+Nt*ie+yt*Oe,x[6]=Xe*E+ot*G+Nt*de+yt*De,x[7]=Xe*P+ot*ee+Nt*ue+yt*Ke,x[8]=(Xe=m[8])*v+(ot=m[9])*O+(Nt=m[10])*se+(yt=m[11])*ke,x[9]=Xe*S+ot*$+Nt*ie+yt*Oe,x[10]=Xe*E+ot*G+Nt*de+yt*De,x[11]=Xe*P+ot*ee+Nt*ue+yt*Ke,x[12]=(Xe=m[12])*v+(ot=m[13])*O+(Nt=m[14])*se+(yt=m[15])*ke,x[13]=Xe*S+ot*$+Nt*ie+yt*Oe,x[14]=Xe*E+ot*G+Nt*de+yt*De,x[15]=Xe*P+ot*ee+Nt*ue+yt*Ke,x}function M(x,d,m){var v,S,E,P,O,$,G,ee,se,ie,de,ue,ke=m[0],Oe=m[1],De=m[2];return d===x?(x[12]=d[0]*ke+d[4]*Oe+d[8]*De+d[12],x[13]=d[1]*ke+d[5]*Oe+d[9]*De+d[13],x[14]=d[2]*ke+d[6]*Oe+d[10]*De+d[14],x[15]=d[3]*ke+d[7]*Oe+d[11]*De+d[15]):(S=d[1],E=d[2],P=d[3],O=d[4],$=d[5],G=d[6],ee=d[7],se=d[8],ie=d[9],de=d[10],ue=d[11],x[0]=v=d[0],x[1]=S,x[2]=E,x[3]=P,x[4]=O,x[5]=$,x[6]=G,x[7]=ee,x[8]=se,x[9]=ie,x[10]=de,x[11]=ue,x[12]=v*ke+O*Oe+se*De+d[12],x[13]=S*ke+$*Oe+ie*De+d[13],x[14]=E*ke+G*Oe+de*De+d[14],x[15]=P*ke+ee*Oe+ue*De+d[15]),x}function I(x,d,m){var v=m[0],S=m[1],E=m[2];return x[0]=d[0]*v,x[1]=d[1]*v,x[2]=d[2]*v,x[3]=d[3]*v,x[4]=d[4]*S,x[5]=d[5]*S,x[6]=d[6]*S,x[7]=d[7]*S,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 L(x,d,m){var v=Math.sin(m),S=Math.cos(m),E=d[4],P=d[5],O=d[6],$=d[7],G=d[8],ee=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*S+G*v,x[5]=P*S+ee*v,x[6]=O*S+se*v,x[7]=$*S+ie*v,x[8]=G*S-E*v,x[9]=ee*S-P*v,x[10]=se*S-O*v,x[11]=ie*S-$*v,x}function R(x,d,m){var v=Math.sin(m),S=Math.cos(m),E=d[0],P=d[1],O=d[2],$=d[3],G=d[8],ee=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*S-G*v,x[1]=P*S-ee*v,x[2]=O*S-se*v,x[3]=$*S-ie*v,x[8]=E*v+G*S,x[9]=P*v+ee*S,x[10]=O*v+se*S,x[11]=$*v+ie*S,x}function q(x,d,m){var v=Math.sin(m),S=Math.cos(m),E=d[0],P=d[1],O=d[2],$=d[3],G=d[4],ee=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*S+G*v,x[1]=P*S+ee*v,x[2]=O*S+se*v,x[3]=$*S+ie*v,x[4]=G*S-E*v,x[5]=ee*S-P*v,x[6]=se*S-O*v,x[7]=ie*S-$*v,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 v,S,E,P=m[0],O=m[1],$=m[2],G=Math.sqrt(P*P+O*O+$*$);return G0&&(E=1/Math.sqrt(E)),x[0]=d[0]*E,x[1]=d[1]*E,x[2]=d[2]*E,x}function $e(x,d){return x[0]*d[0]+x[1]*d[1]+x[2]*d[2]}function ct(x,d,m){var v=d[0],S=d[1],E=d[2],P=m[0],O=m[1],$=m[2];return x[0]=S*$-E*O,x[1]=E*P-v*$,x[2]=v*O-S*P,x}function Te(x,d,m,v){var S=d[0],E=d[1],P=d[2];return x[0]=S+v*(m[0]-S),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x}function ft(x,d,m){var v=d[0],S=d[1],E=d[2],P=m[3]*v+m[7]*S+m[11]*E+m[15];return x[0]=(m[0]*v+m[4]*S+m[8]*E+m[12])/(P=P||1),x[1]=(m[1]*v+m[5]*S+m[9]*E+m[13])/P,x[2]=(m[2]*v+m[6]*S+m[10]*E+m[14])/P,x}function me(x,d,m){var v=d[0],S=d[1],E=d[2];return x[0]=v*m[0]+S*m[3]+E*m[6],x[1]=v*m[1]+S*m[4]+E*m[7],x[2]=v*m[2]+S*m[5]+E*m[8],x}function Ve(x,d,m){var v=m[0],S=m[1],E=m[2],P=m[3],O=d[0],$=d[1],G=d[2],ee=S*G-E*$,se=E*O-v*G,ie=v*$-S*O;return x[0]=O+P*(ee+=ee)+S*(ie+=ie)-E*(se+=se),x[1]=$+P*se+E*ee-v*ie,x[2]=G+P*ie+v*se-S*ee,x}function nt(x){return x[0]=0,x[1]=0,x[2]=0,x}function et(x,d){return x[0]===d[0]&&x[1]===d[1]&&x[2]===d[2]}var Se=pe,rt=xe,Ge=ce;function lt(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0,x[3]=0),x}function qe(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],v=d[1],S=d[2],E=d[3],P=m*m+v*v+S*S+E*E;return P>0&&(P=1/Math.sqrt(P)),x[0]=m*P,x[1]=v*P,x[2]=S*P,x[3]=E*P,x}function Je(x,d,m){var v=d[0],S=d[1],E=d[2],P=d[3];return x[0]=m[0]*v+m[4]*S+m[8]*E+m[12]*P,x[1]=m[1]*v+m[5]*S+m[9]*E+m[13]*P,x[2]=m[2]*v+m[6]*S+m[10]*E+m[14]*P,x[3]=m[3]*v+m[7]*S+m[11]*E+m[15]*P,x}function He(){var x=new u(4);return u!=Float32Array&&(x[0]=0,x[1]=0,x[2]=0),x[3]=1,x}function Qe(x){return x[0]=0,x[1]=0,x[2]=0,x[3]=1,x}function at(x,d,m){m*=.5;var v=d[0],S=d[1],E=d[2],P=d[3],O=Math.sin(m),$=Math.cos(m);return x[0]=v*$+P*O,x[1]=S*$+E*O,x[2]=E*$-S*O,x[3]=P*$-v*O,x}function It(x,d,m){m*=.5;var v=d[0],S=d[1],E=d[2],P=d[3],O=Math.sin(m),$=Math.cos(m);return x[0]=v*$-E*O,x[1]=S*$+P*O,x[2]=E*$+v*O,x[3]=P*$-S*O,x}te(),lt();var Ut,hs,Yt,ts=Ze,Ds=(Ut=te(),hs=ne(1,0,0),Yt=ne(0,1,0),function(x,d,m){var v=$e(d,m);return v<-.999999?(ct(Ut,hs,d),Ge(Ut)<1e-6&&ct(Ut,Yt,d),Me(Ut,Ut),function(S,E,P){P*=.5;var O=Math.sin(P);S[0]=O*E[0],S[1]=O*E[1],S[2]=O*E[2],S[3]=Math.cos(P)}(x,Ut,Math.PI),x):v>.999999?(x[0]=0,x[1]=0,x[2]=0,x[3]=1,x):(ct(Ut,d,m),x[0]=Ut[0],x[1]=Ut[1],x[2]=Ut[2],x[3]=1+v,ts(x,x))});function vr(){var x=new u(2);return u!=Float32Array&&(x[0]=0,x[1]=0),x}function Ct(x,d){var m=new u(2);return m[0]=x,m[1]=d,m}function As(x,d,m){return x[0]=d,x[1]=m,x}function Us(x,d,m){return x[0]=d[0]+m[0],x[1]=d[1]+m[1],x}function kr(x,d,m){return x[0]=d[0]-m[0],x[1]=d[1]-m[1],x}function ta(x,d,m){return x[0]=d[0]*m,x[1]=d[1]*m,x}function ka(x){var d=x[0],m=x[1];return Math.sqrt(d*d+m*m)}function Li(x,d){var m=d[0],v=d[1],S=m*m+v*v;return S>0&&(S=1/Math.sqrt(S)),x[0]=d[0]*S,x[1]=d[1]*S,x}function Wa(x,d){return x[0]*d[0]+x[1]*d[1]}He(),He(),f();var cr,Qr,Hr=kr;function ln(x){return x&&x.__esModule&&Object.prototype.hasOwnProperty.call(x,"default")?x.default:x}vr();var Zr=function(){if(Qr)return cr;function x(d,m,v,S){this.cx=3*d,this.bx=3*(v-d)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*m,this.by=3*(S-m)-this.cy,this.ay=1-this.cy-this.by,this.p1x=d,this.p1y=m,this.p2x=v,this.p2y=S}return Qr=1,cr=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 v=d,S=0;S<8;S++){var E=this.sampleCurveX(v)-d;if(Math.abs(E)E?O=v:$=v,v=.5*($-O)+O;return v},solve:function(d,m){return this.sampleCurveY(this.solveCurveX(d,m))}},cr}(),yi=ln(Zr);function pt(x,d){this.x=x,this.y=d}function ir(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 Oo(x,d,m,v){const S=new yi(x,d,m,v);return function(E){return S.solve(E)}}const $t=Oo(.25,.1,.25,1);function je(x,d,m){return Math.min(m,Math.max(d,x))}function Be(x,d,m){return(m=je((m-x)/(d-x),0,1))*m*(3-2*m)}function Ye(x,d,m){const v=m-d,S=((x-d)%v+v)%v+d;return S===d?m:S}function vt(x,d,m){if(!x.length)return m(null,[]);let v=x.length;const S=new Array(x.length);let E=null;x.forEach((P,O)=>{d(P,($,G)=>{$&&(E=$),S[O]=G,--v==0&&m(E,S)})})}let xt=1;function Rt(){return xt++}function Zt(x){return x<=1?1:Math.pow(2,Math.ceil(Math.log2(x)))}function Vt(x,d){x.forEach(m=>{d[m]&&(d[m]=d[m].bind(d))})}function Qt(x,d,m){const v={};for(const S in x)v[S]=d.call(this,x[S],S,x);return v}function Es(x,d,m){const v={};for(const S in x)d.call(this,x[S],S,x)&&(v[S]=x[S]);return v}function ys(x){return Array.isArray(x)?x.map(ys):typeof x=="object"&&x?Qt(x,ys):x}function yr(x,d){for(let m=0;m=0)return!0;return!1}const Vr={};function fr(x){Vr[x]||(typeof console<"u"&&console.warn(x),Vr[x]=!0)}function Pn(x,d,m){return(m.y-x.y)*(d.x-x.x)>(d.y-x.y)*(m.x-x.x)}function In(x){let d=0;for(let m,v,S=0,E=x.length,P=E-1;S@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(m,v,S,E)=>{const P=S||E;return d[v]=!P||P.toLowerCase(),""}),d["max-age"]){const m=parseInt(d["max-age"],10);isNaN(m)?delete d["max-age"]:d["max-age"]=m}return d}let al=null;function Ja(x,d){return[x[4*d],x[4*d+1],x[4*d+2],x[4*d+3]]}function dl(x,d,m,v){for(;d>1;x[S]>1;x[S]<=v?d=S+1:m=S}return d}function Ea(x){return x>0?1/(1.001-x):1+x}function lo(x){return x>0?1-1/(1.001-x):-x}function Mi(x,d,m){return(x-d.min)*(m.max-m.min)/(d.max-d.min)+m.min}const ca={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(!ca.API_URL)return null;try{const x=new URL(ca.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 co(x){return ca.API_URL_REGEX.test(x)}function Nc(x){return ca.API_SPRITE_REGEX.test(x)}let Uc,ou,Df,Rl,oh,kd;function Gm(){return Uc==null&&(Uc=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&typeof self.createImageBitmap=="function"),Uc}const Fl={now:()=>Rl!==void 0?Rl:performance.now(),setNow(x){Rl=x},restoreNow(){Rl=void 0},frame(x){const d=requestAnimationFrame(x);return{cancel:()=>cancelAnimationFrame(d)}},getImageData(x,d=0){const{width:m,height:v}=x;oh||(oh=document.createElement("canvas"));const S=oh.getContext("2d",{willReadFrequently:!0});if(!S)throw new Error("failed to create canvas 2d context");return(m>oh.width||v>oh.height)&&(oh.width=m,oh.height=v),S.clearRect(-d,-d,m+2*d,v+2*d),S.drawImage(x,0,0,m,v),S.getImageData(-d,-d,m+2*d,v+2*d)},resolveURL:x=>(ou||(ou=document.createElement("a")),ou.href=x,ou.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(Df==null&&(Df=window.matchMedia("(prefers-reduced-motion: reduce)")),Df.matches)},hasCanvasFingerprintNoise(){if(kd!==void 0)return kd;if(!Gm())return kd=!1,!1;const x=new OffscreenCanvas(85,1),d=x.getContext("2d",{willReadFrequently:!0});let m=0;for(let S=0;S0?`?${E}`:""}`}const U1="mapbox-tiles";let V1=500,H1=50;const Dp=["language","worldview","jobid"];let nm,lu;function am(){try{return caches}catch{}}function Bd(){const x=am();x&&nm==null&&(nm=x.open(U1))}let Sd=1/0;const cu={supported:!1,testSupport:function(x){!Km&&Rf&&(Zm?G0(x):Of=x)}};let Of,Rf,Km=!1,Zm=!1;const Cd=typeof self<"u"?self:{};function G0(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,Rf),x.isContextLost())return;cu.supported=!0}catch{}x.deleteTexture(d),Km=!0}Cd.document&&(Rf=Cd.document.createElement("img"),Rf.onload=function(){Of&&G0(Of),Of=null,Zm=!0},Rf.onerror=function(){Km=!0,Of=null},Rf.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Zx={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(Zx);class Ml extends Error{constructor(d,m,v){m===401&&co(v)&&(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=v}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const W1=ya()?()=>self.worker.referrer:()=>(location.protocol==="blob:"?parent:self).location.href,Yx=function(x,d){if(!(/^file:/.test(m=x.url)||/^file:/.test(W1())&&!/^\w+:/.test(m))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(v,S){const E=new AbortController,P=new Request(v.url,{method:v.method||"GET",body:v.body,credentials:v.credentials,headers:v.headers,referrer:W1(),referrerPolicy:v.referrerPolicy,signal:E.signal});let O=!1,$=!1;const G=(ee=P.url).indexOf("sku=")>0&&co(ee);var ee;v.type==="json"&&P.headers.set("Accept","application/json");const se=(de,ue,ke)=>{if($)return;if(de&&de.message!=="SecurityError"&&fr(de.toString()),ue&&ke)return ie(ue);const Oe=Date.now();fetch(P).then(De=>{if(De.ok){const Ke=G?De.clone():null;return ie(De,Ke,Oe)}return S(new Ml(De.statusText,De.status,v.url))}).catch(De=>{De.name!=="AbortError"&&S(new Error(`${De.message} ${v.url}`))})},ie=(de,ue,ke)=>{(v.type==="arrayBuffer"?de.arrayBuffer():v.type==="json"?de.json():de.text()).then(Oe=>{$||(ue&&ke&&function(De,Ke,Xe){if(Bd(),nm==null)return;const ot=vo(Ke.headers.get("Cache-Control")||"");if(ot["no-store"])return;const Nt={status:Ke.status,statusText:Ke.statusText,headers:new Headers};Ke.headers.forEach((Ft,qt)=>Nt.headers.set(qt,Ft)),ot["max-age"]&&Nt.headers.set("Expires",new Date(Xe+1e3*ot["max-age"]).toUTCString());const yt=Nt.headers.get("Expires");if(!yt||new Date(yt).getTime()-Xe<42e4)return;let At=gy(De.url,{persistentParams:Dp});if(Ke.status===206){const Ft=De.headers.get("Range");if(!Ft)return;Nt.status=200,At=Kx(At,{range:Ft})}(function(Ft,qt){if(lu===void 0)try{new Response(new ReadableStream),lu=!0}catch{lu=!1}lu?qt(Ft.body):Ft.blob().then(qt).catch(ns=>fr(ns.message))})(Ke,Ft=>{const qt=new Response((ns=Ke.status)!==200&&ns!==404&&[101,103,204,205,304].includes(ns)?null:Ft,Nt);var ns;Bd(),nm!=null&&nm.then(Gt=>Gt.put(At,qt)).catch(Gt=>fr(Gt.message))})}(P,ue,ke),O=!0,S(null,Oe,de.headers))}).catch(Oe=>{$||S(new Error(Oe.message))})};return G?function(de,ue){if(Bd(),nm==null)return ue(null);nm.then(ke=>{let Oe=gy(de.url,{persistentParams:Dp});const De=de.headers.get("Range");De&&(Oe=Kx(Oe,{range:De})),ke.match(Oe).then(Ke=>{const Xe=function(ot){if(!ot)return!1;const Nt=new Date(ot.headers.get("Expires")||0),yt=vo(ot.headers.get("Cache-Control")||"");return Number(Nt)>Date.now()&&!yt["no-cache"]}(Ke);ke.delete(Oe).catch(ue),Xe&&ke.put(Oe,Ke.clone()).catch(ue),ue(null,Ke,Xe)}).catch(ue)}).catch(ue)}(P,se):se(null,null),{cancel:()=>{$=!0,O||E.abort()}}}(x,d);if(ya(self)&&self.worker.actor)return self.worker.actor.send("getResource",x,d,void 0,!0)}var m;return function(v,S){const E=new XMLHttpRequest;E.open(v.method||"GET",v.url,!0),v.type==="arrayBuffer"&&(E.responseType="arraybuffer");for(const P in v.headers)E.setRequestHeader(P,v.headers[P]);return v.type==="json"&&(E.responseType="text",E.setRequestHeader("Accept","application/json")),E.withCredentials=v.credentials==="include",E.onerror=()=>{S(new Error(E.statusText))},E.onload=()=>{if((E.status>=200&&E.status<300||E.status===0)&&E.response!==null){let P=E.response;if(v.type==="json")try{P=JSON.parse(E.response)}catch($){return S($)}const O=new Headers;E.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach($=>{const G=$.split(": "),ee=G.shift(),se=G.join(": ");O.append(ee,se)}),S(null,P,O)}else S(new Ml(E.statusText,E.status,v.url))},E.send(v.body),{cancel:()=>E.abort()}}(x,d)},Ih=function(x,d){return Yx(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 kC="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let K0,Pa;K0=[],Pa=0;const yy=function(x,d){if(cu.supported&&(x.headers||(x.headers={}),x.headers.accept="image/webp,*/*"),Pa>=ca.MAX_PARALLEL_IMAGE_REQUESTS){const E={requestParameters:x,callback:d,cancelled:!1,cancel(){this.cancelled=!0}};return K0.push(E),E}Pa++;let m=!1;const v=()=>{if(!m)for(m=!0,Pa--;K0.length&&Pa{v(),E?d(E):P&&(self.createImageBitmap?function($,G){const ee=new Blob([new Uint8Array($)],{type:"image/png"});createImageBitmap(ee).then(se=>{G(null,se)}).catch(se=>{G(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.`))})}(P,($,G)=>d($,G,O)):function($,G){const ee=new Image;ee.onload=()=>{G(null,ee),URL.revokeObjectURL(ee.src),ee.onload=null,requestAnimationFrame(()=>{ee.src=kC})},ee.onerror=()=>G(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($)],{type:"image/png"});ee.src=$.byteLength?URL.createObjectURL(se):kC}(P,($,G)=>d($,G,O)))});return{cancel:()=>{S.cancel(),v()}}};var Uw,SC,CC,im={exports:{}},Z0={exports:{}},Y0={exports:{}},Vw=function(){if(CC)return im.exports;CC=1;var x=(Uw||(Uw=1,Z0.exports=function(m,v){var S,E,P,O,$,G,ee,se;for(E=m.length-(S=3&m.length),P=v,$=3432918353,G=461845907,se=0;se>>16)*$&65535)<<16)&4294967295)<<15|ee>>>17))*G+(((ee>>>16)*G&65535)<<16)&4294967295)<<13|P>>>19))+((5*(P>>>16)&65535)<<16)&4294967295))+((58964+(O>>>16)&65535)<<16);switch(ee=0,S){case 3:ee^=(255&m.charCodeAt(se+2))<<16;case 2:ee^=(255&m.charCodeAt(se+1))<<8;case 1:P^=ee=(65535&(ee=(ee=(65535&(ee^=255&m.charCodeAt(se)))*$+(((ee>>>16)*$&65535)<<16)&4294967295)<<15|ee>>>17))*G+(((ee>>>16)*G&65535)<<16)&4294967295}return P^=m.length,P=2246822507*(65535&(P^=P>>>16))+((2246822507*(P>>>16)&65535)<<16)&4294967295,P=3266489909*(65535&(P^=P>>>13))+((3266489909*(P>>>16)&65535)<<16)&4294967295,(P^=P>>>16)>>>0}),Z0.exports),d=(SC||(SC=1,Y0.exports=function(m,v){for(var S,E=m.length,P=v^E,O=0;E>=4;)S=1540483477*(65535&(S=255&m.charCodeAt(O)|(255&m.charCodeAt(++O))<<8|(255&m.charCodeAt(++O))<<16|(255&m.charCodeAt(++O))<<24))+((1540483477*(S>>>16)&65535)<<16),P=1540483477*(65535&P)+((1540483477*(P>>>16)&65535)<<16)^(S=1540483477*(65535&(S^=S>>>24))+((1540483477*(S>>>16)&65535)<<16)),E-=4,++O;switch(E){case 3:P^=(255&m.charCodeAt(O+2))<<16;case 2:P^=(255&m.charCodeAt(O+1))<<8;case 1:P=1540483477*(65535&(P^=255&m.charCodeAt(O)))+((1540483477*(P>>>16)&65535)<<16)}return P=1540483477*(65535&(P^=P>>>13))+((1540483477*(P>>>16)&65535)<<16),(P^=P>>>15)>>>0}),Y0.exports);return im.exports=x,im.exports.murmur3=x,im.exports.murmur2=d,im.exports}(),G1=ln(Vw);class Ym{constructor(d,...m){Object.assign(this,m[0]||{}),this.type=d}}class vy extends Ym{constructor(d,m={}){super("error",Object.assign({error:d},m))}}function Hw(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 v=m[x].indexOf(d);v!==-1&&m[x].splice(v,1)}}class Ms{on(d,m){return this._listeners=this._listeners||{},Hw(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||{},Hw(d,m,this._oneTimeListeners),this):new Promise(v=>{this.once(d,v)})}fire(d,m){const v=typeof d=="string"?new Ym(d,m):d,S=v.type;if(this.listens(S)){v.target=this;const E=this._listeners&&this._listeners[S]?this._listeners[S].slice():[];for(const $ of E)$.call(this,v);const P=this._oneTimeListeners&&this._oneTimeListeners[S]?this._oneTimeListeners[S].slice():[];for(const $ of P)wt(S,$,this._oneTimeListeners),$.call(this,v);const O=this._eventedParent;if(O){const $=typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData;Object.assign(v,$),O.fire(v)}}else v instanceof vy&&console.error(v.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 Js{constructor(d){typeof d=="string"?this.name=d:(this.name=d.name,this.iconsetId=d.iconsetId)}static from(d){return new Js(d)}static toString(d){return d.iconsetId?`${d.name}${d.iconsetId}`:d.name}static parse(d){const[m,v]=d.split("");return new Js({name:m,iconsetId:v})}static isEqual(d,m){return d.name===m.name&&d.iconsetId===m.iconsetId}toString(){return Js.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var pn,fn={},oa=function(){if(pn)return fn;pn=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 v(E){return(P=E[E.length-1]==="%"?parseFloat(E)/100:parseFloat(E))<0?0:P>1?1:P;var P}function S(E,P,O){return O<0?O+=1:O>1&&(O-=1),6*O<1?E+(P-E)*O*6:2*O<1?P:3*O<2?E+(P-E)*(2/3-O)*6:E}try{fn.parseCSSColor=function(E){var P,O=E.replace(/ /g,"").toLowerCase();if(O in x)return x[O].slice();if(O[0]==="#")return O.length===4?(P=parseInt(O.substr(1),16))>=0&&P<=4095?[(3840&P)>>4|(3840&P)>>8,240&P|(240&P)>>4,15&P|(15&P)<<4,1]:null:O.length===7&&(P=parseInt(O.substr(1),16))>=0&&P<=16777215?[(16711680&P)>>16,(65280&P)>>8,255&P,1]:null;var $=O.indexOf("("),G=O.indexOf(")");if($!==-1&&G+1===O.length){var ee=O.substr(0,$),se=O.substr($+1,G-($+1)).split(","),ie=1;switch(ee){case"rgba":if(se.length!==4)return null;ie=v(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=v(se.pop());case"hsl":if(se.length!==3)return null;var de=(parseFloat(se[0])%360+360)%360/360,ue=v(se[1]),ke=v(se[2]),Oe=ke<=.5?ke*(ue+1):ke+ue-ke*ue,De=2*ke-Oe;return[d(255*S(De,Oe,de+1/3)),d(255*S(De,Oe,de)),d(255*S(De,Oe,de-1/3)),ie];default:return null}}return null}}catch{}return fn}();class qr{constructor(d,m,v,S=1){this.r=d,this.g=m,this.b=v,this.a=S}static parse(d){if(!d)return;if(d instanceof qr)return d;if(typeof d!="string")return;const m=oa.parseCSSColor(d);return m?new qr(m[0]/255,m[1]/255,m[2]/255,m[3]):void 0}toString(){const[d,m,v,S]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*d)},${Math.round(255*m)},${Math.round(255*v)},${S})`}toNonPremultipliedRenderColor(d){const{r:m,g:v,b:S,a:E}=this;return new Xx(d,m,v,S,E)}toPremultipliedRenderColor(d){const{r:m,g:v,b:S,a:E}=this;return new Op(d,m*E,v*E,S*E,E)}clone(){return new qr(this.r,this.g,this.b,this.a)}}class uo{constructor(d,m,v,S,E,P=!1){if(this.premultiplied=!1,this.premultiplied=P,d){const O=d.image.height,$=O*O;this.premultiplied?(m=E===0?0:m/E*(O-1),v=E===0?0:v/E*(O-1),S=E===0?0:S/E*(O-1)):(m*=O-1,v*=O-1,S*=O-1);const G=Math.floor(m),ee=Math.floor(v),se=Math.floor(S),ie=Math.ceil(m),de=Math.ceil(v),ue=Math.ceil(S),ke=m-G,Oe=v-ee,De=S-se,Ke=d.image.data,Xe=4*(G+ee*$+se*O),ot=4*(G+ee*$+ue*O),Nt=4*(G+de*$+se*O),yt=4*(G+de*$+ue*O),At=4*(ie+ee*$+se*O),Ft=4*(ie+ee*$+ue*O),qt=4*(ie+de*$+se*O),ns=4*(ie+de*$+ue*O);if(Xe<0||ns>=Ke.length)throw new Error("out of range");this.r=Kr(Kr(Kr(Ke[Xe],Ke[ot],De),Kr(Ke[Nt],Ke[yt],De),Oe),Kr(Kr(Ke[At],Ke[Ft],De),Kr(Ke[qt],Ke[ns],De),Oe),ke)/255*(this.premultiplied?E:1),this.g=Kr(Kr(Kr(Ke[Xe+1],Ke[ot+1],De),Kr(Ke[Nt+1],Ke[yt+1],De),Oe),Kr(Kr(Ke[At+1],Ke[Ft+1],De),Kr(Ke[qt+1],Ke[ns+1],De),Oe),ke)/255*(this.premultiplied?E:1),this.b=Kr(Kr(Kr(Ke[Xe+2],Ke[ot+2],De),Kr(Ke[Nt+2],Ke[yt+2],De),Oe),Kr(Kr(Ke[At+2],Ke[Ft+2],De),Kr(Ke[qt+2],Ke[ns+2],De),Oe),ke)/255*(this.premultiplied?E:1),this.a=E}else this.r=m,this.g=v,this.b=S,this.a=E}toArray(){const{r:d,g:m,b:v,a:S}=this;return[255*d,255*m,255*v,S]}toHslaArray(){let{r:d,g:m,b:v,a:S}=this;if(this.premultiplied){if(S===0)return[0,0,0,0];const ue=1/S;d*=ue,m*=ue,v*=ue}const E=Math.min(Math.max(d,0),1),P=Math.min(Math.max(m,0),1),O=Math.min(Math.max(v,0),1),$=Math.min(E,P,O),G=Math.max(E,P,O),ee=G-$,se=.5*($+G);if(ee===0)return[0,0,100*se,S];const ie=se>.5?ee/(2-G-$):ee/(G+$);let de;switch(G){case E:de=60*((P-O)/ee+(PKr(v,d[S],m))}qr.black=new qr(0,0,0,1),qr.white=new qr(1,1,1,1),qr.transparent=new qr(0,0,0,0),qr.red=new qr(1,0,0,1),qr.blue=new qr(0,0,1,1);var Q0=Object.freeze({__proto__:null,array:X0,color:function(x,d,m){return new qr(Kr(x.r,d.r,m),Kr(x.g,d.g,m),Kr(x.b,d.b,m),Kr(x.a,d.a,m))},number:Kr});class Xm extends Error{constructor(d,m){super(m),this.message=m,this.key=d}}class K1{constructor(d,m=[]){this.parent=d,this.bindings={};for(const[v,S]of m)this.bindings[v]=S}concat(d){return new K1(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"},Br={kind:"number"},Ia={kind:"string"},Ni={kind:"boolean"},lh={kind:"color"},Ff={kind:"object"},mi={kind:"value"},MC={kind:"collator"},Ww={kind:"formatted"},Gw={kind:"resolvedImage"};function $d(x,d){return{kind:"array",itemType:x,N:d}}function bl(x){if(x.kind==="array"){const d=bl(x.itemType);return typeof x.N=="number"?`array<${d}, ${x.N}>`:x.itemType.kind==="value"?"array":`array<${d}>`}return x.kind}const bme=[Rp,Br,Ia,Ni,lh,Ww,Ff,$d(mi),Gw];function by(x,d){if(d.kind==="error")return null;if(x.kind==="array"){if(d.kind==="array"&&(d.N===0&&d.itemType.kind==="value"||!by(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 bme)if(!by(m,d))return null}}return`Expected ${bl(x)} but found ${bl(d)} instead.`}function FE(x,d){return d.some(m=>m.kind===x.kind)}function Kw(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 TC(x,d){return x.kind==="array"&&d.kind==="array"?x.N===d.N&&TC(x.itemType,d.itemType):x.kind===d.kind}class zE{constructor(d,m,v){this.sensitivity=d?m?"variant":"case":m?"accent":"base",this.locale=v,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 AC{constructor(d,m,v,S,E){this.text=d.normalize?d.normalize():d,this.image=m,this.scale=v,this.fontStack=S,this.textColor=E}}class Lu{constructor(d){this.sections=d}static fromString(d){return new Lu([new AC(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 Lu?d:Lu.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 S=m.image.getPrimary().id.toString();d.push(["image",S]);continue}d.push(m.text);const v={};m.fontStack&&(v["text-font"]=["literal",m.fontStack.split(",")]),m.scale&&(v["font-scale"]=m.scale),m.textColor&&(v["text-color"]=["rgba"].concat(m.textColor.toNonPremultipliedRenderColor(null).toArray())),d.push(v)}return d}}class Qx{constructor(d,m={}){this.id=Js.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,v,S,E;try{({id:m,params:v,sx:S,sy:E}=JSON.parse(d)||{})}catch{return null}return m?new Qx(m,{params:v,sx:S,sy:E}):null}scaleSelf(d,m=d){return this.sx*=d,this.sy*=m,this}}class Du{constructor(d,m,v,S,E=!1){this.primaryId=Js.from(d),this.primaryOptions=m,v&&(this.secondaryId=Js.from(v)),this.secondaryOptions=S,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 Qx(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Qx(this.secondaryId,this.secondaryOptions):null}static from(d){return typeof d=="string"?Du.build({name:d}):d}static build(d,m,v,S){return!d||typeof d=="object"&&!("name"in d)?null:new Du(d,v,m,S)}}function J0(x,d,m,v){return typeof x=="number"&&x>=0&&x<=255&&typeof d=="number"&&d>=0&&d<=255&&typeof m=="number"&&m>=0&&m<=255?v===void 0||typeof v=="number"&&v>=0&&v<=1?null:`Invalid rgba value [${[x,d,m,v].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof v=="number"?[x,d,m,v]:[x,d,m]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Z1(x){if(x===null||typeof x=="string"||typeof x=="boolean"||typeof x=="number"||x instanceof qr||x instanceof zE||x instanceof Lu||x instanceof Du)return!0;if(Array.isArray(x)){for(const d of x)if(!Z1(d))return!1;return!0}if(typeof x=="object"){for(const d in x)if(!Z1(x[d]))return!1;return!0}return!1}function kc(x){if(x===null)return Rp;if(typeof x=="string")return Ia;if(typeof x=="boolean")return Ni;if(typeof x=="number")return Br;if(x instanceof qr)return lh;if(x instanceof zE)return MC;if(x instanceof Lu)return Ww;if(x instanceof Du)return Gw;if(Array.isArray(x)){const d=x.length;let m;for(const v of x){const S=kc(v);if(m){if(m===S)continue;m=mi;break}m=S}return $d(m||mi,d)}return Ff}function Qm(x){const d=typeof x;return x===null?"":d==="string"||d==="number"||d==="boolean"?String(x):x instanceof Lu||x instanceof Du||x instanceof qr?x.toString():JSON.stringify(x)}class Jx{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(!Z1(d[1]))return m.error("invalid value");const v=d[1];let S=kc(v);const E=m.expectedType;return S.kind!=="array"||S.N!==0||!E||E.kind!=="array"||typeof E.N=="number"&&E.N!==0||(S=E),new Jx(S,v)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof qr?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Lu?this.value.serialize():this.value}}class ic{constructor(d){this.name="ExpressionEvaluationError",this.message=d}toJSON(){return this.message}}const BE={string:Ia,number:Br,boolean:Ni,object:Ff};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 v,S=1;const E=d[0];if(E==="array"){let O,$;if(d.length>2){const G=d[1];if(typeof G!="string"||!(G in BE)||G==="object")return m.error('The item type argument of "array" must be one of string, number, boolean',1);O=BE[G],S++}else O=mi;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);$=d[2],S++}v=$d(O,$)}else v=BE[E];const P=[];for(;Sd.outputDefined())}serialize(){const d=this.type,m=[d.kind];if(d.kind==="array"){const v=d.itemType;if(v.kind==="string"||v.kind==="number"||v.kind==="boolean"){m.push(v.kind);const S=d.N;(typeof S=="number"||this.args.length>1)&&m.push(S)}}return m.concat(this.args.map(v=>v.serialize()))}}class zf{constructor(d){this.type=Ww,this.sections=d}static parse(d,m){if(d.length<2)return m.error("Expected at least one argument.");const v=d[1];if(!Array.isArray(v)&&typeof v=="object")return m.error("First argument must be an image or text section.");const S=[];let E=!1;for(let P=1;P<=d.length-1;++P){const O=d[P];if(E&&typeof O=="object"&&!Array.isArray(O)){E=!1;let $=null;if(O["font-scale"]&&($=m.parseObjectValue(O["font-scale"],P,"font-scale",Br),!$))return null;let G=null;if(O["text-font"]&&(G=m.parseObjectValue(O["text-font"],P,"text-font",$d(Ia)),!G))return null;let ee=null;if(O["text-color"]&&(ee=m.parseObjectValue(O["text-color"],P,"text-color",lh),!ee))return null;const se=S[S.length-1];se.scale=$,se.font=G,se.textColor=ee}else{const $=m.parse(d[P],P,mi);if(!$)return null;const G=$.type.kind;if(G!=="string"&&G!=="value"&&G!=="null"&&G!=="resolvedImage")return m.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");E=!0,S.push({content:$,scale:null,font:null,textColor:null})}}return new zf(S)}evaluate(d){return new Lu(this.sections.map(m=>{const v=m.content.evaluate(d);return TC(kc(v),Gw)?new AC("",v,null,null,null):new AC(Qm(v),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 v={};m.scale&&(v["font-scale"]=m.scale.serialize()),m.font&&(v["text-font"]=m.font.serialize()),m.textColor&&(v["text-color"]=m.textColor.serialize()),d.push(v)}return d}}class $n{constructor(d,m,v,S){this._imageWarnHistory={},this.type=Gw,this.namePrimary=d,this.nameSecondary=m,v&&(this.paramsPrimary=v.params,this.iconsetIdPrimary=v.iconset?v.iconset.id:void 0),S&&(this.paramsSecondary=S.params,this.iconsetIdSecondary=S.iconset?S.iconset.id:void 0)}static parse(d,m){if(d.length<2)return m.error("Expected two or more arguments.");let v=1;const S=[];function E(){if(vJs.isEqual(P,E)),S.available){const P=S.getSecondary()?S.getSecondary().id:null;P&&(S.available=d.availableImages.some(O=>Js.isEqual(O,P)))}}return S}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 v={};if(m&&(v.iconset={id:m}),d){v.params={};for(const S in d)d[S]&&(v.params[S]=d[S].serialize())}return Object.keys(v).length>0?v: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 Rr(x){return xn(x)?"string":Y1(x)?"number":PC(x)?"boolean":Array.isArray(x)?"array":x===null?"null":EC(x)?"object":typeof x}function EC(x){return x!=null&&!Array.isArray(x)&&typeof x!="function"&&!(x instanceof String||x instanceof Number||x instanceof Boolean)&&typeof x=="object"}function xn(x){return typeof x=="string"||x instanceof String}function Y1(x){return typeof x=="number"||x instanceof Number}function PC(x){return typeof x=="boolean"||x instanceof Boolean}const dn={"to-boolean":Ni,"to-color":lh,"to-number":Br,"to-string":Ia};class Bf{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 v=d[0],S=[];let E=Rp;if(v==="to-array"){if(!Array.isArray(d[1]))return null;const P=d[1].length;if(m.expectedType){if(m.expectedType.kind!=="array")return m.error(`Expected ${m.expectedType.kind} but found array.`);E=$d(m.expectedType.itemType,P)}else{if(!(P>0&&Z1(d[1][0])))return null;E=$d(kc(d[1][0]),P)}for(let O=0;O4?`Invalid rbga value ${JSON.stringify(m)}: expected an array containing either three or four numeric values.`:J0(m[0],m[1],m[2],m[3]),!v))return new qr(m[0]/255,m[1]/255,m[2]/255,m[3])}throw new ic(v||`Could not parse color from value '${typeof m=="string"?m:String(JSON.stringify(m))}'`)}if(this.type.kind==="number"){let m=null;for(const v of this.args){if(m=v.evaluate(d),m===null)return 0;const S=Number(m);if(!isNaN(S))return S}throw new ic(`Could not convert ${JSON.stringify(m)} to number.`)}return this.type.kind==="formatted"?Lu.fromString(Qm(this.args[0].evaluate(d))):this.type.kind==="resolvedImage"?Du.build(Qm(this.args[0].evaluate(d))):this.type.kind==="array"?this.args.map(m=>m.evaluate(d)):Qm(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 zf([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new $n(this.args[0]).serialize();const d=this.type.kind==="array"?[]:[`to-${this.type.kind}`];return this.eachChild(m=>{d.push(m.serialize())}),d}}const $E=["Unknown","Point","LineString","Polygon"];class IC{constructor(d,m,v){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=v}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?$E[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:v,y:S}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(v*m-d[0])+this.featureDistanceData.bearing[1]*(S*m-d[1])}return 0}parseColor(d){let m=this._parseColorCache[d];return m||(m=this._parseColorCache[d]=qr.parse(d)),m}getConfig(d){return this.options?this.options.get(d):null}}class Ou{constructor(d,m,v,S,E){this.name=d,this.type=m,this._evaluate=v,this.args=S,this._overloadIndex=E}evaluate(d){if(!this._evaluate){const m=Ou.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 v=d[0],S=Ou.definitions[v];if(!S)return m.error(`Unknown expression "${v}". If you wanted a literal array, use ["literal", [...]].`,0);const E=Array.isArray(S)?S[0]:S.type,P=Array.isArray(S)?[[S[1],S[2]]]:S.overloads,O=[];let $=null,G=-1;for(const[ee,se]of P){if(Array.isArray(ee)&&ee.length!==d.length-1)continue;O.push(ee),G++,$=new HC(m.registry,m.path,null,m.scope,void 0,m._scope,m.options,m.iconImageUseTheme);const ie=[];let de=!1;for(let ue=1;ueie)).map(LC).join(" | "),se=[];for(let ie=1;iem;){if(v-m>600){const $=v-m+1,G=d-m+1,ee=Math.log($),se=.5*Math.exp(2*ee/3),ie=.5*Math.sqrt(ee*se*($-se)/$)*(G-$/2<0?-1:1);DC(x,d,Math.max(m,Math.floor(d-G*se/$+ie)),Math.min(v,Math.floor(d+($-G)*se/$+ie)),S)}const E=x[d];let P=m,O=v;for(zp(x,m,d),S(x[v],E)>0&&zp(x,m,v);P0;)O--}S(x[m],E)===0?zp(x,m,O):(O++,zp(x,O,v)),O<=d&&(m=O+1),d<=O&&(v=O-1)}}function zp(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function qE(x,d){return xd?1:0}function _y(x){let d=0;for(let m,v,S=0,E=x.length,P=E-1;S=d[2]||x[1]<=d[1]||x[3]>=d[3])}function _me(x,d,m){const v=x[0]-d[0],S=x[1]-d[1],E=x[0]-m[0],P=x[1]-m[1];return v*P-E*S==0&&v*E<=0&&S*P<=0}function X1(x,d,m=!1){let v=!1;for(let O=0,$=d.length;O<$;O++){const G=d[O];for(let ee=0,se=G.length,ie=se-1;ee(S=x)[1]!=(P=ue)[1]>S[1]&&S[0]<(P[0]-E[0])*(S[1]-E[1])/(P[1]-E[1])+E[0]&&(v=!v)}}var S,E,P;return v}function Yw(x,d,m,v){const S=v[0]-m[0],E=v[1]-m[1],P=(x[0]-m[0])*E-S*(x[1]-m[1]),O=(d[0]-m[0])*E-S*(d[1]-m[1]);return P>0&&O<0||P<0&&O>0}function Xw(x,d,m,v){return(S=[v[0]-m[0],v[1]-m[1]])[0]*(E=[d[0]-x[0],d[1]-x[1]])[1]-S[1]*E[0]!=0&&!(!Yw(x,d,m,v)||!Yw(m,v,x,d));var S,E}function eg(x){const d=new pt(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),m=new pt(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const v of x[0])d.x>v.x&&(d.x=v.x),d.y>v.y&&(d.y=v.y),m.xm[2]){const S=.5*v;let E=x[0]-m[0]>S?-v:m[0]-x[0]>S?v:0;E===0&&(E=x[0]-m[2]>S?-v:m[2]-x[0]>S?v:0),x[0]+=E}Jm(d,x)}function CR(x,d,m,v){const S=Math.pow(2,v.z)*wy,E=[v.x*wy,v.y*wy],P=[];if(!x)return P;for(const O of x)for(const $ of O){const G=[$.x+E[0],$.y+E[1]];SR(G,d,m,S),P.push(G)}return P}function OC(x,d,m,v){const S=Math.pow(2,v.z)*wy,E=[v.x*wy,v.y*wy],P=[];if(!x)return P;for(const $ of x){const G=[];for(const ee of $){const se=[ee.x+E[0],ee.y+E[1]];Jm(d,se),G.push(se)}P.push(G)}if(d[2]-d[0]<=S/2){(O=d)[0]=O[1]=1/0,O[2]=O[3]=-1/0;for(const $ of P)for(const G of $)SR(G,d,m,S)}var O;return P}class Ny{constructor(d,m){this.type=Ni,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(Z1(d[1])){const v=d[1];if(v.type==="FeatureCollection")for(let S=0;Sm)return RC(E,P,(m-(v-O))/O)}return d[d.length-1]}pointToSegmentDistance(d,m,v){let[S,E]=m,P=om(v[0]-S)*this.kx,O=(v[1]-E)*this.ky;if(P!==0||O!==0){const $=(om(d[0]-S)*this.kx*P+(d[1]-E)*this.ky*O)/(P*P+O*O);$>1?(S=v[0],E=v[1]):$>0&&(S+=P/this.kx*$,E+=O/this.ky*$)}return P=om(d[0]-S)*this.kx,O=(d[1]-E)*this.ky,Math.sqrt(P*P+O*O)}pointOnLine(d,m){let v=1/0,S=d[0][0],E=d[0][1],P=0,O=0;for(let $=0;$1?(G=d[$+1][0],ee=d[$+1][1]):de>0&&(G+=se/this.kx*de,ee+=ie/this.ky*de)),se=om(m[0]-G)*this.kx,ie=(m[1]-ee)*this.ky;const ue=se*se+ie*ie;ueE.index||S.index===E.index&&S.t>E.t){const G=S;S=E,E=G}const P=[S.point],O=S.index+1,$=E.index;!HE(v[O],P[0])&&O<=$&&P.push(v[O]);for(let G=O+1;G<=$;G++)P.push(v[G]);return HE(v[$],E.point)||P.push(E.point),P}lineSliceAlong(d,m,v){let S=0;const E=[];for(let P=0;Pd&&E.length===0&&E.push(RC(O,$,(d-(S-G))/G)),S>=m)return E.push(RC(O,$,(m-(S-G))/G)),E;S>d&&E.push($)}return E}bufferPoint(d,m){const v=m/this.ky,S=m/this.kx;return[d[0]-S,d[1]-v,d[0]+S,d[1]+v]}bufferBBox(d,m){const v=m/this.ky,S=m/this.kx;return[d[0]-S,d[1]-v,d[2]+S,d[3]+v]}insideBBox(d,m){return om(d[0]-m[0])>=0&&om(d[0]-m[2])<=0&&d[1]>=m[1]&&d[1]<=m[3]}}function HE(x,d){return x[0]===d[0]&&x[1]===d[1]}function RC(x,d,m){const v=om(d[0]-x[0]);return[x[0]+v*m,x[1]+(d[1]-x[1])*m]}function om(x){for(;x<-180;)x+=360;for(;x>180;)x-=360;return x}class FC{constructor(d=[],m=(v,S)=>vS?1:0){if(this.data=d,this.length=this.data.length,this.compare=m,this.length>0)for(let v=(this.length>>1)-1;v>=0;v--)this._down(v)}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:v}=this,S=m[d];for(;d>0;){const E=d-1>>1,P=m[E];if(v(S,P)>=0)break;m[d]=P,d=E}m[d]=S}_down(d){const{data:m,compare:v}=this,S=this.length>>1,E=m[d];for(;d=0)break;m[d]=m[P],d=P}m[d]=E}}var tr=8192;function WE(x,d){return d.dist-x.dist}const zC=100,BC=50;function GE(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=Jw(x);if(d){if(m===2)return[x,null];const v=Math.floor(m/2);return[[x[0],x[0]+v],[x[0]+v,x[1]]]}{if(m===1)return[x,null];const v=Math.floor(m/2)-1;return[[x[0],x[0]+v],[x[0]+v+1,x[1]]]}}function ev(x,d){const m=[1/0,1/0,-1/0,-1/0];if(!$f(d,x.length))return m;for(let v=d[0];v<=d[1];++v)Jm(m,x[v]);return m}function tv(x){const d=[1/0,1/0,-1/0,-1/0];for(let m=0;md[2]&&(v=x[0]-d[2]),x[1]>d[3]&&(S=x[1]-d[3]),x[3]=v)return v;if(Zw(S,E)){if(YE(x,d))return 0}else if(YE(d,x))return 0;let P=v;for(const O of x)for(let $=0,G=O.length,ee=G-1;$=E)continue;const ee=G.range1;if(Jw(ee)<=O){if(!$f(ee,x.length))return NaN;if(d){const se=Cme(x,ee,m,v);if((E=Math.min(E,se))===0)return E}else for(let se=ee[0];se<=ee[1];++se){const ie=Sme(x[se],m,v);if((E=Math.min(E,ie))===0)return E}}else{const se=KE(ee,d);if(se[0]!==null){const ie=ky(ev(x,se[0]),$,v);ie=P)continue;const se=ee.range1,ie=ee.range2;if(Jw(se)<=$&&Jw(ie)<=G){if(!$f(se,x.length)||!$f(ie,m.length))return NaN;if(d&&v?P=Math.min(P,Oa(x,se,m,ie,S)):d||v?d&&!v?P=Math.min(P,ZE(m,ie,x,se,S)):!d&&v&&(P=Math.min(P,ZE(x,se,m,ie,S))):P=Math.min(P,kme(x,se,m,ie,S)),P===0)return P}else{const de=KE(se,d),ue=KE(ie,v);ho(O,P,S,x,m,de[0],ue[0]),ho(O,P,S,x,m,de[0],ue[1]),ho(O,P,S,x,m,de[1],ue[0]),ho(O,P,S,x,m,de[1],ue[1])}}return P}function XE(x,d,m,v,S=1/0){let E=S;const P=ev(x,[0,x.length-1]);for(const O of m)if(!(E!==1/0&&ky(P,ev(O,[0,O.length-1]),v)>=E)&&(E=Math.min(E,ER(x,d,O,!0,v,E)),E===0))return E;return E}function UC(x,d,m,v,S=1/0){let E=S;const P=ev(x,[0,x.length-1]);for(const O of m){if(E!==1/0&&ky(P,tv(O),v)>=E)continue;const $=Tme(x,d,O,v,E);if(isNaN($))return $;if((E=Math.min(E,$))===0)return E}return E}function QE(x){return x==="Point"||x==="MultiPoint"||x==="LineString"||x==="MultiLineString"||x==="Polygon"||x==="MultiPolygon"}class sv{constructor(d,m){this.type=Br,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(Z1(d[1])){const v=d[1];if(v.type==="FeatureCollection"){for(let S=0;S{d&&!eb(m)&&(d=!1)}),d}function e2(x){if(x instanceof Ou&&x.name==="feature-state")return!1;let d=!0;return x.eachChild(m=>{d&&!e2(m)&&(d=!1)}),d}function tb(x,d){if(x instanceof Ou&&d.indexOf(x.name)>=0)return!1;let m=!0;return x.eachChild(v=>{m&&!tb(v,d)&&(m=!1)}),m}function PR(x,d,m){return[x,d,m].filter(Boolean).join("")}function JE(x,d){switch(x){case"string":return Qm(d);case"number":return+d;case"boolean":return!!d;case"color":return qr.parse(d);case"formatted":return Lu.fromString(Qm(d));case"resolvedImage":return Du.build(Qm(d))}return d}function IR(x,d,m,v){return v!==void 0&&(x=v*Math.round(x/v)),d!==void 0&&xm&&(x=m),x}class sb{constructor(d,m,v,S=!1){this.type=d,this.key=m,this.scope=v,this.featureConstant=S}static parse(d,m){let v=m.expectedType;if(v==null&&(v=mi),d.length<2||d.length>3)return m.error("Invalid number of arguments for 'config' expression.");const S=m.parse(d[1],1);if(!(S instanceof Jx))return m.error("Key name of 'config' expression must be a string literal.");let E,P=!0;const O=Qm(S.value);if(d.length>=3){const $=m.parse(d[2],2);if(!($ instanceof Jx))return m.error("Scope of 'config' expression must be a string literal.");E=Qm($.value)}if(m.options){const $=PR(O,E,m._scope),G=m.options.get($);G&&(P=eb(G.value||G.default))}return new sb(v,O,E,P)}evaluate(d){const m=PR(this.key,this.scope,d.scope),v=d.getConfig(m);if(!v)return null;const{type:S,value:E,values:P,minValue:O,maxValue:$,stepValue:G}=v,ee=v.default.evaluate(d);let se=ee;if(E){const ie=d.scope;d.scope=(ie||"").split("").slice(1).join(""),se=E.evaluate(d),d.scope=ie}return S&&(se=JE(S,se)),se===void 0||O===void 0&&$===void 0&&G===void 0||(typeof se=="number"?se=IR(se,O,$,G):Array.isArray(se)&&(se=se.map(ie=>typeof ie=="number"?IR(ie,O,$,G):ie))),E!==void 0&&se!==void 0&&P&&!P.includes(se)&&(se=ee,S&&(se=JE(S,se))),(S&&S!==this.type||se!==void 0&&!TC(kc(se),this.type))&&(se=JE(this.type.kind,se)),se}eachChild(){}outputDefined(){return!1}serialize(){const d=["config",this.key];return this.scope&&d.concat(this.scope),d}}class VC{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 v=d[1];return m.scope.has(v)?new VC(v,m.scope.get(v)):m.error(`Unknown variable "${v}". Make sure "${v}" 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 HC{constructor(d,m=[],v,S=new K1,E=[],P,O,$){this.registry=d,this.path=m,this.key=m.map(G=>typeof G=="string"?`['${G}']`:`[${G}]`).join(""),this.scope=S,this.errors=E,this.expectedType=v,this._scope=P,this.options=O,this.iconImageUseTheme=$}parse(d,m,v,S,E={}){return m||v?this.concat(m,null,v,S)._parse(d,E):this._parse(d,E)}parseObjectValue(d,m,v,S,E,P={}){return this.concat(m,v,S,E)._parse(d,P)}_parse(d,m){function v(S,E,P){return P==="assert"?new Fp(E,[S]):P==="coerce"?new Bf(E,[S]):S}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 S=typeof d[0]=="string"?this.registry[d[0]]:void 0;if(S){let E=S.parse(d,this);if(!E)return null;if(this.expectedType){const P=this.expectedType,O=E.type;if(P.kind!=="string"&&P.kind!=="number"&&P.kind!=="boolean"&&P.kind!=="object"&&P.kind!=="array"||O.kind!=="value")if(P.kind!=="color"&&P.kind!=="formatted"&&P.kind!=="resolvedImage"||O.kind!=="value"&&O.kind!=="string"){if(this.checkSubtype(P,O))return null}else E=v(E,P,m.typeAnnotation||"coerce");else E=v(E,P,m.typeAnnotation||"assert")}if(!(E instanceof Jx)&&E.type.kind!=="resolvedImage"&&e6(E)){const P=new IC(this._scope,this.options,this.iconImageUseTheme);try{E=new Jx(E.type,E.evaluate(P))}catch(O){return this.error(O.message),null}}return E}return Bf.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,v,S){let E=typeof d=="number"?this.path.concat(d):this.path;E=typeof m=="string"?E.concat(m):E;const P=S?this.scope.concat(S):this.scope;return new HC(this.registry,E,v||null,P,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(d,...m){const v=`${this.key}${m.map(S=>`[${S}]`).join("")}`;this.errors.push(new Xm(v,d))}checkSubtype(d,m){const v=by(d,m);return v&&this.error(v),v}}function e6(x){if(x instanceof VC)return e6(x.boundExpression);if(x instanceof Ou&&x.name==="error"||x instanceof Vc||x instanceof Ny||x instanceof sv||x instanceof sb)return!1;const d=x instanceof Bf||x instanceof Fp;let m=!0;return x.eachChild(v=>{m=d?m&&e6(v):m&&v instanceof Jx}),!!m&&eb(x)&&tb(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 WC(x,d){const m=x.length-1;let v,S,E=0,P=m,O=0;for(;E<=P;)if(O=Math.floor((E+P)/2),v=x[O],S=x[O+1],v<=d){if(O===m||dd))throw new ic("Input is not a number.");P=O-1}return 0}class t2{constructor(d,m,v){this.type=d,this.input=m,this.labels=[],this.outputs=[];for(const[S,E]of v)this.labels.push(S),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 v=m.parse(d[1],1,Br);if(!v)return null;const S=[];let E=null;m.expectedType&&m.expectedType.kind!=="value"&&(E=m.expectedType);for(let P=1;P=O)return m.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',G);const se=m.parse($,ee,E);if(!se)return null;E=E||se.type,S.push([O,se])}return new t2(E,v,S)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const S=this.input.evaluate(d);if(S<=m[0])return v[0].evaluate(d);const E=m.length;return S>=m[E-1]?v[E-1].evaluate(d):v[WC(m,S)].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 LR=.95047,DR=1.08883,OR=4/29,rb=6/29,RR=3*rb*rb,Ame=rb*rb*rb,Eme=Math.PI/180,Pme=180/Math.PI;function t6(x){return x>Ame?Math.pow(x,1/3):x/RR+OR}function s6(x){return x>rb?x*x*x:RR*(x-OR)}function r6(x){return 255*(x<=.0031308?12.92*x:1.055*Math.pow(x,1/2.4)-.055)}function n6(x){return(x/=255)<=.04045?x/12.92:Math.pow((x+.055)/1.055,2.4)}function FR(x){const d=n6(x.r),m=n6(x.g),v=n6(x.b),S=t6((.4124564*d+.3575761*m+.1804375*v)/LR),E=t6((.2126729*d+.7151522*m+.072175*v)/1);return{l:116*E-16,a:500*(S-E),b:200*(E-t6((.0193339*d+.119192*m+.9503041*v)/DR)),alpha:x.a}}function GC(x){let d=(x.l+16)/116,m=isNaN(x.a)?d:d+x.a/500,v=isNaN(x.b)?d:d-x.b/200;return d=1*s6(d),m=LR*s6(m),v=DR*s6(v),new qr(r6(3.2404542*m-1.5371385*d-.4985314*v),r6(-.969266*m+1.8760108*d+.041556*v),r6(.0556434*m-.2040259*d+1.0572252*v),x.alpha)}function KC(x,d,m){const v=d-x;return x+m*(v>180||v<-180?v-360*Math.round(v/360):v)}const nb={forward:FR,reverse:GC,interpolate:function(x,d,m){return{l:Kr(x.l,d.l,m),a:Kr(x.a,d.a,m),b:Kr(x.b,d.b,m),alpha:Kr(x.alpha,d.alpha,m)}}},s2={forward:function(x){const{l:d,a:m,b:v}=FR(x),S=Math.atan2(v,m)*Pme;return{h:S<0?S+360:S,c:Math.sqrt(m*m+v*v),l:d,alpha:x.a}},reverse:function(x){const d=x.h*Eme,m=x.c;return GC({l:x.l,a:Math.cos(d)*m,b:Math.sin(d)*m,alpha:x.alpha})},interpolate:function(x,d,m){return{h:KC(x.h,d.h,m),c:Kr(x.c,d.c,m),l:Kr(x.l,d.l,m),alpha:Kr(x.alpha,d.alpha,m)}}};var zR=Object.freeze({__proto__:null,hcl:s2,lab:nb});class lm{constructor(d,m,v,S,E){this.type=d,this.operator=m,this.interpolation=v,this.input=S,this.labels=[],this.outputs=[];for(const[P,O]of E)this.labels.push(P),this.outputs.push(O)}static interpolationFactor(d,m,v,S){let E=0;if(d.name==="exponential")E=ZC(m,d.base,v,S);else if(d.name==="linear")E=ZC(m,1,v,S);else if(d.name==="cubic-bezier"){const P=d.controlPoints;E=new yi(P[0],P[1],P[2],P[3]).solve(ZC(m,1,v,S))}return E}static parse(d,m){let[v,S,E,...P]=d;if(!Array.isArray(S)||S.length===0)return m.error("Expected an interpolation type expression.",1);if(S[0]==="linear")S={name:"linear"};else if(S[0]==="exponential"){const G=S[1];if(typeof G!="number")return m.error("Exponential interpolation requires a numeric base.",1,1);S={name:"exponential",base:G}}else{if(S[0]!=="cubic-bezier")return m.error(`Unknown interpolation type ${String(S[0])}`,1,0);{const G=S.slice(1);if(G.length!==4||G.some(ee=>typeof ee!="number"||ee<0||ee>1))return m.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);S={name:"cubic-bezier",controlPoints:G}}}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,Br),!E)return null;const O=[];let $=null;v==="interpolate-hcl"||v==="interpolate-lab"?$=lh:m.expectedType&&m.expectedType.kind!=="value"&&($=m.expectedType);for(let G=0;G=ee)return m.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',ie);const ue=m.parse(se,de,$);if(!ue)return null;$=$||ue.type,O.push([ee,ue])}return $.kind==="number"||$.kind==="color"||$.kind==="array"&&$.itemType.kind==="number"&&typeof $.N=="number"?new lm($,v,S,E,O):m.error(`Type ${bl($)} is not interpolatable.`)}evaluate(d){const m=this.labels,v=this.outputs;if(m.length===1)return v[0].evaluate(d);const S=this.input.evaluate(d);if(S<=m[0])return v[0].evaluate(d);const E=m.length;if(S>=m[E-1])return v[E-1].evaluate(d);const P=WC(m,S),O=lm.interpolationFactor(this.interpolation,S,m[P],m[P+1]),$=v[P].evaluate(d),G=v[P+1].evaluate(d);return this.operator==="interpolate"?Q0[this.type.kind.toLowerCase()]($,G,O):this.operator==="interpolate-hcl"?s2.reverse(s2.interpolate(s2.forward($),s2.forward(G),O)):nb.reverse(nb.interpolate(nb.forward($),nb.forward(G),O))}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 v=0;vby(S,O.type));return new r2(P?mi:v,E)}evaluate(d){let m,v=null,S=0;for(const E of this.args){if(S++,v=E.evaluate(d),v&&v instanceof Du&&!v.available&&(m||(m=v),v=null,S===this.args.length))return m;if(v!==null)break}return v}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 tg{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 v=[];for(let E=1;E=v.length)throw new ic("Array index out of bounds: index exceeds array size");if(m!==Math.floor(m))throw new ic("Array index must be an integer. Use at-interpolated for fractional indices");return v[m]}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}class XC{constructor(d,m,v){this.type=d,this.index=m,this.input=v}static parse(d,m){if(d.length!==3)return m.error(`Expected 2 arguments, but found ${d.length-1} instead.`);const v=m.parse(d[1],1,Br),S=m.parse(d[2],2,$d(m.expectedType||mi));return v&&S?new XC(S.type.itemType,v,S):null}evaluate(d){const m=this.index.evaluate(d),v=this.input.evaluate(d);if(m<0)throw new ic(`Array index out of bounds: ${m} < 0.`);if(m>v.length-1)throw new ic(`Array index out of bounds: ${m} > ${v.length-1}.`);if(m===Math.floor(m))return v[m];const S=Math.floor(m),E=Math.ceil(m),P=v[S],O=v[E];if(typeof P!="number"||typeof O!="number")throw new ic(`Cannot interpolate between non-number values at index ${m}.`);const $=m-S;return P*(1-$)+O*$}eachChild(d){d(this.index),d(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class a6{constructor(d,m){this.type=Ni,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 v=m.parse(d[1],1,mi),S=m.parse(d[2],2,mi);return v&&S?FE(v.type,[Ni,Ia,Br,Rp,mi])?new a6(v,S):m.error(`Expected first argument to be of type boolean, string, number or null, but found ${bl(v.type)} instead`):null}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(v==null)return!1;if(!Kw(m,["boolean","string","number","null"]))throw new ic(`Expected first argument to be of type boolean, string, number or null, but found ${bl(kc(m))} instead.`);if(!Kw(v,["string","array"]))throw new ic(`Expected second argument to be of type array or string, but found ${bl(kc(v))} instead.`);return v.indexOf(m)>=0}eachChild(d){d(this.needle),d(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class ab{constructor(d,m,v){this.type=Br,this.needle=d,this.haystack=m,this.fromIndex=v}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 v=m.parse(d[1],1,mi),S=m.parse(d[2],2,mi);if(!v||!S)return null;if(!FE(v.type,[Ni,Ia,Br,Rp,mi]))return m.error(`Expected first argument to be of type boolean, string, number or null, but found ${bl(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,Br);return E?new ab(v,S,E):null}return new ab(v,S)}evaluate(d){const m=this.needle.evaluate(d),v=this.haystack.evaluate(d);if(!Kw(m,["boolean","string","number","null"]))throw new ic(`Expected first argument to be of type boolean, string, number or null, but found ${bl(kc(m))} instead.`);if(!Kw(v,["string","array"]))throw new ic(`Expected second argument to be of type array or string, but found ${bl(kc(v))} instead.`);if(this.fromIndex){const S=this.fromIndex.evaluate(d);return v.indexOf(m,S)}return v.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 n2{constructor(d,m,v,S,E,P){this.inputType=d,this.type=m,this.input=v,this.cases=S,this.outputs=E,this.otherwise=P}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 v,S;m.expectedType&&m.expectedType.kind!=="value"&&(S=m.expectedType);const E={},P=[];for(let G=2;GNumber.MAX_SAFE_INTEGER)return ie.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof ue=="number"&&Math.floor(ue)!==ue)return ie.error("Numeric branch labels must be integer values.");if(v){if(ie.checkSubtype(v,kc(ue)))return null}else v=kc(ue);if(E[String(ue)]!==void 0)return ie.error("Branch labels must be unique.");E[String(ue)]=P.length}const de=m.parse(se,G,S);if(!de)return null;S=S||de.type,P.push(de)}const O=m.parse(d[1],1,mi);if(!O)return null;const $=m.parse(d[d.length-1],d.length-1,S);return $?O.type.kind!=="value"&&m.concat(1).checkSubtype(v,O.type)?null:new n2(v,S,O,E,P,$):null}evaluate(d){const m=this.input.evaluate(d);return(TC(kc(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(),v=[],S={};for(const P of m){const O=S[this.cases[P]];O===void 0?(S[this.cases[P]]=v.length,v.push([this.cases[P],[P]])):v[O][1].push(P)}const E=P=>this.inputType.kind==="number"?Number(P):P;for(const[P,O]of v)d.push(O.length===1?E(O[0]):O.map(E)),d.push(this.outputs[P].serialize());return d.push(this.otherwise.serialize()),d}}class a2{constructor(d,m,v){this.type=d,this.branches=m,this.otherwise=v}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 v;m.expectedType&&m.expectedType.kind!=="value"&&(v=m.expectedType);const S=[];for(let P=1;Pm.outputDefined())&&this.otherwise.outputDefined()}serialize(){const d=["case"];return this.eachChild(m=>{d.push(m.serialize())}),d}}class QC{constructor(d,m,v,S){this.type=d,this.input=m,this.beginIndex=v,this.endIndex=S}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 v=m.parse(d[1],1,mi),S=m.parse(d[2],2,Br);if(!v||!S)return null;if(!FE(v.type,[$d(mi),Ia,mi]))return m.error(`Expected first argument to be of type array or string, but found ${bl(v.type)} instead`);if(d.length===4){const E=m.parse(d[3],3,Br);return E?new QC(v.type,v,S,E):null}return new QC(v.type,v,S)}evaluate(d){const m=this.input.evaluate(d),v=this.beginIndex.evaluate(d);if(!Kw(m,["string","array"]))throw new ic(`Expected first argument to be of type array or string, but found ${bl(kc(m))} instead.`);if(this.endIndex){const S=this.endIndex.evaluate(d);return m.slice(v,S)}return m.slice(v)}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 i6{constructor(d,m){this.type=$d(Ia),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 v=m.parse(d[1],1,Ia),S=m.parse(d[2],2,Ia);return v&&S?new i6(v,S):void 0}evaluate(d){const m=this.str.evaluate(d),v=this.delimiter.evaluate(d);return m.split(v)}eachChild(d){d(this.str),d(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function o6(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 l6(x,d,m,v){return v.compare(d,m)===0}function ib(x,d,m){const v=x!=="=="&&x!=="!=";return class uWe{constructor(E,P,O){this.type=Ni,this.lhs=E,this.rhs=P,this.collator=O,this.hasUntypedArgument=E.type.kind==="value"||P.type.kind==="value"}static parse(E,P){if(E.length!==3&&E.length!==4)return P.error("Expected two or three arguments.");const O=E[0];let $=P.parse(E[1],1,mi);if(!$)return null;if(!o6(O,$.type))return P.concat(1).error(`"${O}" comparisons are not supported for type '${bl($.type)}'.`);let G=P.parse(E[2],2,mi);if(!G)return null;if(!o6(O,G.type))return P.concat(2).error(`"${O}" comparisons are not supported for type '${bl(G.type)}'.`);if($.type.kind!==G.type.kind&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error(`Cannot compare types '${bl($.type)}' and '${bl(G.type)}'.`);v&&($.type.kind==="value"&&G.type.kind!=="value"?$=new Fp(G.type,[$]):$.type.kind!=="value"&&G.type.kind==="value"&&(G=new Fp($.type,[G])));let ee=null;if(E.length===4){if($.type.kind!=="string"&&G.type.kind!=="string"&&$.type.kind!=="value"&&G.type.kind!=="value")return P.error("Cannot use collator to compare non-string types.");if(ee=P.parse(E[3],3,MC),!ee)return null}return new uWe($,G,ee)}evaluate(E){const P=this.lhs.evaluate(E),O=this.rhs.evaluate(E);if(v&&this.hasUntypedArgument){const $=kc(P),G=kc(O);if($.kind!==G.kind||$.kind!=="string"&&$.kind!=="number")throw new ic(`Expected arguments for "${x}" to be (string, string) or (number, number), but found (${$.kind}, ${G.kind}) instead.`)}if(this.collator&&!v&&this.hasUntypedArgument){const $=kc(P),G=kc(O);if($.kind!=="string"||G.kind!=="string")return d(E,P,O)}return this.collator?m(E,P,O,this.collator.evaluate(E)):d(E,P,O)}eachChild(E){E(this.lhs),E(this.rhs),this.collator&&E(this.collator)}outputDefined(){return!0}serialize(){const E=[x];return this.eachChild(P=>{E.push(P.serialize())}),E}}}const Ime=ib("==",function(x,d,m){return d===m},l6),Lme=ib("!=",function(x,d,m){return d!==m},function(x,d,m,v){return!l6(0,d,m,v)}),BR=ib("<",function(x,d,m){return d",function(x,d,m){return d>m},function(x,d,m,v){return v.compare(d,m)>0}),JC=ib("<=",function(x,d,m){return d<=m},function(x,d,m,v){return v.compare(d,m)<=0}),Dme=ib(">=",function(x,d,m){return d>=m},function(x,d,m,v){return v.compare(d,m)>=0});class e3{constructor(d,m,v,S,E,P){this.type=Ia,this.number=d,this.locale=m,this.currency=v,this.unit=S,this.minFractionDigits=E,this.maxFractionDigits=P}static parse(d,m){if(d.length!==3)return m.error("Expected two arguments.");const v=m.parse(d[1],1,Br);if(!v)return null;const S=d[2];if(typeof S!="object"||Array.isArray(S))return m.error("NumberFormat options argument must be an object.");let E=null;if(S.locale&&(E=m.parseObjectValue(S.locale,2,"locale",Ia),!E))return null;let P=null;if(S.currency&&(P=m.parseObjectValue(S.currency,2,"currency",Ia),!P))return null;let O=null;if(S.unit&&(O=m.parseObjectValue(S.unit,2,"unit",Ia),!O))return null;let $=null;if(S["min-fraction-digits"]&&($=m.parseObjectValue(S["min-fraction-digits"],2,"min-fraction-digits",Br),!$))return null;let G=null;return S["max-fraction-digits"]&&(G=m.parseObjectValue(S["max-fraction-digits"],2,"max-fraction-digits",Br),!G)?null:new e3(v,E,P,O,$,G)}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 c6{constructor(d){this.type=Br,this.input=d}static parse(d,m){if(d.length!==2)return m.error(`Expected 1 argument, but found ${d.length-1} instead.`);const v=m.parse(d[1],1);return v?v.type.kind!=="array"&&v.type.kind!=="string"&&v.type.kind!=="value"?m.error(`Expected argument of type string or array, but found ${bl(v.type)} instead.`):new c6(v):null}evaluate(d){const m=this.input.evaluate(d);if(typeof m=="string"||Array.isArray(m))return m.length;throw new ic(`Expected value to be of type string or array, but found ${bl(kc(m))} instead.`)}eachChild(d){d(this.input)}outputDefined(){return!1}serialize(){const d=["length"];return this.eachChild(m=>{d.push(m.serialize())}),d}}function qR(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 ob={"==":Ime,"!=":Lme,">":$R,"<":BR,">=":Dme,"<=":JC,array:Fp,at:YC,"at-interpolated":XC,boolean:Fp,case:a2,coalesce:r2,collator:Vc,format:zf,image:$n,in:a6,"index-of":ab,interpolate:lm,"interpolate-hcl":lm,"interpolate-lab":lm,length:c6,let:tg,literal:Jx,match:n2,number:Fp,"number-format":e3,object:Fp,slice:QC,step:t2,string:Fp,"to-boolean":Bf,"to-color":Bf,"to-number":Bf,"to-string":Bf,var:VC,within:Ny,distance:sv,config:sb,split:i6};function d6(x,[d,m,v,S]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=S?S.evaluate(x):1,P=J0(d,m,v,E);if(P)throw new ic(P);return new qr(d/255,m/255,v/255,E)}function u6(x,[d,m,v,S]){d=d.evaluate(x),m=m.evaluate(x),v=v.evaluate(x);const E=S?S.evaluate(x):1,P=function(G,ee,se,ie){return typeof G=="number"&&G>=0&&G<=360?typeof ee=="number"&&ee>=0&&ee<=100&&typeof se=="number"&&se>=0&&se<=100?ie===void 0||typeof ie=="number"&&ie>=0&&ie<=1?null:`Invalid hsla value [${[G,ee,se,ie].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${(typeof ie=="number"?[G,ee,se,ie]:[G,ee,se]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${(typeof ie=="number"?[G,ee,se,ie]:[G,ee,se]).join(", ")}]: 'h' must be between 0 and 360.`}(d,m,v,E);if(P)throw new ic(P);const O=`hsla(${d}, ${m}%, ${v}%, ${E})`,$=qr.parse(O);if(!$)throw new ic(`Failed to parse HSLA color: ${O}`);return $}function UR(x,d){return x in d}function h6(x,d){const m=d[x];return m===void 0?null:m}function Cy(x){return{type:x}}function rv(x){if(x instanceof sb)return new Set([x.key]);let d=new Set;return x.eachChild(m=>{d=new Set([...d,...rv(m)])}),d}function t3(x){if(x instanceof Ou&&x.name==="is-active-floor")return!0;let d=!1;return x.eachChild(m=>{!d&&t3(m)&&(d=!0)}),d}function VR(x){return{result:"success",value:x}}function My(x){return{result:"error",value:x}}function m6(x,d){return!!x&&!!x.parameters&&x.parameters.indexOf(d)>-1}function i2(x){return x["property-type"]==="data-driven"}function HR(x){return m6(x.expression,"measure-light")}function WR(x){return m6(x.expression,"zoom")}function s3(x){return!!x.expression&&x.expression.interpolated}function r3(x){return typeof x=="object"&&x!==null&&!Array.isArray(x)}function GR(x){return x}function KR(x,d){const m=d.type==="color",v=x.stops&&typeof x.stops[0][0]=="object",S=v||!(v||x.property!==void 0),E=x.type||(s3(d)?"exponential":"interval");if(m&&((x=Object.assign({},x)).stops&&(x.stops=x.stops.map(G=>[G[0],qr.parse(G[1])])),x.default=qr.parse(x.default?x.default:d.default)),x.colorSpace&&x.colorSpace!=="rgb"&&!zR[x.colorSpace])throw new Error(`Unknown color space: ${x.colorSpace}`);let P,O,$;if(E==="exponential")P=ZR;else if(E==="interval")P=Rme;else if(E==="categorical"){P=Ome,O=Object.create(null);for(const G of x.stops)O[G[0]]=G[1];$=typeof x.stops[0][0]}else{if(E!=="identity")throw new Error(`Unknown function type "${E}"`);P=YR}if(v){const G={},ee=[];for(let de=0;dede[0]),evaluate:({zoom:de},ue)=>ZR({stops:se,base:x.base},d,de).evaluate(de,ue)}}if(S){const G=E==="exponential"?{name:"exponential",base:x.base!==void 0?x.base:1}:null;return{kind:"camera",interpolationType:G,interpolationFactor:lm.interpolationFactor.bind(void 0,G),zoomStops:x.stops.map(ee=>ee[0]),evaluate:({zoom:ee})=>P(x,d,ee,O,$)}}return{kind:"source",evaluate(G,ee){const se=ee&&ee.properties?ee.properties[x.property]:void 0;return se===void 0?qf(x.default,d.default):P(x,d,se,O,$)}}}function qf(x,d,m){return x!==void 0?x:d!==void 0?d:m!==void 0?m:void 0}function Ome(x,d,m,v,S){return qf(typeof m===S?v[m]:void 0,x.default,d.default)}function Rme(x,d,m){if(!Y1(m))return qf(x.default,d.default);const v=x.stops.length;if(v===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[v-1][0])return x.stops[v-1][1];const S=WC(x.stops.map(E=>E[0]),m);return x.stops[S][1]}function ZR(x,d,m){const v=x.base!==void 0?x.base:1;if(!Y1(m))return qf(x.default,d.default);const S=x.stops.length;if(S===1||m<=x.stops[0][0])return x.stops[0][1];if(m>=x.stops[S-1][0])return x.stops[S-1][1];const E=WC(x.stops.map(ee=>ee[0]),m),P=function(ee,se,ie,de){const ue=de-ie,ke=ee-ie;return ue===0?0:se===1?ke/ue:(Math.pow(se,ke)-1)/(Math.pow(se,ue)-1)}(m,v,x.stops[E][0],x.stops[E+1][0]),O=x.stops[E][1],$=x.stops[E+1][1];let G=Q0[d.type]||GR;if(x.colorSpace&&x.colorSpace!=="rgb"){const ee=zR[x.colorSpace];G=(se,ie)=>ee.reverse(ee.interpolate(ee.forward(se),ee.forward(ie),P))}return typeof O.evaluate=="function"?{evaluate(...ee){const se=O.evaluate.apply(void 0,ee),ie=$.evaluate.apply(void 0,ee);if(se!==void 0&&ie!==void 0)return G(se,ie,P)}}:G(O,$,P)}function YR(x,d,m){return d.type==="color"?m=qr.parse(m):d.type==="formatted"?m=Lu.fromString(m.toString()):d.type==="resolvedImage"?m=Du.build(m.toString()):Rr(m)===d.type||d.type==="enum"&&d.values[m]||(m=void 0),qf(m,x.default,d.default)}Ou.register(ob,{error:[{kind:"error"},[Ia],(x,[d])=>{throw new ic(d.evaluate(x))}],typeof:[Ia,[mi],(x,[d])=>bl(kc(d.evaluate(x)))],"to-rgba":[$d(Br,4),[lh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[$d(Br,4),[lh],(x,[d])=>d.evaluate(x).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[lh,[Br,Br,Br],d6],rgba:[lh,[Br,Br,Br,Br],d6],hsl:[lh,[Br,Br,Br],u6],hsla:[lh,[Br,Br,Br,Br],u6],has:{type:Ni,overloads:[[[Ia],(x,[d])=>UR(d.evaluate(x),x.properties())],[[Ia,Ff],(x,[d,m])=>UR(d.evaluate(x),m.evaluate(x))]]},get:{type:mi,overloads:[[[Ia],(x,[d])=>h6(d.evaluate(x),x.properties())],[[Ia,Ff],(x,[d,m])=>h6(d.evaluate(x),m.evaluate(x))]]},"feature-state":[mi,[Ia],(x,[d])=>h6(d.evaluate(x),x.featureState||{})],properties:[Ff,[],x=>x.properties()],"geometry-type":[Ia,[],x=>x.geometryType()],worldview:[Ia,[],x=>x.globals.worldview||""],"is-active-floor":[Ni,Cy(Ia),(x,d)=>{if(!(x.globals.activeFloors&&x.globals.activeFloors.size>0))return!1;const m=x.globals.activeFloors;return d.some(v=>{const S=v.evaluate(x);return m.has(S)})}],id:[mi,[],x=>x.id()],zoom:[Br,[],x=>x.globals.zoom],pitch:[Br,[],x=>x.globals.pitch||0],"distance-from-center":[Br,[],x=>x.distanceFromCenter()],"measure-light":[Br,[Ia],(x,[d])=>x.measureLight(d.evaluate(x))],"heatmap-density":[Br,[],x=>x.globals.heatmapDensity||0],"line-progress":[Br,[],x=>x.globals.lineProgress||0],"raster-value":[Br,[],x=>x.globals.rasterValue||0],"raster-particle-speed":[Br,[],x=>x.globals.rasterParticleSpeed||0],"sky-radial-progress":[Br,[],x=>x.globals.skyRadialProgress||0],accumulated:[mi,[],x=>x.globals.accumulated===void 0?null:x.globals.accumulated],"+":[Br,Cy(Br),(x,d)=>{let m=0;for(const v of d)m+=v.evaluate(x);return m}],"*":[Br,Cy(Br),(x,d)=>{let m=1;for(const v of d)m*=v.evaluate(x);return m}],"-":{type:Br,overloads:[[[Br,Br],(x,[d,m])=>d.evaluate(x)-m.evaluate(x)],[[Br],(x,[d])=>-d.evaluate(x)]]},"/":[Br,[Br,Br],(x,[d,m])=>d.evaluate(x)/m.evaluate(x)],"%":[Br,[Br,Br],(x,[d,m])=>d.evaluate(x)%m.evaluate(x)],ln2:[Br,[],()=>Math.LN2],pi:[Br,[],()=>Math.PI],e:[Br,[],()=>Math.E],"^":[Br,[Br,Br],(x,[d,m])=>Math.pow(d.evaluate(x),m.evaluate(x))],sqrt:[Br,[Br],(x,[d])=>Math.sqrt(d.evaluate(x))],log10:[Br,[Br],(x,[d])=>Math.log(d.evaluate(x))/Math.LN10],ln:[Br,[Br],(x,[d])=>Math.log(d.evaluate(x))],log2:[Br,[Br],(x,[d])=>Math.log2(d.evaluate(x))],sin:[Br,[Br],(x,[d])=>Math.sin(d.evaluate(x))],cos:[Br,[Br],(x,[d])=>Math.cos(d.evaluate(x))],tan:[Br,[Br],(x,[d])=>Math.tan(d.evaluate(x))],asin:[Br,[Br],(x,[d])=>Math.asin(d.evaluate(x))],acos:[Br,[Br],(x,[d])=>Math.acos(d.evaluate(x))],atan:[Br,[Br],(x,[d])=>Math.atan(d.evaluate(x))],min:[Br,Cy(Br),(x,d)=>Math.min(...d.map(m=>m.evaluate(x)))],max:[Br,Cy(Br),(x,d)=>Math.max(...d.map(m=>m.evaluate(x)))],abs:[Br,[Br],(x,[d])=>Math.abs(d.evaluate(x))],round:[Br,[Br],(x,[d])=>{const m=d.evaluate(x);return m<0?-Math.round(-m):Math.round(m)}],floor:[Br,[Br],(x,[d])=>Math.floor(d.evaluate(x))],ceil:[Br,[Br],(x,[d])=>Math.ceil(d.evaluate(x))],"filter-==":[Ni,[Ia,mi],(x,[d,m])=>x.properties()[d.value]===m.value],"filter-id-==":[Ni,[mi],(x,[d])=>x.id()===d.value],"filter-type-==":[Ni,[Ia],(x,[d])=>x.geometryType()===d.value],"filter-<":[Ni,[Ia,mi],(x,[d,m])=>{const v=x.properties()[d.value],S=m.value;return typeof v==typeof S&&v{const m=x.id(),v=d.value;return typeof m==typeof v&&m":[Ni,[Ia,mi],(x,[d,m])=>{const v=x.properties()[d.value],S=m.value;return typeof v==typeof S&&v>S}],"filter-id->":[Ni,[mi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>v}],"filter-<=":[Ni,[Ia,mi],(x,[d,m])=>{const v=x.properties()[d.value],S=m.value;return typeof v==typeof S&&v<=S}],"filter-id-<=":[Ni,[mi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m<=v}],"filter->=":[Ni,[Ia,mi],(x,[d,m])=>{const v=x.properties()[d.value],S=m.value;return typeof v==typeof S&&v>=S}],"filter-id->=":[Ni,[mi],(x,[d])=>{const m=x.id(),v=d.value;return typeof m==typeof v&&m>=v}],"filter-has":[Ni,[mi],(x,[d])=>d.value in x.properties()],"filter-has-id":[Ni,[],x=>x.id()!==null&&x.id()!==void 0],"filter-type-in":[Ni,[$d(Ia)],(x,[d])=>d.value.indexOf(x.geometryType())>=0],"filter-id-in":[Ni,[$d(mi)],(x,[d])=>d.value.indexOf(x.id())>=0],"filter-in-small":[Ni,[Ia,$d(mi)],(x,[d,m])=>m.value.indexOf(x.properties()[d.value])>=0],"filter-in-large":[Ni,[Ia,$d(mi)],(x,[d,m])=>function(v,S,E,P){for(;E<=P;){const O=E+P>>1;if(S[O]===v)return!0;S[O]>v?P=O-1:E=O+1}return!1}(x.properties()[d.value],m.value,0,m.value.length-1)],all:{type:Ni,overloads:[[[Ni,Ni],(x,[d,m])=>d.evaluate(x)&&m.evaluate(x)],[Cy(Ni),(x,d)=>{for(const m of d)if(!m.evaluate(x))return!1;return!0}]]},any:{type:Ni,overloads:[[[Ni,Ni],(x,[d,m])=>d.evaluate(x)||m.evaluate(x)],[Cy(Ni),(x,d)=>{for(const m of d)if(m.evaluate(x))return!0;return!1}]]},"!":[Ni,[Ni],(x,[d])=>!d.evaluate(x)],"is-supported-script":[Ni,[Ia],(x,[d])=>{const m=x.globals&&x.globals.isSupportedScript;return!m||m(d.evaluate(x))}],upcase:[Ia,[Ia],(x,[d])=>d.evaluate(x).toUpperCase()],downcase:[Ia,[Ia],(x,[d])=>d.evaluate(x).toLowerCase()],concat:[Ia,Cy(mi),(x,d)=>d.map(m=>Qm(m.evaluate(x))).join("")],"resolved-locale":[Ia,[MC],(x,[d])=>d.evaluate(x).resolvedLocale()],random:[Br,[Br,Br,mi],(x,d)=>{const[m,v,S]=d.map(P=>P.evaluate(x));if(m>v||m===v)return m;let E;if(typeof S=="string")E=function(P){let O=0;if(P.length===0)return O;for(let $=0;$JSON.stringify(se)).join(", ")}, but found ${JSON.stringify(ee)} instead.`);return ee}catch(ee){const se=ee;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 o2(x){return Array.isArray(x)&&x.length>0&&typeof x[0]=="string"&&x[0]in ob}function Ty(x,d,m,v,S){const E=new HC(ob,[],d?function(O){const $={color:lh,string:Ia,number:Br,enum:Ia,boolean:Ni,formatted:Ww,resolvedImage:Gw};return O.type==="array"?$d($[O.value]||mi,O.length):$[O.type]}(d):void 0,void 0,void 0,m,v,S),P=E.parse(x,void 0,void 0,void 0,d&&d.type==="string"?{typeAnnotation:"coerce"}:void 0);return P?VR(new n3(P,d,m,v,S)):My(E.errors)}class lb{constructor(d,m,v,S){this.kind=d,this._styleExpression=m,this.isLightConstant=v,this.isLineProgressConstant=S,this.isStateDependent=d!=="constant"&&!e2(m.expression),this.configDependencies=rv(m.expression),this.isIndoorDependent=t3(m.expression)}evaluateWithoutErrorHandling(d,m,v,S,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,S,E,P)}evaluate(d,m,v,S,E,P,O){return this._styleExpression.evaluate(d,m,v,S,E,P,void 0,void 0,O)}}class nv{constructor(d,m,v,S,E,P){this.kind=d,this.zoomStops=v,this._styleExpression=m,this.isStateDependent=d!=="camera"&&!e2(m.expression),this.isIndoorDependent=t3(m.expression),this.isLightConstant=E,this.isLineProgressConstant=P,this.configDependencies=rv(m.expression),this.interpolationType=S}evaluateWithoutErrorHandling(d,m,v,S,E,P){return this._styleExpression.evaluateWithoutErrorHandling(d,m,v,S,E,P)}evaluate(d,m,v,S,E,P){return this._styleExpression.evaluate(d,m,v,S,E,P)}interpolationFactor(d,m,v){return this.interpolationType?lm.interpolationFactor(this.interpolationType,d,m,v):0}}function p6(x,d,m,v,S){if((x=Ty(x,d,m,v,S)).result==="error")return x;const E=x.value.expression,P=eb(E);if(!P&&!i2(d))return My([new Xm("","data expressions not supported")]);const O=tb(E,["zoom","pitch","distance-from-center"]);if(!O&&!WR(d))return My([new Xm("","zoom expressions not supported")]);const $=tb(E,["measure-light"]);if(!$&&!HR(d))return My([new Xm("","measure-light expression not supported")]);const G=tb(E,["line-progress"]);if(!G&&!function(ie){return m6(ie.expression,"line-progress")}(d))return My([new Xm("","line-progress expression not supported")]);const ee=d.expression&&d.expression.relaxZoomRestriction,se=Bp(E);return se||O||ee?se instanceof Xm?My([se]):se instanceof lm&&!s3(d)?My([new Xm("",'"interpolate" expressions cannot be used with this property')]):VR(se?new nv(P&&G?"camera":"composite",x.value,se.labels,se instanceof lm?se.interpolation:void 0,$,G):new lb(P&&G?"constant":"source",x.value,$,G)):My([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 a3{constructor(d,m){this._parameters=d,this._specification=m,Object.assign(this,KR(this._parameters,this._specification))}static deserialize(d){return new a3(d._parameters,d._specification)}static serialize(d){return{_parameters:d._parameters,_specification:d._specification}}}function Bp(x){let d=null;if(x instanceof tg)d=Bp(x.result);else if(x instanceof r2){for(const m of x.args)if(d=Bp(m),d)break}else(x instanceof t2||x instanceof lm)&&x.input instanceof Ou&&x.input.name==="zoom"&&(d=x);return d instanceof Xm||x.eachChild(m=>{const v=Bp(m);v instanceof Xm?d=v:d&&v&&d!==v&&(d=new Xm("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),d}var f6,XR,QR=function(){if(XR)return f6;XR=1,f6=d;var x=3;function d(m,v,S){var E=this.cells=[];if(m instanceof ArrayBuffer){this.arrayBuffer=m;var P=new Int32Array(this.arrayBuffer);m=P[0],this.d=(v=P[1])+2*(S=P[2]);for(var O=0;O=ie[ke+0]&&E>=ie[ke+1])?($[ue]=!0,O.push(se[ue])):$[ue]=!1}}},d.prototype._forEachCell=function(m,v,S,E,P,O,$,G){for(var ee=this._convertToCellCoord(m),se=this._convertToCellCoord(v),ie=this._convertToCellCoord(S),de=this._convertToCellCoord(E),ue=ee;ue<=ie;ue++)for(var ke=se;ke<=de;ke++){var Oe=this.d*ke+ue;if((!G||G(this._convertFromCellCoord(ue),this._convertFromCellCoord(ke),this._convertFromCellCoord(ue+1),this._convertFromCellCoord(ke+1)))&&P.call(this,m,v,S,E,Oe,O,$,G))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,v=x+this.cells.length+1+1,S=0,E=0;E=0||(S[E]=sg(x[E],d)));x instanceof Error&&(S.message=x.message)}if(S.$name)throw new Error("$name property is reserved for worker serialization logic.");return v!=="Object"&&(S.$name=v),S}throw new Error("can't serialize object of type "+typeof x)}function Ay(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||l2(x)||x instanceof ImageBitmap||ArrayBuffer.isView(x)||x instanceof ImageData)return x;if(Array.isArray(x))return x.map(Ay);if(typeof x=="object"){const d=x.$name||"Object";if(d==="Map"){const S=x.entries||[],E=new Map;for(let P=0;Px>=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 c2(x){for(const d of x)if(i3(d.charCodeAt(0)))return!0;return!1}function x6(x){for(const d of x)if(!JR(d.charCodeAt(0)))return!1;return!0}function JR(x){return!(Jr.Arabic(x)||Jr["Arabic Supplement"](x)||Jr["Arabic Extended-A"](x)||Jr["Arabic Presentation Forms-A"](x)||Jr["Arabic Presentation Forms-B"](x))}function i3(x){return!(x!==746&&x!==747&&(x<4352||!(Jr["Bopomofo Extended"](x)||Jr.Bopomofo(x)||Jr["CJK Compatibility Forms"](x)&&!(x>=65097&&x<=65103)||Jr["CJK Compatibility Ideographs"](x)||Jr["CJK Compatibility"](x)||Jr["CJK Radicals Supplement"](x)||Jr["CJK Strokes"](x)||!(!Jr["CJK Symbols and Punctuation"](x)||x>=12296&&x<=12305||x>=12308&&x<=12319||x===12336)||Jr["CJK Unified Ideographs Extension A"](x)||Jr["CJK Unified Ideographs"](x)||Jr["Enclosed CJK Letters and Months"](x)||Jr["Hangul Compatibility Jamo"](x)||Jr["Hangul Jamo Extended-A"](x)||Jr["Hangul Jamo Extended-B"](x)||Jr["Hangul Jamo"](x)||Jr["Hangul Syllables"](x)||Jr.Hiragana(x)||Jr["Ideographic Description Characters"](x)||Jr.Kanbun(x)||Jr["Kangxi Radicals"](x)||Jr["Katakana Phonetic Extensions"](x)||Jr.Katakana(x)&&x!==12540||!(!Jr["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)||!(!Jr["Small Form Variants"](x)||x>=65112&&x<=65118||x>=65123&&x<=65126)||Jr["Unified Canadian Aboriginal Syllabics"](x)||Jr["Unified Canadian Aboriginal Syllabics Extended"](x)||Jr["Vertical Forms"](x)||Jr["Yijing Hexagram Symbols"](x)||Jr["Yi Syllables"](x)||Jr["Yi Radicals"](x))))}function o3(x){return!(i3(x)||function(d){return!!(Jr["Latin-1 Supplement"](d)&&(d===167||d===169||d===174||d===177||d===188||d===189||d===190||d===215||d===247)||Jr["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)||Jr["Letterlike Symbols"](d)||Jr["Number Forms"](d)||Jr["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)||Jr["Control Pictures"](d)&&d!==9251||Jr["Optical Character Recognition"](d)||Jr["Enclosed Alphanumerics"](d)||Jr["Geometric Shapes"](d)||Jr["Miscellaneous Symbols"](d)&&!(d>=9754&&d<=9759)||Jr["Miscellaneous Symbols and Arrows"](d)&&(d>=11026&&d<=11055||d>=11088&&d<=11097||d>=11192&&d<=11243)||Jr["CJK Symbols and Punctuation"](d)||Jr.Katakana(d)||Jr["Private Use Area"](d)||Jr["CJK Compatibility Forms"](d)||Jr["Small Form Variants"](d)||Jr["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 l3(x){return Jr.Arabic(x)||Jr["Arabic Supplement"](x)||Jr["Arabic Extended-A"](x)||Jr["Arabic Presentation Forms-A"](x)||Jr["Arabic Presentation Forms-B"](x)}function g6(x){return x>=1424&&x<=2303||Jr["Arabic Presentation Forms-A"](x)||Jr["Arabic Presentation Forms-B"](x)}function rg(x,d){return!(!d&&g6(x)||x>=2304&&x<=3583||x>=3840&&x<=4255||Jr.Khmer(x))}function Fme(x){for(const d of x)if(g6(d.charCodeAt(0)))return!0;return!1}const Lh={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let y6=null,Ru=Lh.unavailable,ng=null;const d2=function(x){x&&typeof x=="string"&&x.indexOf("NetworkError")>-1&&(Ru=Lh.error),y6&&y6(x)};function c3(){d3.fire(new Ym("pluginStateChange",{pluginStatus:Ru,pluginURL:ng}))}const d3=new Ms,u2=function(){return Ru},eF=function(){if(Ru!==Lh.deferred||!ng)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Ru=Lh.loading,c3(),ng&&Ih({url:ng},x=>{x?d2(x):(Ru=Lh.loaded,c3())})},ag={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Ru===Lh.loaded||ag.applyArabicShaping!=null,isLoading:()=>Ru===Lh.loading,setState(x){Ru=x.pluginStatus,ng=x.pluginURL},isParsing:()=>Ru===Lh.parsing,isParsed:()=>Ru===Lh.parsed,getPluginURL:()=>ng};class Ki{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,v){for(const S of m)if(!rg(S.charCodeAt(0),v))return!1;return!0}(d,ag.isLoaded())}}class u3{constructor(d,m,v,S,E){this.property=d,this.value=m,this.expression=function(P,O,$,G,ee){if(r3(P))return new a3(P,O);if(o2(P)||Array.isArray(P)&&P.length>0){const se=p6(P,O,$,G,ee);if(se.result==="error")throw new Error(se.value.map(ie=>`${ie.key}: ${ie.message}`).join(", "));return se.value}{let se=P;return typeof P=="string"&&O.type==="color"&&(se=qr.parse(P)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>se}}}(m===void 0?d.specification.default:m,d.specification,v,S,E)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(d,m,v,S){return this.property.possiblyEvaluate(this,d,m,v,S)}}class v6{constructor(d,m,v,S){this.property=d,this.value=new u3(d,void 0,m,v,S)}transitioned(d,m){return new sF(this.property,this.value,m,Object.assign({},d.transition,this.transition),d.now)}untransitioned(){return new sF(this.property,this.value,null,{},0)}}class tF{constructor(d,m,v,S){this._properties=d,this._values=Object.create(d.defaultTransitionablePropertyValues),this._scope=m,this._options=v,this._iconImageUseTheme=S,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 v6(this._values[d].property,this._scope,this._options,this._iconImageUseTheme)),this._values[d].value=new u3(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 v=this._properties.properties;if(d)for(const S in d){const E=d[S];if(S.endsWith("-transition")){const P=S.slice(0,-11);v[P]&&this.setTransition(P,E)}else v.hasOwnProperty(S)&&this.setValue(S,E)}}getTransition(d){return ys(this._values[d].transition)}setTransition(d,m){this._values.hasOwnProperty(d)||(this._values[d]=new v6(this._values[d].property)),this._values[d].transition=ys(m)||void 0}serialize(){const d={};for(const m of Object.keys(this._values)){const v=this.getValue(m);v!==void 0&&(d[m]=v);const S=this.getTransition(m);S!==void 0&&(d[`${m}-transition`]=S)}return d}transitioned(d,m){const v=new rF(this._properties);for(const S of Object.keys(this._values))v._values[S]=this._values[S].transitioned(d,m._values[S]);return v}untransitioned(){const d=new rF(this._properties);for(const m of Object.keys(this._values))d._values[m]=this._values[m].untransitioned();return d}isIndoorDependent(){return this._isIndoorDependent}}class sF{constructor(d,m,v,S,E){const P=S.delay||0,O=S.duration||0;E=E||0,this.property=d,this.value=m,this.begin=E+P,this.end=this.begin+O,d.specification.transition&&(S.delay||S.duration)&&(this.prior=v)}possiblyEvaluate(d,m,v){const S=d.now||0,E=this.value.possiblyEvaluate(d,m,v),P=this.prior;if(P){if(S>this.end)return this.prior=null,E;if(this.value.isDataDriven())return this.prior=null,E;if(S":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 aF(x){return x instanceof Number||x instanceof String||x instanceof Boolean?x.valueOf():x}function h3(x){if(Array.isArray(x))return x.map(h3);if(x instanceof Object&&!(x instanceof Number||x instanceof String||x instanceof Boolean)){const d={};for(const m in x)d[m]=h3(x[m]);return d}return aF(x)}function Uf(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(!Uf(d)&&typeof d!="boolean")return!1;return!0;default:return!0}}function m3(x,d="",m=null,v="fill"){if(x==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Uf(x)||(x=p3(x));const S=x;let E=!0;try{E=function(ee){if(!db(ee))return ee;let se=h3(ee);return iF(se),se=cv(se),se}(S)}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(S,null,2)} `)}let P=null,O=null;if(v!=="background"&&v!=="sky"&&v!=="slot"){O=Kt[`filter_${v}`];const ee=Ty(E,O,d,m);if(ee.result==="error")throw new Error(ee.value.map(se=>`${se.key}: ${se.message}`).join(", "));P=(se,ie,de)=>ee.value.evaluate(se,ie,{},de)}let $=null,G=null;if(E!==S){const ee=Ty(S,O,d,m);if(ee.result==="error")throw new Error(ee.value.map(se=>`${se.key}: ${se.message}`).join(", "));$=(se,ie,de,ue,ke)=>ee.value.evaluate(se,ie,{},de,void 0,void 0,ue,ke),G=!eb(ee.value.expression)}return{filter:P,dynamicFilter:$||void 0,needGeometry:oF(E),needFeature:!!G}}function cv(x){if(!Array.isArray(x))return x;const d=function(m){if(zme.has(m[0])){for(let v=1;vcv(m))}function iF(x){let d=!1;const m=[];if(x[0]==="case"){for(let v=1;v",">=","<","<=","to-boolean"]);function Bme(x,d){return xd?1:0}function oF(x){if(!Array.isArray(x))return!1;if(x[0]==="within"||x[0]==="distance")return!0;for(let d=1;d"||d==="<="||d===">="?f3(x[1],x[2],d):d==="any"?(m=x.slice(1),["any"].concat(m.map(p3))):d==="all"?["all"].concat(x.slice(1).map(p3)):d==="none"?["all"].concat(x.slice(1).map(p3).map(h2)):d==="in"?x3(x[1],x.slice(2)):d==="!in"?h2(x3(x[1],x.slice(2))):d==="has"?g3(x[1]):d!=="!has"||h2(g3(x[1]));var m}function f3(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 x3(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(Bme)]]:["filter-in-small",x,["literal",d]]}}function g3(x){switch(x){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",x]}}function h2(x){return["!",x]}const dv="";function $p(x,d){return d?`${x}${dv}${d}`:x}let lF;const cF=()=>lF||(lF=new Eo({"icon-size":new nr(Kt.layout_symbol["icon-size"]),"icon-image":new nr(Kt.layout_symbol["icon-image"]),"icon-rotate":new nr(Kt.layout_symbol["icon-rotate"]),"icon-offset":new nr(Kt.layout_symbol["icon-offset"]),"text-size":new nr(Kt.layout_symbol["text-size"]),"text-rotate":new nr(Kt.layout_symbol["text-rotate"]),"text-offset":new nr(Kt.layout_symbol["text-offset"])}));class dF{constructor(d,m,v,S,E,P){const O=Ty(d,Kt.appearance.condition);if(O.result==="success"&&(this.condition=O.value),this.name=m,v){this.properties=new ov(cF()),this.unevaluatedLayout=new nF(cF(),S,E,P);for(const $ in v)this.unevaluatedLayout.setValue($,v[$])}}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,v){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(d,void 0,m,v))}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"),v=this.hasProperty("icon-offset"),S=this.hasProperty("icon-rotate");return d||m||v||S}hasTextProperties(){const d=this.hasProperty("text-size"),m=this.hasProperty("text-offset"),v=this.hasProperty("text-rotate");return d||m||v}hasProperty(d){return this.getUnevaluatedProperty(d).value!==void 0}}const uF="-transition",Vf=new Set(["fill","line","background","hillshade","raster"]);class Fu extends Ms{constructor(d,m,v,S,E,P){if(super(),this.id=d.id,this.fqid=$p(this.id,v),this.type=d.type,this.scope=v,this.lut=S,this.options=E,this.iconImageUseTheme=P,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 O=Ty(this.filter,Kt[`filter_${d.type}`]);O.result!=="error"&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...O.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||O.value.isIndoorDependent)}if(d.slot&&(this.slot=d.slot),d.appearances&&this.setAppearances(d.appearances),m.layout&&(this._unevaluatedLayout=new nF(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 tF(m.paint,this.scope,E);for(const O in d.paint)this.setPaintProperty(O,d.paint[O]);for(const O in d.layout)this.setLayoutProperty(O,d.layout[O]);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 ov(m.paint)}}}onAdd(d){}onRemove(d){}isDraped(d){return!this.is3D(!0)&&Vf.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 v=this._unevaluatedLayout;v._properties.properties[d]&&(v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),d==="visibility"&&this.possiblyEvaluateVisibility())}setAppearances(d){this.appearances=[],d.forEach(m=>{this.appearances.push(new dF(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(uF)?this._transitionablePaint.getTransition(d.slice(0,-11)):this._transitionablePaint.getValue(d)}isPaintProperty(d){return!!this._transitionablePaint._properties.properties[d]}setPaintProperty(d,m){const v=this._transitionablePaint,S=v._properties.properties;if(d.endsWith(uF)){const se=d.slice(0,-11);return S[se]&&v.setTransition(se,m||void 0),!1}if(!S[d])return!1;const E=v._values[d],P=E.value.isDataDriven(),O=E.value;v.setValue(d,m),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...v.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||v.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(d);const $=v._values[d].value,G=$.isDataDriven(),ee=d.endsWith("pattern")||d==="line-dasharray";return G||P||ee||this._handleOverridablePaintPropertyUpdate(d,O,$)}_handleSpecialPaintPropertyUpdate(d){}getProgramIds(){return null}getDefaultProgramParams(d,m,v){return null}_handleOverridablePaintPropertyUpdate(d,m,v){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())),Es(d,(m,v)=>!(m===void 0||v==="layout"&&!Object.keys(m).length||v==="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 iv&&i2(m.property.specification)&&(m.value.kind==="source"||m.value.kind==="composite")&&m.value.isStateDependent)return!0}for(const d of this.appearances)if(!e2(d.condition.expression))return!0;return!1}compileFilter(d){this._filterCompiled||(this._featureFilter=m3(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,v){return{}}queryRadius(d){}queryIntersectsFeature(d,m,v,S,E,P,O,$,G){}}const hF={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class m2{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 $me=new ArrayBuffer(0);class so{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=$me),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 ua(x,d=1){let m=0,v=0;return{members:x.map(S=>{const E=hF[S.type].BYTES_PER_ELEMENT,P=m=mF(m,Math.max(d,E)),O=S.components||1;return v=Math.max(v,E),m+=E*O,{name:S.name,type:S.type,components:O,offset:P}}),size:mF(m,Math.max(v,d)),alignment:d}}function mF(x,d){return Math.ceil(x/d)*d}class Ey extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const S=2*d;return this.int16[S+0]=m,this.int16[S+1]=v,d}}Ey.prototype.bytesPerElement=4,Sr(Ey,"StructArrayLayout2i4");class ub extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const S=this.length;return this.resize(S+1),this.emplace(S,d,m,v)}emplace(d,m,v,S){const E=3*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=S,d}}ub.prototype.bytesPerElement=6,Sr(ub,"StructArrayLayout3i6");class hb extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,S){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,S)}emplace(d,m,v,S,E){const P=4*d;return this.int16[P+0]=m,this.int16[P+1]=v,this.int16[P+2]=S,this.int16[P+3]=E,d}}hb.prototype.bytesPerElement=8,Sr(hb,"StructArrayLayout4i8");class ig extends so{_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}}ig.prototype.bytesPerElement=4,Sr(ig,"StructArrayLayout1f4");class b6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const S=this.length;return this.resize(S+1),this.emplace(S,d,m,v)}emplace(d,m,v,S){const E=4*d,P=2*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.float32[P+1]=S,d}}b6.prototype.bytesPerElement=8,Sr(b6,"StructArrayLayout2i1f8");class _6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v){const S=this.length;return this.resize(S+1),this.emplace(S,d,m,v)}emplace(d,m,v,S){const E=4*d;return this.int16[E+0]=m,this.int16[E+1]=v,this.int16[E+2]=S,d}}_6.prototype.bytesPerElement=8,Sr(_6,"StructArrayLayout3i8");class w6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,S,E)}emplace(d,m,v,S,E,P){const O=5*d;return this.int16[O+0]=m,this.int16[O+1]=v,this.int16[O+2]=S,this.int16[O+3]=E,this.int16[O+4]=P,d}}w6.prototype.bytesPerElement=10,Sr(w6,"StructArrayLayout5i10");class y3 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,S,E,P,O)}emplace(d,m,v,S,E,P,O,$){const G=6*d,ee=12*d,se=3*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.uint8[ee+4]=S,this.uint8[ee+5]=E,this.uint8[ee+6]=P,this.uint8[ee+7]=O,this.float32[se+2]=$,d}}y3.prototype.bytesPerElement=12,Sr(y3,"StructArrayLayout2i4ub1f12");class cm extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v){const S=this.length;return this.resize(S+1),this.emplace(S,d,m,v)}emplace(d,m,v,S){const E=3*d;return this.float32[E+0]=m,this.float32[E+1]=v,this.float32[E+2]=S,d}}cm.prototype.bytesPerElement=12,Sr(cm,"StructArrayLayout3f12");class ch extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,S,E)}emplace(d,m,v,S,E,P){const O=6*d,$=3*d;return this.uint16[O+0]=m,this.uint16[O+1]=v,this.uint16[O+2]=S,this.uint16[O+3]=E,this.float32[$+2]=P,d}}ch.prototype.bytesPerElement=12,Sr(ch,"StructArrayLayout4ui1f12");class uv extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,S){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,S)}emplace(d,m,v,S,E){const P=4*d;return this.uint16[P+0]=m,this.uint16[P+1]=v,this.uint16[P+2]=S,this.uint16[P+3]=E,d}}uv.prototype.bytesPerElement=8,Sr(uv,"StructArrayLayout4ui8");class v3 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,S,E,P)}emplace(d,m,v,S,E,P,O){const $=6*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=S,this.int16[$+3]=E,this.int16[$+4]=P,this.int16[$+5]=O,d}}v3.prototype.bytesPerElement=12,Sr(v3,"StructArrayLayout6i12");class j6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O,$,G,ee,se,ie){const de=this.length;return this.resize(de+1),this.emplace(de,d,m,v,S,E,P,O,$,G,ee,se,ie)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie,de){const ue=12*d;return this.int16[ue+0]=m,this.int16[ue+1]=v,this.int16[ue+2]=S,this.int16[ue+3]=E,this.uint16[ue+4]=P,this.uint16[ue+5]=O,this.uint16[ue+6]=$,this.uint16[ue+7]=G,this.int16[ue+8]=ee,this.int16[ue+9]=se,this.int16[ue+10]=ie,this.int16[ue+11]=de,d}}j6.prototype.bytesPerElement=24,Sr(j6,"StructArrayLayout4i4ui4i24");class N6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,S,E,P)}emplace(d,m,v,S,E,P,O){const $=10*d,G=5*d;return this.int16[$+0]=m,this.int16[$+1]=v,this.int16[$+2]=S,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=O,d}}N6.prototype.bytesPerElement=20,Sr(N6,"StructArrayLayout3i3f20");class Py extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,S)}emplace(d,m,v,S,E){const P=4*d;return this.float32[P+0]=m,this.float32[P+1]=v,this.float32[P+2]=S,this.float32[P+3]=E,d}}Py.prototype.bytesPerElement=16,Sr(Py,"StructArrayLayout4f16");class b3 extends so{_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}}b3.prototype.bytesPerElement=4,Sr(b3,"StructArrayLayout1ul4");class dm extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const S=2*d;return this.uint16[S+0]=m,this.uint16[S+1]=v,d}}dm.prototype.bytesPerElement=4,Sr(dm,"StructArrayLayout2ui4");class _3 extends so{_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,v,S,E,P,O,$,G,ee,se,ie,de){const ue=this.length;return this.resize(ue+1),this.emplace(ue,d,m,v,S,E,P,O,$,G,ee,se,ie,de)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue){const ke=20*d,Oe=10*d;return this.int16[ke+0]=m,this.int16[ke+1]=v,this.int16[ke+2]=S,this.int16[ke+3]=E,this.int16[ke+4]=P,this.float32[Oe+3]=O,this.float32[Oe+4]=$,this.float32[Oe+5]=G,this.float32[Oe+6]=ee,this.int16[ke+14]=se,this.uint32[Oe+8]=ie,this.uint16[ke+18]=de,this.uint16[ke+19]=ue,d}}_3.prototype.bytesPerElement=40,Sr(_3,"StructArrayLayout5i4f1i1ul2ui40");class w3 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,S,E,P,O)}emplace(d,m,v,S,E,P,O,$){const G=8*d;return this.int16[G+0]=m,this.int16[G+1]=v,this.int16[G+2]=S,this.int16[G+4]=E,this.int16[G+5]=P,this.int16[G+6]=O,this.int16[G+7]=$,d}}w3.prototype.bytesPerElement=16,Sr(w3,"StructArrayLayout3i2i2i16");class j3 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,S,E)}emplace(d,m,v,S,E,P){const O=4*d,$=8*d;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=S,this.int16[$+6]=E,this.int16[$+7]=P,d}}j3.prototype.bytesPerElement=16,Sr(j3,"StructArrayLayout2f1f2i16");class k6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,S,E,P)}emplace(d,m,v,S,E,P,O){const $=20*d,G=5*d;return this.uint8[$+0]=m,this.uint8[$+1]=v,this.float32[G+1]=S,this.float32[G+2]=E,this.float32[G+3]=P,this.float32[G+4]=O,d}}k6.prototype.bytesPerElement=20,Sr(k6,"StructArrayLayout2ub4f20");class zl extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v){const S=this.length;return this.resize(S+1),this.emplace(S,d,m,v)}emplace(d,m,v,S){const E=3*d;return this.uint16[E+0]=m,this.uint16[E+1]=v,this.uint16[E+2]=S,d}}zl.prototype.bytesPerElement=6,Sr(zl,"StructArrayLayout3ui6");class mb extends so{_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,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt){const yt=this.length;return this.resize(yt+1),this.emplace(yt,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt,yt){const At=30*d,Ft=15*d,qt=60*d;return this.int16[At+0]=m,this.int16[At+1]=v,this.int16[At+2]=S,this.float32[Ft+2]=E,this.float32[Ft+3]=P,this.uint16[At+8]=O,this.uint16[At+9]=$,this.uint32[Ft+5]=G,this.uint32[Ft+6]=ee,this.uint32[Ft+7]=se,this.uint16[At+16]=ie,this.uint16[At+17]=de,this.uint16[At+18]=ue,this.float32[Ft+10]=ke,this.float32[Ft+11]=Oe,this.uint8[qt+48]=De,this.uint8[qt+49]=Ke,this.uint8[qt+50]=Xe,this.uint32[Ft+13]=ot,this.int16[At+28]=Nt,this.uint8[qt+58]=yt,d}}mb.prototype.bytesPerElement=60,Sr(mb,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class S6 extends so{_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,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt,yt,At,Ft,qt,ns,Gt,ds,js,Ns,Fs,Bs,Is){const Ls=this.length;return this.resize(Ls+1),this.emplace(Ls,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt,yt,At,Ft,qt,ns,Gt,ds,js,Ns,Fs,Bs,Is)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt,yt,At,Ft,qt,ns,Gt,ds,js,Ns,Fs,Bs,Is,Ls){const cs=20*d,as=40*d,Os=80*d;return this.float32[cs+0]=m,this.float32[cs+1]=v,this.int16[as+4]=S,this.int16[as+5]=E,this.int16[as+6]=P,this.int16[as+7]=O,this.int16[as+8]=$,this.int16[as+9]=G,this.int16[as+10]=ee,this.int16[as+11]=se,this.int16[as+12]=ie,this.uint16[as+13]=de,this.uint16[as+14]=ue,this.uint16[as+15]=ke,this.uint16[as+16]=Oe,this.uint16[as+17]=De,this.uint16[as+18]=Ke,this.uint16[as+19]=Xe,this.uint16[as+20]=ot,this.uint16[as+21]=Nt,this.uint16[as+22]=yt,this.uint16[as+23]=At,this.uint16[as+24]=Ft,this.uint16[as+25]=qt,this.uint16[as+26]=ns,this.uint16[as+27]=Gt,this.uint32[cs+14]=ds,this.float32[cs+15]=js,this.float32[cs+16]=Ns,this.float32[cs+17]=Fs,this.float32[cs+18]=Bs,this.uint8[Os+76]=Is,this.uint16[as+39]=Ls,d}}S6.prototype.bytesPerElement=80,Sr(S6,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class C6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P){const O=this.length;return this.resize(O+1),this.emplace(O,d,m,v,S,E,P)}emplace(d,m,v,S,E,P,O){const $=6*d;return this.float32[$+0]=m,this.float32[$+1]=v,this.float32[$+2]=S,this.float32[$+3]=E,this.float32[$+4]=P,this.float32[$+5]=O,d}}C6.prototype.bytesPerElement=24,Sr(C6,"StructArrayLayout6f24");class hv extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E){const P=this.length;return this.resize(P+1),this.emplace(P,d,m,v,S,E)}emplace(d,m,v,S,E,P){const O=5*d;return this.float32[O+0]=m,this.float32[O+1]=v,this.float32[O+2]=S,this.float32[O+3]=E,this.float32[O+4]=P,d}}hv.prototype.bytesPerElement=20,Sr(hv,"StructArrayLayout5f20");class M6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,S,E,P,O)}emplace(d,m,v,S,E,P,O,$){const G=7*d;return this.float32[G+0]=m,this.float32[G+1]=v,this.float32[G+2]=S,this.float32[G+3]=E,this.float32[G+4]=P,this.float32[G+5]=O,this.float32[G+6]=$,d}}M6.prototype.bytesPerElement=28,Sr(M6,"StructArrayLayout7f28");class T6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O,$,G,ee,se){const ie=this.length;return this.resize(ie+1),this.emplace(ie,d,m,v,S,E,P,O,$,G,ee,se)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie){const de=11*d;return this.float32[de+0]=m,this.float32[de+1]=v,this.float32[de+2]=S,this.float32[de+3]=E,this.float32[de+4]=P,this.float32[de+5]=O,this.float32[de+6]=$,this.float32[de+7]=G,this.float32[de+8]=ee,this.float32[de+9]=se,this.float32[de+10]=ie,d}}T6.prototype.bytesPerElement=44,Sr(T6,"StructArrayLayout11f44");class pb extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O,$,G){const ee=this.length;return this.resize(ee+1),this.emplace(ee,d,m,v,S,E,P,O,$,G)}emplace(d,m,v,S,E,P,O,$,G,ee){const se=9*d;return this.float32[se+0]=m,this.float32[se+1]=v,this.float32[se+2]=S,this.float32[se+3]=E,this.float32[se+4]=P,this.float32[se+5]=O,this.float32[se+6]=$,this.float32[se+7]=G,this.float32[se+8]=ee,d}}pb.prototype.bytesPerElement=36,Sr(pb,"StructArrayLayout9f36");class Hf extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m){const v=this.length;return this.resize(v+1),this.emplace(v,d,m)}emplace(d,m,v){const S=2*d;return this.float32[S+0]=m,this.float32[S+1]=v,d}}Hf.prototype.bytesPerElement=8,Sr(Hf,"StructArrayLayout2f8");class dh extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(d,m,v,S){const E=this.length;return this.resize(E+1),this.emplace(E,d,m,v,S)}emplace(d,m,v,S,E){const P=6*d;return this.uint32[3*d+0]=m,this.uint16[P+2]=v,this.uint16[P+3]=S,this.uint16[P+4]=E,d}}dh.prototype.bytesPerElement=12,Sr(dh,"StructArrayLayout1ul3ui12");class Iy extends so{_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}}Iy.prototype.bytesPerElement=2,Sr(Iy,"StructArrayLayout1ui2");class A6 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe){const De=this.length;return this.resize(De+1),this.emplace(De,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe)}emplace(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De){const Ke=16*d;return this.float32[Ke+0]=m,this.float32[Ke+1]=v,this.float32[Ke+2]=S,this.float32[Ke+3]=E,this.float32[Ke+4]=P,this.float32[Ke+5]=O,this.float32[Ke+6]=$,this.float32[Ke+7]=G,this.float32[Ke+8]=ee,this.float32[Ke+9]=se,this.float32[Ke+10]=ie,this.float32[Ke+11]=de,this.float32[Ke+12]=ue,this.float32[Ke+13]=ke,this.float32[Ke+14]=Oe,this.float32[Ke+15]=De,d}}A6.prototype.bytesPerElement=64,Sr(A6,"StructArrayLayout16f64");class N3 extends so{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(d,m,v,S,E,P,O){const $=this.length;return this.resize($+1),this.emplace($,d,m,v,S,E,P,O)}emplace(d,m,v,S,E,P,O,$){const G=10*d,ee=5*d;return this.uint16[G+0]=m,this.uint16[G+1]=v,this.uint16[G+2]=S,this.uint16[G+3]=E,this.float32[ee+2]=P,this.float32[ee+3]=O,this.float32[ee+4]=$,d}}N3.prototype.bytesPerElement=20,Sr(N3,"StructArrayLayout4ui3f20");class E6 extends so{_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}}E6.prototype.bytesPerElement=2,Sr(E6,"StructArrayLayout1i2");class k3 extends so{_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}}k3.prototype.bytesPerElement=1,Sr(k3,"StructArrayLayout1ub1");class S3 extends m2{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]}}S3.prototype.size=40;class pF extends _3{get(d){return new S3(this,d)}}Sr(pF,"CollisionBoxArray");class C3 extends m2{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}}C3.prototype.size=60;class fF extends mb{get(d){return new C3(this,d)}}Sr(fF,"PlacedSymbolArray");class xF extends m2{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]}}xF.prototype.size=80;class P6 extends S6{get(d){return new xF(this,d)}}Sr(P6,"SymbolInstanceArray");class M3 extends ig{getoffsetX(d){return this.float32[1*d+0]}}Sr(M3,"GlyphOffsetArray");class gF extends Ey{getx(d){return this.int16[2*d+0]}gety(d){return this.int16[2*d+1]}}Sr(gF,"SymbolLineVertexArray");class I6 extends m2{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]}}I6.prototype.size=12;class L6 extends dh{get(d){return new I6(this,d)}}Sr(L6,"FeatureIndexArray");class yF extends dm{geta_centroid_pos0(d){return this.uint16[2*d+0]}geta_centroid_pos1(d){return this.uint16[2*d+1]}}Sr(yF,"FillExtrusionCentroidArray");class T3 extends m2{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]}}T3.prototype.size=6;class p2 extends ub{get(d){return new T3(this,d)}}Sr(p2,"FillExtrusionWallArray");const vF=ua([{name:"a_pos",components:2,type:"Int16"}],4),qme=ua([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),bF=ua([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class bo{constructor(d=[]){this.segments=d}_prepareSegment(d,m,v,S){let E=this.segments[this.segments.length-1];return d>bo.MAX_VERTEX_ARRAY_LENGTH&&fr(`Max vertices per segment is ${bo.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${d}`),(!E||E.vertexLength+d>bo.MAX_VERTEX_ARRAY_LENGTH||E.sortKey!==S)&&(E={vertexOffset:m,primitiveOffset:v,vertexLength:0,primitiveLength:0},S!==void 0&&(E.sortKey=S),this.segments.push(E)),E}prepareSegment(d,m,v,S){return this._prepareSegment(d,m.length,v.length,S)}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,v,S){return new bo([{vertexOffset:d,primitiveOffset:m,vertexLength:v,primitiveLength:S,vaos:{},sortKey:0}])}}function A3(x,d){return 256*(x=je(Math.floor(x),0,255))+je(Math.floor(d),0,255)}bo.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Sr(bo,"SegmentVector");const Ume=ua([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Vme=ua([{name:"a_pattern_b",components:4,type:"Uint16"}]),Hme=ua([{name:"a_dash",components:4,type:"Uint16"}]);class f2{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(d,m,v,S){this.ids.push(D6(d)),this.positions.push(m,v,S)}eachPosition(d,m){const v=D6(d);let S=0,E=this.ids.length-1;for(;S>1;this.ids[P]>=v?E=P:S=P+1}for(;this.ids[S]===v;)m(this.positions[3*S],this.positions[3*S+1],this.positions[3*S+2]),S++}static serialize(d,m){const v=new Float64Array(d.ids),S=new Uint32Array(d.positions);return O6(v,S,0,v.length-1),m&&(m.add(v.buffer),m.add(S.buffer)),{ids:v,positions:S}}static deserialize(d){const m=new f2;let v;m.ids=d.ids,m.positions=d.positions;for(const S of m.ids)S!==v&&m.uniqueIds.push(S),v=S;return m.indexed=!0,m}}function D6(x){const d=+x;return Number.isSafeInteger(d)?d:G1(String(x))}function O6(x,d,m,v){for(;m>1];let E=m-1,P=v+1;for(;;){do E++;while(x[E]S);if(E>=P)break;E3(x,E,P),E3(d,3*E,3*P),E3(d,3*E+1,3*P+1),E3(d,3*E+2,3*P+2)}P-m`u_${E}`),this.type=v,this.context=S}setUniform(d,m,v,S,E){const P=S.constantOr(this.value);m.set(d,E,P instanceof qr?P.toPremultipliedRenderColor(this.lutExpression&&this.lutExpression.kind==="constant"&&this.lutExpression.value==="none"?null:this.context.lut):P)}getBinding(d,m){return this.type==="color"?new g2(d):new Bl(d)}}class fb{constructor(d,m){this.uniformNames=m.map(v=>`u_${v}`),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,v,S,E){let P=null;E!=="u_pattern"&&E!=="u_dash"||(P=this.pattern),E==="u_pattern_b"&&(P=this.patternTransition),E==="u_pixel_ratio"&&(P=this.pixelRatio),P&&m.set(d,E,P)}getBinding(d,m){return m==="u_pattern"||m==="u_pattern_b"||m==="u_dash"?new I3(d):new Bl(d)}}class lg{constructor(d,m,v,S){this.expression=d,this.type=v,this.maxValue=0,this.paintVertexAttributes=m.map(E=>({name:`a_${E}`,type:"Float32",components:v==="color"?2:1,offset:0})),this.paintVertexArray=new S}populatePaintArray(d,m,v,S,E,P,O,$){const G=this.paintVertexArray.length,ee=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate(new Ki(0,{brightness:P,worldview:$}),m,{},E,S,O):this.expression.kind==="constant"&&this.expression.value,se=v2(this.lutExpression,m,{},S,E,P,O,$);this.paintVertexArray.resize(d),this._setPaintValue(G,d,ee,se?null:this.context.lut)}updatePaintArray(d,m,v,S,E,P,O,$){const G=this.expression.kind==="composite"||this.expression.kind==="source"?this.expression.evaluate({zoom:0,brightness:O,worldview:$},v,S,void 0,E):this.expression.kind==="constant"&&this.expression.value,ee=v2(this.lutExpression,v,S,E,void 0,O,void 0,$);this._setPaintValue(d,m,G,ee?null:this.context.lut)}_setPaintValue(d,m,v,S){if(this.type==="color"){const E=R6(v.toPremultipliedRenderColor(S));for(let P=d;P`u_${O}_t`),this.type=v,this.useIntegerZoom=S,this.context=E,this.maxValue=0,this.paintVertexAttributes=m.map(O=>({name:`a_${O}`,type:"Float32",components:v==="color"?4:2,offset:0})),this.paintVertexArray=new P}populatePaintArray(d,m,v,S,E,P,O,$){const G=this.expression.evaluate(new Ki(this.context.zoom,{brightness:P,worldview:$}),m,{},E,S,O),ee=this.expression.evaluate(new Ki(this.context.zoom+1,{brightness:P,worldview:$}),m,{},E,S,O),se=v2(this.lutExpression,m,{},S,E,P,O,$),ie=this.paintVertexArray.length;this.paintVertexArray.resize(d),this._setPaintValue(ie,d,G,ee,se?null:this.context.lut)}updatePaintArray(d,m,v,S,E,P,O,$){const G=this.expression.evaluate({zoom:this.context.zoom,brightness:O,worldview:$},v,S,void 0,E),ee=this.expression.evaluate({zoom:this.context.zoom+1,brightness:O,worldview:$},v,S,void 0,E),se=v2(this.lutExpression,v,S,E,void 0,O,void 0,$);this._setPaintValue(d,m,G,ee,se?null:this.context.lut)}_setPaintValue(d,m,v,S,E){if(this.type==="color"){const P=R6(v.toPremultipliedRenderColor(E)),O=R6(v.toPremultipliedRenderColor(E));for(let $=d;$!0){this.binders={},this._buffers=[],this.context=m;const S=[];for(const E in d.paint._values){const P=d.paint.get(E);if(E.endsWith("-use-theme")||!v(E)||!(P instanceof iv&&i2(P.property.specification)))continue;const O=Zme(E,d.type),$=P.value,G=P.property.specification.type,ee=!!P.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($.kind!=="constant"||de)if($.kind==="source"||de||se){const ue=F6(E,G,"source");this.binders[E]=se?new dg($,O,G,ue,d.id):new lg($,O,G,ue),S.push(`/a_${E}`)}else{const ue=F6(E,G,"composite");this.binders[E]=new cg($,O,G,ee,m,ue),S.push(`/z_${E}`)}else this.binders[E]=se?new fb($.value,O):new b2($.value,O,G,m),S.push(`/u_${E}`);ie&&(this.binders[E].lutExpression=ie.value)}this.cacheKey=S.sort().join("")}getMaxValue(d){const m=this.binders[d];return m instanceof lg||m instanceof cg?m.maxValue:0}populatePaintArrays(d,m,v,S,E,P,O,$){for(const G in this.binders){const ee=this.binders[G];ee.context=this.context,(ee instanceof lg||ee instanceof cg||ee instanceof dg)&&ee.populatePaintArray(d,m,v,S,E,P,O,$)}}setConstantPatternPositions(d,m){for(const v in this.binders){const S=this.binders[v];S instanceof fb&&S.setConstantPatternPositions(d,m)}}getPatternTransitionVertexBuffer(d){const m=this.binders[d];return m instanceof dg?m.paintTransitionVertexBuffer:null}updatePaintArrays(d,m,v,S,E,P,O,$,G,ee){let se=!1;const ie=Object.keys(d),de=ie.length!==0&&!$,ue=de?ie:m.uniqueIds;this.context.lut=E.lut;for(const ke in this.binders){const Oe=this.binders[ke];if(Oe.context=this.context,(Oe instanceof lg||Oe instanceof cg||Oe instanceof dg)&&Oe.expression&&Oe.expression.kind&&Oe.expression.kind!=="constant"&&(Oe.expression.isStateDependent===!0||Oe.expression.isLightConstant===!1)){const De=E.paint.get(ke);Oe.expression=De.value;for(const Ke of ue){const Xe=d[Ke.toString()];m.eachPosition(Ke,(ot,Nt,yt)=>{const At=S.feature(ot);Oe.updatePaintArray(Nt,yt,At,Xe,P,O,G,ee)})}if(!de)for(const Ke of v.uniqueIds){const Xe=d[Ke.toString()];v.eachPosition(Ke,(ot,Nt,yt)=>{const At=S.feature(ot);Oe.updatePaintArray(Nt,yt,At,Xe,P,O,G,ee)})}se=!0}}return se}defines(){const d=[];for(const m in this.binders){const v=this.binders[m];(v instanceof b2||v instanceof fb)&&d.push(...v.uniformNames.map(S=>`#define HAS_UNIFORM_${S}`))}return d}getPaintVertexBuffers(){return this._buffers}getUniforms(d){const m=[];for(const v in this.binders){const S=this.binders[v];if(S instanceof b2||S instanceof fb||S instanceof cg)for(const E of S.uniformNames)m.push({name:E,property:v,binding:S.getBinding(d,E)})}return m}setUniforms(d,m,v,S,E){for(const{name:P,property:O,binding:$}of v)this.binders[O].setUniform(d,$,E,S.get(O),P)}updatePaintBuffers(){this._buffers=[];for(const d in this.binders){const m=this.binders[d];(m instanceof lg||m instanceof cg||m instanceof dg)&&m.paintVertexBuffer&&this._buffers.push(m.paintVertexBuffer),m instanceof dg&&m.paintTransitionVertexBuffer&&this._buffers.push(m.paintTransitionVertexBuffer)}}upload(d){for(const m in this.binders){const v=this.binders[m];(v instanceof lg||v instanceof cg||v instanceof dg)&&v.upload(d)}this.updatePaintBuffers()}destroy(){for(const d in this.binders){const m=this.binders[d];(m instanceof lg||m instanceof cg||m instanceof dg)&&m.destroy()}}}class qp{constructor(d,m,v=()=>!0){this.programConfigurations={};for(const S of d)this.programConfigurations[S.id]=new Ly(S,m,v);this.needsUpload=!1,this._featureMap=new f2,this._featureMapWithoutIds=new f2,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(d,m,v,S,E,P,O,$,G){for(const ee in this.programConfigurations)this.programConfigurations[ee].populatePaintArrays(d,m,S,E,P,O,$,G);m.id!==void 0?this._featureMap.add(m.id,v,this._bufferOffset,d):(this._featureMapWithoutIds.add(this._idlessCounter,v,this._bufferOffset,d),this._idlessCounter+=1),this._bufferOffset=d,this.needsUpload=!0}updatePaintArrays(d,m,v,S,E,P,O,$){for(const G of v)this.needsUpload=this.programConfigurations[G.id].updatePaintArrays(d,this._featureMap,this._featureMapWithoutIds,m,G,S,E,P,O||0,$)||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 Kme={"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 Zme(x,d){return Kme[x]||[x.replace(`${d}-`,"").replace(/-/g,"_")]}const Yme={"line-pattern":{source:ch,composite:ch},"fill-pattern":{source:ch,composite:ch},"fill-extrusion-pattern":{source:ch,composite:ch},"line-dasharray":{source:uv,composite:uv}},Xme={color:{source:Hf,composite:Py},number:{source:ig,composite:Hf}};function F6(x,d,m){const v=Yme[x];return v&&v[m]||Xme[d][m]}Sr(b2,"ConstantBinder"),Sr(fb,"PatternConstantBinder"),Sr(lg,"SourceExpressionBinder"),Sr(dg,"PatternCompositeBinder"),Sr(cg,"CompositeExpressionBinder"),Sr(Ly,"ProgramConfiguration",{omit:["_buffers"]}),Sr(qp,"ProgramConfigurationSet");const qd=tr/Math.PI/2,tp=5,O3=6,Qme=16383,xb=64,z6=[xb,32,16],sp=-qd,rp=qd;function mv(x,d,m,v=qd){return m=jr(m),[x*Math.sin(m)*v,-d*v,x*Math.cos(m)*v]}function gb(x,d,m){return mv(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,v=this.lat*m,S=d.lat*m,E=Math.sin(v)*Math.sin(S)+Math.cos(v)*Math.cos(S)*Math.cos((d.lng-this.lng)*m);return T*Math.acos(Math.min(E,1))}toBounds(d=0){const m=360*d/40075017,v=m/Math.cos(Math.PI/180*this.lat);return new A({lng:this.lng-v,lat:this.lat-m},{lng:this.lng+v,lat:this.lat+m})}toEcef(d){return gb(this.lat,this.lng,qd+d*qd/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,v=this._ne;let S,E;if(d instanceof y)S=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(S=d._sw,E=d._ne,!S||!E)return this}return m||v?(m.lng=Math.min(S.lng,m.lng),m.lat=Math.min(S.lat,m.lat),v.lng=Math.max(E.lng,v.lng),v.lat=Math.max(E.lat,v.lat)):(this._sw=new y(S.lng,S.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:v}=y.convert(d);let S=this._sw.lng<=m&&m<=this._ne.lng;return this._sw.lng>this._ne.lng&&(S=this._sw.lng>=m&&m>=this._ne.lng),this._sw.lat<=v&&v<=this._ne.lat&&S}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 W(x){return(180+x)/360}function Q(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 oe(x){return 360*x-180}function ve(x){return 360/Math.PI*Math.atan(Math.exp((180-360*x)*Math.PI/180))-90}function ge(x,d){return x*z(ve(d))}const be=85.051129;function Le(x){return Math.cos(jr(je(x,-be,be)))}function Ee(x,d){const m=je(d,D,F),v=Math.pow(2,m);return Le(x)*h/(512*v)}function We(x){return 1/Math.cos(x*Math.PI/180)}function Ue(x,d=0){const m=Math.exp(Math.PI*(1-(x.y+d/tr)/(1<=$?(ut(x,d,m,G,ee,E,se,O,$),ut(x,G,ee,v,S,se,P,O,$)):x.push(P)}function it(x,d,m){let v=x[0],S=v.x,E=v.y;d(v);const P=[v];for(let O=1;Ox.x+1||vx.y+1)&&fr("Geometry exceeds allowed extent, reduce your vector tile buffer size"),x}function Ot(x,d,m){const v=x.loadGeometry(),S=x.extent,E=tr/S;if(d&&m&&m.projection.isReprojectedInTileSpace){const P=1<{const de=oe((d.x+ie.x/S)/P),ue=ve((d.y+ie.y/S)/P),ke=ee.project(de,ue);ie.x=(ke.x*O-$)*S,ie.y=(ke.y*O-G)*S};for(let ie=0;ie=S||ue.y<0||ue.y>=S||(se(ue),de.push(ue));v[ie]=de}}for(const P of v)for(const O of P)gt(O,E);return v}function Wt(x,d){return{type:x.type,id:x.id,properties:x.properties,geometry:d?Ot(x):[]}}class Ht{constructor(d,m,v,S,E){this.properties={},this.extent=v,this.type=0,this.id=void 0,this._pbf=d,this._geometry=-1,this._keys=S,this._values=E,d.readFields(ss,this,m)}loadGeometry(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos,v=[];let S,E=1,P=0,O=0,$=0;for(;d.pos>3}if(P--,E===1||E===2)O+=d.readSVarint(),$+=d.readSVarint(),E===1&&(S&&v.push(S),S=[]),S&&S.push(new pt(O,$));else{if(E!==7)throw new Error(`unknown command ${E}`);S&&S.push(S[0].clone())}}return S&&v.push(S),v}bbox(){const d=this._pbf;d.pos=this._geometry;const m=d.readVarint()+d.pos;let v=1,S=0,E=0,P=0,O=1/0,$=-1/0,G=1/0,ee=-1/0;for(;d.pos>3}if(S--,v===1||v===2)E+=d.readSVarint(),P+=d.readSVarint(),E$&&($=E),Pee&&(ee=P);else if(v!==7)throw new Error(`unknown command ${v}`)}return[O,G,$,ee]}toGeoJSON(d,m,v){const S=this.extent*Math.pow(2,v),E=this.extent*d,P=this.extent*m,O=this.loadGeometry();function $(ie){return[360*(ie.x+E)/S-180,360/Math.PI*Math.atan(Math.exp((1-2*(ie.y+P)/S)*Math.PI))-90]}function G(ie){return ie.map($)}let ee;if(this.type===1){const ie=[];for(const ue of O)ie.push(ue[0]);const de=G(ie);ee=ie.length===1?{type:"Point",coordinates:de[0]}:{type:"MultiPoint",coordinates:de}}else if(this.type===2){const ie=O.map(G);ee=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(ue){const ke=ue.length;if(ke<=1)return[ue];const Oe=[];let De,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 $s(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(v){let S=null;const E=v.readVarint()+v.pos;for(;v.pos>3;S=P===1?v.readString():P===2?v.readFloat():P===3?v.readDouble():P===4?v.readVarint64():P===5?v.readVarint():P===6?v.readSVarint():P===7?v.readBoolean():null}if(S==null)throw new Error("unknown feature value");return S}(m))}class Xt{constructor(d,m){this.layers=d.readFields(Bt,{},m)}}function Bt(x,d,m){if(x===3){const v=new gs(m,m.readVarint()+m.pos);v.length&&(d[v.name]=v)}}const is="3d_elevation_id",Jt="level";class Ps{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,v){return this.get(d,!0,m,v)}optional(d,m,v){return this.get(d,!1,m,v)}success(){return this._valid}get(d,m,v,S){const E=this.feature.properties.hasOwnProperty(d)?+this.feature.properties[d]:void 0;return this._valid&&E!==void 0&&!Number.isNaN(E)?v(S?S(E):E):m&&(this._valid=!1),this}}class rr{constructor(d,m){this.featureFunc=d,this.vertexFunc=m}parseFeature(d,m,v){return this.featureFunc(d,m,v)}parseVertex(d,m,v){return this.vertexFunc(d,m,v)}}const gr=new rr((x,d,m)=>x.reset(d).require(is,v=>{m.id=v}).optional("fixed_height_relative",v=>{m.constantHeight=v},Vs.decodeRelativeHeight).geometry(v=>{m.bounds=v},eg).success(),(x,d,m)=>x.reset(d).require(is,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height_relative",v=>{m.height=v},Vs.decodeRelativeHeight).geometry(v=>{m.position=v},Vs.getPoint).success()),er=new rr((x,d,m)=>x.reset(d).require(is,v=>{m.id=v}).optional("fixed_height",v=>{m.constantHeight=v},Vs.decodeMetricHeight).geometry(v=>{m.bounds=v},eg).success(),(x,d,m)=>x.reset(d).require(is,v=>{m.id=v}).require("elevation_idx",v=>{m.idx=v}).require("extent",v=>{m.extent=v}).require("height",v=>{m.height=v},Vs.decodeMetricHeight).geometry(v=>{m.position=v},Vs.getPoint).success());class Vs{static getPoint(d){return Ct(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"?er:void 0:gr}static parse(d){const m=[],v=[],S=d.length,E=new Ps;for(let P=0;P=0);if(E===0)return 0;E!==d.length&&(m=!1)}return m?2:1}function Tn(x,d){for(const m of x.projections){const v=br(d,x.points[0],m.axis);if(m.projection[1]v[1])return 0}return 1}function va(x,d){let m=0;const v=[0,0,0,0];for(let P=0;P=0&&m++;var S,E;return m}class ei{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=Dr.fromPoints(this.points),this.projections=[],this.frustumEdges=[Se([],this.points[2],this.points[3]),Se([],this.points[0],this.points[3]),Se([],this.points[4],this.points[0]),Se([],this.points[5],this.points[1]),Se([],this.points[6],this.points[2]),Se([],this.points[7],this.points[3])];for(const v of this.frustumEdges){const S=[0,-v[2],v[1]],E=[v[2],0,-v[0]];this.projections.push({axis:S,projection:br(this.points,this.points[0],S)}),this.projections.push({axis:E,projection:br(this.points,this.points[0],E)})}}static fromInvProjectionMatrix(d,m,v,S){const E=Math.pow(2,v),P=[[-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(G=>{const ee=Je([],G,d),se=1/ee[3]/m*E;return(ie=ee)[0]=(de=ee)[0]*(ue=[se,se,S?1/ee[3]:se,se])[0],ie[1]=de[1]*ue[1],ie[2]=de[2]*ue[2],ie[3]=de[3]*ue[3],ie;var ie,de,ue}),O=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(G=>{const ee=Me([],ct([],Se([],P[G[0]],P[G[1]]),Se([],P[G[2]],P[G[1]]))),se=-$e(ee,P[G[1]]);return ee.concat(se)}),$=[];for(let G=0;GG[1]||G[0]>$[1])return 0}return 1}containsPoint(d){for(const m of this.planes){const v=m[3];if($e([m[0],m[1],m[2]],d)+v<0)return!1}return!0}}class Dr{static fromPoints(d){const m=[1/0,1/0,1/0],v=[-1/0,-1/0,-1/0];for(const S of d)_e(m,m,S),fe(v,v,S);return new Dr(m,v)}static fromTileIdAndHeight(d,m,v){const S=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])]}}Sr(Dr,"Aabb");class Ka{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,v=m[1],S=-m[0],E=(d.extent+1)*this.metersToTile;return[new pt(Math.trunc(d.position[0]+v*E),Math.trunc(d.position[1]+S*E)),new pt(Math.trunc(d.position[0]-v*E),Math.trunc(d.position[1]-S*E))]}next(){this.index++}valid(){return this.index{return O.a0?we($,$,1/G):re($,0,0,1)}getSafeArea(){return this.safeArea}isTunnel(){return this.heightRange.max<=-5}getClosestEdge(d){if(this.edges.length===0)return;let m=0,v=Number.POSITIVE_INFINITY,S=0;const[E,P,O,$,G,ee,se]=this._tmpVec2;As(se,d.x,d.y);const ie=new Pr(se,null);for(let de=0;de0?Wa($,O)/ot:0,yt=je(Nt,0,1),At=Math.abs((Nt-yt)*this.edgeProps[de].len);kr(G,se,Oe),As(ee,ke[1],-ke[0]);const Ft=At+Math.abs(Wa(G,ee));Ft=0;--P){const O=this.edges[P].a,$=this.edges[P].b,{position:G,height:ee,extent:se}=this.vertices[O],{position:ie,height:de,extent:ue}=this.vertices[$],ke=this.vertexProps[O].dir,Oe=this.vertexProps[$].dir;if(re(m,G[0]/d,G[1]/d,ee),re(v,ie[0]/d,ie[1]/d,de),re(S,ke[1],-ke[0],0),we(S,S,se),re(E,Oe[1],-Oe[0],0),we(E,E,ue),this.distSqLines(ne(m[0]+.5*S[0],m[1]+.5*S[1],m[2]+.5*S[2]),ne(v[0]-.5*E[0],v[1]-.5*E[1],v[2]-.5*E[2]),ne(m[0]-.5*S[0],m[1]-.5*S[1],m[2]-.5*S[2]),ne(v[0]+.5*E[0],v[1]+.5*E[1],v[2]+.5*E[2]))<=.0025000000000000005)continue;const De=this.vertices.length,Ke=Us(vr(),G,ie);this.vertices.push({position:ta(Ke,Ke,.5),height:.5*(ee+de),extent:.5*(se+ue)});const Xe=Us(vr(),ke,Oe);this.vertexProps.push({dir:Li(Xe,Xe)}),this.edges.splice(P,1),this.edgeProps.splice(P,1),this.edges.push({a:O,b:De}),this.edges.push({a:De,b:$});const ot=kr(vr(),this.vertices[De].position,G),Nt=ka(ot),yt={vec:ot,dir:ta(vr(),ot,1/Nt),len:Nt};this.edgeProps.push(yt),this.edgeProps.push(yt)}}distSqLines(d,m,v,S){const E=pe(te(),m,d),P=pe(te(),S,v),O=pe(te(),d,v),$=$e(E,E),G=$e(E,P),ee=$e(E,O),se=$e(P,P),ie=$e(P,O),de=$*se-G*G;if(de===0)return Ae(Te(E,v,S,$e(O,P)/$e(P,P)),d);const ue=($*ie-G*ee)/de;return Ae(Te(E,d,m,(G*ie-ee*se)/de),Te(P,v,S,ue))}}class ci{static parseFrom(d,m){const v=Vs.parse(d);if(!v)return[];let{vertices:S,features:E}=v;const P=1/Ue(m);E.sort((ee,se)=>ee.id-se.id),S.sort((ee,se)=>ee.id-se.id||ee.idx-se.idx),S=S.filter((ee,se,ie)=>se===ie.findIndex(de=>de.id===ee.id&&de.idx===ee.idx));const O=new Array;let $=0;const G=S.length;for(const ee of E){if(ee.constantHeight){O.push(new jn(ee.id,ee.bounds,ee.constantHeight));continue}for(;$!==G&&S[$].idS.id===v)}}class ki{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,v){const S=this.constantElevation(m,v);return S??(d.x=d.x*this.zScale+this.xOffset,d.y=d.y*this.zScale+this.yOffset,this.computeBiasedHeight(m.pointElevation(d),v))}computeBiasedHeight(d,m){return m<=0?d:d+m*Be(0,m,d>=0?d:Math.abs(.5*d))}}Sr(jn,"ElevationFeature");class vi{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 Ey,this.indexArray=new zl,this.segments=new bo,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 ig),this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,S){}populate(d,m,v,S){const E=this.layers[0],P=[];let O=null;E.type==="circle"&&(O=E.layout.get("circle-sort-key"));for(const{feature:G,id:ee,index:se,sourceLayerIndex:ie}of d){const de=this.layers[0]._featureFilter.needGeometry,ue=Wt(G,de);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ue,v))continue;const ke=O?O.evaluate(ue,{},v):void 0,Oe={id:ee,properties:G.properties,type:G.type,sourceLayerIndex:ie,index:se,geometry:de?ue.geometry:Ot(G,v,S),patterns:{},sortKey:ke};P.push(Oe)}O&&P.sort((G,ee)=>G.sortKey-ee.sortKey);let $=null;S.projection.name==="globe"&&(this.globeExtVertexArray=new v3,$=S.projection);for(const G of P){const{geometry:ee,index:se,sourceLayerIndex:ie}=G,de=d[se].feature;this.addFeature(G,ee,se,m.availableImages,v,$,m.brightness,m.elevationFeatures),m.featureIndex.insert(de,ee,se,ie,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(d,m,v,S,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,S,P,O,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,vF.members),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,bF.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=d.createVertexBuffer(this.elevatedLayoutVertexArray,qme.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,v,S,E,P,O,$){let G;this.elevationMode!=="none"&&(G=ci.getElevationFeature(d,$));for(const ee of m)for(const se of ee){const ie=se.x,de=se.y;if(ie<0||ie>=tr||de<0||de>=tr)continue;if(P){const Oe=P.projectTilePoint(ie,de,E),De=P.upVector(E,ie,de);this.addGlobeExtVertex(Oe,De),this.addGlobeExtVertex(Oe,De),this.addGlobeExtVertex(Oe,De),this.addGlobeExtVertex(Oe,De)}const ue=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,d.sortKey),ke=ue.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 Oe=G?G.pointElevation(new pt(ie,de)):0;this.hasElevation=this.hasElevation||Oe!==0;for(let De=0;De<4;De++)this.elevatedLayoutVertexArray.emplaceBack(Oe)}this.indexArray.emplaceBack(ke,ke+1,ke+2),this.indexArray.emplaceBack(ke,ke+2,ke+3),ue.vertexLength+=4,ue.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,{},S,E,O,void 0,this.worldview)}addCircleVertex(d,m,v,S){this.layoutVertexArray.emplaceBack(2*d+(v+1)/2,2*m+(S+1)/2)}addGlobeExtVertex(d,m){this.globeExtVertexArray.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}}function Ga(x,d){for(let m=0;m1){if(ro(x,d))return!0;for(let v=0;v1?m:m.sub(d)._mult(S)._add(d))}function _o(x,d){let m,v,S,E=!1;for(let P=0;Pd.y!=S.y>d.y&&d.x<(S.x-v.x)*(d.y-v.y)/(S.y-v.y)+v.x&&(E=!E)}return E}function Di(x,d){let m=!1;for(let v=0,S=x.length-1;vd.y!=P.y>d.y&&d.x<(P.x-E.x)*(d.y-E.y)/(P.y-E.y)+E.x&&(m=!m)}return m}function zu(x,d,m,v,S){for(const P of x)if(d<=P.x&&m<=P.y&&v>=P.x&&S>=P.y)return!0;const E=[new pt(d,m),new pt(d,S),new pt(v,S),new pt(v,m)];if(x.length>2){for(const P of E)if(Di(x,P))return!0}for(let P=0;PS.x&&d.x>S.x||x.yS.y&&d.y>S.y)return!1;const E=Pn(x,d,m[0]);return E!==Pn(x,d,m[1])||E!==Pn(x,d,m[2])||E!==Pn(x,d,m[3])}function $l(x,d,m,v,S,E){let P=d.y-x.y,O=x.x-d.x;if(E=E||0){const $=P*P+O*O;if($===0)return!0;const G=Math.sqrt($);P/=G,O/=G}return!((m.x-x.x)*P+(m.y-x.y)*O-E<0||(v.x-x.x)*P+(v.y-x.y)*O-E<0||(S.x-x.x)*P+(S.y-x.y)*O-E<0)}function Ud(x,d,m,v,S,E,P){return!($l(x,d,v,S,E,P)||$l(d,m,v,S,E,P)||$l(m,x,v,S,E,P)||$l(v,S,x,d,m,P)||$l(S,E,x,d,m,P)||$l(E,v,x,d,m,P))}function Vd(x,d,m){const v=d.paint.get(x).value;return v.kind==="constant"?v.value:m.programConfigurations.get(d.id).getMaxValue(x)}function ad(x){return Math.sqrt(x[0]*x[0]+x[1]*x[1])}function um(x,d,m,v,S){if(!d[0]&&!d[1])return x;const E=pt.convert(d)._mult(S);m==="viewport"&&E._rotate(-v);const P=[];for(let O=0;O>m&&d.y===this.y>>m}url(d,m){const v=function(E,P,O){var $=Qo(256*E,256*(P=Math.pow(2,O)-P-1),O),G=Qo(256*(E+1),256*(P+1),O);return $[0]+","+$[1]+","+G[0]+","+G[1]}(this.x,this.y,this.z),S=function(E,P,O){let $,G="";for(let ee=E;ee>0;ee--)$=1<this.canonical.z?new So(d,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new So(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 wo(this.wrap*+m,d,this.canonical.z,this.canonical.x,this.canonical.y);{const v=this.canonical.z-d;return wo(this.wrap*+m,d,d,this.canonical.x>>v,this.canonical.y>>v)}}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 So(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const m=this.canonical.z+1,v=2*this.canonical.x,S=2*this.canonical.y;return[new So(m,this.wrap,m,v,S),new So(m,this.wrap,m,v+1,S),new So(m,this.wrap,m,v,S+1),new So(m,this.wrap,m,v+1,S+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 So(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,(x.canonical.y===0?1<new So(x.overscaledZ,x.wrap,x.canonical.z,x.canonical.x,x.canonical.y===(1<1?null:function(v,S,E,P){const O=Math.sin(E);return v*(Math.sin((1-P)*E)/O)+S*(Math.sin(P*E)/O)}(x.a[d],x.b[d],x.angle,je(m,0,1))+x.center[d]}function Vp(x){if(x.z<=1)return ug[x.z+2*x.y+x.x];const d=Jme(_F(x));return Dr.fromPoints(d)}function mg(x,d,m){return we(x,x,1-m),Ie(x,x,d,m)}function pCe(x,d,m){for(const v of x)ft(v,v,d),we(v,v,m)}function fCe(x,d,m,v){const S=d/x.worldSize,E=x.globeMatrix;if(m.z<=1){const qt=Vp(m).getCorners();return pCe(qt,E,S),Dr.fromPoints(qt)}const P=_F(m,v),O=Jme(P,qd+Gf(x._tileCoverLift));pCe(O,E,S);const $=Number.MAX_VALUE,G=[-$,-$,-$],ee=[$,$,$];if(P.contains(x.center)){for(const Gt of O)_e(ee,ee,Gt),fe(G,G,Gt);G[2]=0;const qt=x.point,ns=[qt.x*S,qt.y*S,0];return _e(ee,ee,ns),fe(G,G,ns),new Dr(ee,G)}if(x._tileCoverLift>0){for(const qt of O)_e(ee,ee,qt),fe(G,G,qt);return new Dr(ee,G)}const se=[E[12]*S,E[13]*S,E[14]*S],ie=P.getCenter(),de=je(x.center.lat,-be,be),ue=je(ie.lat,-be,be),ke=W(x.center.lng),Oe=Q(de);let De=ke-W(ie.lng);const Ke=Oe-Q(ue);De>.5?De-=1:De<-.5&&(De+=1);let Xe=0;Math.abs(De)>Math.abs(Ke)?Xe=De>=0?1:3:(Xe=Ke>=0?0:2,Ie(se,se,[E[4]*S,E[5]*S,E[6]*S],-Math.sin(jr(Ke>=0?P.getSouth():P.getNorth()))*qd));const ot=O[Xe],Nt=O[(Xe+1)%4],yt=new Dy(ot,Nt,se),At=[hg(yt,0)||ot[0],hg(yt,1)||ot[1],hg(yt,2)||ot[2]],Ft=bb(x.zoom);if(Ft>0){const qt=function({x:Gt,y:ds,z:js},Ns,Fs,Bs,Is){const Ls=1/(1<.5?Hs=-1:Fr<-.5&&(Hs=1),cs=((cs+Hs)*Ns-(Bs*=Ns))*Fs+Bs,as=((as+Hs)*Ns-Bs)*Fs+Bs,Os=(Os*Ns-(Is*=Ns))*Fs+Is,sr=(sr*Ns-Is)*Fs+Is,[[cs,sr,0],[as,sr,0],[as,Os,0],[cs,Os,0]]}(m,d,x._pixelsPerMercatorPixel,ke,Oe);for(let Gt=0;GtMath.PI/2*1.01}const bCe=jr(85),Nct=Math.cos(bCe),kct=Math.sin(bCe),Sct=_(),_Ce=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 wCe(x,d,m,v,S,E,P,O,$){if(E&&x.queryGeometry.isAboveHorizon)return!1;E&&($*=x.pixelToTileUnitsFactor);const G=x.tileID.canonical,ee=m.projection.upVectorScale(G,m.center.lat,m.worldSize).metersToTile;for(const se of d)for(const ie of se){const de=ie.add(O),ue=S&&m.elevation?m.elevation.exaggeration()*S.getElevationAt(de.x,de.y,!0):0,ke=m.projection.projectTilePoint(de.x,de.y,G);if(ue>0){const Xe=m.projection.upVector(G,de.x,de.y);ke.x+=Xe[0]*ee*ue,ke.y+=Xe[1]*ee*ue,ke.z+=Xe[2]*ee*ue}const Oe=E?de:Cct(ke.x,ke.y,ke.z,v),De=E?x.tilespaceRays.map(Xe=>Tct(Xe,ue)):x.queryGeometry.screenGeometry,Ke=Je([],[ke.x,ke.y,ke.z,1],v);if(!P&&E?$*=Ke[3]/m.cameraToCenterDistance:P&&!E&&($*=m.cameraToCenterDistance/Ke[3]),E){const Xe=ve((ie.y/tr+G.y)/(1<x.width||S.height>x.height||m.x>x.width-S.width||m.y>x.height-S.height)throw new RangeError("out of range source coordinates for image copy");if(S.width>d.width||S.height>d.height||v.x>d.width-S.width||v.y>d.height-S.height)throw new RangeError("out of range destination coordinates for image copy");const $=x.data,G=d.data,ee=E===4&&O;for(let se=0;se{d[x.evaluationKey]=$;const G=x.expression.evaluate(d),ee=G?G.toNonPremultipliedRenderColor(null):null;ee&&(S.data[P+O+0]=Math.floor(255*ee.r),S.data[P+O+1]=Math.floor(255*ee.g),S.data[P+O+2]=Math.floor(255*ee.b),S.data[P+O+3]=Math.floor(255*ee.a))};if(x.clips)for(let P=0,O=0;P80*m){O=x[0],$=x[1];let ee=O,se=$;for(let ie=m;ieee&&(ee=de),ue>se&&(se=ue)}G=Math.max(ee-O,se-$),G=G!==0?32767/G:0}return q6(E,P,m,O,$,G,0),P}function PCe(x,d,m,v,S){let E;if(S===function(P,O,$,G){let ee=0;for(let se=O,ie=$-G;se<$;se+=G)ee+=(P[ie]-P[se])*(P[se+1]+P[ie+1]),ie=se;return ee}(x,d,m,v)>0)for(let P=d;P=d;P-=v)E=OCe(P/v|0,x[P],x[P+1],E);return E&&F3(E,E.next)&&(H6(E),E=E.next),E}function j2(x,d){if(!x)return x;d||(d=x);let m,v=x;do if(m=!1,v.steiner||!F3(v,v.next)&&Hc(v.prev,v,v.next)!==0)v=v.next;else{if(H6(v),v=d=v.prev,v===v.next)break;m=!0}while(m||v!==d);return d}function q6(x,d,m,v,S,E,P){if(!x)return;!P&&E&&function($,G,ee,se){let ie=$;do ie.z===0&&(ie.z=npe(ie.x,ie.y,G,ee,se)),ie.prevZ=ie.prev,ie.nextZ=ie.next,ie=ie.next;while(ie!==$);ie.prevZ.nextZ=null,ie.prevZ=null,function(de){let ue,ke=1;do{let Oe,De=de;de=null;let Ke=null;for(ue=0;De;){ue++;let Xe=De,ot=0;for(let yt=0;yt0||Nt>0&&Xe;)ot!==0&&(Nt===0||!Xe||De.z<=Xe.z)?(Oe=De,De=De.nextZ,ot--):(Oe=Xe,Xe=Xe.nextZ,Nt--),Ke?Ke.nextZ=Oe:de=Oe,Oe.prevZ=Ke,Ke=Oe;De=Xe}Ke.nextZ=null,ke*=2}while(ue>1)}(ie)}(x,v,S,E);let O=x;for(;x.prev!==x.next;){const $=x.prev,G=x.next;if(E?Dct(x,v,S,E):Lct(x))d.push($.i,x.i,G.i),H6(x),x=G.next,O=G.next;else if((x=G)===O){P?P===1?q6(x=Oct(j2(x),d),d,m,v,S,E,2):P===2&&Rct(x,d,m,v,S,E):q6(j2(x),d,m,v,S,E,1);break}}}function Lct(x){const d=x.prev,m=x,v=x.next;if(Hc(d,m,v)>=0)return!1;const S=d.x,E=m.x,P=v.x,O=d.y,$=m.y,G=v.y,ee=Math.min(S,E,P),se=Math.min(O,$,G),ie=Math.max(S,E,P),de=Math.max(O,$,G);let ue=v.next;for(;ue!==d;){if(ue.x>=ee&&ue.x<=ie&&ue.y>=se&&ue.y<=de&&U6(S,O,E,$,P,G,ue.x,ue.y)&&Hc(ue.prev,ue,ue.next)>=0)return!1;ue=ue.next}return!0}function Dct(x,d,m,v){const S=x.prev,E=x,P=x.next;if(Hc(S,E,P)>=0)return!1;const O=S.x,$=E.x,G=P.x,ee=S.y,se=E.y,ie=P.y,de=Math.min(O,$,G),ue=Math.min(ee,se,ie),ke=Math.max(O,$,G),Oe=Math.max(ee,se,ie),De=npe(de,ue,d,m,v),Ke=npe(ke,Oe,d,m,v);let Xe=x.prevZ,ot=x.nextZ;for(;Xe&&Xe.z>=De&&ot&&ot.z<=Ke;){if(Xe.x>=de&&Xe.x<=ke&&Xe.y>=ue&&Xe.y<=Oe&&Xe!==S&&Xe!==P&&U6(O,ee,$,se,G,ie,Xe.x,Xe.y)&&Hc(Xe.prev,Xe,Xe.next)>=0||(Xe=Xe.prevZ,ot.x>=de&&ot.x<=ke&&ot.y>=ue&&ot.y<=Oe&&ot!==S&&ot!==P&&U6(O,ee,$,se,G,ie,ot.x,ot.y)&&Hc(ot.prev,ot,ot.next)>=0))return!1;ot=ot.nextZ}for(;Xe&&Xe.z>=De;){if(Xe.x>=de&&Xe.x<=ke&&Xe.y>=ue&&Xe.y<=Oe&&Xe!==S&&Xe!==P&&U6(O,ee,$,se,G,ie,Xe.x,Xe.y)&&Hc(Xe.prev,Xe,Xe.next)>=0)return!1;Xe=Xe.prevZ}for(;ot&&ot.z<=Ke;){if(ot.x>=de&&ot.x<=ke&&ot.y>=ue&&ot.y<=Oe&&ot!==S&&ot!==P&&U6(O,ee,$,se,G,ie,ot.x,ot.y)&&Hc(ot.prev,ot,ot.next)>=0)return!1;ot=ot.nextZ}return!0}function Oct(x,d){let m=x;do{const v=m.prev,S=m.next.next;!F3(v,S)&&LCe(v,m,m.next,S)&&V6(v,S)&&V6(S,v)&&(d.push(v.i,m.i,S.i),H6(m),H6(m.next),m=x=S),m=m.next}while(m!==x);return j2(m)}function Rct(x,d,m,v,S,E){let P=x;do{let O=P.next.next;for(;O!==P.prev;){if(P.i!==O.i&&qct(P,O)){let $=DCe(P,O);return P=j2(P,P.next),$=j2($,$.next),q6(P,d,m,v,S,E,0),void q6($,d,m,v,S,E,0)}O=O.next}P=P.next}while(P!==x)}function Fct(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 zct(x,d){const m=function(S,E){let P=E;const O=S.x,$=S.y;let G,ee=-1/0;if(F3(S,P))return P;do{if(F3(S,P.next))return P.next;if($<=P.y&&$>=P.next.y&&P.next.y!==P.y){const ke=P.x+($-P.y)*(P.next.x-P.x)/(P.next.y-P.y);if(ke<=O&&ke>ee&&(ee=ke,G=P.x=P.x&&P.x>=ie&&O!==P.x&&ICe($G.x||P.x===G.x&&Bct(G,P)))&&(G=P,ue=ke)}P=P.next}while(P!==se);return G}(x,d);if(!m)return d;const v=DCe(m,x);return j2(v,v.next),j2(m,m.next)}function Bct(x,d){return Hc(x.prev,x,d.prev)<0&&Hc(d.next,x,x.next)<0}function npe(x,d,m,v,S){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-m)*S|0)|x<<8))|x<<4))|x<<2))|x<<1))|(d=1431655765&((d=858993459&((d=252645135&((d=16711935&((d=(d-v)*S|0)|d<<8))|d<<4))|d<<2))|d<<1))<<1}function $ct(x){let d=x,m=x;do(d.x=(x-P)*(E-O)&&(x-P)*(v-O)>=(m-P)*(d-O)&&(m-P)*(E-O)>=(S-P)*(v-O)}function U6(x,d,m,v,S,E,P,O){return!(x===P&&d===O)&&ICe(x,d,m,v,S,E,P,O)}function qct(x,d){return x.next.i!==d.i&&x.prev.i!==d.i&&!function(m,v){let S=m;do{if(S.i!==m.i&&S.next.i!==m.i&&S.i!==v.i&&S.next.i!==v.i&&LCe(S,S.next,m,v))return!0;S=S.next}while(S!==m);return!1}(x,d)&&(V6(x,d)&&V6(d,x)&&function(m,v){let S=m,E=!1;const P=(m.x+v.x)/2,O=(m.y+v.y)/2;do S.y>O!=S.next.y>O&&S.next.y!==S.y&&P<(S.next.x-S.x)*(O-S.y)/(S.next.y-S.y)+S.x&&(E=!E),S=S.next;while(S!==m);return E}(x,d)&&(Hc(x.prev,x,d.prev)||Hc(x,d.prev,d))||F3(x,d)&&Hc(x.prev,x,x.next)>0&&Hc(d.prev,d,d.next)>0)}function Hc(x,d,m){return(d.y-x.y)*(m.x-d.x)-(d.x-x.x)*(m.y-d.y)}function F3(x,d){return x.x===d.x&&x.y===d.y}function LCe(x,d,m,v){const S=kF(Hc(x,d,m)),E=kF(Hc(x,d,v)),P=kF(Hc(m,v,x)),O=kF(Hc(m,v,d));return S!==E&&P!==O||!(S!==0||!NF(x,m,d))||!(E!==0||!NF(x,v,d))||!(P!==0||!NF(m,x,v))||!(O!==0||!NF(m,d,v))}function NF(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 kF(x){return x>0?1:x<0?-1:0}function V6(x,d){return Hc(x.prev,x,x.next)<0?Hc(x,d,x.next)>=0&&Hc(x,x.prev,d)>=0:Hc(x,d,x.prev)<0||Hc(x,x.next,d)<0}function DCe(x,d){const m=ape(x.i,x.x,x.y),v=ape(d.i,d.x,d.y),S=x.next,E=d.prev;return x.next=d,d.prev=x,m.next=S,S.prev=m,v.next=m,m.prev=v,E.next=v,v.prev=E,v}function OCe(x,d,m,v){const S=ape(x,d,m);return v?(S.next=v.next,S.prev=v,v.next.prev=S,v.next=S):(S.prev=S,S.next=S),S}function H6(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 ape(x,d,m){return{i:x,x:d,y:m,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function W6(x,d){const m=x.length;if(m<=1)return[x];const v=[];let S,E;for(let P=0;P1)for(let P=0;P=tr&&m>=tr}static evaluate(d){if(d.length===0)return new pv;let m=[];for(const $ of d)m.push(...$.portals);if(m.length===0)return new pv;for(const $ of m){const G=$.va,ee=$.vb;(pv.isOnBorder(G.x,ee.x)||pv.isOnBorder(G.y,ee.y))&&($.type="border")}const v=m.filter($=>$.type!=="unevaluated"),S=m.filter($=>$.type==="unevaluated");if(S.length===0)return new pv;S.sort(($,G)=>$.hash===G.hash?$.isTunnel===G.isTunnel?0:$.isTunnel?-1:1:$.hash$.hashE!=="fill-tunnel-structure-color"),this.tunnelProgramConfigurations=new qp(m,{zoom:v,lut:S},E=>E!=="fill-bridge-guard-rail-color")}addVertices(d,m){const v=this.unevalVertices.length;for(let S=0;S=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||Md(se,ie,O))||this.isOnBorder(se.x,ie.x)||this.isOnBorder(se.y,ie.y))continue;const de=hm.computeEdgeHash(this.unevalVertices[G],this.unevalVertices[ee]);let ue,ke=this.vertexHashLookup.get(hm.computePosHash(se));ke!=null?ue=ke.next:(ke=this.vertexHashLookup.get(hm.computePosHash(ie)),ue=ke!=null?ke.prev:de),this.unevalEdges.push({polygonIdx:d,a:G,b:ee,hash:de,portalHash:ue,isTunnel:S,type:"unevaluated",featureInfo:P})}}addPortalCandidates(d,m,v,S,E){if(m.length===0)return;this.portalPolygons.add(d,{geometry:m,zLevel:E});const P=m[0];this.vertexHashLookup.clear();let O=hm.computeEdgeHash(P[P.length-2],P[P.length-1]);for(let $=0;$({vertexOffset:0,primitiveOffset:this.indexArray.length}),v=ie=>{ie.primitiveLength=this.indexArray.length-ie.primitiveOffset},S=new Vct(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(d.portals,this.unevalEdges);const E=m(),P=m(),O=m(),$=(ie,de)=>{ie.sort((ke,Oe)=>ke.type===de&&Oe.type!==de?-1:ke.type!==de&&Oe.type===de?1:0);const ue=ie.findIndex(ke=>ke.type!==de);return ue>=0?ue:ie.length};let G=0;this.unevalEdges.length>0&&(G=$(this.unevalEdges,"none"),this.constructBridgeStructures(S,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},this.tileToMeters)),v(O);const ee=m(),se=m();if(this.unevalEdges.length>0){const ie=this.unevalEdges.splice(G),de=$(ie,"tunnel")+G;this.unevalEdges.push(...ie),this.constructTunnelStructures(S,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:G},{min:G,max:de})}v(ee),S.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),v(se),S.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),v(P),S.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),v(E),this.maskSegments=bo.simpleSegment(0,se.primitiveOffset,0,se.primitiveLength),this.depthSegments=bo.simpleSegment(0,P.primitiveOffset,0,P.primitiveLength),this.renderableBridgeSegments=bo.simpleSegment(0,O.primitiveOffset,0,O.primitiveLength),this.renderableTunnelSegments=bo.simpleSegment(0,ee.primitiveOffset,0,ee.primitiveLength),this.shadowCasterSegments=bo.simpleSegment(0,E.primitiveOffset,0,E.primitiveLength)}update(d,m,v,S,E,P,O,$){this.bridgeProgramConfigurations.updatePaintArrays(d,m,E,v,S,P,O,$),this.tunnelProgramConfigurations.updatePaintArrays(d,m,E,v,S,P,O,$)}upload(d){this.vertexBuffer||this.vertexPositions.length===0||this.vertexNormals.length===0||this.indexArray.length===0||(this.vertexBuffer=d.createVertexBuffer(this.vertexPositions,Pct.members),this.vertexBufferNormal=d.createVertexBuffer(this.vertexNormals,Ict.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,v,S,E){const P=(O,$)=>{for(let G=0;G<$.length-1;G++){const ee=$[G].featureIndex,se=$[G+1].vertexStart,ie=d.feature(ee);O.populatePaintArrays(se,ie,ee,{},v,m,S,void 0,E)}};P(this.bridgeProgramConfigurations,this.bridgeFeatureSections),P(this.tunnelProgramConfigurations,this.tunnelFeatureSections)}computeVertexConnections(d,m,v,S,E){const P=new Map;for(let O=S;Ore(Fs,m[Bs].x,m[Bs].y,v[Bs]*$),se=te(),ie=te(),de=te(),ue=te(),ke=te(),Oe=(Fs,Bs)=>{const Is=O.get(hm.computePosHash(m[Bs])),Ls=Is.from,cs=Is.to;if(!Ls||!cs)return;ee(se,Ls),ee(ie,Bs),ee(de,cs),nt(ue),et(se,ie)||(Se(ke,ie,se),Me(ue,ke)),et(de,ie)||(Se(ke,de,ie),le(ue,ue,Me(ke,ke)));const as=Ge(ue);return as>0?we(Fs,ue,1/as):void 0};let De=Number.POSITIVE_INFINITY;this.sortSubarray(S,E.min,E.max,(Fs,Bs)=>Fs.featureInfo.featureIndex-Bs.featureInfo.featureIndex);const Ke=te(),Xe=te(),ot=te(),Nt=te(),yt=te(),At=te(),Ft=te(),qt=te(),ns=te(),Gt=[te(),te(),te(),te()],ds=[te(),te(),te(),te()],js=[{coord:new pt(0,0),height:0},{coord:new pt(0,0),height:0}],Ns=(Fs,Bs)=>Fs>Bs;for(let Fs=E.min;FsDe.featureInfo.featureIndex-Ke.featureInfo.featureIndex;this.sortSubarray(S,E.min,E.max,$),this.sortSubarray(S,P.min,P.max,$);const G=De=>Me(De,De),ee=[{coord:new pt(0,0),height:0},{coord:new pt(0,0),height:0}],se=(De,Ke)=>DeO.hash===$.hash?$.polygonIdx-O.polygonIdx:$.hash>O.hash?1:-1);let v=0,S=0,E=0,P=m[v].polygonIdx;do S++,(S===m.length||m[v].hash!==m[S].hash)&&((S-v==1||m[S-1].polygonIdx!==P)&&(EG.portalHashee.hash?O++:ee.hash>G.portalHash?$++:(G.type=ee.type,O++)}}}isOnBorder(d,m){return d<=0&&m<=0||d>=tr&&m>=tr}addFeatureSection(d,m,v,S){return d!==m&&(m=d,v.push({featureIndex:d,vertexStart:S.getVertexCount()}),S.clearVertexLookup()),m}sortSubarray(d,m,v,S){const E=d.slice(m,v);E.sort(S),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(hm.computePosHash(d))<<32n|BigInt(hm.computePosHash(m))}static computePosHash(d){return((65535&d.x)<<16|65535&d.y)>>>0}}var zCe,BCe={exports:{}},$Ce=(zCe||(zCe=1,function(x){function d(bt,St){return bt>St?1:bt0){var zr=zs+Math.floor(lr/2),Ur={key:St[zr],data:ms[zr],parent:bt};return Ur.left=S(Ur,St,ms,zs,zr),Ur.right=S(Ur,St,ms,zr+1,or),Ur}return null}function E(bt,St,ms,zs,or){if(!(ms>=zs)){for(var lr=bt[ms+zs>>1],zr=ms-1,Ur=zs+1;;){do zr++;while(or(bt[zr],lr)<0);do Ur--;while(or(bt[Ur],lr)>0);if(zr>=Ur)break;var An=bt[zr];bt[zr]=bt[Ur],bt[Ur]=An,An=St[zr],St[zr]=St[Ur],St[Ur]=An}E(bt,St,ms,Ur,or),E(bt,St,Ur+1,zs,or)}}m.prototype.rotateLeft=function(bt){var St=bt.right;St&&(bt.right=St.left,St.left&&(St.left.parent=bt),St.parent=bt.parent),bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.left=bt),bt.parent=St},m.prototype.rotateRight=function(bt){var St=bt.left;St&&(bt.left=St.right,St.right&&(St.right.parent=bt),St.parent=bt.parent),bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.right=bt),bt.parent=St},m.prototype._splay=function(bt){for(;bt.parent;){var St=bt.parent;St.parent?St.left===bt&&St.parent.left===St?(this.rotateRight(St.parent),this.rotateRight(St)):St.right===bt&&St.parent.right===St?(this.rotateLeft(St.parent),this.rotateLeft(St)):St.left===bt&&St.parent.right===St?(this.rotateRight(St),this.rotateLeft(St)):(this.rotateLeft(St),this.rotateRight(St)):St.left===bt?this.rotateRight(St):this.rotateLeft(St)}},m.prototype.splay=function(bt){for(var St,ms,zs,or,lr;bt.parent;)(ms=(St=bt.parent).parent)&&ms.parent?((zs=ms.parent).left===ms?zs.left=bt:zs.right=bt,bt.parent=zs):(bt.parent=null,this._root=bt),or=bt.left,lr=bt.right,bt===St.left?(ms&&(ms.left===St?(St.right?(ms.left=St.right,ms.left.parent=ms):ms.left=null,St.right=ms,ms.parent=St):(or?(ms.right=or,or.parent=ms):ms.right=null,bt.left=ms,ms.parent=bt)),lr?(St.left=lr,lr.parent=St):St.left=null,bt.right=St,St.parent=bt):(ms&&(ms.right===St?(St.left?(ms.right=St.left,ms.right.parent=ms):ms.right=null,St.left=ms,ms.parent=St):(lr?(ms.left=lr,lr.parent=ms):ms.left=null,bt.right=ms,ms.parent=bt)),or?(St.right=or,or.parent=St):St.right=null,bt.left=St,St.parent=bt)},m.prototype.replace=function(bt,St){bt.parent?bt===bt.parent.left?bt.parent.left=St:bt.parent.right=St:this._root=St,St&&(St.parent=bt.parent)},m.prototype.minNode=function(bt){if(bt===void 0&&(bt=this._root),bt)for(;bt.left;)bt=bt.left;return bt},m.prototype.maxNode=function(bt){if(bt===void 0&&(bt=this._root),bt)for(;bt.right;)bt=bt.right;return bt},m.prototype.insert=function(bt,St){var ms=this._root,zs=null,or=this._compare;if(this._noDuplicates)for(;ms;){if(zs=ms,or(ms.key,bt)===0)return;ms=or(ms.key,bt)<0?ms.right:ms.left}else for(;ms;)zs=ms,ms=or(ms.key,bt)<0?ms.right:ms.left;return ms={key:bt,data:St,left:null,right:null,parent:zs},zs?or(zs.key,ms.key)<0?zs.right=ms:zs.left=ms:this._root=ms,this.splay(ms),this._size++,ms},m.prototype.find=function(bt){for(var St=this._root,ms=this._compare;St;){var zs=ms(St.key,bt);if(zs<0)St=St.right;else{if(!(zs>0))return St;St=St.left}}return null},m.prototype.contains=function(bt){for(var St=this._root,ms=this._compare;St;){var zs=ms(bt,St.key);if(zs===0)return!0;St=zs<0?St.left:St.right}return!1},m.prototype.remove=function(bt){var St=this.find(bt);if(!St)return!1;if(this.splay(St),St.left)if(St.right){var ms=this.minNode(St.right);ms.parent!==St&&(this.replace(ms,ms.right),ms.right=St.right,ms.right.parent=ms),this.replace(St,ms),ms.left=St.left,ms.left.parent=ms}else this.replace(St,St.left);else this.replace(St,St.right);return this._size--,!0},m.prototype.removeNode=function(bt){if(!bt)return!1;if(this.splay(bt),bt.left)if(bt.right){var St=this.minNode(bt.right);St.parent!==bt&&(this.replace(St,St.right),St.right=bt.right,St.right.parent=St),this.replace(bt,St),St.left=bt.left,St.left.parent=St}else this.replace(bt,bt.left);else this.replace(bt,bt.right);return this._size--,!0},m.prototype.erase=function(bt){var St=this.find(bt);if(St){this.splay(St);var ms=St.left,zs=St.right,or=null;ms&&(ms.parent=null,or=this.maxNode(ms),this.splay(or),this._root=or),zs&&(ms?or.right=zs:this._root=zs,zs.parent=or),this._size--}},m.prototype.pop=function(){var bt=this._root,St=null;if(bt){for(;bt.left;)bt=bt.left;St={key:bt.key,data:bt.data},this.remove(bt.key)}return St},m.prototype.next=function(bt){var St=bt;if(St)if(St.right)for(St=St.right;St&&St.left;)St=St.left;else for(St=bt.parent;St&&St.right===bt;)bt=St,St=St.parent;return St},m.prototype.prev=function(bt){var St=bt;if(St)if(St.left)for(St=St.left;St&&St.right;)St=St.right;else for(St=bt.parent;St&&St.left===bt;)bt=St,St=St.parent;return St},m.prototype.forEach=function(bt){for(var St=this._root,ms=[],zs=!1,or=0;!zs;)St?(ms.push(St),St=St.left):ms.length>0?(bt(St=ms.pop(),or++),St=St.right):zs=!0;return this},m.prototype.range=function(bt,St,ms,zs){for(var or=[],lr=this._compare,zr=this._root;or.length!==0||zr;)if(zr)or.push(zr),zr=zr.left;else{if(lr((zr=or.pop()).key,St)>0)break;if(lr(zr.key,bt)>=0&&ms.call(zs,zr))return this;zr=zr.right}return this},m.prototype.keys=function(){for(var bt=this._root,St=[],ms=[],zs=!1;!zs;)bt?(St.push(bt),bt=bt.left):St.length>0?(bt=St.pop(),ms.push(bt.key),bt=bt.right):zs=!0;return ms},m.prototype.values=function(){for(var bt=this._root,St=[],ms=[],zs=!1;!zs;)bt?(St.push(bt),bt=bt.left):St.length>0?(bt=St.pop(),ms.push(bt.data),bt=bt.right):zs=!0;return ms},m.prototype.at=function(bt){for(var St=this._root,ms=[],zs=!1,or=0;!zs;)if(St)ms.push(St),St=St.left;else if(ms.length>0){if(St=ms.pop(),or===bt)return St;or++,St=St.right}else zs=!0;return null},m.prototype.load=function(bt,St,ms){if(bt===void 0&&(bt=[]),St===void 0&&(St=[]),ms===void 0&&(ms=!1),this._size!==0)throw new Error("bulk-load: tree is not empty");var zs=bt.length;return ms&&E(bt,St,0,zs-1,this._compare),this._root=S(null,bt,St,0,zs),this._size=zs,this},m.prototype.min=function(){var bt=this.minNode(this._root);return bt?bt.key:null},m.prototype.max=function(){var bt=this.maxNode(this._root);return bt?bt.key:null},m.prototype.isEmpty=function(){return this._root===null},v.size.get=function(){return this._size},m.createTree=function(bt,St,ms,zs,or){return new m(ms,or).load(bt,St,zs)},Object.defineProperties(m.prototype,v);var P=0,O=1,$=2,G=3,ee=0,se=1,ie=2,de=3;function ue(bt,St,ms){St===null?(bt.inOut=!1,bt.otherInOut=!0):(bt.isSubject===St.isSubject?(bt.inOut=!St.inOut,bt.otherInOut=St.otherInOut):(bt.inOut=!St.otherInOut,bt.otherInOut=St.isVertical()?!St.inOut:St.inOut),St&&(bt.prevInResult=!ke(St,ms)||St.isVertical()?St.prevInResult:St));var zs=ke(bt,ms);bt.resultTransition=zs?function(or,lr){var zr,Ur=!or.inOut,An=!or.otherInOut;switch(lr){case ee:zr=Ur&&An;break;case se:zr=Ur||An;break;case de:zr=Ur^An;break;case ie:zr=or.isSubject?Ur&&!An:An&&!Ur}return zr?1:-1}(bt,ms):0}function ke(bt,St){switch(bt.type){case P:switch(St){case ee:return!bt.otherInOut;case se:return bt.otherInOut;case ie:return bt.isSubject&&bt.otherInOut||!bt.isSubject&&!bt.otherInOut;case de:return!0}break;case $:return St===ee||St===se;case G:return St===ie;case O:return!1}return!1}var Oe=function(bt,St,ms,zs,or){this.left=St,this.point=bt,this.otherEvent=ms,this.isSubject=zs,this.type=or||P,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},De={inResult:{configurable:!0}};function Ke(bt,St){return bt[0]===St[0]&&bt[1]===St[1]}Oe.prototype.isBelow=function(bt){var St=this.point,ms=this.otherEvent.point;return this.left?(St[0]-bt[0])*(ms[1]-bt[1])-(ms[0]-bt[0])*(St[1]-bt[1])>0:(ms[0]-bt[0])*(St[1]-bt[1])-(St[0]-bt[0])*(ms[1]-bt[1])>0},Oe.prototype.isAbove=function(bt){return!this.isBelow(bt)},Oe.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},De.inResult.get=function(){return this.resultTransition!==0},Oe.prototype.clone=function(){var bt=new Oe(this.point,this.left,this.otherEvent,this.isSubject,this.type);return bt.contourId=this.contourId,bt.resultTransition=this.resultTransition,bt.prevInResult=this.prevInResult,bt.isExteriorRing=this.isExteriorRing,bt.inOut=this.inOut,bt.otherInOut=this.otherInOut,bt},Object.defineProperties(Oe.prototype,De);var Xe=11102230246251565e-32,ot=134217729,Nt=(3+8*Xe)*Xe;function yt(bt,St,ms,zs,or){var lr,zr,Ur,An,Wn=St[0],Yn=zs[0],ha=0,rn=0;Yn>Wn==Yn>-Wn?(lr=Wn,Wn=St[++ha]):(lr=Yn,Yn=zs[++rn]);var gn=0;if(haWn==Yn>-Wn?(Ur=lr-((zr=Wn+lr)-Wn),Wn=St[++ha]):(Ur=lr-((zr=Yn+lr)-Yn),Yn=zs[++rn]),lr=zr,Ur!==0&&(or[gn++]=Ur);haWn==Yn>-Wn?(Ur=lr-((zr=lr+Wn)-(An=zr-lr))+(Wn-An),Wn=St[++ha]):(Ur=lr-((zr=lr+Yn)-(An=zr-lr))+(Yn-An),Yn=zs[++rn]),lr=zr,Ur!==0&&(or[gn++]=Ur);for(;ha0!=ha>0)return rn;var gn=Math.abs(Yn+ha);return Math.abs(rn)>=Ft*gn?rn:-function(Ua,Za,Ya,bi,Ri,Ai,ti){var ui,Gn,Na,mo,en,ma,Ii,Ui,Zi,Jo,Hi,tn,jo,_i,no,ql,Cc,_l,wl=Ua-Ri,lc=Ya-Ri,hh=Za-Ai,Wi=bi-Ai;Gt[0]=(no=(Ui=wl-(Ii=(ma=ot*wl)-(ma-wl)))*(Jo=Wi-(Zi=(ma=ot*Wi)-(ma-Wi)))-((_i=wl*Wi)-Ii*Zi-Ui*Zi-Ii*Jo))-((Hi=no-(Cc=(Ui=hh-(Ii=(ma=ot*hh)-(ma-hh)))*(Jo=lc-(Zi=(ma=ot*lc)-(ma-lc)))-((ql=hh*lc)-Ii*Zi-Ui*Zi-Ii*Jo)))+(en=no-Hi))+(en-Cc),Gt[1]=(jo=_i-((tn=_i+Hi)-(en=tn-_i))+(Hi-en))-((Hi=jo-ql)+(en=jo-Hi))+(en-ql),Gt[2]=tn-((_l=tn+Hi)-(en=_l-tn))+(Hi-en),Gt[3]=_l;var Ho=function(Fy,Td){for(var Bu=Td[0],pm=1;pm<4;pm++)Bu+=Td[pm];return Bu}(0,Gt),el=qt*ti;if(Ho>=el||-Ho>=el||(ui=Ua-(wl+(en=Ua-wl))+(en-Ri),Na=Ya-(lc+(en=Ya-lc))+(en-Ri),Gn=Za-(hh+(en=Za-hh))+(en-Ai),mo=bi-(Wi+(en=bi-Wi))+(en-Ai),ui===0&&Gn===0&&Na===0&&mo===0)||(el=ns*ti+Nt*Math.abs(Ho),(Ho+=wl*mo+Wi*ui-(hh*Na+lc*Gn))>=el||-Ho>=el))return Ho;Fs[0]=(no=(Ui=ui-(Ii=(ma=ot*ui)-(ma-ui)))*(Jo=Wi-(Zi=(ma=ot*Wi)-(ma-Wi)))-((_i=ui*Wi)-Ii*Zi-Ui*Zi-Ii*Jo))-((Hi=no-(Cc=(Ui=Gn-(Ii=(ma=ot*Gn)-(ma-Gn)))*(Jo=lc-(Zi=(ma=ot*lc)-(ma-lc)))-((ql=Gn*lc)-Ii*Zi-Ui*Zi-Ii*Jo)))+(en=no-Hi))+(en-Cc),Fs[1]=(jo=_i-((tn=_i+Hi)-(en=tn-_i))+(Hi-en))-((Hi=jo-ql)+(en=jo-Hi))+(en-ql),Fs[2]=tn-((_l=tn+Hi)-(en=_l-tn))+(Hi-en),Fs[3]=_l;var Dh=yt(4,Gt,4,Fs,ds);Fs[0]=(no=(Ui=wl-(Ii=(ma=ot*wl)-(ma-wl)))*(Jo=mo-(Zi=(ma=ot*mo)-(ma-mo)))-((_i=wl*mo)-Ii*Zi-Ui*Zi-Ii*Jo))-((Hi=no-(Cc=(Ui=hh-(Ii=(ma=ot*hh)-(ma-hh)))*(Jo=Na-(Zi=(ma=ot*Na)-(ma-Na)))-((ql=hh*Na)-Ii*Zi-Ui*Zi-Ii*Jo)))+(en=no-Hi))+(en-Cc),Fs[1]=(jo=_i-((tn=_i+Hi)-(en=tn-_i))+(Hi-en))-((Hi=jo-ql)+(en=jo-Hi))+(en-ql),Fs[2]=tn-((_l=tn+Hi)-(en=_l-tn))+(Hi-en),Fs[3]=_l;var Ul=yt(Dh,ds,4,Fs,js);Fs[0]=(no=(Ui=ui-(Ii=(ma=ot*ui)-(ma-ui)))*(Jo=mo-(Zi=(ma=ot*mo)-(ma-mo)))-((_i=ui*mo)-Ii*Zi-Ui*Zi-Ii*Jo))-((Hi=no-(Cc=(Ui=Gn-(Ii=(ma=ot*Gn)-(ma-Gn)))*(Jo=Na-(Zi=(ma=ot*Na)-(ma-Na)))-((ql=Gn*Na)-Ii*Zi-Ui*Zi-Ii*Jo)))+(en=no-Hi))+(en-Cc),Fs[1]=(jo=_i-((tn=_i+Hi)-(en=tn-_i))+(Hi-en))-((Hi=jo-ql)+(en=jo-Hi))+(en-ql),Fs[2]=tn-((_l=tn+Hi)-(en=_l-tn))+(Hi-en),Fs[3]=_l;var Zf=yt(Ul,js,4,Fs,Ns);return Ns[Zf-1]}(or,lr,zr,Ur,An,Wn,gn)}(bt[0],bt[1],St[0],St[1],ms[0],ms[1]);return zs>0?-1:zs<0?1:0}function Is(bt,St){var ms=bt.point,zs=St.point;return ms[0]>zs[0]?1:ms[0]zs[1]?1:-1:function(or,lr,zr,Ur){return or.left!==lr.left?or.left?1:-1:Bs(zr,or.otherEvent.point,lr.otherEvent.point)!==0?or.isBelow(lr.otherEvent.point)?-1:1:!or.isSubject&&lr.isSubject?1:-1}(bt,St,ms)}function Ls(bt,St,ms){var zs=new Oe(St,!1,bt,bt.isSubject),or=new Oe(St,!0,bt.otherEvent,bt.isSubject);return Ke(bt.point,bt.otherEvent.point)&&console.warn("what is that, a collapsed segment?",bt),zs.contourId=or.contourId=bt.contourId,Is(or,bt.otherEvent)>0&&(bt.otherEvent.left=!0,or.left=!1),bt.otherEvent.otherEvent=or,bt.otherEvent=zs,ms.push(or),ms.push(zs),ms}function cs(bt,St){return bt[0]*St[1]-bt[1]*St[0]}function as(bt,St){return bt[0]*St[0]+bt[1]*St[1]}function Os(bt,St,ms){var zs=function(An,Wn,Yn,ha,rn){var gn=[Wn[0]-An[0],Wn[1]-An[1]],Ua=[ha[0]-Yn[0],ha[1]-Yn[1]];function Za(ma,Ii,Ui){return[ma[0]+Ii*Ui[0],ma[1]+Ii*Ui[1]]}var Ya=[Yn[0]-An[0],Yn[1]-An[1]],bi=cs(gn,Ua),Ri=bi*bi,Ai=as(gn,gn);if(Ri>0){var ti=cs(Ya,Ua)/bi;if(ti<0||ti>1)return null;var ui=cs(Ya,gn)/bi;return ui<0||ui>1?null:ti===0||ti===1?[Za(An,ti,gn)]:ui===0||ui===1?[Za(Yn,ui,Ua)]:[Za(An,ti,gn)]}if((Ri=(bi=cs(Ya,gn))*bi)>0)return null;var Gn=as(gn,Ya)/Ai,Na=Gn+as(gn,Ua)/Ai,mo=Math.min(Gn,Na),en=Math.max(Gn,Na);return mo<=1&&en>=0?mo===1?[Za(An,mo>0?mo:0,gn)]:en===0?[Za(An,en<1?en:1,gn)]:[Za(An,mo>0?mo:0,gn),Za(An,en<1?en:1,gn)]:null}(bt.point,bt.otherEvent.point,St.point,St.otherEvent.point),or=zs?zs.length:0;if(or===0||or===1&&(Ke(bt.point,St.point)||Ke(bt.otherEvent.point,St.otherEvent.point))||or===2&&bt.isSubject===St.isSubject)return 0;if(or===1)return Ke(bt.point,zs[0])||Ke(bt.otherEvent.point,zs[0])||Ls(bt,zs[0],ms),Ke(St.point,zs[0])||Ke(St.otherEvent.point,zs[0])||Ls(St,zs[0],ms),1;var lr=[],zr=!1,Ur=!1;return Ke(bt.point,St.point)?zr=!0:Is(bt,St)===1?lr.push(St,bt):lr.push(bt,St),Ke(bt.otherEvent.point,St.otherEvent.point)?Ur=!0:Is(bt.otherEvent,St.otherEvent)===1?lr.push(St.otherEvent,bt.otherEvent):lr.push(bt.otherEvent,St.otherEvent),zr&&Ur||zr?(St.type=O,bt.type=St.inOut===bt.inOut?$:G,zr&&!Ur&&Ls(lr[1].otherEvent,lr[0].point,ms),2):Ur?(Ls(lr[0],lr[1].point,ms),3):lr[0]!==lr[3].otherEvent?(Ls(lr[0],lr[1].point,ms),Ls(lr[1],lr[2].point,ms),3):(Ls(lr[0],lr[1].point,ms),Ls(lr[3].otherEvent,lr[2].point,ms),3)}function sr(bt,St){if(bt===St)return 0;if(Bs(bt.point,bt.otherEvent.point,St.point)!==0||Bs(bt.point,bt.otherEvent.point,St.otherEvent.point)!==0)return Ke(bt.point,St.point)?bt.isBelow(St.otherEvent.point)?-1:1:bt.point[0]===St.point[0]?bt.point[1]St.contourId?1:-1:Is(bt,St)===1?1:-1}var Hs=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function Fr(bt,St,ms,zs){var or,lr=bt+1,zr=St[bt].point,Ur=St.length;for(lrzs;)lr--;return lr}Hs.prototype.isExterior=function(){return this.holeOf==null};var hr=Tr,_r=Tr;function Tr(bt,St){if(!(this instanceof Tr))return new Tr(bt,St);if(this.data=bt||[],this.length=this.data.length,this.compare=St||Qn,this.length>0)for(var ms=(this.length>>1)-1;ms>=0;ms--)this._down(ms)}function Qn(bt,St){return btSt?1:0}Tr.prototype={push:function(bt){this.data.push(bt),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var bt=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),bt}},peek:function(){return this.data[0]},_up:function(bt){for(var St=this.data,ms=this.compare,zs=St[bt];bt>0;){var or=bt-1>>1,lr=St[or];if(ms(zs,lr)>=0)break;St[bt]=lr,bt=or}St[bt]=zs},_down:function(bt){for(var St=this.data,ms=this.compare,zs=this.length>>1,or=St[bt];bt=0)break;St[bt]=Ur,bt=lr}St[bt]=or}},hr.default=_r;var Zs=Math.max,Ar=Math.min,yn=0;function ba(bt,St,ms,zs,or,lr){var zr,Ur,An,Wn,Yn,ha;for(zr=0,Ur=bt.length-1;zr0?ha.left=!0:Yn.left=!0;var rn=An[0],gn=An[1];or[0]=Ar(or[0],rn),or[1]=Ar(or[1],gn),or[2]=Zs(or[2],rn),or[3]=Zs(or[3],gn),zs.push(Yn),zs.push(ha)}}var Sa=[];function Fn(bt,St,ms){typeof bt[0][0][0]=="number"&&(bt=[bt]),typeof St[0][0][0]=="number"&&(St=[St]);var zs=function(gn,Ua,Za){var Ya=null;return gn.length*Ua.length==0&&(Za===ee?Ya=Sa:Za===ie?Ya=gn:Za!==se&&Za!==de||(Ya=gn.length===0?Ua:gn)),Ya}(bt,St,ms);if(zs)return zs===Sa?null:zs;var or=[1/0,1/0,-1/0,-1/0],lr=[1/0,1/0,-1/0,-1/0],zr=function(gn,Ua,Za,Ya,bi){var Ri,Ai,ti,ui,Gn,Na,mo=new hr(null,Is);for(ti=0,ui=gn.length;tiYa[2]||Ya[0]>Za[2]||Za[1]>Ya[3]||Ya[1]>Za[3])&&(bi===ee?Ri=Sa:bi===ie?Ri=gn:bi!==se&&bi!==de||(Ri=gn.concat(Ua))),Ri}(bt,St,or,lr,ms))return zs===Sa?null:zs;for(var Ur=function(gn){var Ua,Za,Ya=function(ti){var ui,Gn,Na,mo,en=[];for(Gn=0,Na=ti.length;Gn0){var Hi=ma[Jo];if(Hi.holeOf!=null){var tn=Hi.holeOf;ma[tn].holeIds.push(Ii),Ui.holeOf=tn,Ui.depth=ma[Jo].depth}else ma[Jo].holeIds.push(Ii),Ui.holeOf=Jo,Ui.depth=ma[Jo].depth+1}else Ui.holeOf=null,Ui.depth=ma[Jo].depth}else Ui.holeOf=null,Ui.depth=0;return Ui}(Ya[Ua],Ri,ti),Gn=function(en){bi[en]=!0,en=Ya.length)&&Ya[Na];);Ri.push(ui)}};for(Ua=0,Za=Ya.length;Uamo||Ri===ie&&en.point[0]>Ya[2])break;if(en.left){ti=Ai=Gn.insert(en),Ai=Ai!==(ui=Gn.minNode())?Gn.prev(Ai):null,ti=Gn.next(ti);var ma=Ai?Ai.key:null;if(ue(en,ma,Ri),ti&&Os(en,ti.key,gn)===2&&(ue(en,ma,Ri),ue(ti.key,en,Ri)),Ai&&Os(Ai.key,en,gn)===2){var Ii=Ai;ue(ma,(Ii=Ii!==ui?Gn.prev(Ii):null)?Ii.key:null,Ri),ue(en,ma,Ri)}}else ti=Ai=Gn.find(en=en.otherEvent),Ai&&ti&&(Ai=Ai!==ui?Gn.prev(Ai):null,ti=Gn.next(ti),Gn.remove(en),ti&&Ai&&Os(Ai.key,ti.key,gn))}return Na}(zr,0,0,or,lr,ms)),An=[],Wn=0;Wn * @license MIT * @preserve */function SF(x,d,m,v){const S=[],E=v===0?(P,O,$,G,ee,se)=>{P.push(new pt(se,$+(se-O)/(G-O)*(ee-$)))}:(P,O,$,G,ee,se)=>{P.push(new pt(O+(se-$)/(ee-$)*(G-O),se))};for(const P of x){const O=[];for(const $ of P){if($.length<=2)continue;const G=[];for(let ie=0;ie<$.length-1;ie++){const de=$[ie].x,ue=$[ie].y,ke=$[ie+1].x,Oe=$[ie+1].y,De=v===0?de:ue,Ke=v===0?ke:Oe;Ded&&E(G,de,ue,ke,Oe,d):De>m?Ke=d&&E(G,de,ue,ke,Oe,d),Ke>m&&De<=m&&E(G,de,ue,ke,Oe,m)}let ee=$[$.length-1];const se=v===0?ee.x:ee.y;se>=d&&se<=m&&G.push(ee),G.length&&(ee=G[G.length-1],G[0].x===ee.x&&G[0].y===ee.y||G.push(G[0]),O.push(G))}O.length&&S.push(O)}return S}function Hct(x,d){const m=lpe(x),v=lpe([d]),S=$Ce.intersection(m,v);return S==null?[]:qCe(S)}function Wct(x,d){let v=lpe(x,65536);const S=[];for(;d.valid();d.next()){const[E,P]=d.get(),O=E.x*65536,$=E.y*65536,G=P.x*65536,ee=P.y*65536,se=G-O,ie=ee-$,de=Math.hypot(se,ie);if(de===0)continue;const ue=Math.trunc(ie/de*3),ke=-Math.trunc(se/de*3);S.push([[[O,$],[G,ee],[G+ue,ee+ke],[O+ue,$+ke],[O,$]]])}return S.length>0&&(v=$Ce.diff(v,S)),qCe(v,1/65536)}function lpe(x,d=1){return[x.map(m=>m.map(v=>[v.x*d,v.y*d]))]}function qCe(x,d=1){return x.map(m=>m.map((v,S)=>{const E=v.map(P=>new pt(P[0]*d,P[1]*d).round());return S>0&&E.reverse(),E}))}class cpe{constructor(d,m){this.layoutVertexArray=new Ey,this.indexArray=new zl,this.lineIndexArray=new dm,this.triangleSegments=new bo,this.lineSegments=new bo,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.uploaded=!1,m&&(this.elevatedLayoutVertexArray=new ig)}update(d,m,v,S,E,P,O,$){this.programConfigurations.updatePaintArrays(d,m,E,v,S,P,O,$)}isEmpty(){return this.layoutVertexArray.length===0}needsUpload(){return this.programConfigurations.needsUpload}upload(d){this.uploaded||(this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Act.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,Ect.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,v,S,E,P,O){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,m,v,S,E,P,void 0,O)}}class dpe{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 cpe(d,!1),this.elevationBufferData=new cpe(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,v,S){}populate(d,m,v,S){this.hasPattern=ipe("fill",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("fill-sort-key"),P=[];for(const{feature:O,id:$,index:G,sourceLayerIndex:ee}of d){const se=this.layers[0]._featureFilter.needGeometry,ie=Wt(O,se);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ie,v))continue;const de=E?E.evaluate(ie,{},v,m.availableImages):void 0,ue={id:$,properties:O.properties,type:O.type,sourceLayerIndex:ee,index:G,geometry:se?ie.geometry:Ot(O,v,S),patterns:{},sortKey:de};P.push(ue)}E&&P.sort((O,$)=>O.sortKey-$.sortKey);for(const O of P){const{geometry:$,index:G,sourceLayerIndex:ee}=O;if(this.hasPattern){const se=ope("fill",this.layers,O,this.zoom,this.pixelRatio,m);this.patternFeatures.push(se)}else this.addFeature(O,$,G,v,{},m.availableImages,m.brightness,m.elevationFeatures);m.featureIndex.insert(d[G].feature,$,G,ee,this.index)}}update(d,m,v,S,E,P,O){this.bufferData.update(d,m,v,S,E,P,O,this.worldview),this.elevationBufferData.update(d,m,v,S,E,P,O,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(d,m,v,S,E,P,O,this.worldview)}addFeatures(d,m,v,S,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,S,P,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,v,S,E,P=[],O,$){const G=W6(m,500);this.elevationMode!=="none"?this.addElevatedRoadFeature(d,G,S,v,$):this.addGeometry(G,this.bufferData),this.bufferData.populatePaintArrays(d,v,E,P,S,O,this.worldview),this.elevationBufferData.populatePaintArrays(d,v,E,P,S,O,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(d,m,v,S,E){this.elevatedStructures&&(this.elevatedStructures.construct(d),this.elevatedStructures.populatePaintArrays(m,v,S,E,this.worldview))}addElevatedRoadFeature(d,m,v,S,E){const P=new Array,O=ci.getElevationFeature(d,E);if(!O)return void this.addGeometry(m,this.bufferData);{const G=this.clipPolygonsToTile(m,1);G.length>0&&P.push({polygons:G,elevationFeature:O,elevationTileID:v})}const $={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(d,{},v),featureIndex:S};for(const G of P)if(G.elevationFeature){if(this.elevationMode==="hd-road-base"){this.elevatedStructures||(this.elevatedStructures=new hm(G.elevationTileID,this.layers,this.zoom,this.lut));const se=G.elevationFeature.isTunnel();let ie=0;d.properties.hasOwnProperty(Jt)&&(ie=+d.properties[Jt]);for(const de of G.polygons)this.elevatedStructures.addPortalCandidates(G.elevationFeature.id,de,se,G.elevationFeature,ie)}G.elevationFeature.constantHeight==null&&(G.polygons=this.prepareElevatedPolygons(G.polygons,G.elevationFeature,G.elevationTileID));const ee=new ki(v,G.elevationTileID);this.addElevatedGeometry(G.polygons,ee,G.elevationFeature,this.elevationMode==="hd-road-base"?0:.05,S,$)}}addElevatedGeometry(d,m,v,S,E,P){const O={elevation:v,elevationSampler:m,bias:S,index:E,featureInfo:P},[$,G]=this.addGeometry(d,this.elevationBufferData,O);this.elevationBufferData.heightRange==null?this.elevationBufferData.heightRange={min:$,max:G}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,$),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,G))}addGeometry(d,m,v){let S=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,P=null;v&&(P=v.elevationSampler.constantElevation(v.elevation,v.bias),P!=null&&(S=P,E=P));const O=($,G,ee)=>{if(v!=null)if(G.push($),P!=null)m.elevatedLayoutVertexArray.emplaceBack(P),ee.push(P);else{const se=v.elevationSampler.pointElevation($,v.elevation,v.bias);m.elevatedLayoutVertexArray.emplaceBack(se),ee.push(se),S=Math.min(S,se),E=Math.max(E,se)}};for(const $ of d){let G=0;for(const Xe of $)G+=Xe.length;const ee=m.triangleSegments.prepareSegment(G,m.layoutVertexArray,m.indexArray),se=ee.vertexLength,ie=[],de=[],ue=[],ke=[],Oe=[],De=m.layoutVertexArray.length;for(const Xe of $){if(Xe.length===0)continue;Xe!==$[0]&&de.push(ie.length/2);const ot=m.lineSegments.prepareSegment(Xe.length,m.layoutVertexArray,m.lineIndexArray),Nt=ot.vertexLength;v&&Oe.push(m.layoutVertexArray.length-De),O(Xe[0],ue,ke),m.layoutVertexArray.emplaceBack(Xe[0].x,Xe[0].y),m.lineIndexArray.emplaceBack(Nt+Xe.length-1,Nt),ie.push(Xe[0].x),ie.push(Xe[0].y);for(let yt=1;yt0&&v&&this.elevationMode==="hd-road-base"){const Xe=v.elevation.isTunnel(),ot=v.elevation.safeArea,Nt=this.elevatedStructures.addVertices(ue,ke);this.elevatedStructures.addTriangles(Ke,Nt,Xe);const yt=Oe.length;if(yt>0){for(let At=0;At=v&&de.max.x<=E&&de.min.y>=S&&de.max.y<=P?$:G).push(ie)}if($.length===d.length)return d;const ee=[new pt(v,S),new pt(E,S),new pt(E,P),new pt(v,P),new pt(v,S)],se=$;for(const ie of G)se.push(...Hct(ie,ee));return se}}let UCe,VCe,HCe,WCe;Sr(dpe,"FillBucket",{omit:["layers","patternFeatures"]}),Sr(cpe,"FillBufferData"),Sr(hm,"ElevatedStructures");class CF{constructor(d,m,v,S){if(this.triangleCount=m.length/3,this.min=new pt(0,0),this.max=new pt(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,P]=[d[0].clone(),d[0].clone()];for(let se=1;sese.cellIdx-ie.cellIdx||se.triIdx-ie.triIdx);let ee=0;for(;eethis.max.x||this.min.x>d.x||d.y>this.max.y||this.min.y>d.y)return;const v=Oy(d.x-this.min.x,this.xScale,this.cellsX),S=Oy(d.y-this.min.y,this.yScale,this.cellsY),E=this.cells[S*this.cellsX+v];if(E){this._lazyInitLookup();for(let P=0;Pthis.max.x||this.min.x>m.x||d.y>this.max.y||this.min.y>m.y)return;this._lazyInitLookup();const S=Oy(d.x-this.min.x,this.xScale,this.cellsX),E=Oy(m.x-this.min.x,this.xScale,this.cellsX),P=Oy(d.y-this.min.y,this.yScale,this.cellsY),O=Oy(m.y-this.min.y,this.yScale,this.cellsY);for(let $=P;$<=O;$++)for(let G=S;G<=E;G++){const ee=this.cells[$*this.cellsX+G];if(ee)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 v of this.footprints)m.push({footprint:v,id:d})}updateAppearances(d,m,v,S){}populate(d,m,v,S){const E=[];for(const{feature:P,id:O,index:$,sourceLayerIndex:G}of d){const ee=this.layers[0]._featureFilter.needGeometry,se=Wt(P,ee);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ie={id:O,properties:P.properties,type:P.type,sourceLayerIndex:G,index:$,geometry:ee?se.geometry:Ot(P,v,S),patterns:{}};E.push(ie)}for(const P of E){const{geometry:O,index:$,sourceLayerIndex:G}=P;this.addFeature(P,O,$,v,{},m.availableImages,m.brightness),m.featureIndex.insert(d[$].feature,O,$,G,this.index)}}isEmpty(){return this.footprints.length===0}uploadPending(){return!1}upload(d){}update(d,m,v,S,E,P,O){}destroy(){}addFeature(d,m,v,S,E,P=[],O){for(const $ of W6(m,2)){const G=[],ee=[],se=[],ie=new pt(1/0,1/0),de=new pt(-1/0,-1/0);for(const Oe of $)if(Oe.length!==0){Oe!==$[0]&&se.push(ee.length/2);for(let De=0;DeP===S)===void 0}(v,x.clipScope)}function MF(x,d){return x.x-d.x||x.y-d.y}function YCe(x,d){return MF(x.min,d.min)===0&&MF(x.max,d.max)===0}function upe(x,d){return!(x.min.x>d.max.x||x.max.xd.max.y||x.max.ynew pt(($.x+E.x*tr)*O-P.x*tr,($.y+E.y*tr)*O-P.y*tr))}return hpe(m,S,x.indices,0,x.indices.length,0,0)}function JCe(x,d,m,v){const S=Math.pow(2,v.z-m.z);return new pt((x+m.x*tr)*S-v.x*tr,(d+m.y*tr)*S-v.y*tr)}function e3e(x,d){const m=[];d.grid.queryPoint(x,m);const v=d.indices,S=d.vertices;for(let E=0;E0&&(v.length>1&&m.push(v),v=[])}return v.length>1&&m.push(v),m}const ppe=Ht.types,sdt=["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"],rdt=["fill-extrusion-flood-light-ground-radius"],ndt=Math.pow(2,13),adt=Math.pow(2,15)-1,s3e=new pt(0,1),fv=2147483648,r3e=7,n3e=450;function K6(x,d,m,v,S,E,P,O){x.emplaceBack((d<<1)+P,(m<<1)+E,(Math.floor(v*ndt)<<1)+S,Math.round(O))}function Z6(x,d,m){x.emplaceBack(d.x*tr,d.y*tr,m?1:0)}function AF(x,d,m,v,S,E){x.emplaceBack(d.x,d.y,(m.x<<1)+v,(m.y<<1)+S,E)}function Y6(x,d,m){x.emplaceBack(d.x,d.y,d.z,m[0]*16384,m[1]*16384,m[2]*16384)}class a3e{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class i3e{constructor(){this.centroidXY=new pt(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 pt(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new pt(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new pt(this.max.x-this.min.x,this.max.y-this.min.y)}}class o3e{constructor(){this.acc=new pt(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,v){this.accCount++,this.acc._add(m);let S=!!this.borders;m.xd.max.x&&(d.max.x=m.x,S=!0),m.yd.max.y&&(d.max.y=m.y,S=!0),((m.x===0||m.x===tr)&&m.x===v.x)!=((m.y===0||m.y===tr)&&m.y===v.y)&&this.processBorderOverlap(m,v),S&&this.checkBorderIntersection(m,v)}checkBorderIntersection(d,m){m.x<0!=d.x<0&&this.addBorderIntersection(0,Kr(m.y,d.y,(0-m.x)/(d.x-m.x))),m.x>tr!=d.x>tr&&this.addBorderIntersection(1,Kr(m.y,d.y,(tr-m.x)/(d.x-m.x))),m.y<0!=d.y<0&&this.addBorderIntersection(2,Kr(m.x,d.x,(0-m.y)/(d.y-m.y))),m.y>tr!=d.y>tr&&this.addBorderIntersection(3,Kr(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 v=this.borders[d];mv[1]&&(v[1]=m)}processBorderOverlap(d,m){if(d.x===m.x){if(d.y===m.y)return;const v=d.x===0?0:1;this.addBorderIntersection(v,m.y),this.addBorderIntersection(v,d.y)}else{const v=d.y===0?2:3;this.addBorderIntersection(v,m.x),this.addBorderIntersection(v,d.x)}}centroid(){return this.accCount===0?new pt(0,0):new pt(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 l3e(x,d){const m=x.add(d)._unit(),v=je(x.x*m.x+x.y*m.y,-1,1);var S,E,P;return S=Math.acos(v),Math.min(4,Math.max(-4,Math.tan(S)))/4*adt*((E=x).x*(P=d).y-E.y*P.x<0?-1:1)}const idt=[x=>x.x<0,x=>x.x>tr,x=>x.y<0,x=>x.y>tr];function odt(x,d,m,v){const S=[4];if(v===0)return S;m._mult(v);const E=x.sub(m),P=d.sub(m),O=[x,d,E,P];for(let $=0;$<4;$++)for(const G of O)if(idt[$](G)){S.push($);break}return S}class fpe{constructor(d){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new w6,this.indexArray=new zl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>rdt.includes(m)),this._segments=new bo,this.hiddenByLandmarkVertexArray=new k3,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new bo}getDefaultSegment(){return this.regionSegments[4]}hasData(){return this.vertexArray.length!==0}addData(d,m,v,S=!1){const E=d.length;if(E>2){let P=Math.max(0,this._segments.get().length-1);const O=this._segments._prepareSegment(4*E,this.vertexArray.length,2*this._segmentToGroundQuads[P].length);let $;P!==this._segments.get().length-1&&(P++,this._segmentToGroundQuads[P]=[],this._segmentToRegionTriCounts[P]=[0,0,0,0,0]);{const G=d[0],ee=d[1];$=l3e(G.sub(d[E-1])._perp()._unit(),ee.sub(G)._perp()._unit())}for(let G=0;GS.region-E.region);for(let v=0;v$+G,0);let O=0;for(let $=0;$<=4;$++){const G=P[$];if(G!==0){let ee=this.regionSegments[$];ee||(ee=this.regionSegments[$]=new bo);const se={vertexOffset:E.vertexOffset,primitiveOffset:E.primitiveOffset+O,vertexLength:E.vertexLength,primitiveLength:G};ee.get().push(se)}O+=G}for(let $=0;$0?this.hiddenByLandmarkVertexBuffer=d.createVertexBuffer(this.hiddenByLandmarkVertexArray,Qct.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 EF{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 zl,this.footprintVertices=new Ey,this.footprintSegments=[],this.layoutVertexArray=new hb,this.centroidVertexArray=new yF,this.wallVertexArray=new p2,this.indexArray=new zl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut},m=>sdt.includes(m)),this.segments=new bo,this.stateDependentLayerIds=this.layers.filter(m=>m.isStateDependent()).map(m=>m.id),this.groundEffect=new fpe(d),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=d.worldview,this.hasAppearances=null}updateFootprints(d,m){}updateAppearances(d,m,v,S){}populate(d,m,v,S){this.features=[],this.hasPattern=ipe("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=Ue(v),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:P,index:O,sourceLayerIndex:$}of d){const G=this.layers[0]._featureFilter.needGeometry,ee=Wt(E,G);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),ee,v))continue;const se={id:P,sourceLayerIndex:$,index:O,geometry:G?ee.geometry:Ot(E,v,S),properties:E.properties,type:E.type,patterns:{}},ie=this.layoutVertexArray.length,de=ppe[se.type]==="Polygon";if(this.hasPattern)this.features.push({featureId:E.id,feature:ope("fill-extrusion",this.layers,se,this.zoom,this.pixelRatio,m)});else if(this.wallMode)for(const ue of se.geometry)for(const ke of t3e(ue,de))this.addFeature(E.id,se,[ke],O,v,{},m.availableImages,S,m.brightness);else this.addFeature(E.id,se,se.geometry,O,v,{},m.availableImages,S,m.brightness);m.featureIndex.insert(E,se.geometry,O,$,this.index,ie)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(d,m,v,S,E,P){for(const{featureId:O,feature:$}of this.features){const G=ppe[$.type]==="Polygon",{geometry:ee}=$;if(this.wallMode)for(const se of ee)for(const ie of t3e(se,G))this.addFeature(O,$,[ie],$.index,m,v,S,E,P);else this.addFeature(O,$,ee,$.index,m,v,S,E,P)}this.sortBorders(),this.projection.name==="mercator"&&this.splitToSubtiles()}update(d,m,v,S,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,S,P,O,this.worldview),this.groundEffect.update(d,m,E,v,S,P,O,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,edt),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.wallVertexBuffer=d.createVertexBuffer(this.wallVertexArray,Xct.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=d.createVertexBuffer(this.layoutVertexExtArray,Jct.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,Yct.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,v,S,E,P,O,$,G){const ee=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(m,{})/this.tileToMeter,se=[new pt(0,0),new pt(tr,tr)],ie=$.projection,de=ie.name==="globe",ue=this.wallMode||ppe[m.type]==="Polygon",ke=new o3e;ke.centroidDataIndex=this.centroidData.length;const Oe=new i3e;Oe.buildingId=d,m.properties&&m.properties.hasOwnProperty("building_id")&&(Oe.buildingId=m.properties.building_id);const De=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(Oe.height=Ke,Oe.vertexArrayOffset=this.layoutVertexArray.length,Oe.groundVertexArrayOffset=this.groundEffect.vertexArray.length,de&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new v3),this.wallMode){if(de)return void fr("Non zero fill-extrusion-line-width is not yet supported on globe.");if(v.length!==1)return;Xe=function(Gt){const ds=Gt[0].x===Gt[Gt.length-1].x&&Gt[0].y===Gt[Gt.length-1].y;(function(_r){let Tr=0;const Qn=_r.length;for(let Zs=0;Zs=0})(Gt)||(Gt=Gt.reverse());const Ns={geometry:[],joinNormals:[],indices:[]},Fs=[],Bs=[],Is=[];let Ls=Gt.length;for(;Ls>=2&&Gt[Ls-1].equals(Gt[Ls-2]);)Ls--;if(Ls<(ds?3:2))return Ns;let cs,as,Os,sr,Hs,Fr=0;for(;Fr0;let yn="miter";const ba=2;yn==="miter"&&Zs>ba&&(yn="bevel"),yn==="bevel"&&(Zs>100&&(yn="flipbevel"),Zs{const ms=new pt(Fn.x,Fn.y),zs=new pt(Fn.x,Fn.y);ms.x+=Ti.x*St,ms.y+=Ti.y*St,zs.x-=Ti.x*Math.max(bt,1),zs.y-=Ti.y*Math.max(bt,1),Is.push(Ti),Fs.push(ms),Bs.push(zs)};if(yn==="miter")Tr._mult(Zs),Sa(cs,Tr,0,0);else if(yn==="flipbevel")Tr=Hs.mult(-1),Sa(cs,Tr,0,0),Sa(cs,Tr.mult(-1),0,0);else{const Fn=-Math.sqrt(Zs*Zs-1),Ti=Ar?Fn:0,bt=Ar?0:Fn;as&&Sa(cs,sr,Ti,bt),Os&&Sa(cs,Hs,Ti,bt)}}Ns.geometry=[...Fs,...Bs.reverse(),Fs[0]],Ns.joinNormals=[...Is,...Is.reverse(),Is[Is.length-1]];const hr=Ns.geometry.length-1;for(let _r=0;_r
Gt<(ds.length-1)/2||Gt===ds.length-1,Nt=this.wallMode?[v]:W6(v,500);for(let Gt=Nt.length-1;Gt>=0;Gt--){const ds=Nt[Gt];(ds.length===0||(yt=ds[0]).every(js=>js.x<=0)||yt.every(js=>js.x>=tr)||yt.every(js=>js.y<=0)||yt.every(js=>js.y>=tr))&&Nt.splice(Gt,1)}var yt;let At;if(de)At=f3e(Nt,se,E);else{At=[];for(const Gt of Nt)At.push({polygon:Gt,bounds:se})}const Ft=ue?this.edgeRadius:0,qt=Ft>0&&this.zoom<17,ns=(Gt,ds)=>{if(Gt.length===0)return!1;const js=Gt[Gt.length-1];return ds.x===js.x&&ds.y===js.y};for(const{polygon:Gt,bounds:ds}of At){let js=0,Ns=0;for(const Ls of Gt)ue&&!Ls[0].equals(Ls[Ls.length-1])&&Ls.push(Ls[0]),Ns+=ue?Ls.length-1:Ls.length;const Fs=this.segments.prepareSegment((ue?5:4)*Ns,this.layoutVertexArray,this.indexArray);Oe.footprintSegIdx<0&&(Oe.footprintSegIdx=this.footprintSegments.length),Oe.polygonSegIdx<0&&(Oe.polygonSegIdx=this.polygonSegments.length);const Bs={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},Is=new a3e;if(Is.vertexOffset=this.footprintVertices.length,Is.indexOffset=3*this.footprintIndices.length,Is.ringIndices=[],ue){const Ls=[],cs=[];js=Fs.vertexLength;for(let Os=0;Os4&&h3e(cs[cs.length-2],cs[0],cs[1]),Os=Ft?ldt(cs[cs.length-2],cs[0],cs[1],Ft):0;const sr=[];let Hs,Fr,hr;Fr=cs[1].sub(cs[0])._perp()._unit();let _r=!0;for(let Tr=1,Qn=0;Tr0?1:0,Ti=Zs.dist(Ar);if(Qn+Ti>32768&&(Qn=0),Ft){hr=yn.sub(Ar)._perp()._unit();let zs=d3e(Zs,Ar,yn,c3e(Fr,hr),Ft);isNaN(zs)&&(zs=0);const or=Ar.sub(Zs)._unit();Zs=Zs.add(or.mult(Os))._round(),Ar=Ar.add(or.mult(-zs))._round(),Os=zs,Fr=hr,De&&this.zoom>=17&&(ns(sr,Zs)||sr.push(Zs),ns(sr,Ar)||sr.push(Ar))}const bt=Fs.vertexLength,St=cs.length>4&&h3e(Zs,Ar,yn);let ms=m3e(Qn,as,_r);if(K6(this.layoutVertexArray,Zs.x,Zs.y,Sa,Fn,0,0,ms),K6(this.layoutVertexArray,Zs.x,Zs.y,Sa,Fn,0,1,ms),this.wallMode){const zs=ot(Tr-1,cs),or=Xe.joinNormals[Tr-1];Z6(this.wallVertexArray,or,zs),Z6(this.wallVertexArray,or,zs)}if(Qn+=Ti,ms=m3e(Qn,St,!_r),as=St,K6(this.layoutVertexArray,Ar.x,Ar.y,Sa,Fn,0,0,ms),K6(this.layoutVertexArray,Ar.x,Ar.y,Sa,Fn,0,1,ms),this.wallMode){const zs=ot(Tr,cs),or=Xe.joinNormals[Tr];Z6(this.wallVertexArray,or,zs),Z6(this.wallVertexArray,or,zs)}if(Fs.vertexLength+=4,this.indexArray.emplaceBack(bt+0,bt+1,bt+2),this.indexArray.emplaceBack(bt+1,bt+3,bt+2),Fs.primitiveLength+=2,Ft){const zs=js+(Tr===1?cs.length-2:Tr-2),or=Tr===1?js:zs+1;if(this.indexArray.emplaceBack(bt+1,zs,bt+3),this.indexArray.emplaceBack(zs,or,bt+3),Fs.primitiveLength+=2,Hs===void 0&&(Hs=bt),!xpe(yn,cs[Tr],ds)){const lr=Tr===cs.length-1?Hs:Fs.vertexLength;this.indexArray.emplaceBack(bt+2,bt+3,lr),this.indexArray.emplaceBack(bt+3,lr+1,lr),this.indexArray.emplaceBack(bt+3,or,lr+1),Fs.primitiveLength+=3}_r=!_r}if(de){const zs=this.layoutVertexExtArray,or=ie.projectTilePoint(Zs.x,Zs.y,E),lr=ie.projectTilePoint(Ar.x,Ar.y,E),zr=ie.upVector(E,Zs.x,Zs.y),Ur=ie.upVector(E,Ar.x,Ar.y);Y6(zs,or,zr),Y6(zs,or,zr),Y6(zs,lr,Ur),Y6(zs,lr,Ur)}}ue&&(js+=cs.length-1),De&&Ft&&this.zoom>=17&&(sr.length!==0&&ns(sr,sr[0])&&sr.pop(),this.groundEffect.addData(sr,ds,ee,Ft>0))}this.footprintSegments.push(Is),Bs.triangleCount=this.indexArray.length-Bs.triangleArrayOffset,this.polygonSegments.push(Bs),++Oe.footprintSegLen,++Oe.polygonSegLen}if(Oe.vertexCount=this.layoutVertexArray.length-Oe.vertexArrayOffset,Oe.groundVertexCount=this.groundEffect.vertexArray.length-Oe.groundVertexArrayOffset,Oe.vertexCount!==0){if(Oe.centroidXY=ke.borders?s3e:this.encodeCentroid(ke,Oe),this.centroidData.push(Oe),ke.borders){this.featuresOnBorder.push(ke);const Gt=this.featuresOnBorder.length-1;for(let ds=0;dsthis.featuresOnBorder[m].borders[d][0]-this.featuresOnBorder[v].borders[d][0])}splitToSubtiles(){const d=[];for(let O=0;Otr),ee=2*G+(+($.min.x+$.max.x>tr)^G);for(let se=0;se<$.polygonSegLen;se++){const ie=$.polygonSegIdx+se;d.push({centroidIdx:O,subtile:ee,polygonSegmentIdx:ie,triangleSegmentIdx:this.polygonSegments[ie].triangleSegIdx})}}const m=new zl;d.sort((O,$)=>O.triangleSegmentIdx===$.triangleSegmentIdx?O.subtile-$.subtile:O.triangleSegmentIdx-$.triangleSegmentIdx);let v=0,S=0,E=0;for(const O of d){if(O.triangleSegmentIdx!==v)break;E++}const P=d.length;for(;S!==d.length;){v=d[S].triangleSegmentIdx;let O=0,$=S,G=S;for(let ee=$;ee0&&this.triangleSubSegments.push({segment:de,min:se,max:ie}),$=G;for(let ue=$;ue[ke[0]*(1-De[0])+Oe[0]*De[0],ke[1]*(1-De[1])+Oe[1]*De[1]],de=[],ue=[];for(const ke of this.triangleSubSegments){de[0]=ke.min.x/tr,de[1]=ke.min.y/tr,ue[0]=ke.max.x/tr,ue[1]=ke.max.y/tr;const Oe=ie(ee,se,de),De=ie(ee,se,ue);if(new Dr([Oe[0],Oe[1],E],[De[0],De[1],P]).intersectsPrecise(v)===0){G&&(S.segments.push(G),G=void 0);continue}const Ke=ke.segment;G&&G.vertexOffset!==Ke.vertexOffset&&(S.segments.push(G),G=void 0),G?(G.vertexLength+=Ke.vertexLength,G.primitiveLength+=Ke.primitiveLength):G={vertexOffset:Ke.vertexOffset,primitiveLength:Ke.primitiveLength,vertexLength:Ke.vertexLength,primitiveOffset:Ke.primitiveOffset,sortKey:void 0,vaos:{}}}return G&&S.segments.push(G),S}encodeCentroid(d,m){const v=d.centroid(),S=m.span(),E=Math.min(7,Math.round(S.x*this.tileToMeter/10)),P=Math.min(7,Math.round(S.y*this.tileToMeter/10));return new pt(je(v.x,1,tr-1)<<3|E,je(v.y,1,tr-1)<<3|P)}encodeBorderCentroid(d){if(!d.borders)return new pt(0,0);const m=d.borders,v=Number.MAX_VALUE;if(m[0][0]!==v||m[1][0]!==v){const S=m[0][0]!==v?0:1;return new pt(6|(m[0][0]!==v?0:65528),(m[S][0]+m[S][1])/2<<3|6)}{const S=m[2][0]!==v?2:3;return new pt((m[S][0]+m[S][1])/2<<3|6,6|(m[2][0]!==v?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,v=d.vertexCount+d.vertexArrayOffset,S=d.flags&fv?s3e:d.centroidXY,E=this.centroidVertexArray.geta_centroid_pos0(m);if(this.centroidVertexArray.geta_centroid_pos1(m)!==S.y||E!==S.x){for(let P=m;P$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y||P.footprint.buildingIds.has($.buildingId)&&($.flags|=fv);else for(const $ of this.centroidData)if(!($.flags&fv||P.min.x>$.max.x||$.min.x>P.max.x||P.min.y>$.max.y||$.min.y>P.max.y))for(let G=0;G<$.footprintSegLen;G++){const ee=this.footprintSegments[$.footprintSegIdx+G];if(E.length=0,cdt(this.footprintVertices,ee.vertexOffset,ee.vertexCount,P.footprintTileId.canonical,d.canonical,E),hpe(P.footprint,E,this.footprintIndices.uint16,ee.indexOffset,ee.indexCount,-ee.vertexOffset,-O)){$.flags|=fv;break}}}for(const P of this.centroidData)this.writeCentroidToBuffer(P);this.borderDoneWithNeighborZ=[-1,-1,-1,-1]}footprintContainsPoint(d,m,v){let S=!1;for(let E=0;Em!=de>m&&d<(this.footprintVertices.int16[2*(ee+P.vertexOffset)+0]-se)*(m-ie)/(de-ie)+se&&(S=!S)}O=$}}return S}getHeightAtTileCoord(d,m){let v=Number.NEGATIVE_INFINITY,S=!0;const E=4*(d+tr)*tr+(m+tr);if(this.partLookup.hasOwnProperty(E)){const P=this.partLookup[E];return P?{height:P.height,hidden:!!(P.flags&fv)}:void 0}for(const P of this.centroidData)d>P.max.x||P.min.x>d||m>P.max.y||P.min.y>m||P.height<=v||this.footprintContainsPoint(d,m,P)&&(v=P.height,this.partLookup[E]=P,S=!!(P.flags&fv));if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:S};this.partLookup[E]=void 0}}function c3e(x,d){const m=x.add(d)._unit();return x.x*m.x+x.y*m.y}function ldt(x,d,m,v){const S=d.sub(x)._perp()._unit(),E=m.sub(d)._perp()._unit();return d3e(x,d,m,c3e(S,E),v)}function d3e(x,d,m,v,S){const E=Math.sqrt(1-v*v);return Math.min(x.dist(d)/3,d.dist(m)/3,S*E/v)}function xpe(x,d,m){return x.xm[1].x&&d.x>m[1].x||x.ym[1].y&&d.y>m[1].y}function u3e(x,d){return x.xd[1].x||x.yd[1].y}function h3e(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 v=m.sub(d),S=v.perp(),E=x.sub(d);return(v.x*E.x+v.y*E.y)/Math.sqrt((v.x*v.x+v.y*v.y)*(E.x*E.x+E.y*E.y))>-.866&&S.x*E.x+S.y*E.y<0}function m3e(x,d,m){const v=d?2|x:-3&x;return m?1|v:-2&v}function p3e(){const x=Math.PI/32,d=Math.tan(x),m=T;return m*Math.sqrt(1+2*d*d)-m}function f3e(x,d,m){const v=1<{for(const Ft of yt)ue.push({polygon:Ft,bounds:At})},Oe=Math.ceil(Math.log2(ee)),De=Math.ceil(Math.log2(se)),Ke=Oe-De,Xe=[];for(let yt=0;yt0?0:1);for(let yt=0;ytAt+1?Nt.push({polygons:Ns,bounds:Bs,depth:At+1}):ke(Ns,Bs)}if(Fs.length){const Bs=[new pt(Ft===0?js:qt.x,Ft===1?js:qt.y),ns];Xe.length>At+1?Nt.push({polygons:Fs,bounds:Bs,depth:At+1}):ke(Fs,Bs)}}return ue}(x,d,Math.ceil((E-S)/11.25),Math.ceil((P-O)/11.25),1,($,G,ee)=>{if($===0)return .5*(G+ee);{const se=ve((m.y+G/tr)/v);return(Q(.5*(ve((m.y+ee/tr)/v)+se))*v-m.y)*tr}})}function cdt(x,d,m,v,S,E){const P=Math.pow(2,v.z-S.z);for(let O=0;O=$[P]&&(O=d,$=x),O[P]S&&v3e(O,$,P,S),O[P]E&&v3e($,O,P,E)}}function PF(x,d,m,v,S,E){const P=[];for(let O=0;O=v&&ue.x>=v||(de.x>=v?de=new pt(v,de.y+(v-de.x)/(ue.x-de.x)*(ue.y-de.y))._round():ue.x>=v&&(ue=new pt(v,de.y+(v-de.x)/(ue.x-de.x)*(ue.y-de.y))._round()),de.y>=S&&ue.y>=S||(de.y>=S?de=new pt(de.x+(S-de.y)/(ue.y-de.y)*(ue.x-de.x),S)._round():ue.y>=S&&(ue=new pt(de.x+(S-de.y)/(ue.y-de.y)*(ue.x-de.x),S)._round()),G&&de.equals(G[G.length-1])||(G=[de],P.push(G),E&&E.push({progress:{min:Oe+_3e(De,Ke,de)*ke,max:1},parentIndex:O,prevPoint:De,nextPoint:Ke})),G.push(ue),E&&(E[E.length-1].progress.max=Oe+_3e(De,Ke,ue)*ke,E[E.length-1].nextPoint=Ke)))))}if(E&&se>0)for(let ie=ee;ieG.t-ee.t);let P=0,O=0,$=[];for(v.push($);P!==x.length;){if(O===E.length){for(;P!==x.length;)$.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++;break}E[O].t<=P?($.length!==0&&$[$.length-1].equals(E[O].point)||$.push(E[O].point),Math.trunc(E[O].t),O++):($.length!==0&&$[$.length-1].equals(x[P])||$.push(x[P]),P++)}}function _3e(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 X6(x,d){return x.x*d.x+x.y*d.y}function w3e(x,d){if(x.length===1){let m=0;const v=d[m++];let S;for(;!S||v.equals(S);)if(S=d[m++],!S)return 1/0;for(;m{js[0]=Ns,js[1]=Fs,js[2]=Bs,js[3]=1},ds=p3e();de>0&&(de+=ds),ue+=ds;for(const js of ie){const Ns=[],Fs=[];for(const Bs of js){const Is=Bs.x+ke.x,Ls=Bs.y+ke.y,cs=se.projection.projectTilePoint(Is,Ls,Nt),as=se.projection.upVector(Nt,Bs.x,Bs.y);let Os=de,sr=ue;if(De){const Hs=k3e(Is,Ls,de,ue,De,Ke,Xe,ot);Os+=Hs.base,sr+=Hs.top}de!==0?Gt(qt,cs.x+as[0]*Ft*Os,cs.y+as[1]*Ft*Os,cs.z+as[2]*Ft*Os):Gt(qt,cs.x,cs.y,cs.z),Gt(ns,cs.x+as[0]*Ft*sr,cs.y+as[1]*Ft*sr,cs.z+as[2]*Ft*sr),ft(qt,qt,Oe),ft(ns,ns,Oe),Ns.push(new N2(qt[0],qt[1],qt[2])),Fs.push(new N2(ns[0],ns[1],ns[2]))}yt.push(Ns),At.push(Fs)}return[yt,At]}(x,d,m,v,S,E,P,O,$,G,ee):P?function(se,ie,de,ue,ke,Oe,De,Ke,Xe){const ot=[],Nt=[],yt=[0,0,0,1];for(const At of se){const Ft=[],qt=[];for(const ns of At){const Gt=ns.x+ue.x,ds=ns.y+ue.y,js=k3e(Gt,ds,ie,de,Oe,De,Ke,Xe);yt[0]=Gt,yt[1]=ds,yt[2]=js.base,yt[3]=1,Je(yt,yt,ke),yt[3]=Math.max(yt[3],1e-5);const Ns=new N2(yt[0]/yt[3],yt[1]/yt[3],yt[2]/yt[3]);yt[0]=Gt,yt[1]=ds,yt[2]=js.top,yt[3]=1,Je(yt,yt,ke),yt[3]=Math.max(yt[3],1e-5);const Fs=new N2(yt[0]/yt[3],yt[1]/yt[3],yt[2]/yt[3]);Ft.push(Ns),qt.push(Fs)}ot.push(Ft),Nt.push(qt)}return[ot,Nt]}(d,m,v,S,E,P,O,$,G):function(se,ie,de,ue,ke){const Oe=[],De=[],Ke=ke[8]*ie,Xe=ke[9]*ie,ot=ke[10]*ie,Nt=ke[11]*ie,yt=ke[8]*de,At=ke[9]*de,Ft=ke[10]*de,qt=ke[11]*de;for(const ns of se){const Gt=[],ds=[];for(const js of ns){const Ns=js.x+ue.x,Fs=js.y+ue.y,Bs=ke[0]*Ns+ke[4]*Fs+ke[12],Is=ke[1]*Ns+ke[5]*Fs+ke[13],Ls=ke[2]*Ns+ke[6]*Fs+ke[14],cs=ke[3]*Ns+ke[7]*Fs+ke[15],as=Bs+Ke,Os=Is+Xe,sr=Ls+ot,Hs=Math.max(cs+Nt,1e-5),Fr=Bs+yt,hr=Is+At,_r=Ls+Ft,Tr=Math.max(cs+qt,1e-5);Gt.push(new N2(as/Hs,Os/Hs,sr/Hs)),ds.push(new N2(Fr/Tr,hr/Tr,_r/Tr))}Oe.push(Gt),De.push(ds)}return[Oe,De]}(d,m,v,S,E)}function k3e(x,d,m,v,S,E,P,O){const $=P*S.getElevationAt(x,d,!0,!0),G=E[0]!==0,ee=G?E[1]===0?P*(E[0]/r3e-n3e):P*function(se,ie,de){const ue=Math.floor(ie[0]/8),ke=Math.floor(ie[1]/8),Oe=10*(ie[0]-8*ue),De=10*(ie[1]-8*ke),Ke=se.getElevationAt(ue,ke,!0,!0),Xe=se.getMeterToDEM(de),ot=Math.floor(.5*(Oe*Xe-1)),Nt=Math.floor(.5*(De*Xe-1)),yt=se.tileCoordToPixel(ue,ke),At=2*ot+1,Ft=2*Nt+1,qt=function(Fs,Bs,Is,Ls,cs){return[Fs.getElevationAtPixel(Bs,Is,!0),Fs.getElevationAtPixel(Bs+cs,Is,!0),Fs.getElevationAtPixel(Bs,Is+cs,!0),Fs.getElevationAtPixel(Bs+Ls,Is+cs,!0)]}(se,yt.x-ot,yt.y-Nt,At,Ft),ns=Math.abs(qt[0]-qt[1]),Gt=Math.abs(qt[2]-qt[3]),ds=Math.abs(qt[0]-qt[2])+Math.abs(qt[1]-qt[3]),js=Math.min(.25,.5*Xe*(ns+Gt)/At),Ns=Math.min(.25,.5*Xe*ds/Ft);return Ke+Math.max(js*Oe,Ns*De)}(S,E,O):$;return{base:$+(m===0?-1:m),top:G?Math.max(ee+v,$+m+2):$+v}}class udt{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 hdt{constructor(){this.tasks={},this.taskQueue=[],Vt(["process"],this),this.invoker=new udt(this.process),this.nextId=0}add(d,m){const v=this.nextId++,S=function({type:E,isSymbolTile:P,zoom:O}){return O=O||0,E==="message"?0:E!=="maybePrepare"||P?E!=="parseTile"||P?E==="parseTile"&&P?300-O:E==="maybePrepare"&&P?400-O:500:200-O:100-O}(m);if(S===0){try{d()}finally{}return null}return this.tasks[v]={fn:d,metadata:m,priority:S,id:v},this.taskQueue.push(v),this.invoker.trigger(),{cancel:()=>{delete this.tasks[v]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(v=>!!this.tasks[v]),!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 S=0;S{v&&delete this.callbacks[O],this.target.postMessage({id:O,type:"",targetMapId:S,sourceMapId:this.mapId})}}}receive(d){const m=d.data;if(!m)return;const v=m.id;if(v&&(!m.targetMapId||this.mapId===m.targetMapId))if(m.type===""){const S=this.cancelCallbacks[v];delete this.cancelCallbacks[v],S&&S.cancel()}else if(m.mustQueue||ya(self)){const S=this.callbacks[v],E=this.scheduler.add(()=>this.processTask(v,m),S&&S.metadata||{type:"message"});E&&(this.cancelCallbacks[v]=E)}else this.processTask(v,m)}processTask(d,m){if(delete this.cancelCallbacks[d],m.type===""){const v=this.callbacks[d];delete this.callbacks[d],v&&(m.error?v(Ay(m.error)):v(null,Ay(m.data)))}else{const v=new Set,S=m.hasCallback?(P,O)=>{this.target.postMessage({id:d,type:"",sourceMapId:this.mapId,error:P?sg(P):null,data:sg(O,v)},v)}:()=>{},E=Ay(m.data);if(this.parent[m.type])this.parent[m.type](m.sourceMapId,E,S);else if(this.parent.getWorkerSource){const P=m.type.split("."),{source:O,scope:$}=E;this.parent.getWorkerSource(m.sourceMapId,P[0],O,$)[P[1]](E,S)}else S(new Error(`Could not find function ${m.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Q6={workerUrl:"",workerClass:null,workerParams:void 0};const gpe="mapboxgl_preloaded_worker_pool";class k2{constructor(d){this.active={},this.name=d}acquire(d,m=k2.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{m.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[gpe]}numActive(){return Object.keys(this.active).length}}k2.workerCount=2;class z3{constructor(d,m,v="Worker",S=k2.workerCount){this.workerPool=d,this.actors=[],this.currentActor=0,this.id=Rt();const E=this.workerPool.acquire(this.id,S);for(let P=0;P{this.ready=!0})}broadcast(d,m,v){vt(this.actors,(S,E)=>{S.send(d,m,E)},v=v||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 J6,ype;function IF(){return J6||(J6=new k2),J6}z3.Actor=S3e;const vpe=4096;class mdt{constructor(d){this.module=d,this.memoryStack=this.module.malloc(vpe),this.memoryStackNextFree=this.memoryStack}createIntArray(d){const m=this.memoryStackNextFree;return this.memoryStackNextFree+=d.length*Int32Array.BYTES_PER_ELEMENT,this.memoryStackNextFree-this.memoryStack>vpe?-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>vpe?-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,v){this.module.setFauxFacadeOptions(d?1:0,m?1:0,v)}setFacadeClassifierOptions(d){this.module.setFacadeClassifierOptions(d)}generateMesh(d,m){this.memoryStackNextFree=this.memoryStack;for(const O of d){const $=this.createIntArray(O.ringIndices),G=this.createFloatArray(O.coordinates);if($===-1||G===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFeature(O.id,O.sourceId,O.minHeight,O.height,O.roofType,G,$,O.ringIndices.length-1)}for(const O of m){let $;$=O.entrances?JSON.parse(O.entrances):[];const G=this.createFloatArray($),ee=this.createFloatArray(O.coordinates);if(G===-1||ee===-1)return`building_gen: Out of stack memory: ${this.memoryStackNextFree-this.memoryStack}/4096`;this.module.addFacade(O.sourceId,O.crossPerc,O.distanceToRoad,G,$.length,ee,O.coordinates.length)}if(!this.module.generateMesh()){const O=this.module.getLastError();return this.readStringBuffer(O)}const v=this.module.getMeshCount(),S=new Array(v);for(let O=0;OS.arrayBuffer()).then(S=>{d.buffers[m]=S})}function L3e(x,d){const m=x.json.bufferViews[d];return new Uint8Array(x.buffers[m.buffer],m.byteOffset||0,m.byteLength)}function vdt(x,d,m,v){if(x.uri){const S=I3e(x.uri,v);return fetch(S).then(E=>E.blob()).then(E=>createImageBitmap(E)).then(E=>{d.images[m]=E})}if(x.bufferView!==void 0){const S=L3e(d,x.bufferView),E=new Blob([S],{type:x.mimeType});return createImageBitmap(E).then(P=>{d.images[m]=P})}}function D3e(x,d=0,m){const v={json:null,images:[],buffers:[]};if(new Uint32Array(x,d,1)[0]===E3e){const ee=new Uint32Array(x,d);let se=2;const ie=(ee[se++]>>2)-3,de=ee[se++]>>2;if(se++,v.json=JSON.parse(P3e.decode(ee.subarray(se,se+de))),se+=de,se{const ee=[],se=O&&O.includes(wpe),ie=O&&O.includes(OF);if(se&&ee.push(function(){if(!pg)return eP??(eP=function(de){let ue,ke=null;function Oe(){ue=new Uint8Array(ke.buffer)}function De(){throw new Error("Unexpected Draco error.")}const Ke={a:{a:De,d:function(Xe,ot,Nt){return ue.copyWithin(Xe,ot,ot+Nt)},c:function(Xe){const ot=ue.length,Nt=Math.max(Xe>>>0,Math.ceil(1.2*ot)),yt=Math.ceil((Nt-ot)/65536);try{return ke.grow(yt),Oe(),!0}catch{return!1}},b:De}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(de,Ke):de.then(Xe=>Xe.arrayBuffer()).then(Xe=>WebAssembly.instantiate(Xe,Ke))).then(Xe=>{const{Rb:ot,Qb:Nt,P:yt,T:At,X:Ft,Ja:qt,La:ns,Qa:Gt,Va:ds,Wa:js,eb:Ns,jb:Fs,f:Bs,e:Is,yb:Ls,zb:cs,Ab:as,Bb:Os,Db:sr,Gb:Hs}=Xe.instance.exports;ke=Is;const Fr=(()=>{let hr=0,_r=0,Tr=0,Qn=0;return Zs=>{Tr&&(ot(Qn),ot(hr),_r+=Tr,Tr=hr=0),hr||(_r+=128,hr=Nt(_r));const Ar=Zs.length+7&-8;let yn=hr;Ar>=_r&&(Tr=Ar,yn=Qn=Nt(Ar));for(let ba=0;ba{pg=de,eP=void 0}))}()),ie&&ee.push(function(){if(_pe)return;const de=function(ue){let ke;const Oe=WebAssembly.instantiateStreaming(ue,{}).then(Xe=>{ke=Xe.instance,ke.exports.__wasm_call_ctors()}),De={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Ke={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:Oe,supported:!0,decodeGltfBuffer(Xe,ot,Nt,yt,At,Ft){(function(qt,ns,Gt,ds,js,Ns,Fs){const Bs=qt.exports.sbrk,Is=ds+3&-4,Ls=Bs(Is*js),cs=Bs(Ns.length),as=new Uint8Array(qt.exports.memory.buffer);as.set(Ns,cs);const Os=ns(Ls,ds,js,cs,Ns.length);if(Os===0&&Fs&&Fs(Ls,Is,js),Gt.set(as.subarray(Ls,Ls+ds*js)),Bs(Ls-Bs(0)),Os!==0)throw new Error(`Malformed buffer data: ${Os}`)})(ke,ke.exports[Ke[At]],Xe,ot,Nt,yt,ke.exports[De[Ft]])}}}(fetch(T3e()));return de.ready.then(()=>{_pe=de})}()),E)for(let de=0;de{if(se&&P)for(const{primitives:de}of P)for(const ue of de)xdt(ue,v);if(ie&&P&&$)for(const de of $)gdt(de,v);return v})})}function O3e(x){return fetch(x).then(d=>d.arrayBuffer()).then(d=>D3e(d,0,x))}function jpe(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 Npe(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 kpe{constructor(d,m,v,S){this.context=d,this.format=v,this.useMipmap=S&&S.useMipmap,this.texture=d.gl.createTexture(),this.update(m,{premultiply:S&&S.premultiply})}update(d,m){const v=d&&d instanceof HTMLVideoElement&&d.width===0?d.videoWidth:d.width,S=d&&d instanceof HTMLVideoElement&&d.height===0?d.videoHeight:d.height,{context:E}=this,{gl:P}=E,{x:O,y:$}=m&&m.position?m.position:{x:0,y:0},G=O+v,ee=$+S;!this.size||this.size[0]===G&&this.size[1]===ee||(P.bindTexture(P.TEXTURE_2D,null),P.deleteTexture(this.texture),this.texture=P.createTexture(),this.size=null),P.bindTexture(P.TEXTURE_2D,this.texture),E.pixelStoreUnpackFlipY.set(!1),E.pixelStoreUnpack.set(1),E.pixelStoreUnpackPremultiplyAlpha.set(this.format===P.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&&G>0&&ee>0){const ie=this.useMipmap?Math.floor(Math.log2(Math.max(G,ee)))+1:1;P.texStorage2D(P.TEXTURE_2D,ie,this.format,G,ee),this.size=[G,ee]}this.size&&(se?P.texSubImage2D(P.TEXTURE_2D,0,O,$,jpe(this.format),Npe(this.format),d):"data"in d&&d.data&&P.texSubImage2D(P.TEXTURE_2D,0,O,$,v,S,jpe(this.format),Npe(this.format),d.data)),this.useMipmap&&P.generateMipmap(P.TEXTURE_2D)}bind(d,m,v=!1){const{context:S}=this,{gl:E}=S;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&&!v?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,v,S,E){const{context:P}=this,{gl:O}=P;O.bindTexture(O.TEXTURE_2D,this.texture),m!==this.magFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MAG_FILTER,m),this.magFilter=m),d!==this.minFilter&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_MIN_FILTER,this.useMipmap?d===O.NEAREST?O.NEAREST_MIPMAP_NEAREST:O.LINEAR_MIPMAP_LINEAR:d),this.minFilter=d),v!==this.wrapS&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_S,v),this.wrapS=v),S!==this.wrapT&&(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_WRAP_T,S),this.wrapT=S),E!==this.compareMode&&(E?(O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.COMPARE_REF_TO_TEXTURE),O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_FUNC,E)):O.texParameteri(O.TEXTURE_2D,O.TEXTURE_COMPARE_MODE,O.NONE),this.compareMode=E)}destroy(){const{gl:d}=this.context;d.deleteTexture(this.texture),this.texture=null}}class sP{constructor(d,m){this.context=d,this.texture=m}bind(d,m){const{context:v}=this,{gl:S}=v;S.bindTexture(S.TEXTURE_2D,this.texture),d!==this.minFilter&&(S.texParameteri(S.TEXTURE_2D,S.TEXTURE_MAG_FILTER,d),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_MIN_FILTER,d),this.minFilter=d),m!==this.wrapS&&(S.texParameteri(S.TEXTURE_2D,S.TEXTURE_WRAP_S,m),S.texParameteri(S.TEXTURE_2D,S.TEXTURE_WRAP_T,m),this.wrapS=m)}}const bdt=ua([{name:"a_pos_3f",components:3,type:"Float32"}]),_dt=ua([{name:"a_color_3f",components:3,type:"Float32"}]),wdt=ua([{name:"a_color_4f",components:4,type:"Float32"}]),jdt=ua([{name:"a_uv_2f",components:2,type:"Float32"}]),Ndt=ua([{name:"a_normal_3f",components:3,type:"Float32"}]),kdt=ua([{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"}]),Sdt=ua([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function R3e(x,d){const m=RF(x.projection,x.zoom,x.width,x.height),v=function(E,P,O,$,G){const ee=new y(O.lng-180*wb,O.lat),se=new y(O.lng+180*wb,O.lat),ie=E.project(ee.lng,ee.lat),de=E.project(se.lng,se.lat),ue=-Math.atan2(de.y-ie.y,de.x-ie.x),ke=st.fromLngLat(O);ke.y=je(ke.y,-1+wb,1-wb);const Oe=ke.toLngLat(),De=E.project(Oe.lng,Oe.lat),Ke=st.fromLngLat(Oe);Ke.x+=wb;const Xe=Ke.toLngLat(),ot=E.project(Xe.lng,Xe.lat),Nt=z3e(ot.x-De.x,ot.y-De.y,ue),yt=st.fromLngLat(Oe);yt.y+=wb;const At=yt.toLngLat(),Ft=E.project(At.lng,At.lat),qt=z3e(Ft.x-De.x,Ft.y-De.y,ue),ns=Math.abs(Nt.x)/Math.abs(qt.y),Gt=w([]);q(Gt,Gt,-ue*(1-(G?0:$)));const ds=w([]);return I(ds,ds,[1,1-(1-ns)*$,1]),ds[4]=-qt.x/qt.y*$,q(ds,ds,ue),C(ds,Gt,ds),ds}(x.projection,0,x.center,m,d),S=F3e(x);return I(v,v,[S,S,1]),v}function F3e(x){const d=x.projection,m=RF(x.projection,x.zoom,x.width,x.height),v=Spe(d,x.center),S=Spe(d,y.convert(d.center));return Math.pow(2,v*m+(1-m)*S)}function RF(x,d,m,v,S=1/0){const E=x.range;if(!E)return 0;const P=Math.min(S,Math.max(m,v)),O=Math.log2(P/1024);return Be(E[0]+O,E[1]+O,d)}const wb=1/4e4;function Spe(x,d){const m=je(d.lat,-be,be),v=new y(d.lng-180*wb,m),S=new y(d.lng+180*wb,m),E=x.project(v.lng,m),P=x.project(S.lng,m),O=st.fromLngLat(v),$=st.fromLngLat(S),G=P.x-E.x,ee=P.y-E.y,se=$.x-O.x,ie=$.y-O.y,de=Math.sqrt((se*se+ie*ie)/(G*G+ee*ee));return Math.log2(de)}function z3e(x,d,m){const v=Math.cos(m),S=Math.sin(m);return{x:x*v-d*S,y:x*S+d*v}}function B3e(x,d,m){w(x),q(x,x,jr(d[2])),L(x,x,jr(d[0])),R(x,x,jr(d[1])),I(x,x,m),C(x,x,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function FF(x,d,m,v,S,E,P,O){const $=[m[0]-d[0],m[1]-d[1],0],G=[v[0]-d[0],v[1]-d[1],0];if(ce($)<1e-12||ce(G)<1e-12)return Qe(x);const ee=ct([],$,G);Me(ee,ee),pe(G,v,d),$[2]=(E-S)*O,G[2]=(P-S)*O;const se=$;return ct(se,$,G),Me(se,se),Ds(x,ee,se)}function zF(x,d,m=!1){const v=bb(d.zoom),S=function(E,P,O){const $=P.worldSize,G=[E[12],E[13],E[14]],ee=ve(G[1]/$),se=oe(G[0]/$),ie=w([]),de=ae(1,ee)*$,ue=ae(1,0)*$*Ee(ee,P.zoom),ke=1/tpe($);let Oe=ue*ke;if(O){const ot=RF(P.projection,P.zoom,P.width,P.height,1024);Oe=ke*P.projection.pixelSpaceConversion(P.center.lat,$,ot)}const De=gb(ee,se);le(De,De,we([],Me([],De),de*Oe*G[2]));const Ke=function(ot){const Nt=[ot[0],ot[1],ot[2]];let yt=[0,1,0];const At=ct([],yt,Nt);return ct(yt,Nt,At),Fe(yt)===0&&(yt=[0,1,0],ct(At,Nt,yt)),Me(At,At),Me(yt,yt),Me(Nt,Nt),[At[0],At[1],At[2],0,yt[0],yt[1],yt[2],0,Nt[0],Nt[1],Nt[2],0,ot[0],ot[1],ot[2],1]}(De);I(ie,ie,[Oe,Oe,Oe*de]),M(ie,ie,[-G[0],-G[1],-G[2]]);const Xe=C([],P.globeMatrix,Ke);return C(Xe,Xe,ie),C(Xe,Xe,E),Xe}(x,d,m);if(v>0){const E=function(P,O){const $=O.worldSize,G=ae(1,0)*$*Ee(O.center.lat,O.zoom)/tpe($),ee=ae(1,O.center.lat)*$,se=w([]);R(se,se,jr(O.center.lng)),L(se,se,jr(O.center.lat)),M(se,se,[0,0,qd]),I(se,se,[G,G,G*ee]);const ie=O.point;return M(se,se,[-ie.x,-ie.y,0]),C(se,se,P),C(se,O.globeMatrix,se)}(x,d);return function(P,O,$){const G=(ue,ke,Oe)=>{const De=ce(ue),Ke=ce(ke),Xe=mg(ue,ke,Oe);return we(Xe,Xe,1/ce(Xe)*Kr(De,Ke,Oe))},ee=G([P[0],P[1],P[2]],[O[0],O[1],O[2]],$),se=G([P[4],P[5],P[6]],[O[4],O[5],O[6]],$),ie=G([P[8],P[9],P[10]],[O[8],O[9],O[10]],$),de=mg([P[12],P[13],P[14]],[O[12],O[13],O[14]],$);return[ee[0],ee[1],ee[2],0,se[0],se[1],se[2],0,ie[0],ie[1],ie[2],0,de[0],de[1],de[2],1]}(S,E,v)}return S}function Cpe(x,d,m,v){const S=Dr.projectAabbCorners(v,m);let E=Number.MAX_VALUE;for(let O=0;O0||Oe===0&&ue[0]*ke[0]+ue[1]*ke[1]>=0&&ue[0]*ue[0]+ue[1]*ue[1]>ke[0]*ke[0]+ke[1]*ke[1])&&(ee=de)}se=ee}while(se!==G);return $.length>0&&$.push($[0]),$}(S);if(Ga(x,P))return E}const S2=64,U3={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function BF(x,d,m,v,S,E,P,O,$,G=!1){const ee=m.zoom,se=m.project(v),ie=Ee(v.lat,ee),de=1/ie;w(x),M(x,x,[se.x+P[0]*de,se.y+P[1]*de,P[2]]);let ue=1,ke=1;const Oe=m.worldSize;if(G){if(m.projection.name==="mercator"){let ot=0;m.elevation&&(ot=m.elevation.getAtPointOrZero(new st(se.x/Oe,se.y/Oe),0));const Nt=Je([],[se.x,se.y,ot,1],m.projMatrix)[3]/m.cameraToCenterDistance;ue=Nt,ke=Nt*Ee(m.center.lat,ee)}else if(m.projection.name==="globe"){const ot=zF(x,m),Nt=[0,0,0,1];Je(Nt,Nt,C([],m.projMatrix,ot));const yt=Nt[3]/m.cameraToCenterDistance,At=bb(ee),Ft=m.projection.pixelsPerMeter(v.lat,Oe)*Ee(v.lat,ee),qt=m.projection.pixelsPerMeter(m.center.lat,Oe)*Ee(m.center.lat,ee);ue=yt/Kr(Ft,Le(m.center.lat),At),ke=yt*ie/Ft,ue*=qt,ke*=qt}}else ue=de;I(x,x,[ue,ue,ke]);const De=[...x],Ke=d.orientation,Xe=[];if(B3e(Xe,[Ke[0]+(S?S[0]:0),Ke[1]+(S?S[1]:0),Ke[2]+(S?S[2]:0)],E),C(x,De,Xe),O&&m.elevation){let ot=0;const Nt=[];if($&&m.elevation){ot=function(At,Ft,qt,ns,Gt){const ds=Ft.elevation;if(!ds)return 0;const js=Dr.projectAabbCorners(qt,ns),Ns=ae(1,Gt.lat)*Ft.worldSize,Fs=function(_r,Tr){const Qn=[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 Ar of Zs){const yn=_r[Ar.corners[0]],ba=_r[Ar.corners[1]],Sa=_r[Ar.corners[2]],Fn=[ba[0]-yn[0],ba[1]-yn[1],Tr*(ba[2]-yn[2])],Ti=ct(Fn,Fn,[Sa[0]-yn[0],Sa[1]-yn[1],Tr*(Sa[2]-yn[2])]);Me(Ti,Ti),Ar.dotProductWithUp=$e(Ti,Qn)}return Zs.sort((Ar,yn)=>Ar.dotProductWithUp-yn.dotProductWithUp),Zs[0].corners}(js,Ns),Bs=js[Fs[0]],Is=js[Fs[1]],Ls=js[Fs[2]],cs=js[Fs[3]],as=ds.getAtPointOrZero(new st(Bs[0]/Ft.worldSize,Bs[1]/Ft.worldSize),0),Os=ds.getAtPointOrZero(new st(Is[0]/Ft.worldSize,Is[1]/Ft.worldSize),0),sr=ds.getAtPointOrZero(new st(Ls[0]/Ft.worldSize,Ls[1]/Ft.worldSize),0),Hs=ds.getAtPointOrZero(new st(cs[0]/Ft.worldSize,cs[1]/Ft.worldSize),0),Fr=(as+Hs)/2,hr=(Os+sr)/2;return Fr>hr?Os=d.gl.NEAREST_MIPMAP_NEAREST}),x.uploaded=!0,x.image=null)}function Cdt(x,d,m){x.indexBuffer=d.createIndexBuffer(x.indexArray,!1,!0),x.vertexBuffer=d.createVertexBuffer(x.vertexArray,bdt.members,!1,!0),x.normalArray&&(x.normalBuffer=d.createVertexBuffer(x.normalArray,Ndt.members,!1,!0)),x.texcoordArray&&(x.texcoordBuffer=d.createVertexBuffer(x.texcoordArray,jdt.members,!1,!0)),x.colorArray&&(x.colorBuffer=d.createVertexBuffer(x.colorArray,(x.colorArray.bytesPerElement===12?_dt:wdt).members,!1,!0)),x.featureArray&&(x.pbrBuffer=d.createVertexBuffer(x.featureArray,Sdt.members,!0)),x.segments=bo.simpleSegment(0,0,x.vertexArray.length,x.indexArray.length);const v=x.material;v.pbrMetallicRoughness.baseColorTexture&&rP(v.pbrMetallicRoughness.baseColorTexture,d),v.pbrMetallicRoughness.metallicRoughnessTexture&&rP(v.pbrMetallicRoughness.metallicRoughnessTexture,d),v.normalTexture&&rP(v.normalTexture,d),v.occlusionTexture&&rP(v.occlusionTexture,d,m),v.emissionTexture&&rP(v.emissionTexture,d)}function Mpe(x,d,m){if(x.meshes)for(const v of x.meshes)Cdt(v,d,m);if(x.children)for(const v of x.children)Mpe(v,d,m)}function $F(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)$F(d)}function Tpe(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)Tpe(m)}function C2(x,d){const m=x.json.bufferViews[d.bufferView],v=DF[d.componentType];return new v(x.buffers[m.buffer],(d.byteOffset||0)+(m.byteOffset||0),d.count*(m.byteStride&&m.byteStride!==tP[d.type]*v.BYTES_PER_ELEMENT?m.byteStride/v.BYTES_PER_ELEMENT:tP[d.type]))}function Ape(x,d,m,v){const S=DF[d.componentType],E=function(ee){switch(ee){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:return 1}}(S),P=x.json.bufferViews[d.bufferView],O=P.byteStride?P.byteStride/S.BYTES_PER_ELEMENT:tP[d.type],$=m.float32,G=$.length/m.capacity;for(let ee=0,se=0;ee0){for(let Oe=0;Oe0){E.texcoordArray=new Hf;const ie=d.json.accessors[S.TEXCOORD_0];E.texcoordArray.resize(ie.count);const de=C2(d,ie);Ape(d,ie,E.texcoordArray,de)}if(S._FEATURE_ID_RGBA4444!==void 0){const ie=d.json.accessors[S._FEATURE_ID_RGBA4444];d.json.extensionsUsed&&d.json.extensionsUsed.includes("EXT_meshopt_compression")&&(E.featureData=C2(d,ie))}S._FEATURE_RGBA4444!==void 0&&(E.featureData=new Uint32Array(C2(d,d.json.accessors[S._FEATURE_RGBA4444]).buffer));const se=x.material;return E.material=function(ie,de){const{emissiveFactor:ue=[0,0,0],alphaMode:ke="OPAQUE",alphaCutoff:Oe=.5,normalTexture:De,occlusionTexture:Ke,emissiveTexture:Xe,doubleSided:ot,name:Nt}=ie,{baseColorFactor:yt=[1,1,1,1],metallicFactor:At=1,roughnessFactor:Ft=1,baseColorTexture:qt,metallicRoughnessTexture:ns}=ie.pbrMetallicRoughness||{},Gt=Ke?de[Ke.index]:void 0;if(Ke&&Ke.extensions&&Ke.extensions.KHR_texture_transform&&Gt){const ds=Ke.extensions.KHR_texture_transform;Gt.offsetScale=[ds.offset[0],ds.offset[1],ds.scale[0],ds.scale[1]]}return{name:Nt,pbrMetallicRoughness:{baseColorFactor:new qr(...yt),metallicFactor:At,roughnessFactor:Ft,baseColorTexture:qt?de[qt.index]:void 0,metallicRoughnessTexture:ns?de[ns.index]:void 0},doubleSided:ot,emissiveFactor:new qr(...ue),alphaMode:ke,alphaCutoff:Oe,normalTexture:De?de[De.index]:void 0,occlusionTexture:Gt,emissionTexture:Xe?de[Xe.index]:void 0,defined:ie.defined===void 0}}(se!==void 0?d.json.materials[se]:{defined:!1},m),E}function q3e(x,d,m){const{matrix:v,rotation:S,translation:E,scale:P,mesh:O,extras:$,children:G,name:ee}=x,se={};if(se.name=ee,se.localMatrix=v||function(ie,de,ue,ke){var Oe=de[0],De=de[1],Ke=de[2],Xe=de[3],ot=Oe+Oe,Nt=De+De,yt=Ke+Ke,At=Oe*ot,Ft=Oe*Nt,qt=Oe*yt,ns=De*Nt,Gt=De*yt,ds=Ke*yt,js=Xe*ot,Ns=Xe*Nt,Fs=Xe*yt,Bs=ke[0],Is=ke[1],Ls=ke[2];return ie[0]=(1-(ns+ds))*Bs,ie[1]=(Ft+Fs)*Bs,ie[2]=(qt-Ns)*Bs,ie[3]=0,ie[4]=(Ft-Fs)*Is,ie[5]=(1-(At+ds))*Is,ie[6]=(Gt+js)*Is,ie[7]=0,ie[8]=(qt+Ns)*Ls,ie[9]=(Gt-js)*Ls,ie[10]=(1-(At+ns))*Ls,ie[11]=0,ie[12]=ue[0],ie[13]=ue[1],ie[14]=ue[2],ie[15]=1,ie}([],S||[0,0,0,1],E||[0,0,0],P||[1,1,1]),se.globalMatrix=j(se.localMatrix),O!==void 0){se.meshes=m[O];const ie=se.anchor=[0,0];for(const de of se.meshes){const{min:ue,max:ke}=de.aabb;ie[0]+=ue[0]+ke[0],ie[1]+=ue[1]+ke[1]}ie[0]=Math.floor(ie[0]/se.meshes.length/2),ie[1]=Math.floor(ie[1]/se.meshes.length/2)}if($&&($.id&&(se.id=$.id),$.lights&&(se.lights=function(ie){if(!ie.length)return[];const de=function(Ke){const Xe=atob(Ke),ot=new Uint8Array(Xe.length);for(let Nt=0;Nt1&&v[v.length-1].equals(v[0])&&v.pop();let S=0;for(let P=0;P0&&v.reverse();const E=R3(v.flatMap(P=>[P.x,P.y]),[]);return E.length===0?null:{vertices:v,indices:E}}function Edt(x,d){const m=[],v=[];let S=0;const E=[];for(const P of x){S=m.length;const O=P.vertexArray.float32,$=P.indexArray.uint16;for(let G=0;G0&&([v[P+1],v[P+2]]=[v[P+2],v[P+1]])}return{vertices:m,indices:v}}function Epe(x){const d=function($,G){const ee=[],se=WebGL2RenderingContext;if($.json.textures)for(const ie of $.json.textures){const de={magFilter:se.LINEAR,minFilter:se.NEAREST,wrapS:se.REPEAT,wrapT:se.REPEAT};ie.sampler!==void 0&&Object.assign(de,$.json.samplers[ie.sampler]),ee.push({image:G[ie.source],sampler:de,uploaded:!1})}return ee}(x,x.images),m=function($,G){const ee=[];for(const se of $.json.meshes){const ie=[];for(const de of se.primitives)ie.push(Mdt(de,$,G));ee.push(ie)}return ee}(x,d),{scenes:v,scene:S,nodes:E}=x.json,P=v?v[S||0].nodes:[...E.keys()],O=[];for(const $ of P)O.push(q3e(E[$],x,m));return function($,G,ee){const se={},ie=new Set;for(let de=0;de<$.length;de++){const ue=ee[G[de]];if(!ue.extras)continue;const ke=ue.extras["mapbox:footprint:version"],Oe=ue.extras["mapbox:footprint:id"];(ke||Oe)&&ie.add(de),ke==="1.0.0"&&Oe&&(se[Oe]=de)}for(let de=0;de<$.length;de++){if(ie.has(de))continue;const ue=$[de],ke=ee[G[de]];if(!ke.extras)continue;let Oe=null;ue.id in se&&(Oe=Edt($[se[ue.id]].meshes,ue.localMatrix)),Oe||(Oe=Adt(ke)),Oe&&(ue.footprint=Tdt(Oe))}if(ie.size>0){const de=Array.from(ie.values()).sort((ue,ke)=>ue-ke);for(let ue=de.length-1;ue>=0;ue--)$.splice(de[ue],1)}}(O,P,x.json.nodes),O}function Pdt(x){x.heightmap=new Float32Array(4096),x.heightmap.fill(-1);const d=x.vertexArray.float32,m=x.aabb.min[0]-1,v=x.aabb.min[1]-1,S=S2/(x.aabb.max[0]-m+2),E=S2/(x.aabb.max[1]-v+2);for(let P=0;Px.heightmap[G*S2+$]&&(x.heightmap[G*S2+$]=O)}}function U3e(x,d,m,v,S){m.reserve(m.length+4*x.length),v.reserve(v.length+10*x.length),S.reserve(S.length+10*x.length);let E=v.length;for(const P of x){const O=Math.min(10,Math.max(4,1.3*P.height))*d,$=[-P.normal[1],P.normal[0],0],G=Math.min(.29,.1*P.width/P.depth),ee=P.width-2*P.depth*d*(G+.01),se=Ie([],P.pos,$,ee/2),ie=Ie([],P.pos,$,-ee/2),de=[se[0],se[1],se[2]+P.height],ue=[ie[0],ie[1],ie[2]+P.height],ke=Ie([],P.normal,$,G);we(ke,ke,O);const Oe=Ie([],P.normal,$,-G);we(Oe,Oe,O),le(ke,se,ke),le(Oe,ie,Oe),se[2]+=.1,ie[2]+=.1,v.emplaceBack(ke[0],ke[1],ke[2]),v.emplaceBack(Oe[0],Oe[1],Oe[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(de[0],de[1],de[2]),v.emplaceBack(ue[0],ue[1],ue[2]),v.emplaceBack(se[0],se[1],se[2]),v.emplaceBack(ie[0],ie[1],ie[2]),v.emplaceBack(ke[0],ke[1],ke[2]),v.emplaceBack(Oe[0],Oe[1],Oe[2]);const De=ee/O/2;S.emplaceBack(-De-G,-1,De,.8),S.emplaceBack(De+G,-1,De,.8),S.emplaceBack(-De,0,De,1.3),S.emplaceBack(De,0,De,1.3),S.emplaceBack(De+G,-.8,De,.7),S.emplaceBack(De+G,-.8,De,.7),S.emplaceBack(0,0,De,1.3),S.emplaceBack(0,0,De,1.3),S.emplaceBack(De+G,-1.2,De,.8),S.emplaceBack(De+G,-1.2,De,.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 Idt(x,d){const m={};m.indexArray=new zl,m.vertexArray=new cm,m.colorArray=new Py,U3e(x,d,m.indexArray,m.vertexArray,m.colorArray);const v={defined:!0};v.emissiveFactor=qr.black;const S={};return S.baseColorFactor=qr.white,v.pbrMetallicRoughness=S,m.material=v,m.aabb=new Dr([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),m}const V3e=ua([{name:"a_pos_3f",components:3,type:"Float32"}]),Ldt=ua([{name:"a_normal_3",components:3,type:"Int16"}]),Ddt=ua([{name:"a_centroid_3",components:3,type:"Int16"}]),H3e=ua([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),Odt=ua([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),Rdt=ua([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),Fdt=ua([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),zdt=ua([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),Bdt=ua([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),W3e=Ht.types,qF=32767;function $dt(x,d){const m=tr+d;for(const v of x)for(const S of v)if(S.x<-d||S.x>m||S.y<-d||S.y>m)return!1;return!0}function qdt(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 Ppe{constructor(){this.layoutVertexArray=new cm,this.layoutAttenuationArray=new Py,this.layoutColorArray=new dm,this.indexArray=new zl,this.indexArrayForConflation=new zl,this.segmentsBucket=new bo}}class Ipe{constructor(d){this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.segmentsBucket=new bo,this.entranceBloom=new Ppe;const m=66560;this.layoutVertexArray=new cm,this.layoutVertexArray.reserve(m),this.layoutNormalArray=new ub,this.layoutNormalArray.reserve(m),this.layoutCentroidArray=new ub,this.layoutCentroidArray.reserve(m),this.layoutColorArray=new dm,this.layoutColorArray.reserve(m),this.layoutFloodLightDataArray=new Iy,this.layoutFloodLightDataArray.reserve(m),this.layoutAOArray=new k3,this.layoutAOArray.reserve(m),this.indexArray=new zl,this.indexArray.reserve(66560),this.indexArrayForConflation=new zl,this.segmentsBucket=new bo,this.entranceBloom=new Ppe,d&&(this.layoutFacadePaintArray=new dm,this.layoutFacadeDataArray=new uv,this.layoutFacadeVerticalRangeArray=new dm)}reserve(d,m,v){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),v&&(this.layoutFacadePaintArray.reserveForAdditional(d),this.layoutFacadeDataArray.reserveForAdditional(d),this.layoutFacadeVerticalRangeArray.reserveForAdditional(d))}}class G3e{constructor(d){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.footprintsVertices=new Hf,this.footprintsIndices=new Iy,this.footprintsMin=new pt(1/0,1/0),this.footprintsMax=new pt(-1/0,-1/0),this.featuresOnBorder=[],this.buildingWithoutFacade=new Ipe(!1),this.buildingWithFacade=new Ipe(!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 fpe(d),this.groundEffect.groundRadiusArray=new ig,this.hasAppearances=null}updateFootprints(d,m){const v=new CF([],[],1),S={vertices:[],indices:new Uint32Array(0),grid:v,min:this.footprintsMin,max:this.footprintsMax,buildingIds:this.buildingIds};m.push({footprint:S,id:d})}updateAppearances(d,m,v,S){}prepare(){return function(){if(LF!=null||C3e!=null)return null;if(q3!=null)return q3;const d=fetch(ca.BUILDING_GEN_URL);return q3=function(m){let v,S,E,P,O;function $(){v=new Uint8Array(O.buffer),S=new Int16Array(O.buffer),E=new Int32Array(O.buffer),P=new Float32Array(O.buffer)}function G(){throw new Error("Unexpected BuildingGen error.")}const ee=()=>{},se={a:{a:G,f:function(ie){const de=v.length,ue=Math.max(ie>>>0,Math.ceil(1.2*de)),ke=Math.ceil((ue-de)/65536);try{return O.grow(ke),$(),!0}catch{return!1}},g:G,b:ee,c:ee,d:ee,e:ee}};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)(),O=de.f,$(),new mdt({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:v,heap16:S,heap32:E,heapF32:P})})}(d).then(m=>(q3=null,LF=m,LF)).catch(m=>{fr("Could not load building-gen"),q3=null,C3e=m}),q3}()}populate(d,m,v,S){const E=pdt();if(!E)return;const P=Ue(v);this.tileToMeter=P,this.brightness=m.brightness,E.setStyle({normalScale:[1,-1,P],tileToMeters:P}),E.setAOOptions(!1,.3),E.setMetricOptions(!1,16),E.setStructuralOptions(!0),E.setFacadeClassifierOptions(3);const O=new Map,$=new Map;let G=0;for(const{feature:De}of d){if(W3e[De.type]!=="LineString"){O.set(De.id,De.properties.source_id);continue}const Ke=this.layers[0]._featureFilter.needGeometry;if(Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),De,v))continue;const Xe=Wt(De,Ke);if(!Ke&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),Xe,v))continue;const ot=Ke?Xe.geometry:Ot(De,v,S),Nt=[];for(const qt of ot)for(const ns of qt)Nt.push(ns.x),Nt.push(ns.y);const yt={coordinates:Nt,crossPerc:De.properties.cross_perc,distanceToRoad:De.properties.distance_to_road,entrances:De.properties.entrances,sourceId:0},At=De.properties.source_id;let Ft=$.get(At);Ft||(Ft=[],$.set(At,Ft)),Ft.push(yt),++G}this.maxHeight=0;const ee=new Array,se=new Set,ie=De=>{De!=null&&se.add(De)},de=(De,Ke)=>{De!=null&&ee.push({buildingId:De,footprintIndex:Ke})},ue=64*(d.length-G),ke=ue/2;this.buildingWithFacade.reserve(ue,ke,!0),this.buildingWithoutFacade.reserve(2*ue,2*ke,!1),this.footprintsIndices.reserve(16*(d.length-G)),this.footprintsVertices.reserve(8*(d.length-G));for(const{feature:De,id:Ke,index:Xe,sourceLayerIndex:ot}of d){if(W3e[De.type]==="LineString")continue;const Nt=this.layers[0]._featureFilter.needGeometry;if(Nt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),De,v))continue;let yt=null;if(De.properties&&De.properties.hasOwnProperty("building_id")&&(yt=De.properties.building_id,se.has(yt)))continue;const At=Wt(De,Nt);if(!Nt&&!this.layers[0]._featureFilter.filter(new Ki(this.zoom),At,v))continue;const Ft=Nt?At.geometry:Ot(De,v,S),qt=W6(Ft,500);let ns=!1;for(const tn of qt)if(tn.length!==1){ns=!0;break}if(ns){ie(yt);continue}if(!$dt(Ft,163)){ie(yt);continue}const Gt=this.layers[0],ds=qdt(Gt.layout.get("building-roof-shape").evaluate(De,{},v)),js=Gt.layout.get("building-base").evaluate(De,{},v),Ns=Gt.layout.get("building-height").evaluate(De,{},v),Fs=Gt.layout.get("building-flood-light-ground-radius").evaluate(De,{},v),Bs=Gt.paint.get("building-ambient-occlusion-intensity"),Is=Fs/this.tileToMeter;De.properties["building-part"]="roof";const Ls=Gt.paint.get("building-color").evaluate(De,{},this.canonical).toPremultipliedRenderColor(this.lut),cs=Gt.paint.get("building-emissive-strength").evaluate(De,{},this.canonical);De.properties["building-part"]="wall";const as=Gt.paint.get("building-color").evaluate(De,{},this.canonical).toPremultipliedRenderColor(this.lut),Os=Gt.paint.get("building-emissive-strength").evaluate(De,{},this.canonical);De.properties["building-part"]="window";const sr=Gt.paint.get("building-color").evaluate(De,{},this.canonical).toPremultipliedRenderColor(this.lut),Hs=Gt.paint.get("building-emissive-strength").evaluate(De,{},this.canonical);De.properties["building-part"]="door";const Fr=Gt.paint.get("building-color").evaluate(De,{},this.canonical).toPremultipliedRenderColor(this.lut),hr=Gt.paint.get("building-emissive-strength").evaluate(De,{},this.canonical);let _r=Gt.layout.get("building-flood-light-wall-radius").evaluate(De,{},v);_r=je(_r,0,2048);const Tr=_r/2048*qF,Qn=O.get(Ke),Zs=$.get(Qn)||[],Ar=Zs.length!==0&&Gt.layout.get("building-facade").evaluate(De,{},v);E.setFacadeOptions(4,!0),E.setFauxFacadeOptions(Ar,!1,1);let yn=0,ba=0,Sa=0,Fn=0,Ti=0,bt=0,St=0,ms=0,zs=0,or=0,lr=0;if(Ar){let tn=Math.round(Gt.layout.get("building-facade-floors").evaluate(De,{},v));if(js===0){tn=Math.max(1,tn-(Zs.length>0?1:0));let _i=4;if(Ns>100){const no=[10,13,15];_i=no[De.id?De.id%no.length:0]}else Ns<=10&&(_i=3);E.setFacadeOptions(_i,!0),Ti=(Ns<15?1.3:1.61803)*_i/P}else Ti=js/P;bt=Ns/P,Ti=Math.min(Ti,bt),Sa=Gt.layout.get("building-facade-unit-width").evaluate(De,{},v)/P,Fn=(bt-Ti)/tn,E.setFauxFacadeOptions(!0,!0,Sa);const jo=Gt.layout.get("building-facade-window").evaluate(De,{},v);yn=jo[0],ba=jo[1],St=Math.floor(65535*Math.min(1,Ti/tr)),ms=Math.floor(65535*Math.min(1,bt/tr)),zs=Math.floor(255*yn)<<8|Math.floor(255*ba),or=Math.floor(65535*Math.min(1,Sa/tr)),lr=Math.floor(65535*Math.min(1,Fn/tr))}const zr=Array(qt.length),Ur={x:1/0,y:1/0},An={x:-1/0,y:-1/0},Wn={x:0,y:0};let Yn=0;for(let tn=0;tn0){const _i=[],no=Array(jo.length+1);no[0]=0;for(let ql=0;qltr||Ur.y<0||An.y>tr)&&this.featuresOnBorder.push({featureId:De.id,footprintIndex:this.footprints.length});{const tn=R3(Ii,null,2);this.footprintsIndices.resize(this.footprintsIndices.length+tn.length),this.footprintsIndices.uint16.set(tn,en),this.buildingIds.add(yt??De.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,Zi.x),this.footprintsMax.y=Math.max(this.footprintsMax.y,Zi.y);const jo={footprintVertexOffset:ma,footprintVertexLength:this.footprintsVertices.length-ma,footprintIndexOffset:en,footprintIndexLength:this.footprintsIndices.length-en,min:Ui,max:Zi,hiddenFlags:0,indicesOffset:ui,indicesLength:mo,bloomIndicesOffset:bi,bloomIndicesLength:Ri,groundEffectVertexOffset:Jo,groundEffectVertexLength:Hi,hasFauxFacade:Ar,height:Gn,promoteId:Ke,feature:At,parts:Za,buildingBloom:Ya},_i=this.footprints.length;De.id!==void 0&&this.featureFootprintLookup.set(De.id,_i),de(yt,_i),this.footprints.push(jo)}this.programConfigurations.populatePaintArrays(rn.layoutVertexArray.length,De,Xe,{},m.availableImages,v,m.brightness),this.groundEffect.addPaintPropertiesData(De,Xe,{},m.availableImages,v,m.brightness),m.featureIndex.insert(De,Ft,Xe,ot,this.index,Ai)}ee.forEach(({buildingId:De,footprintIndex:Ke})=>{se.has(De)&&(this.footprints[Ke].hiddenFlags|=4)});const Oe=new Set;this.buildingIds.forEach((De,Ke,Xe)=>{se.has(De)||Oe.add(De)}),this.buildingIds=Oe,this.groundEffect.prepareBorderSegments()}update(d,m,v,S,E,P,O){this.programConfigurations.updatePaintArrays(d,m,E,v,S,P,O),this.groundEffect.update(d,m,E,v,S,P,O),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=v=>{v.layoutVertexBuffer=d.createVertexBuffer(v.layoutVertexArray,V3e.members),v.layoutNormalBuffer=d.createVertexBuffer(v.layoutNormalArray,Ldt.members),v.layoutCentroidBuffer=d.createVertexBuffer(v.layoutCentroidArray,Ddt.members),v.layoutFloodLightDataBuffer=d.createVertexBuffer(v.layoutFloodLightDataArray,Bdt.members),v.layoutFacadeDataArray&&v.layoutFacadeDataArray.length&&(v.layoutFacadeDataBuffer=d.createVertexBuffer(v.layoutFacadeDataArray,Rdt.members)),v.layoutFacadeVerticalRangeArray&&v.layoutFacadeVerticalRangeArray.length&&(v.layoutFacadeVerticalRangeBuffer=d.createVertexBuffer(v.layoutFacadeVerticalRangeArray,Fdt.members)),v.entranceBloom.layoutVertexArray.length&&(v.entranceBloom.layoutVertexBuffer=d.createVertexBuffer(v.entranceBloom.layoutVertexArray,V3e.members),v.entranceBloom.layoutAttenuationBuffer=d.createVertexBuffer(v.entranceBloom.layoutAttenuationArray,zdt.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,v=!0){let S=!1;const E=v?m:0,P=0|(v?-1:~m);this.groundEffect.hiddenByLandmarkVertexArray.length===0&&this.groundEffect.hiddenByLandmarkVertexArray.resize(this.groundEffect.vertexArray.length);for(const O of d){const $=this.footprints[O],G=$.hiddenFlags&P|E;$.hiddenFlags!==G&&($.hiddenFlags=G,S=!0,this.groundEffect.updateHiddenByLandmarkRange($.groundEffectVertexOffset,$.groundEffectVertexLength,$.hiddenFlags!==0))}return S&&(this.indexArrayForConflationUploaded=!1),S}uploadUpdatedIndexBuffer(d){if(this.groundEffect.uploadHiddenByLandmark(d),this.indexArrayForConflationUploaded)return;const m=S=>{S.indexArray.length!==0&&(S.indexArrayForConflation.resize(S.indexArray.length),S.indexArrayForConflation.uint16.set(S.indexArray.uint16),S.entranceBloom.indexArrayForConflation.resize(S.entranceBloom.indexArray.length),S.entranceBloom.indexArrayForConflation.uint16.set(S.entranceBloom.indexArray.uint16))};m(this.buildingWithoutFacade),m(this.buildingWithFacade);for(const S of this.footprints){const E=S.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade,P=S.indicesOffset+S.indicesLength;if(S.hiddenFlags!==0){for(let $=S.indicesOffset;${S.indexArray.length!==0&&(S.indexBuffer?S.indexBuffer.updateData(S.indexArrayForConflation):S.indexBuffer=d.createIndexBuffer(S.indexArrayForConflation,!0),S.entranceBloom.indexBuffer?S.entranceBloom.indexBuffer.updateData(S.entranceBloom.indexArrayForConflation):S.entranceBloom.indexBuffer=d.createIndexBuffer(S.entranceBloom.indexArrayForConflation,!0))};v(this.buildingWithoutFacade),v(this.buildingWithFacade),this.indexArrayForConflationUploaded=!0}uploadUpdatedColorBuffer(d){const m=v=>{v.layoutColorBuffer?v.layoutColorBuffer.updateData(v.layoutColorArray):v.layoutColorBuffer=d.createVertexBuffer(v.layoutColorArray,H3e.members,!0),v.layoutFacadePaintArray&&(v.layoutFacadePaintBuffer?v.layoutFacadePaintBuffer.updateData(v.layoutFacadePaintArray):v.layoutFacadePaintBuffer=d.createVertexBuffer(v.layoutFacadePaintArray,Odt.members,!0)),v.entranceBloom.layoutColorBuffer?v.entranceBloom.layoutColorBuffer.updateData(v.entranceBloom.layoutColorArray):v.entranceBloom.layoutColorBuffer=d.createVertexBuffer(v.entranceBloom.layoutColorArray,H3e.members,!0)};m(this.buildingWithoutFacade),m(this.buildingWithFacade),this.colorBufferUploaded=!0}evaluate(d,m){const v=d.paint.get("building-ambient-occlusion-intensity");for(const S of this.footprints){if(4&S.hiddenFlags)continue;const E=m[S.promoteId],P=S.feature;P.properties["building-part"]="roof";const O=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),$=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="wall";const G=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ee=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="window";const se=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ie=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical);P.properties["building-part"]="door";const de=d.paint.get("building-color").evaluate(P,E,this.canonical).toPremultipliedRenderColor(this.lut),ue=d.paint.get("building-emissive-strength").evaluate(P,E,this.canonical),ke=S.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const De of S.parts){let Ke,Xe=O;De.part===1?(Xe=O,Ke=$):De.part===0?(Xe=G,Ke=ee):De.part===2?(Xe=se,Ke=ie):De.part===3&&(Xe=de,Ke=ue),Ke=je(Ke,0,1);for(let ot=0;otP.max.x||$.max.xP.max.y||$.max.yO.max.x||O.min.x>d||m>O.max.y||O.min.y>m||O.height<=v||Udt(P,this.footprintsVertices.float32.subarray(2*O.footprintVertexOffset,2*(O.footprintVertexOffset+O.footprintVertexLength)),this.footprintsIndices.uint16.subarray(O.footprintIndexOffset,O.footprintIndexOffset+O.footprintIndexLength))&&(v=O.height,this.footprintLookup[E]=O,S=O.hiddenFlags!==0);if(v!==Number.NEGATIVE_INFINITY)return{height:v,hidden:S};this.footprintLookup[E]=void 0}}function Udt(x,d,m){for(let v=0;v1&&($=d[++O]);const ee=Math.abs(G-$.left),se=Math.abs(G-$.right),ie=Math.min(ee,se);let de;const ue=E/v*(S+1);if($.isDash){const ke=S-Math.abs(ue);de=Math.sqrt(ie*ie+ke*ke)}else de=S-Math.sqrt(ie*ie+ue*ue);this.image.data[P+G]=Math.max(0,Math.min(255,de+128))}}}addRegularDash(d,m){for(let $=d.length-1;$>=0;--$){const G=d[$],ee=d[$+1];G.zeroLength?d.splice($,1):ee&&ee.isDash===G.isDash&&(ee.left=G.left,d.splice($,1))}const v=d[0],S=d[d.length-1];v.isDash===S.isDash&&(v.left=S.left-this.width,S.right=v.right+this.width);const E=this.width*this.nextRow;let P=0,O=d[P];for(let $=0;$1&&(O=d[++P]);const G=Math.abs($-O.left),ee=Math.abs($-O.right),se=Math.min(G,ee);this.image.data[E+$]=Math.max(0,Math.min(255,(O.isDash?se:-se)+m+128))}}addDash(d,m){const v=this.getKey(d,m);if(this.positions[v])return this.positions[v];const S=m==="round",E=S?7:0,P=2*E+1;if(this.nextRow+P>this.height)return fr("LineAtlas out of space"),null;d.length===0&&d.push(1);let O=0;for(let ee=0;eem.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 y3,this.layoutVertexArray2=new cm,this.patternVertexArray=new cm,this.indexArray=new zl,this.programConfigurations=new qp(d.layers,{zoom:d.zoom,lut:d.lut}),this.segments=new bo,this.maxLineLength=0,this.zOffsetVertexArray=new cm,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,v,S){}populate(d,m,v,S){this.hasPattern=ipe("line",this.layers,this.pixelRatio,m);const E=this.layers[0].layout.get("line-sort-key");this.tileToMeter=Ue(v);const P=this.layers[0].layout.get("line-elevation-reference");if(P==="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=P!=="sea"&&P!=="ground"&&de?"none":"offset",this.elevationType==="offset"&&P==="none"&&fr(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const O=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope=this.elevationType==="offset"&&O!==void 0;const $=[];for(const{feature:ie,id:de,index:ue,sourceLayerIndex:ke}of d){const Oe=this.layers[0]._featureFilter.needGeometry,De=Wt(ie,Oe);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),De,v))continue;const Ke=E?E.evaluate(De,{},v):void 0,Xe={id:de,properties:ie.properties,type:ie.type,sourceLayerIndex:ke,index:ue,geometry:Oe?De.geometry:Ot(ie,v,S),patterns:{},sortKey:Ke};$.push(Xe)}E&&$.sort((ie,de)=>ie.sortKey-de.sortKey);const{lineAtlas:G,featureIndex:ee}=m,se=this.addConstantDashes(G);for(const ie of $){const{geometry:de,index:ue,sourceLayerIndex:ke}=ie;if(se&&this.addFeatureDashes(ie,G),this.hasPattern){const Oe=ope("line",this.layers,ie,this.zoom,this.pixelRatio,m);this.patternFeatures.push(Oe)}else this.addFeature(ie,de,ue,v,G.positions,m.availableImages,m.brightness,m.elevationFeatures);ee.insert(d[ue].feature,de,ue,ke,this.index)}}addConstantDashes(d){let m=!1;for(const v of this.layers){const S=v.paint.get("line-dasharray").value,E=v.layout.get("line-cap").value;if(S.kind!=="constant"||E.kind!=="constant")m=!0;else{const P=E.value,O=S.value;if(!O)continue;d.addDash(O,P)}}return m}addFeatureDashes(d,m){const v=this.zoom;for(const S of this.layers){const E=S.paint.get("line-dasharray").value,P=S.layout.get("line-cap").value;if(E.kind==="constant"&&P.kind==="constant")continue;let O,$;if(E.kind==="constant"){if(O=E.value,!O)continue}else O=E.evaluate({zoom:v},d);$=P.kind==="constant"?P.value:P.evaluate({zoom:v},d),m.addDash(O,$),d.patterns[S.id]=[m.getKey(O,$)]}}update(d,m,v,S,E,P,O,$){this.programConfigurations.updatePaintArrays(d,m,E,v,S,P,O,$)}addFeatures(d,m,v,S,E,P){for(const O of this.patternFeatures)this.addFeature(O,O.geometry,O.index,m,v,S,P,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,Zdt)),this.patternVertexArray.length!==0&&(this.patternVertexBuffer=d.createVertexBuffer(this.patternVertexArray,Xdt)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,Wdt.members,!0)),this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,Gdt),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 v,S;if(m&&m>0?(v=`mapbox_clip_start_${m}`,S=`mapbox_clip_end_${m}`):(v="mapbox_clip_start",S="mapbox_clip_end"),d.properties&&d.properties.hasOwnProperty(v)&&d.properties.hasOwnProperty(S))return{start:+d.properties[v],end:+d.properties[S]}}addFeature(d,m,v,S,E,P,O,$){const G=this.layers[0].layout,ee=G.get("line-join").evaluate(d,{}),se=G.get("line-cap").evaluate(d,{}),ie=G.get("line-miter-limit"),de=G.get("line-round-limit");this.lineClips=this.lineFeatureClips(d),this.lineFeature=d;const ue=!(!d.properties||!d.properties.hasOwnProperty("mapbox_line_metrics"))&&d.properties.mapbox_line_metrics;this.zOffsetValue=G.get("line-z-offset").value;const ke=this.layers[0].paint.get("line-width").value;if(ke.kind!=="constant"&&ke.isLineProgressConstant===!1&&(this.variableWidthValue=ke),this.elevationType==="road"){const Oe=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(d,m,S,$,ee,se,ie,de)){const[De,Ke]=this.clipRuntimeLinesToTile(m,1);for(let Xe=0;Xe0?Nt.parentIndex:null)}this.fillNonElevatedRoadSegment(Oe)}}else for(let Oe=0;Oe0?Oe:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,d,v,E,P,S,O,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 PF(d,-m,-m,tr+m,tr+m)}clipRuntimeLinesToTile(d,m){const v=[];return[PF(d,-m,-m,tr+m,tr+m,v),v]}addElevatedRoadFeature(d,m,v,S,E,P,O,$){const G=[],ee=ci.getElevationFeature(d,S);if(ee){const se=this.clipLinesToTile(m,1),ie=this.prepareElevatedLines(se,ee,v);for(const de of ie)G.push({geometry:de,elevation:ee,elevationTileID:v,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(G.length===0)return!1;for(const se of G){const ie=this.layoutVertexArray.length;this.addLine(se.geometry,d,v,E,P,O,$);const de=new ki(v,se.elevationTileID);if(se.elevation)for(let ue=ie;ue>1,this.layoutVertexArray.int16[6*ue+1]>>1),Oe=de.pointElevation(ke,se.elevation,.05);this.updateHeightRange(Oe),this.zOffsetVertexArray.emplaceBack(Oe,0,0)}else this.fillNonElevatedRoadSegment(ie)}return!0}prepareElevatedLines(d,m,v){if(m.constantHeight!=null)return d;const S=[],E=1/Ue(v);for(const P of d)ddt(P,new Ka(m,E),0,S);return S}fillNonElevatedRoadSegment(d){for(let m=d;m0,ie=$&&$.progress.max<1;if(this.lineClips){let qt={min:this.lineClips.start,max:this.lineClips.end},ns=1;if($){const js=this.lineClips.end-this.lineClips.start;qt=function(Ns,Fs,Bs){return{min:Mi(Ns.min,Fs,Bs),max:Mi(Ns.max,Fs,Bs)}}($.progress,{min:0,max:1},qt),js>0&&(ns=(qt.max-qt.min)/js)}const Gt=+m.properties.mapbox_clip_feature_len,ds=+m.properties.mapbox_clip_seg_len;if(Number.isNaN(Gt)||Number.isNaN(ds)){for(let Ns=0;Ns=2&&d[ue-1].equals(d[ue-2]);)ue--;let ke=0;for(;ke0,cs=this.overscaling<=16?15*tr/(512*this.overscaling):0;if(ns&&Gt==="round"){if(FsP&&(Gt="bevel"),Gt==="bevel"&&(Fs>2&&(Gt="flipbevel"),Fs2*cs){const sr=De.sub(De.sub(Ke)._mult(cs/as)._round());this.updateDistance(Ke,sr),this.addCurrentVertex(sr,ot,0,0,Oe,Ft),Ke=sr}this.updateDistance(Ke,De),js._mult(Fs),this.addCurrentVertex(De,js,0,0,Oe,Ft);const Os=De.dist(Xe);if(Os>2*cs){const sr=De.add(Xe.sub(De)._mult(cs/Os)._round());this.updateDistance(De,sr),this.addCurrentVertex(sr,Nt,0,0,Oe,Ft),De=sr}}else js._mult(Fs),this.addCurrentVertex(De,js,0,0,Oe,Ft);else if(Gt==="flipbevel"){if(Fs>100)js=Nt.mult(-1);else{const as=Fs*ot.add(Nt).mag()/ot.sub(Nt).mag();js._perp()._mult(as*(Ls?-1:1))}this.addCurrentVertex(De,js,0,0,Oe,Ft),this.addCurrentVertex(De,js.mult(-1),0,0,Oe,Ft)}else if(Gt==="bevel"||Gt==="fakeround"){Ft!=null&&Ke&&this.addCurrentVertex(De,At||ot,-1,-1,Oe,Ft);const as=De.dist(Ke)<=2*cs&&Gt!=="bevel",Os=js.mult(Ls?1:-1);Os._mult(Fs);const sr=Nt.mult(Ls?-1:1),Hs=ot.mult(Ls?-1:1),Fr=this.evaluateLineProgressFeatures(this.distance);if(Ft==null&&(this.addHalfVertex(De,Os.x,Os.y,!1,!Ls,0,Oe,Fr),as||this.addHalfVertex(De,Os.x+2*Hs.x,Os.y+2*Hs.y,!1,Ls,0,Oe,Fr)),Gt==="fakeround"){const hr=Math.round(180*Bs/Math.PI/20);this.addHalfVertex(De,Hs.x,Hs.y,!1,Ls,0,Oe,Fr);for(let _r=0;_r1){this.lineSoFar=d.w;const ke=(m.x-d.x)/se,Oe=(m.y-d.y)/se,De=(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,ee),$.primitiveLength++),P?this.e2=ee:this.e1=ee,G!=null&&this.zOffsetVertexArray.emplaceBack(G.zOffset,G.variableWidth,G.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 Dpe(x,d,m){return x.xm||x.ym}let X3e,Q3e;function J3e(x,d,m){return d*(tr/(x.tileSize*Math.pow(2,m-x.tileID.overscaledZ)))}Sr(Lpe,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const e5e=(x,d,m)=>(1-m)*x+m*d;function t5e(x,d){return 1/J3e(x,1,d.tileZoom)}function s5e(x,d,m,v){return x.translatePosMatrix(v||d.tileID.projMatrix,d,m.paint.get("line-translate"),m.paint.get("line-translate-anchor"))}const r5e=x=>{const d=[];n5e(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 v=x.layout.get("line-join").constantOr("miter")==="none",S=!!x.paint.get("line-pattern").constantOr(1);return v&&S&&d.push("LINE_JOIN_NONE"),d};function n5e(x){const d=x.paint.get("line-dasharray").value;return d.kind!=="constant"||d.value}let Ope;const a5e=()=>Ope||(Ope={layout:X3e||(X3e=new Eo({"line-cap":new nr(Kt.layout_line["line-cap"]),"line-join":new nr(Kt.layout_line["line-join"]),"line-miter-limit":new Xs(Kt.layout_line["line-miter-limit"]),"line-round-limit":new Xs(Kt.layout_line["line-round-limit"]),"line-sort-key":new nr(Kt.layout_line["line-sort-key"]),"line-z-offset":new nr(Kt.layout_line["line-z-offset"]),"line-elevation-reference":new Xs(Kt.layout_line["line-elevation-reference"]),"line-cross-slope":new Xs(Kt.layout_line["line-cross-slope"]),visibility:new Xs(Kt.layout_line.visibility),"line-width-unit":new Xs(Kt.layout_line["line-width-unit"])})),paint:Q3e||(Q3e=new Eo({"line-opacity":new nr(Kt.paint_line["line-opacity"]),"line-color":new nr(Kt.paint_line["line-color"]),"line-translate":new Xs(Kt.paint_line["line-translate"]),"line-translate-anchor":new Xs(Kt.paint_line["line-translate-anchor"]),"line-width":new nr(Kt.paint_line["line-width"]),"line-gap-width":new nr(Kt.paint_line["line-gap-width"]),"line-offset":new nr(Kt.paint_line["line-offset"]),"line-blur":new nr(Kt.paint_line["line-blur"]),"line-dasharray":new nr(Kt.paint_line["line-dasharray"]),"line-pattern":new nr(Kt.paint_line["line-pattern"]),"line-pattern-cross-fade":new Xs(Kt.paint_line["line-pattern-cross-fade"]),"line-gradient":new lv(Kt.paint_line["line-gradient"]),"line-trim-offset":new Xs(Kt.paint_line["line-trim-offset"]),"line-trim-fade-range":new Xs(Kt.paint_line["line-trim-fade-range"]),"line-trim-color":new Xs(Kt.paint_line["line-trim-color"]),"line-emissive-strength":new nr(Kt.paint_line["line-emissive-strength"]),"line-border-width":new nr(Kt.paint_line["line-border-width"]),"line-border-color":new nr(Kt.paint_line["line-border-color"]),"line-occlusion-opacity":new Xs(Kt.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},Ope);class tut extends nr{possiblyEvaluate(d,m){return m=new Ki(Math.floor(m.zoom),{now:m.now,fadeDuration:m.fadeDuration,transition:m.transition,worldview:m.worldview}),super.possiblyEvaluate(d,m)}evaluate(d,m,v,S){return m=Object.assign({},m,{zoom:Math.floor(m.zoom)}),super.evaluate(d,m,v,S)}}let nP;function i5e(x,d){return d>0?d+2*x:x}const sut=ua([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),rut=ua([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),nut=ua([{name:"a_projected_pos",components:4,type:"Float32"}],4);ua([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const aut=ua([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),iut=ua([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),out=ua([{name:"a_texb",components:2,type:"Uint16"}]),lut=ua([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),cut=ua([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ua([{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 o5e=ua([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),dut=ua([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ua([{name:"triangle",components:3,type:"Uint16"}]),ua([{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"}]),ua([{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"}]),ua([{type:"Float32",name:"offsetX"}]),ua([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var Sc=24;function uut(x,d,m){return x.sections.forEach(v=>{v.text=function(S,E,P){const O=E.layout.get("text-transform").evaluate(P,{});return O==="uppercase"?S=S.toLocaleUpperCase():O==="lowercase"&&(S=S.toLocaleLowerCase()),ag.applyArabicShaping&&(S=ag.applyArabicShaping(S)),S}(v.text,d,m)}),x}const aP={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function hut(x){return x==="︶"||x==="﹈"||x==="︸"||x==="﹄"||x==="﹂"||x==="︾"||x==="︼"||x==="︺"||x==="︘"||x==="﹀"||x==="︐"||x==="︓"||x==="︔"||x==="`"||x===" ̄"||x==="︑"||x==="︒"}function mut(x){return x==="︵"||x==="﹇"||x==="︷"||x==="﹃"||x==="﹁"||x==="︽"||x==="︻"||x==="︹"||x==="︗"||x==="︿"}const Rpe=4294967296,l5e=1/Rpe,c5e=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");let UF=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&v,x(S,d,this),this.pos===E&&this.skip(v)}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)*Rpe;return this.pos+=8,x}readSFixed64(){const x=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Rpe;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,v;return v=d[this.pos++],m=127&v,v<128?m:(v=d[this.pos++],m|=(127&v)<<7,v<128?m:(v=d[this.pos++],m|=(127&v)<<14,v<128?m:(v=d[this.pos++],m|=(127&v)<<21,v<128?m:(v=d[this.pos],m|=(15&v)<<28,function(S,E,P){const O=P.buf;let $,G;if(G=O[P.pos++],$=(112&G)>>4,G<128||(G=O[P.pos++],$|=(127&G)<<3,G<128)||(G=O[P.pos++],$|=(127&G)<<10,G<128)||(G=O[P.pos++],$|=(127&G)<<17,G<128)||(G=O[P.pos++],$|=(127&G)<<24,G<128)||(G=O[P.pos++],$|=(1&G)<<31,G<128))return V3(S,$,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&&c5e?c5e.decode(this.buf.subarray(d,x)):function(m,v,S){let E="",P=v;for(;P239?4:O>223?3:O>191?2:1;if(P+ie>S)break;ie===1?O<128&&(se=O):ie===2?($=m[P+1],(192&$)==128&&(se=(31&O)<<6|63&$,se<=127&&(se=null))):ie===3?($=m[P+1],G=m[P+2],(192&$)==128&&(192&G)==128&&(se=(15&O)<<12|(63&$)<<6|63&G,(se<=2047||se>=55296&&se<=57343)&&(se=null))):ie===4&&($=m[P+1],G=m[P+2],ee=m[P+3],(192&$)==128&&(192&G)==128&&(192&ee)==128&&(se=(15&O)<<18|(63&$)<<12|(63&G)<<6|63&ee,(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),P+=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 v,S;if(d>=0?(v=d%4294967296|0,S=d/4294967296|0):(v=~(-d%4294967296),S=~(-d/4294967296),4294967295^v?v=v+1|0:(v=0,S=S+1|0)),d>=18446744073709552e3||d<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");m.realloc(10),function(E,P,O){O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,E>>>=7,O.buf[O.pos++]=127&E|128,O.buf[O.pos]=127&(E>>>=7)}(v,0,m),function(E,P){const O=(7&E)<<4;P.buf[P.pos++]|=O|((E>>>=3)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E|((E>>>=7)?128:0),E&&(P.buf[P.pos++]=127&E)))))}(S,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(v,S,E){for(let P,O,$=0;$55295&&P<57344){if(!O){P>56319||$+1===S.length?(v[E++]=239,v[E++]=191,v[E++]=189):O=P;continue}if(P<56320){v[E++]=239,v[E++]=191,v[E++]=189,O=P;continue}P=O-55296<<10|P-56320|65536,O=null}else O&&(v[E++]=239,v[E++]=191,v[E++]=189,O=null);P<128?v[E++]=P:(P<2048?v[E++]=P>>6|192:(P<65536?v[E++]=P>>12|224:(v[E++]=P>>18|240,v[E++]=P>>12&63|128),v[E++]=P>>6&63|128),v[E++]=63&P|128)}return E}(this.buf,x,this.pos);const m=this.pos-d;m>=128&&d5e(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&&d5e(m,v,this),this.pos=m-1,this.writeVarint(v),this.pos+=v}writeMessage(x,d,m){this.writeTag(x,2),this.writeRawMessage(d,m)}writePackedVarint(x,d){d.length&&this.writeMessage(x,put,d)}writePackedSVarint(x,d){d.length&&this.writeMessage(x,fut,d)}writePackedBoolean(x,d){d.length&&this.writeMessage(x,yut,d)}writePackedFloat(x,d){d.length&&this.writeMessage(x,xut,d)}writePackedDouble(x,d){d.length&&this.writeMessage(x,gut,d)}writePackedFixed32(x,d){d.length&&this.writeMessage(x,vut,d)}writePackedSFixed32(x,d){d.length&&this.writeMessage(x,but,d)}writePackedFixed64(x,d){d.length&&this.writeMessage(x,_ut,d)}writePackedSFixed64(x,d){d.length&&this.writeMessage(x,wut,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 V3(x,d,m){return m?4294967296*d+(x>>>0):4294967296*(d>>>0)+(x>>>0)}function d5e(x,d,m){const v=d<=16383?1:d<=2097151?2:d<=268435455?3:Math.floor(Math.log(d)/(7*Math.LN2));m.realloc(v);for(let S=m.pos-1;S>=x;S--)m.buf[S+v]=m.buf[S]}function put(x,d){for(let m=0;m=0&&v>=d&&VF[this.text.charCodeAt(v)];v--)m--;this.text=this.text.substring(d,m),this.sectionIndex=this.sectionIndex.slice(d,m)}substring(d,m){const v=new H3;return v.text=this.text.substring(d,m),v.sectionIndex=this.sectionIndex.slice(d,m),v.sections=this.sections,v}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(iP.forText(d.scale,d.fontStack||m));const v=this.sections.length-1;for(let S=0;S=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function zpe(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke=1){const Oe=H3.fromFeature(x,S,ke);se===mm.vertical&&Oe.verticalizePunctuation(ie);let De=[];const Ke=function(At,Ft,qt,ns,Gt,ds){if(!At)return[];const js=[],Ns=function(Ls,cs,as,Os,sr,Hs){let Fr=0;for(let hr=0;hr=0;let Bs=0;for(let Ls=0;Ls0&&Ya>Fn&&(Fn=Ya)}else{const Ua=qt[zs.fontStack];if(!Ua)continue;Ua[lr]&&(An=Ua[lr]);const Za=Ft[zs.fontStack];if(!Za)continue;const Ya=Za.glyphs[lr];if(!Ya)continue;if(Ur=Ya.metrics,Yn=lr!==8203?Sc:0,Hs){const bi=Za.ascender!==void 0?Math.abs(Za.ascender):0,Ri=Za.descender!==void 0?Math.abs(Za.descender):0,Ai=(bi+Ri)*zr;Ti-m/2;){if(P--,P<0)return!1;O-=x[P].dist(E),E=x[P]}O+=x[P].dist(x[P+1]),P++;const $=[];let G=0;for(;Ov;)G-=$.shift().angleDelta;if(G>S)return!1;P++,O+=ee.dist(se)}return!0}function _5e(x){let d=0;for(let m=0;mG){const ue=(G-$)/de,ke=Kr(se.x,ie.x,ue),Oe=Kr(se.y,ie.y,ue),De=new xv(ke,Oe,0,ie.angleTo(se),ee);return!P||b5e(x,De,O,P,d)?De:void 0}$+=de}}function Tut(x,d,m,v,S,E,P,O,$){const G=w5e(v,E,P),ee=j5e(v,S),se=ee*P,ie=x[0].x===0||x[0].x===$||x[0].y===0||x[0].y===$;return d-se=0&&ot<$&&Nt>=0&&Nt<$&&ie-G>=0&&ie+G<=ee){const yt=new xv(ot,Nt,0,Ke,ue);v&&!b5e(x,yt,E,v,S)||de.push(yt)}}se+=De}return O||de.length||P||(de=N5e(x,se/2,m,v,S,E,P,!0,$)),de}function k5e(x){let d=0,m=0;for(const P of x)d+=P.w*P.h,m=Math.max(m,P.w);x.sort((P,O)=>O.h-P.h);const v=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(d/.95)),m),h:1/0}];let S=0,E=0;for(const P of x)for(let O=v.length-1;O>=0;O--){const $=v[O];if(!(P.w>$.w||P.h>$.h)){if(P.x=$.x,P.y=$.y,E=Math.max(E,P.y+P.h),S=Math.max(S,P.x+P.w),P.w===$.w&&P.h===$.h){const G=v.pop();G&&O1?ue-1:ue,Hd.copy(se.data,G,{x:0,y:0},{x:ke,y:Oe},se.data,v),Hd.copy(se.data,G,{x:0,y:Ke-ue},{x:ke,y:Oe-ue},{width:De,height:ue},v),Hd.copy(se.data,G,{x:0,y:0},{x:ke,y:Oe+Ke},{width:De,height:ue},v),Hd.copy(se.data,G,{x:De-ue,y:0},{x:ke-ue,y:Oe},{width:ue,height:Ke},v),Hd.copy(se.data,G,{x:0,y:0},{x:ke+De,y:Oe},{width:ue,height:Ke},v),Hd.copy(se.data,G,{x:De-ue,y:Ke-ue},{x:ke-ue,y:Oe-ue},{width:ue,height:ue},v),Hd.copy(se.data,G,{x:0,y:Ke-ue},{x:ke+De,y:Oe-ue},{width:ue,height:ue},v),Hd.copy(se.data,G,{x:0,y:0},{x:ke+De,y:Oe+Ke},{width:ue,height:ue},v),Hd.copy(se.data,G,{x:De-ue,y:0},{x:ke-ue,y:Oe+Ke},{width:ue,height:ue},v)}this.lut=v,this.image=G,this.iconPositions=S,this.patternPositions=E}addImages(d,m,v,S){for(const[E,P]of d.entries()){const{bin:O,imagePosition:$,imageVariant:G}=Vpe(E,P,v);m.set(E,$),S.push(O),P.hasRenderCallback&&this.haveRenderCallbacks.push(G.id)}}patchUpdatedImages(d,m,v){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(S=>d.hasImage(S,v)),d.dispatchRenderCallbacks(this.haveRenderCallbacks,v);for(const S of d.getUpdatedImages(v)){for(const E of this.iconPositions.keys()){const P=Qx.parse(E);if(Js.isEqual(P.id,S)){const O=d.getImage(S,v);this.patchUpdatedImage(this.iconPositions.get(E),O,m,null)}}for(const E of this.patternPositions.keys()){const P=Qx.parse(E);if(Js.isEqual(P.id,S)){const O=d.getImage(S,v);this.patchUpdatedImage(this.patternPositions.get(E),O,m,this.lut)}}}}patchUpdatedImage(d,m,v,S=null){if(!d||!m||d.version===m.version)return;d.version=m.version;const[E,P]=d.tl,O=d.sdf;if(this.lut||O){const $={width:m.data.width,height:m.data.height},G=new Hd($);Hd.copy(m.data,G,{x:0,y:0},{x:0,y:0},$,S,O),v.update(G,{position:{x:E,y:P}})}else v.update(m.data,{position:{x:E,y:P}})}}Sr(oP,"ImagePosition"),Sr(S5e,"ImageAtlas");const lP=1e20;function C5e(x,d,m,v,S,E,P,O,$){for(let G=d;G-1);$++,E[$]=O,P[$]=G,P[$+1]=lP}for(let O=0,$=0;O{let $=this.entries[E];$||($=this.entries[E]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let G=$.glyphs[P];if(G!==void 0)return void O(null,{stack:E,id:P,glyph:G});if(G=this._tinySDF($,E,P),G)return $.glyphs[P]=G,void O(null,{stack:E,id:P,glyph:G});const ee=Math.floor(P/256);if(256*ee>65535)return fr("glyphs > 65535 not supported"),void O(null,{stack:E,id:P,glyph:G});if($.ranges[ee])return void O(null,{stack:E,id:P,glyph:G});let se=$.requests[ee];se||(se=$.requests[ee]=[],K3.loadGlyphRange(E,ee,S,this.requestManager,(ie,de)=>{if(de){$.ascender=de.ascender,$.descender=de.descender;for(const ue in de.glyphs)this._doesCharSupportLocalGlyph(+ue)||($.glyphs[+ue]=de.glyphs[+ue]);$.ranges[ee]=!0}for(const ue of se)ue(ie,de);delete $.requests[ee]})),se.push((ie,de)=>{ie?O(ie):de&&O(null,{stack:E,id:P,glyph:de.glyphs[P]||null})})},(E,P)=>{if(E)m(E);else if(P){const O={};for(const{stack:$,id:G,glyph:ee}of P)O[$]===void 0&&(O[$]={}),O[$].glyphs===void 0&&(O[$].glyphs={}),O[$].glyphs[G]=ee&&{id:ee.id,bitmap:ee.bitmap.clone(),metrics:ee.metrics},O[$].ascender=this.entries[$].ascender,O[$].descender=this.entries[$].descender;m(null,O)}})}_doesCharSupportLocalGlyph(d){return this.localGlyphMode!==Hpe.none&&(this.localGlyphMode===Hpe.all?!!this.localFontFamily:!!this.localFontFamily&&(Jr["CJK Unified Ideographs"](d)||Jr["Hangul Syllables"](d)||Jr.Hiragana(d)||Jr.Katakana(d)||Jr["CJK Symbols and Punctuation"](d)||Jr["CJK Unified Ideographs Extension A"](d)||Jr["CJK Unified Ideographs Extension B"](d)||Jr.Osage(d)))}_tinySDF(d,m,v){const S=this.localFontFamily;if(!S||!this._doesCharSupportLocalGlyph(v))return;let E=d.tinySDF;if(!E){let ke="400";/bold/i.test(m)?ke="900":/medium/i.test(m)?ke="500":/light/i.test(m)&&(ke="200"),E=d.tinySDF=new K3.TinySDF({fontFamily:S,fontWeight:ke,fontSize:24*xg,buffer:3*xg,radius:8*xg}),E.fontWeight=ke}if(this.localGlyphs[E.fontWeight][v])return this.localGlyphs[E.fontWeight][v];const P=String.fromCodePoint(v),{data:O,width:$,height:G,glyphWidth:ee,glyphHeight:se,glyphLeft:ie,glyphTop:de,glyphAdvance:ue}=E.draw(P);return this.localGlyphs[E.fontWeight][v]={id:v,bitmap:new _b({width:$,height:G},O),metrics:{width:ee/xg,height:se/xg,left:ie/xg,top:de/xg-27,advance:ue/xg,localGlyph:!0}}}}K3.loadGlyphRange=function(x,d,m,v,S){const E=256*d,P=E+255,O=v.transformRequest(v.normalizeGlyphsURL(m).replace("{fontstack}",x).replace("{range}",`${E}-${P}`),Zx.Glyphs);Ih(O,($,G)=>{if($)S($);else if(G){const ee={},se=function(ie){return new UF(ie).readFields(jut,{})}(G);for(const ie of se.glyphs)ee[ie.id]=ie;S(null,{glyphs:ee,ascender:se.ascender,descender:se.descender})}})},K3.TinySDF=class{constructor({fontSize:x=24,buffer:d=3,radius:m=8,cutoff:v=.25,fontFamily:S="sans-serif",fontWeight:E="normal",fontStyle:P="normal",lang:O=null}={}){this.buffer=d,this.cutoff=v,this.radius=m,this.lang=O;const $=this.size=x+4*d,G=this._createCanvas($),ee=this.ctx=G.getContext("2d",{willReadFrequently:!0});ee.font=`${P} ${E} ${x}px ${S}`,ee.textBaseline="alphabetic",ee.textAlign="left",ee.fillStyle="black",this.gridOuter=new Float64Array($*$),this.gridInner=new Float64Array($*$),this.f=new Float64Array($),this.z=new Float64Array($+1),this.v=new Uint16Array($)}_createCanvas(x){const d=document.createElement("canvas");return d.width=d.height=x,d}draw(x){const{width:d,actualBoundingBoxAscent:m,actualBoundingBoxDescent:v,actualBoundingBoxLeft:S,actualBoundingBoxRight:E}=this.ctx.measureText(x),P=Math.ceil(m),O=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(E-S))),$=Math.min(this.size-this.buffer,P+Math.ceil(v)),G=O+2*this.buffer,ee=$+2*this.buffer,se=Math.max(G*ee,0),ie=new Uint8ClampedArray(se),de={data:ie,width:G,height:ee,glyphWidth:O,glyphHeight:$,glyphTop:P,glyphLeft:0,glyphAdvance:d};if(O===0||$===0)return de;const{ctx:ue,buffer:ke,gridInner:Oe,gridOuter:De}=this;this.lang&&(ue.lang=this.lang),ue.clearRect(ke,ke,O,$),ue.fillText(x,ke,ke+P);const Ke=ue.getImageData(ke,ke,O,$);De.fill(lP,0,se),Oe.fill(0,0,se);for(let Xe=0;Xe<$;Xe++)for(let ot=0;ot0?At*At:0,Oe[yt]=At<0?At*At:0}}C5e(De,0,0,G,ee,G,this.f,this.v,this.z),C5e(Oe,ke,ke,O,$,G,this.f,this.v,this.z);for(let Xe=0;Xe{const Fs=GF(Gt.stretch-Ke,Xe,ee,x.left*S),Bs=KF(Gt.fixed-yt,At,Gt.stretch,ue),Is=GF(ds.stretch-ot,Nt,se,x.top*S),Ls=KF(ds.fixed-Ft,qt,ds.stretch,ke),cs=GF(js.stretch-Ke,Xe,ee,x.left*S),as=KF(js.fixed-yt,At,js.stretch,ue),Os=GF(Ns.stretch-ot,Nt,se,x.top*S),sr=KF(Ns.fixed-Ft,qt,Ns.stretch,ke),Hs=new pt(Fs,Is),Fr=new pt(cs,Is),hr=new pt(cs,Os),_r=new pt(Fs,Os),Tr=new pt(Bs/O,Ls/O),Qn=new pt(as/O,sr/O),Zs=d*Math.PI/180;if(Zs){const Ti=Math.sin(Zs),bt=Math.cos(Zs),St=[bt,-Ti,Ti,bt];Hs._matMult(St),Fr._matMult(St),_r._matMult(St),hr._matMult(St)}const Ar=Gt.stretch+Gt.fixed,yn=js.stretch+js.fixed,ba=ds.stretch+ds.fixed,Sa=Ns.stretch+Ns.fixed,Fn=x.imageSecondary;return{tl:Hs,tr:Fr,bl:_r,br:hr,texPrimary:{x:P.paddedRect.x+Ry+Ar,y:P.paddedRect.y+Ry+ba,w:yn-Ar,h:Sa-ba},texSecondary:Fn?{x:Fn.paddedRect.x+Ry+Ar,y:Fn.paddedRect.y+Ry+ba,w:yn-Ar,h:Sa-ba}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Tr,pixelOffsetBR:Qn,minFontScaleX:At/O/ee,minFontScaleY:qt/O/se,isSDF:m}};if(v&&(P.stretchX||P.stretchY)){const Gt=A5e(ie,Oe,ue),ds=A5e(de,De,ke);for(let js=0;jsE)&&(E=ue.x),(!de||ue.y>P)&&(P=ue.y)}const $=Math.min(E-v,P-S);let G=$/2;const ee=new FC([],Iut);if($===0)return new pt(v,S);for(let de=v;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||(G=de.h/2,ee.push(new Z3(de.p.x-G,de.p.y-G,G,x)),ee.push(new Z3(de.p.x+G,de.p.y-G,G,x)),ee.push(new Z3(de.p.x-G,de.p.y+G,G,x)),ee.push(new Z3(de.p.x+G,de.p.y+G,G,x)),ie+=4)}return m&&(console.log(`num probes: ${ie}`),console.log(`best distance: ${se.d}`)),se.p}function Iut(x,d){return d.max-x.max}class Z3{constructor(d,m,v,S){this.p=new pt(d,m),this.h=v,this.d=function(E,P){let O=!1,$=1/0;for(let G=0;GE.y!=ke.y>E.y&&E.x<(ke.x-ue.x)*(E.y-ue.y)/(ke.y-ue.y)+ue.x&&(O=!O),$=Math.min($,Vo(E,ue,ke))}}return(O?1:-1)*Math.sqrt($)}(this.p,S),this.max=this.d+this.h*Math.SQRT2}}const Lut=Object.keys,Gpe=Number.POSITIVE_INFINITY,Dut=Math.sqrt(2);function jb(x,d,m,v,S){const E=$pe(x)&&x.collisionPadding?x.collisionPadding:[0,0,0,0],P={top:x.top-E[1],bottom:x.bottom+E[3],left:x.left-E[0],right:x.right+E[2],scaled:!1};return v!==void 0&&function(O,$){O.top*=$,O.bottom*=$,O.left*=$,O.right*=$,O.scaled=!0}(P,v),m&&function(O,$){if(!$)return;const G=jr($),ee=new pt(O.left,O.top),se=new pt(O.right,O.top),ie=new pt(O.left,O.bottom),de=new pt(O.right,O.bottom),ue=new pt(0,0);ee._rotateAround(G,ue),se._rotateAround(G,ue),ie._rotateAround(G,ue),de._rotateAround(G,ue),O.left=Math.min(ee.x,se.x,ie.x,de.x),O.right=Math.max(ee.x,se.x,ie.x,de.x),O.top=Math.min(ee.y,se.y,ie.y,de.y),O.bottom=Math.max(ee.y,se.y,ie.y,de.y)}(P,m),S&&(P.left+=S[0],P.right+=S[0],P.top+=S[1],P.bottom+=S[1]),d?{top:Math.min(d.top,P.top),bottom:Math.max(d.bottom,P.bottom),left:Math.min(d.left,P.left),right:Math.max(d.right,P.right),scaled:d.scaled||P.scaled}:P}function P5e(x,[d,m]){let v=0,S=0;if(m===Gpe){d<0&&(d=0);const E=d/Dut;switch(x){case"top-right":case"top-left":S=E-7;break;case"bottom-right":case"bottom-left":S=7-E;break;case"bottom":S=7-d;break;case"top":S=d-7}switch(x){case"top-right":case"bottom-right":v=-E;break;case"top-left":case"bottom-left":v=E;break;case"left":v=d;break;case"right":v=-d}}else{switch(d=Math.abs(d),m=Math.abs(m),x){case"top-right":case"top-left":case"top":S=m-7;break;case"bottom-right":case"bottom-left":case"bottom":S=7-m}switch(x){case"top-right":case"bottom-right":case"right":v=-d;break;case"top-left":case"bottom-left":case"left":v=d}}return[v,S]}function Out(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de){const ue=x.layers[0],ke=ue.appearances;if(ke.length===0)return{iconBBox:null,iconVerticalBBox:null,textBBox:null,textVerticalBBox:null};const Oe={iconBBox:null,iconVerticalBBox:null},De={textBBox:null,textVerticalBBox:null},{baseIconRotate:Ke,baseTextRotate:Xe,iconScaleFactor:ot}=function(yt,At,Ft){const qt=yt.get("icon-rotate").evaluate(At,{},Ft),ns=yt.get("text-rotate").evaluate(At,{},Ft),[Gt,ds]=yt.get("icon-size-scale-range");return{baseIconRotate:qt,baseTextRotate:ns,iconScaleFactor:je(1,Gt,ds)}}(v,S,E);d&&(Oe.iconBBox=jb(d,Oe.iconBBox,Ke,P),m)&&(Oe.iconVerticalBBox=jb(m,Oe.iconVerticalBBox,Ke+90,P));const Nt=YF(se.horizontal);Nt&&(De.textBBox=jb(Nt,De.textBBox,Xe,1,de)),se.vertical&&(De.textVerticalBBox=jb(se.vertical,De.textVerticalBBox,Xe+90,1,de));for(const yt of ke)yt.hasIconProperties()&&Rut(Oe,x,ue,yt,S,E,O,Ke,P,$,d,G,ot,ee),yt.hasTextProperties()&&Fut(De,ue,yt,S,E,de,Xe,ie,Nt,se.vertical);return{iconBBox:Oe.iconBBox,iconVerticalBBox:Oe.iconVerticalBBox,textBBox:De.textBBox,textVerticalBBox:De.textVerticalBBox}}function Rut(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de){const{appearanceIconOffset:ue,appearanceIconRotate:ke,appearanceIconSize:Oe}=function(ot,Nt,yt,At,Ft,qt,ns,Gt){const ds=ot.hasProperty("icon-offset")?Nt.getAppearanceValueAndResolveTokens(ot,"icon-offset",yt,At,[]):null,js=ds&&Array.isArray(ds)?ds:Ft,Ns=ot.hasProperty("icon-rotate")?Nt.getAppearanceValueAndResolveTokens(ot,"icon-rotate",yt,At,[]):null,Fs=typeof Ns=="number"?Ns:qt,Bs=ot.hasProperty("icon-size")?Nt.getAppearanceValueAndResolveTokens(ot,"icon-size",yt,At,[]):null;return{appearanceIconOffset:js,appearanceIconRotate:Fs,appearanceIconSize:typeof Bs=="number"?Bs*Gt.iconScaleFactor:ns}}(v,m,S,E,P,O,$,G);let De=null,Ke=null,Xe=null;v.hasProperty("icon-image")?Xe=function(ot,Nt,yt,At,Ft,qt,ns){let Gt=null;const ds=Nt.getAppearanceValueAndResolveTokens(yt,"icon-image",At,Ft,[]);if(ds){const js=ot.getResolvedImageFromTokens(ds),Ns=yt.getUnevaluatedProperty("icon-size"),Fs=cP(js,W3(ot.zoom,Ns,ot.worldview),Ns,Ft,ot.zoom,At,ot.pixelRatio,ns,ot.worldview);Gt=qt.get(Fs.iconPrimary.toString())}return Gt}(d,m,v,S,E,se,ie):ee&&(Xe=ee.imagePrimary),Xe&&(De=HF(Xe,null,ue,de),d.allowVerticalPlacement&&(Ke=HF(Xe,null,ue,de))),De&&(x.iconBBox=jb(De,x.iconBBox,ke,Oe)),Ke&&(x.iconVerticalBBox=jb(Ke,x.iconVerticalBBox,ke+90,Oe))}function Fut(x,d,m,v,S,E,P,O,$,G){const{appearanceTextOffset:ee,appearanceTextRotate:se,appearanceTextSize:ie}=function(ue,ke,Oe,De,Ke,Xe,ot){const Nt=ue.hasProperty("text-offset")?ke.getAppearanceValueAndResolveTokens(ue,"text-offset",Oe,De,[]):null,yt=Nt&&Array.isArray(Nt)?[Nt[0]*Sc,Nt[1]*Sc]:Ke,At=ue.hasProperty("text-rotate")?ke.getAppearanceValueAndResolveTokens(ue,"text-rotate",Oe,De,[]):null,Ft=typeof At=="number"?At:Xe,qt=ue.hasProperty("text-size")?ke.getAppearanceValueAndResolveTokens(ue,"text-size",Oe,De,[]):null;return{appearanceTextOffset:yt,appearanceTextRotate:Ft,appearanceTextSize:typeof qt=="number"?qt:ot}}(m,d,v,S,E,P,O),de=ie/O;$&&(x.textBBox=jb($,x.textBBox,se,de,ee)),G&&(x.textVerticalBBox=jb(G,x.textVerticalBBox,se+90,de,ee))}function ZF(x,d,m,v,S,E,P,O,$){if(!d||!d.usvg)return;const G=v5e(v),ee=v5e(S),se=E!=="both"&&E!=="width"||!g5e(v)?1:ee.width/G.width,ie=E!=="both"&&E!=="height"||!y5e(v)?1:ee.height/G.height;m.scaleSelf(se,ie);const de=m.toString();P.set(de,m),O.set(de,d);const{imagePosition:ue}=Vpe(de,d,M2);$.set(de,ue)}function I5e(x,d,m,v,S,E,P,O,$){if(!x)return;const G=function(ee,se,ie,de,ue,ke){if(ee.kind==="camera")return ee.maxSize;if(ee.kind==="composite"){const Oe=se.possiblyEvaluate(new Ki(ee.maxZoom,{worldview:ke}),ie).evaluate(ue,{},ie),De=se.possiblyEvaluate(new Ki(ee.minZoom,{worldview:ke}),ie).evaluate(ue,{},ie);return Math.max(Oe,De)}return se.possiblyEvaluate(new Ki(de,{worldview:ke})).evaluate(ue,{},ie)}(d,m,v,S,E,$);return x.scaleSelf(G*O*P)}function cP(x,d,m,v,S,E,P,O,$){return{iconPrimary:I5e(x.getPrimary(),d,m,v,S,E,P,O,$),iconSecondary:I5e(x.getSecondary(),d,m,v,S,E,P,O,$)}}function zut(x,d,m){if(!d)return;const v=m.get(x.toString()),S=m.get(d.toString());v&&S&&(v.paddedRect.w===S.paddedRect.w&&v.paddedRect.h===S.paddedRect.h||fr(`Mismatch in icon variant sizes: ${x.toString()} and ${d.toString()}`),v.usvg!==S.usvg&&fr(`Mismatch in icon variant image types: ${x.id} and ${d.id}`))}function L5e(x,d,m,v){if(!x)return;const S=d.get(m.toString());if(x.imagePrimary=S,v){const E=d.get(v.toString());x.imageSecondary=E}}function But(x,d){for(const m in x.horizontal)D5e(x.horizontal[m],d);D5e(x.vertical,d)}function D5e(x,d){if(x){for(const m of x.positionedLines)for(const v of m.positionedGlyphs)if(v.image!==null){const S=v.image.toString();v.rect=d.get(S).paddedRect}}}function Kpe(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 $ut(x,d,m,v,S,E,P,O,$){const G=YF(E.horizontal)||E.vertical,ee=m.get("icon-text-fit-padding").evaluate(v,{},S);let se,ie=d;return d&&$!=="none"&&(x.allowVerticalPlacement&&E.vertical&&(se=qpe(d,E.vertical,$,ee,O,P)),G&&(ie=qpe(d,G,$,ee,O,P))),{defaultShapedIcon:ie,verticallyShapedIcon:se}}function qut(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke,Xe,ot,Nt,yt,At){let Ft=P.textMaxSize.evaluate(d,{},ie);Ft===void 0?Ft=O*P.textScaleFactor:Ft*=P.textScaleFactor;const qt=x.layers[0].layout,ns=Sc,Gt=O*P.textScaleFactor/ns,ds=YF(m.horizontal)||m.vertical;if(Oe!=="none"&&x.appearanceFeatureData&&d.index18&&Os>2&&(Os>>=1),Math.max(tr/(512*Os),1)*qt.get("symbol-spacing")),Bs=qt.get("text-padding")*x.tilePixelRatio,Is=qt.get("icon-padding")*x.tilePixelRatio,Ls=jr(qt.get("text-max-angle")),cs=qt.get("icon-rotation-alignment")==="map"&&Xe!=="point",as=Fs/2;var Os;x.hasAnyIconTextFit===!1&&Oe!=="none"&&(x.hasAnyIconTextFit=!0);const sr=d.properties?+d.properties[is]:null,Hs=sr&&x.elevationFeatureIdToIndex?x.elevationFeatureIdToIndex.get(sr):65535,Fr=(hr,_r,Tr)=>{if(_r.x<0||_r.x>=tr||_r.y<0||_r.y>=tr)return;let Qn=null;if(js){const{x:Zs,y:Ar,z:yn}=de.projectTilePoint(_r.x,_r.y,Tr);Qn={anchor:new xv(Zs,Ar,yn,0,void 0),up:de.upVector(Tr,_r.x,_r.y)}}(function(Zs,Ar,yn,ba,Sa,Fn,Ti,bt,St,ms,zs,or,lr,zr,Ur,An,Wn,Yn,ha,rn,gn,Ua,Za,Ya,bi,Ri,Ai,ti,ui,Gn,Na,mo,en){const ma=Zs.addToLineVertexArray(Ar,ba);let Ii,Ui,Zi,Jo,Hi,tn,jo,_i=0,no=0,ql=0,Cc=0,_l=-1,wl=-1;const lc={};let hh=G1("");const Wi=yn?yn.anchor:Ar,Ho=ti!=="none";let el=0,Dh=0;if(St._unevaluatedLayout.getValue("text-radial-offset")===void 0){const Td=St.layout.get("text-offset").evaluate(gn,{},bi);el=Td[0]*Sc,Dh=Td[1]*Sc}else el=St.layout.get("text-radial-offset").evaluate(gn,{},bi)*Sc,Dh=Gpe;if(Zs.allowVerticalPlacement&&Sa.vertical){const Td=Sa.vertical;if(Ur)tn=Zpe(Td),bt&&(jo=Zpe(bt));else{const Bu=St.layout.get("text-rotate").evaluate(gn,{},bi)+90;Zi=XF(ms,Wi,Ar,zs,or,lr,Td,zr,Bu,An,mo),bt&&(Jo=XF(ms,Wi,Ar,zs,or,lr,bt,Yn,Bu,null,Na))}}if(Fn){const Td=Zs.iconSizeData,Bu=St.layout.get("icon-rotate").evaluate(gn,{},bi),pm=Wpe(Fn,Bu,Za,Ho,Ua.iconScaleFactor),Sb=bt?Wpe(bt,Bu,Za,Ho,Ua.iconScaleFactor):void 0;Ui=XF(ms,Wi,Ar,zs,or,lr,Fn,Yn,Bu,null,Gn);const s5=function(bg,CP,eTe,emt,tTe,sTe,tmt,smt){const rTe=bg.layers[0],nTe=rTe.appearances;let r5=CP.length;if(eTe&&(r5=Math.max(r5,eTe.length)),nTe.length===0)return r5;const[rmt,nmt]=emt.get("icon-size-scale-range"),amt=je(1,rmt,nmt);for(const aTe of nTe){const iTe=aTe.getUnevaluatedProperties();if(iTe._values["icon-image"].value!==void 0){const oTe=rTe.getAppearanceValueAndResolveTokens(aTe,"icon-image",tTe,sTe,[]);if(oTe){const lTe=bg.getResolvedImageFromTokens(oTe);if(lTe){const cTe=iTe._values["icon-size"],imt=cP(lTe,W3(bg.zoom,cTe,bg.worldview),cTe,sTe,bg.zoom,tTe,bg.pixelRatio,amt,bg.worldview),omt=tmt.get(imt.iconPrimary.toString());r5=Math.max(r5,Aut(omt,smt))}}}}return r5}(Zs,pm,Sb,St.layout,gn,bi,Zs.iconAtlasPositions,Ho);_i=4*s5;let vg=null;Td.kind==="source"?(vg=[fg*St.layout.get("icon-size").evaluate(gn,{},bi)*Ua.iconScaleFactor],vg[0]>gv&&fr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${dP}. Reduce your "icon-size".`)):Td.kind==="composite"&&(vg=[fg*Ua.compositeIconSizes[0].evaluate(gn,{},bi)*Ua.iconScaleFactor,fg*Ua.compositeIconSizes[1].evaluate(gn,{},bi)*Ua.iconScaleFactor],(vg[0]>gv||vg[1]>gv)&&fr(`${Zs.layerIds[0]}: Value for "icon-size" is >= ${dP}. Reduce your "icon-size".`)),Zs.addSymbols(Zs.icon,pm,vg,rn,ha,gn,void 0,yn,Ar,ma.lineStartIndex,ma.lineLength,-1,Ya,bi,Ri,Ai,Zs.symbolInstances.length,s5),_l=Zs.icon.placedSymbolArray.length-1,Sb&&(no=4*s5,Zs.addSymbols(Zs.icon,Sb,vg,rn,ha,gn,mm.vertical,yn,Ar,ma.lineStartIndex,ma.lineLength,-1,Ya,bi,Ri,Ai,Zs.symbolInstances.length,s5),wl=Zs.icon.placedSymbolArray.length-1)}for(const Td in Sa.horizontal){const Bu=Td,pm=Sa.horizontal[Bu];Ii||(hh=G1(pm.text),Ur?Hi=Zpe(pm):Ii=XF(ms,Wi,Ar,zs,or,lr,pm,zr,St.layout.get("text-rotate").evaluate(gn,{},bi),An,mo));const Sb=pm.positionedLines.length===1;if(ql+=O5e(Zs,yn,Ar,pm,Ti,St,Ur,gn,An,ma,Sa.vertical?mm.horizontal:mm.horizontalOnly,Sb?Lut(Sa.horizontal):[Bu],lc,_l,Ua,Ya,bi,Zs.symbolInstances.length,Ri),Sb)break}Sa.vertical&&(Cc+=O5e(Zs,yn,Ar,Sa.vertical,Ti,St,Ur,gn,An,ma,mm.vertical,["vertical"],lc,wl,Ua,Ya,bi,Zs.symbolInstances.length,Ri));let Ul=-1;const Zf=(Td,Bu)=>Td?Math.max(Td,Bu):Bu;Ul=Zf(Hi,Ul),Ul=Zf(tn,Ul),Ul=Zf(jo,Ul);const Fy=Ul>-1?1:0;Zs.glyphOffsetArray.length>=65535&&fr("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),gn.sortKey!==void 0&&Zs.addToSortKeyRanges(Zs.symbolInstances.length,gn.sortKey),Zs.symbolInstances.emplaceBack(Ar.x,Ar.y,Wi.x,Wi.y,Wi.z,lc.right>=0?lc.right:-1,lc.center>=0?lc.center:-1,lc.left>=0?lc.left:-1,lc.vertical>=0?lc.vertical:-1,_l,wl,hh,Ii!==void 0?Ii:Zs.collisionBoxArray.length,Ii!==void 0?Ii+1:Zs.collisionBoxArray.length,Zi!==void 0?Zi:Zs.collisionBoxArray.length,Zi!==void 0?Zi+1:Zs.collisionBoxArray.length,Ui!==void 0?Ui:Zs.collisionBoxArray.length,Ui!==void 0?Ui+1:Zs.collisionBoxArray.length,Jo||Zs.collisionBoxArray.length,Jo?Jo+1:Zs.collisionBoxArray.length,zs,ql,Cc,_i,no,Fy,0,el,Dh,Ul,0,Ho?1:0,ui)})(x,_r,Qn,hr,m,v,E,S,x.layers[0],x.collisionBoxArray,d.index,d.sourceLayerIndex,x.index,Bs,Ke,G,0,Is,cs,De,d,P,ee,se,ie,ue,ke,Oe,Hs,ot,Nt,yt)};if(Xe==="line")for(const hr of PF(d.geometry,0,0,tr,tr)){const _r=Tut(hr,Fs,Ls,m.vertical||ds,v,ns,Ns,x.overscaling,tr);for(const Tr of _r)ds&&Uut(x,ds.text,as,Tr)||Fr(hr,Tr,ie)}else if(Xe==="line-center"){for(const hr of d.geometry)if(hr.length>1){const _r=Mut(hr,Ls,m.vertical||ds,v,ns,Ns);_r&&Fr(hr,_r,ie)}}else if(d.type==="Polygon")for(const hr of W6(d.geometry,0)){const _r=Put(hr,16);Fr(hr[0],new xv(_r.x,_r.y,0,0,void 0),ie)}else if(d.type==="LineString")for(const hr of d.geometry)Fr(hr,new xv(hr[0].x,hr[0].y,0,0,void 0),ie);else if(d.type==="Point")for(const hr of d.geometry)for(const _r of hr)Fr([_r],new xv(_r.x,_r.y,0,0,void 0),ie)}const dP=255,gv=dP*fg;function O5e(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke){const Xe=function(yt,At,Ft,qt,ns,Gt,ds,js){const Ns=[];if(At.positionedLines.length===0)return Ns;const Fs=qt.layout.get("text-rotate").evaluate(Gt,{})*Math.PI/180,Bs=function(Os){const sr=Os[0],Hs=Os[1],Fr=sr*Hs;return Fr>0?[sr,-Hs]:Fr<0?[-sr,Hs]:sr===0?[Hs,sr]:[Hs,-sr]}(Ft);let Is=Math.abs(At.top-At.bottom);for(const Os of At.positionedLines)Is-=Os.lineOffset;const Ls=At.positionedLines.length,cs=Is/Ls;let as=At.top-Ft[1];for(let Os=0;Osgv&&fr(`${x.layerIds[0]}: Value for "text-size" is >= ${dP}. Reduce your "text-size".`)):ot.kind==="composite"&&(Nt=[fg*ue.compositeTextSizes[0].evaluate(O,{},Oe)*ue.textScaleFactor,fg*ue.compositeTextSizes[1].evaluate(O,{},Oe)*ue.textScaleFactor],(Nt[0]>gv||Nt[1]>gv)&&fr(`${x.layerIds[0]}: Value for "text-size" is >= ${dP}. Reduce your "text-size".`)),x.addSymbols(x.text,Xe,Nt,$,P,O,ee,d,m,G.lineStartIndex,G.lineLength,de,ke,Oe,Ke,!1,De,Xe.length);for(const yt of se)ie[yt]=x.text.placedSymbolArray.length-1;return 4*Xe.length}function YF(x){for(const d in x)return x[d];return null}function XF(x,d,m,v,S,E,P,O,$,G,ee){let se,ie,de,ue;if(se=ee?ee.top:P.top,ie=ee?ee.bottom:P.bottom,de=ee?ee.left:P.left,ue=ee?ee.right:P.right,$pe(P)&&P.collisionPadding){const ke=P.collisionPadding;de-=ke[0],se-=ke[1],ue+=ke[2],ie+=ke[3]}if($){const ke=new pt(de,se),Oe=new pt(ue,se),De=new pt(de,ie),Ke=new pt(ue,ie),Xe=jr($);let ot=new pt(0,0);G&&(ot=new pt(G[0],G[1])),ke._rotateAround(Xe,ot),Oe._rotateAround(Xe,ot),De._rotateAround(Xe,ot),Ke._rotateAround(Xe,ot),de=Math.min(ke.x,Oe.x,De.x,Ke.x),ue=Math.max(ke.x,Oe.x,De.x,Ke.x),se=Math.min(ke.y,Oe.y,De.y,Ke.y),ie=Math.max(ke.y,Oe.y,De.y,Ke.y)}return x.emplaceBack(d.x,d.y,d.z,m.x,m.y,de,se,ue,ie,O,v,S,E),x.length-1}function Zpe(x){$pe(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 Uut(x,d,m,v){const S=x.compareText;if(d in S){const E=S[d];for(let P=E.length-1;P>=0;P--)if(v.dist(E[P])Xe&&(ot(yt,Ns,Ft,qt,ds,js),ot(Ns,At,ds,js,ns,Gt))}ot(se,ie,v,E,S,E),ot(ie,de,S,E,S,P),ot(de,ue,S,P,v,P),ot(ue,se,v,P,v,E),ke-=Xe,Oe-=Xe,De+=Xe,Ke+=Xe;const Nt=1/Math.max(De-ke,Ke-Oe);return{scale:Nt,x:ke*Nt,y:Oe*Nt,x2:De*Nt,y2:Ke*Nt,projection:d}}function F5e(x,{x:d,y:m},v=0){return new pt(((d-v)*x.scale-x.x)*tr,(m*x.scale-x.y)*tr)}const Vut=w(new Float32Array(16));class Nb{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,v){return{x:d,y:m,z:0}}locationPoint(d,m,v,S=!0){return d._coordinatePoint(d.locationCoordinate(m,v),S)}pixelsPerMeter(d,m){return ae(1,d)*m}pixelSpaceConversion(d,m,v){return 1}farthestPixelDistance(d){return R5e(d,d.pixelsPerMeter)}pointCoordinate(d,m,v,S){const E=d.horizonLineFromTop(!1),P=new pt(m,Math.max(E,v));return d.rayIntersectionCoordinate(d.pointRayIntersection(P,S))}pointCoordinate3D(d,m,v){const S=new pt(m,v);if(d.elevation)return d.elevation.pointCoordinate(S);{const E=this.pointCoordinate(d,S.x,S.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 v=d.horizonLineFromTop();return m.y0?m<-Y3+v&&(m=-Y3+v):m>Y3-v&&(m=Y3-v);const P=E/Math.pow(JF(m),S);let O=P*Math.sin(S*d),$=E-P*Math.cos(S*d);return O=.5*(O/Math.PI+.5),$=.5*($/Math.PI+.5),{x:O,y:this.southernCenter?$:1-$,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:v,f:S}=this,E=S-m,P=Math.sign(E),O=Math.sign(v)*Math.sqrt(d*d+E*E);let $=Math.atan2(d,Math.abs(E))*P;E*v<0&&($-=Math.PI*Math.sign(d)*P);const G=je(Xn($/v)+this.center[0],-180,180),ee=je(Xn(2*Math.atan(Math.pow(S/O,1/v))-Y3),-be,be);return new y(G,this.southernCenter?-ee:ee)}}class z5e extends Nb{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:W(d),y:Q(m),z:0}}unproject(d,m){const v=oe(d),S=ve(m);return new y(v,S)}}const B5e=jr(be);class Zut extends Nb{project(d,m){const v=(m=jr(m))*m,S=v*v;return{x:.5*((d=jr(d))*(.8707-.131979*v+S*(S*(.003971*v-.001529*S)-.013791))/Math.PI+.5),y:1-.5*(m*(1.007226+v*(.015085+S*(.028874*v-.044475-.005916*S)))/Math.PI+1),z:0}}unproject(d,m){d=(2*d-.5)*Math.PI;let v=m=(2*(1-m)-1)*Math.PI,S=25,E=0,P=v*v;do{P=v*v;const G=P*P;E=(v*(1.007226+P*(.015085+G*(.028874*P-.044475-.005916*G)))-m)/(1.007226+P*(.045255+G*(.259866*P-.311325-.005916*11*G))),v=je(v-E,-B5e,B5e)}while(Math.abs(E)>1e-6&&--S>0);P=v*v;const O=je(Xn(d/(.8707+P*(P*(P*P*P*(.003971-.001529*P)-.013791)-.131979))),-180,180),$=Xn(v);return new y(O,$)}}const $5e=jr(be);class Yut extends Nb{project(d,m){m=jr(m),d=jr(d);const v=Math.cos(m),S=2/Math.PI,E=Math.acos(v*Math.cos(d/2)),P=Math.sin(E)/E,O=.5*(d*S+2*v*Math.sin(d/2)/P)||0,$=.5*(m+Math.sin(m)/P)||0;return{x:.5*(O/Math.PI+.5),y:1-.5*($/Math.PI+1),z:0}}unproject(d,m){let v=d=(2*d-.5)*Math.PI,S=m=(2*(1-m)-1)*Math.PI,E=25;const P=1e-6;let O=0,$=0;do{const G=Math.cos(S),ee=Math.sin(S),se=2*ee*G,ie=ee*ee,de=G*G,ue=Math.cos(v/2),ke=Math.sin(v/2),Oe=2*ue*ke,De=ke*ke,Ke=1-de*ue*ue,Xe=Ke?1/Ke:0,ot=Ke?Math.acos(G*ue)*Math.sqrt(1/Ke):0,Nt=.5*(2*ot*G*ke+2*v/Math.PI)-d,yt=.5*(ot*ee+S)-m,At=.5*Xe*(de*De+ot*G*ue*ie)+1/Math.PI,Ft=Xe*(Oe*se/4-ot*ee*ke),qt=.125*Xe*(se*ke-ot*ee*de*Oe),ns=.5*Xe*(ie*ue+ot*De*G)+.5,Gt=Ft*qt-ns*At;O=(yt*Ft-Nt*ns)/Gt,$=(Nt*qt-yt*At)/Gt,v=je(v-O,-Math.PI,Math.PI),S=je(S-$,-$5e,$5e)}while((Math.abs(O)>P||Math.abs($)>P)&&--E>0);return new y(Xn(v),Xn(S))}}class q5e extends Nb{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:v,cosPhi:S}=this;return{x:jr(d)*S*v+.5,y:-Math.sin(jr(m))/S*v+.5,z:0}}unproject(d,m){const{scale:v,cosPhi:S}=this,E=-(m-.5)/v,P=je(Xn((d-.5)/v)/S,-180,180),O=Math.asin(je(E*S,-1,1)),$=je(Xn(O),-be,be);return new y(P,$)}}class Xut extends z5e{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,v){const S=B6(d,m,v);return ft(S,S,jF(Vp(v))),{x:S[0],y:S[1],z:S[2]}}locationPoint(d,m,v){const S=gb(m.lat,m.lng),E=Me([],S),P=v?d._centerAltitude+v:d.elevation?d.elevation.getAtPointOrZero(d.locationCoordinate(m),d._centerAltitude):d._centerAltitude;Ie(S,S,E,ae(1,0)*tr*P);const O=w(new Float64Array(16));return C(O,d.pixelMatrix,d.globeMatrix),ft(S,S,O),new pt(S[0],S[1])}pixelsPerMeter(d,m){return ae(1,0)*m}pixelSpaceConversion(d,m,v){const S=ae(1,d)*m,E=Kr(ae(1,45)*m,S,v);return this.pixelsPerMeter(d,m)/E}createTileMatrix(d,m,v){const S=epe(Vp(v.canonical));return C(new Float64Array(16),d.globeMatrix,S)}createInversionMatrix(d,m){const{center:v}=d,S=jF(Vp(m));return R(S,S,jr(v.lng)),L(S,S,jr(v.lat)),I(S,S,[d._pixelsPerMercatorPixel,d._pixelsPerMercatorPixel,1]),Float32Array.from(S)}pointCoordinate(d,m,v,S){return vb(d,m,v,!0)||new st(0,0)}pointCoordinate3D(d,m,v){const S=this.pointCoordinate(d,m,v,0);return[S.x,S.y,S.z]}isPointAboveHorizon(d,m){return!vb(d,m.x,m.y,!1)}farthestPixelDistance(d){const m=function(S,E){const P=S.cameraToCenterDistance,O=S._centerAltitude*E,$=S._camera,G=S._camera.forward(),ee=le([],we([],G,-P),[0,0,O]),se=S.worldSize/(2*Math.PI),ie=[0,0,-se],de=S.width/S.height,ue=Math.tan(S.fovAboveCenter),ke=we([],$.up(),ue),Oe=we([],$.right(),ue*de),De=Me([],le([],le([],G,ke),Oe)),Ke=[];let Xe;if(new Mr(ee,De).closestPointOnSphere(ie,se,Ke)){const ot=le([],Ke,ie),Nt=Se([],ot,ee);Xe=Math.cos(S.fovAboveCenter)*ce(Nt)}else{const ot=Se([],ee,ie),Nt=Se([],ie,ee);Me(Nt,Nt);const yt=ce(ot)-se;Xe=Math.sqrt(yt*(yt+2*se));const At=Math.acos(Xe/(se+yt))-Math.acos($e(G,Nt));Xe*=Math.cos(At)}return 1.01*Xe}(d,this.pixelsPerMeter(d.center.lat,d.worldSize)),v=bb(d.zoom);if(v>0){const S=R5e(d,ae(1,d.center.lat)*d.worldSize),E=d.worldSize/(2*Math.PI),P=Math.max(d.width,d.height)/d.worldSize*Math.PI;return Kr(m,S+E*(1-Math.cos(P)),Math.pow(v,10))}return m}upVector(d,m,v){return B6(m,v,d,1)}upVectorScale(d){return{metersToTile:Gf(wF(Vp(d)))}}}function U5e(x){const d=x.parallels,m=!!d&&Math.abs(d[0]+d[1])<.01;switch(x.name){case"mercator":return new z5e(x);case"equirectangular":return new Gut(x);case"naturalEarth":return new Zut(x);case"equalEarth":return new Wut(x);case"winkelTripel":return new Yut(x);case"albers":return m?new q5e(x):new Hut(x);case"lambertConformalConic":return m?new q5e(x):new Kut(x);case"globe":return new Xut(x)}throw new Error(`Invalid projection name: ${x.name}`)}const Qut=Ht.types,Jut=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function xP(x,d,m,v,S,E,P,O,$,G,ee,se,ie){const de=O?Math.min(gv,Math.round(O[0])):0,ue=O?Math.min(gv,Math.round(O[1])):0;x.emplaceBack(d,m,Math.round(32*v),Math.round(32*S),E,P,(de<<1)+($?1:0),0+(ue<<1),16*G,16*ee,256*se,256*ie)}function gP(x,d,m){x.emplaceBack(d,m)}function yP(x,d,m,v,S,E,P){x.emplaceBack(d,m,v,S,E,P)}const e7=(x,d,m,v)=>{for(let S=0;S0&&(this.iconTransitioningVertexBuffer=d.createVertexBuffer(this.iconTransitioningVertexArray,out.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=d.createVertexBuffer(this.globeExtVertexArray,rut.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||E)&&(this.zOffsetVertexBuffer=d.createVertexBuffer(this.zOffsetVertexArray,aut.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=d.createVertexBuffer(this.orientationVertexArray,iut.members,!0)),this.opacityVertexBuffer.itemSize=1),(v||S)&&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())}}Sr(Ype,"SymbolBuffers");class Xpe{constructor(d,m,v){this.layoutVertexArray=new d,this.layoutAttributes=m,this.indexArray=new v,this.segments=new bo,this.collisionVertexArray=new k6,this.collisionVertexArrayExt=new Py}upload(d){this.layoutVertexBuffer=d.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=d.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=d.createVertexBuffer(this.collisionVertexArray,lut.members,!0),this.collisionVertexBufferExt=d.createVertexBuffer(this.collisionVertexArrayExt,cut.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Sr(Xpe,"CollisionBuffers");class t7{constructor(d){this.collisionBoxArray=d.collisionBoxArray,this.zoom=d.zoom,this.overscaling=d.overscaling,this.layers=d.layers,this.layerIds=this.layers.map(P=>P.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=w([]),this.placementViewportMatrix=w([]);const m=this.layers[0]._unevaluatedLayout._values;this.worldview=d.worldview,this.localizable=d.localizable,this.textSizeData=W3(this.zoom,m["text-size"],this.worldview),this.iconSizeData=W3(this.zoom,m["icon-size"],this.worldview);const v=this.layers[0].layout,S=v.get("symbol-sort-key"),E=v.get("symbol-z-order");this.lut=d.lut,this.canOverlap=v.get("text-allow-overlap")||v.get("icon-allow-overlap")||v.get("text-ignore-placement")||v.get("icon-ignore-placement"),this.sortFeaturesByKey=E!=="viewport-y"&&S.constantOr(1)!==void 0,this.sortFeaturesByY=(E==="viewport-y"||E==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=v.get("text-writing-mode").map(P=>mm[P]),this.stateDependentLayerIds=this.layers.filter(P=>P.isStateDependent()).map(P=>P.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(v=>v.getProperty(d)!=null)}createArrays(){this.text=new Ype(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("text")||d.startsWith("symbol"))),this.icon=new Ype(new qp(this.layers,{zoom:this.zoom,lut:this.lut},d=>d.startsWith("icon")||d.startsWith("symbol"))),this.glyphOffsetArray=new M3,this.lineVertexArray=new gF,this.symbolInstances=new P6}calculateGlyphDependencies(d,m,v,S,E){for(const P of d){const O=P.codePointAt(0);if(O===void 0)break;if(m[O]=!0,S&&E&&O<=65535){const $=aP[P];$&&(m[$.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(d,m,v,S,E,P){let O=1;const $=d.getUnevaluatedProperties()._values["icon-size"],G=W3(this.zoom,$,this.worldview),ee=G3(G,m);if(G.kind!=="constant"&&G.kind!=="camera"||(O=ee.uSize),G.kind==="composite"){const{minZoom:se,maxZoom:ie}=G,de=$.possiblyEvaluate(new Ki(se,{worldview:this.worldview}),S),ue=$.possiblyEvaluate(new Ki(ie,{worldview:this.worldview}),S),ke=de.evaluate(v,{},S,E);O=ke+(ue.evaluate(v,{},S,E)-ke)*ee.uSizeT}return G.kind==="source"&&(O=$.possiblyEvaluate(new Ki(this.zoom,{worldview:this.worldview}),S).evaluate(v,{},S,E)),O*P}updateFootprints(d,m){}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);return!TF(this.activeReplacements,v)&&(this.activeReplacements=v,!0)}getResolvedImageFromTokens(d){return typeof d=="string"?Du.build(d):d}populate(d,m,v,S){const E=this.layers[0],P=E.layout,O=this.projection.name==="globe",$=P.get("text-font"),G=P.get("text-field"),ee=P.get("icon-image"),[se,ie]=P.get("icon-size-scale-range"),de=je(m.scaleFactor||1,se,ie),ue=(G.value.kind!=="constant"||G.value.value instanceof Lu&&!G.value.value.isEmpty()||G.value.value.toString().length>0)&&($.value.kind!=="constant"||$.value.value.length>0),ke=ee.value.kind!=="constant"||!!ee.value.value||Object.keys(ee.parameters).length>0,Oe=this.hasAnyAppearanceProperty("icon-image"),De=P.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!ue&&!ke&&!Oe)return;const Ke=m.iconDependencies,Xe=m.glyphDependencies,ot=m.availableImages,Nt=new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),yt=At=>{const Ft=At.id.toString();Ke.has(Ft)?Ke.get(Ft).push(At):Ke.set(Ft,[At])};for(const At of d){const{feature:Ft,id:qt,index:ns,sourceLayerIndex:Gt}=At,ds=E._featureFilter.needGeometry,js=Wt(Ft,ds);if(!E._featureFilter.filter(Nt,js,v))continue;if(ds||(js.geometry=Ot(Ft,v,S)),O&&Ft.type!==1&&v.z<=5){const Os=js.geometry,sr=.98078528056,Hs=(Fr,hr)=>$e(B6(Fr.x,Fr.y,v,1),B6(hr.x,hr.y,v,1)){if(!Os.getProperty("icon-image"))return;const sr=this.getCombinedIconPrimary(Os,Bs,js,v,ot,cs,de);sr&&yt(sr)}),Ns){const Os=$.evaluate(js,{},v).join(","),sr=P.get("text-rotation-alignment")==="map"&&P.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(mm.vertical)>=0;for(const Hs of Ns.sections)if(Hs.image){const Fr=Hs.image.getPrimary().scaleSelf(this.pixelRatio),hr=Fr.id.toString(),_r=Ke.get(hr)||[];_r.push(Fr),Ke.set(hr,_r)}else{const Fr=c2(Ns.toString()),hr=Hs.fontStack||Os,_r=Xe[hr]=Xe[hr]||{};this.calculateGlyphDependencies(Hs.text,_r,sr,this.allowVerticalPlacement,Fr)}}}if(P.get("symbol-placement")==="line"&&(this.features=function(At){const Ft={},qt={},ns=[];let Gt=0;function ds(Bs){ns.push(At[Bs]),Gt++}function js(Bs,Is,Ls){const cs=qt[Bs];return delete qt[Bs],qt[Is]=cs,ns[cs].geometry[0].pop(),ns[cs].geometry[0]=ns[cs].geometry[0].concat(Ls[0]),cs}function Ns(Bs,Is,Ls){const cs=Ft[Is];return delete Ft[Is],Ft[Bs]=cs,ns[cs].geometry[0].shift(),ns[cs].geometry[0]=Ls[0].concat(ns[cs].geometry[0]),cs}function Fs(Bs,Is,Ls){const cs=Ls?Is[0][Is[0].length-1]:Is[0][0];return`${Bs}:${cs.x}:${cs.y}`}for(let Bs=0;BsBs.geometry)}(this.features)),P.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 P.get("symbol-z-elevate")&&(this.elevationType="offset");this.elevationType!=="none"&&(this.zOffsetBuffersNeedUpload=!0),this.sortFeaturesByKey&&this.features.sort((At,Ft)=>At.sortKey-Ft.sortKey)}getCombinedIconPrimary(d,m,v,S,E,P,O){let $,G;const ee=d.getUnevaluatedProperties();if(ee._values["icon-image"].value!==void 0){const se=m.getAppearanceValueAndResolveTokens(d,"icon-image",v,S,E);$=this.getResolvedImageFromTokens(se)}else{const se=m.getValueAndResolveTokens("icon-image",v,S,E);$=this.getResolvedImageFromTokens(se)}if($){const se=ee._values["icon-size"]||m._unevaluatedLayout._values["icon-size"];G=cP($,W3(this.zoom,se,this.worldview),se,S,this.zoom,P,this.pixelRatio,O,this.worldview).iconPrimary}return G}updateAppearanceBasedIconTextures(d,m,v,S){if(!this.appearanceFeatureData||!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)return!1;const E=this.layers[0];let P=!1,O=0;const $=E.layout,[G,ee]=$.get("icon-size-scale-range"),se=je(1,G,ee);for(let ie=0;ie=0){const Oe=ke.id,De=m&&Oe!==void 0?m[String(Oe)]:void 0,Ke={type:"Point",id:ke.id,properties:ke.properties,geometry:[]},Xe=this.layers[0].appearances&&this.layers[0].appearances.find(ot=>ot.isActive({globals:S,feature:Ke,canonical:d,featureState:De}));if(ke.activeAppearance===Xe){O+=de.numIconVertices;continue}if(Xe){ke.activeAppearance=Xe;const ot=this.getCombinedIconPrimary(Xe,E,Ke,d,v,{sortKey:void 0,text:void 0,icon:null,index:de.featureIndex,sourceLayerIndex:de.featureIndex,geometry:[],properties:ke.properties,type:"Point",id:ke.id},se);if(!ot)continue;const Nt=ot.toString(),yt=this.iconAtlasPositions&&this.iconAtlasPositions.get(Nt);if(yt){const At=E.getAppearanceValueAndResolveTokens(Xe,"icon-offset",Ke,d,v),Ft=At&&Array.isArray(At)?At:[0,0];let qt=HF(yt,void 0,Ft,E.layout.get("icon-anchor").evaluate(Ke,{},d));const ns=E.getAppearanceValueAndResolveTokens(Xe,"icon-rotate",Ke,d,v),Gt=typeof ns=="number"?ns:0,ds=yt.sdf,js=E.layout.get("icon-text-fit").constantOr("none");js!=="none"&&ke.textShaping&&ke.iconTextFitPadding&&ke.fontScale&&(qt=qpe(qt,ke.textShaping,js,ke.iconTextFitPadding,Ft,ke.fontScale));const Ns=this.calculateEffectiveAppearanceIconSize(Xe,S.zoom,Ke,d,v,se),Fs=0,Bs=1+(Math.min(gv,Math.round(Ns*fg))<<1),Is=Wpe(qt,Gt,ds,js!=="none",se);ke.isUsingAppearanceVertexData||(ke.isUsingAppearanceVertexData=!0,ke.layoutBasedVertexData=this.icon.getIconVertexData(O,de.numIconVertices));for(let cs=0;cs0&&(this.icon.updateIconVertexData(O,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(O+3,0,0,0,0,0,0,0,0,0,0,0,0),P=!0),O+=de.numIconVertices,ke.activeAppearance=null;else if(ke.isUsingAppearanceVertexData){const Nt=ke.layoutBasedVertexData.length/12;for(let yt=0;yt0||ie>0,Oe=de>0,De=this.elevationFeatures[$.elevationFeatureIndex];if(De){const Ke=new pt($.tileAnchorX,$.tileAnchorY),Xe=.075+De.pointElevation(Ke);$.zOffset!==Xe&&(m=!0,$.zOffset=Xe),Xe!==0&&(this.hasAnyZOffset=!0);const ot=De.computeSlopeNormal(Ke,S),Nt=Ds(He(),ne(0,0,1),ot);Ve(G,G,Nt),Ve(ee,ee,Nt),G[2]*=v,ee[2]*=v,G[0]===1&&G[1]===0&&G[2]===0&&ee[0]===0&&ee[1]===1&&ee[2]===0||(E=E||ke,P=P||Oe)}if(ke&&(e7(this.text.orientationVertexArray,se,G,ee),e7(this.text.orientationVertexArray,ie,G,ee)),Oe){const{placedIconSymbolIndex:Ke,verticalPlacedIconSymbolIndex:Xe}=$;Ke>=0&&e7(this.icon.orientationVertexArray,de,G,ee),Xe>=0&&e7(this.icon.orientationVertexArray,ue,G,ee)}}E||(this.text.orientationVertexArray=void 0),P||(this.icon.orientationVertexArray=void 0),m&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const d=(E,P,O)=>{v+=P,v>E.length&&E.resize(v);for(let $=-P;$<0;$++)E.emplace($+v,O)},m=(E,P,O)=>{S+=P,S>E.length&&E.resize(S);for(let $=-P;$<0;$++)E.emplace($+S,O)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let v=0,S=0;for(let E=0;E0;if((O>0||$>0)&&(d(this.text.zOffsetVertexArray,O,ee),d(this.text.zOffsetVertexArray,$,ee)),se){const{placedIconSymbolIndex:ie,verticalPlacedIconSymbolIndex:de}=P;ie>=0&&m(this.icon.zOffsetVertexArray,G,ee),de>=0&&m(this.icon.zOffsetVertexArray,P.numVerticalIconVertices,ee)}}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,v,S,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(P=>P.appearances&&P.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,v,S){return!!(d&&m&&v)&&!(!this.icon.layoutVertexArray||this.icon.layoutVertexArray.length===0)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(d,m,v,S)&&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=U5e(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(d,m){const v=this.lineVertexArray.length;if(d.segment!==void 0)for(const{x:S,y:E}of m)this.lineVertexArray.emplaceBack(S,E);return{lineStartIndex:v,lineLength:this.lineVertexArray.length-v}}addSymbols(d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke,Oe,De,Ke){const Xe=d.indexArray,ot=d.layoutVertexArray,Nt=d.globeExtVertexArray,yt=d.segments.prepareSegment(4*Ke,ot,Xe,this.canOverlap?P.sortKey:void 0),At=this.glyphOffsetArray.length,Ft=yt.vertexLength,qt=this.allowVerticalPlacement&&O===mm.vertical?Math.PI/2:0,ns=P.text&&P.text.sections;for(let js=0;js=0?m.rightJustifiedTextSymbolIndex:m.centerJustifiedTextSymbolIndex>=0?m.centerJustifiedTextSymbolIndex:m.leftJustifiedTextSymbolIndex>=0?m.leftJustifiedTextSymbolIndex:m.verticalPlacedTextSymbolIndex>=0?m.verticalPlacedTextSymbolIndex:S),P=Upe(this.textSizeData,d,E)/Sc;return this.tilePixelRatio*P}getSymbolInstanceIconSize(d,m,v){const S=this.icon.placedSymbolArray.get(v),E=Upe(this.iconSizeData,d,S);return this.tilePixelRatio*E}_commitDebugCollisionVertexUpdate(d,m,v,S){d.emplaceBack(m,-v,-v,S),d.emplaceBack(m,v,-v,S),d.emplaceBack(m,v,v,S),d.emplaceBack(m,-v,v,S)}_updateTextDebugCollisionBoxes(d,m,v,S,E,P,O){for(let $=S;$0}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 v=d.placedSymbolArray.get(m),S=v.vertexStartIndex+4*v.numGlyphs;for(let E=v.vertexStartIndex;ES[O]-S[$]||E[$]-E[O]),P}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 v=this.sortKeyRanges[this.sortKeyRanges.length-1];v&&v.sortKey===m?v.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 v=this.symbolInstances.get(m);this.featureSortOrder.push(v.featureIndex);const{rightJustifiedTextSymbolIndex:S,centerJustifiedTextSymbolIndex:E,leftJustifiedTextSymbolIndex:P,verticalPlacedTextSymbolIndex:O,placedIconSymbolIndex:$,verticalPlacedIconSymbolIndex:G}=v;S>=0&&this.addIndicesForPlacedSymbol(this.text,S),E>=0&&E!==S&&this.addIndicesForPlacedSymbol(this.text,E),P>=0&&P!==E&&P!==S&&this.addIndicesForPlacedSymbol(this.text,P),O>=0&&this.addIndicesForPlacedSymbol(this.text,O),$>=0&&this.addIndicesForPlacedSymbol(this.icon,$),G>=0&&this.addIndicesForPlacedSymbol(this.icon,G)}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 v;return this.elevationFeatures&&mv in x?String(x[v]):"")}let H5e,W5e,Qpe;Sr(t7,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),t7.addDynamicAttributes=X3;class G5e{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}}Sr(G5e,"FormatSectionOverride",{omit:["defaultValue"]});const Jpe=()=>Qpe||(Qpe={layout:H5e||(H5e=new Eo({"symbol-placement":new Xs(Kt.layout_symbol["symbol-placement"]),"symbol-spacing":new Xs(Kt.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Xs(Kt.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new nr(Kt.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Xs(Kt.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Xs(Kt.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Xs(Kt.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Xs(Kt.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Xs(Kt.layout_symbol["icon-ignore-placement"]),"icon-optional":new Xs(Kt.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Xs(Kt.layout_symbol["icon-rotation-alignment"]),"icon-size":new nr(Kt.layout_symbol["icon-size"]),"icon-size-scale-range":new Xs(Kt.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new nr(Kt.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new nr(Kt.layout_symbol["icon-text-fit-padding"]),"icon-image":new nr(Kt.layout_symbol["icon-image"]),"icon-image-use-theme":new Xs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new nr(Kt.layout_symbol["icon-rotate"]),"icon-padding":new Xs(Kt.layout_symbol["icon-padding"]),"icon-keep-upright":new Xs(Kt.layout_symbol["icon-keep-upright"]),"icon-offset":new nr(Kt.layout_symbol["icon-offset"]),"icon-anchor":new nr(Kt.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Xs(Kt.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Xs(Kt.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Xs(Kt.layout_symbol["text-rotation-alignment"]),"text-field":new nr(Kt.layout_symbol["text-field"]),"text-font":new nr(Kt.layout_symbol["text-font"]),"text-size":new nr(Kt.layout_symbol["text-size"]),"text-size-scale-range":new Xs(Kt.layout_symbol["text-size-scale-range"]),"text-max-width":new nr(Kt.layout_symbol["text-max-width"]),"text-line-height":new nr(Kt.layout_symbol["text-line-height"]),"text-letter-spacing":new nr(Kt.layout_symbol["text-letter-spacing"]),"text-justify":new nr(Kt.layout_symbol["text-justify"]),"text-radial-offset":new nr(Kt.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Xs(Kt.layout_symbol["text-variable-anchor"]),"text-anchor":new nr(Kt.layout_symbol["text-anchor"]),"text-max-angle":new Xs(Kt.layout_symbol["text-max-angle"]),"text-writing-mode":new Xs(Kt.layout_symbol["text-writing-mode"]),"text-rotate":new nr(Kt.layout_symbol["text-rotate"]),"text-padding":new Xs(Kt.layout_symbol["text-padding"]),"text-keep-upright":new Xs(Kt.layout_symbol["text-keep-upright"]),"text-transform":new nr(Kt.layout_symbol["text-transform"]),"text-offset":new nr(Kt.layout_symbol["text-offset"]),"text-allow-overlap":new Xs(Kt.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Xs(Kt.layout_symbol["text-ignore-placement"]),"text-optional":new Xs(Kt.layout_symbol["text-optional"]),visibility:new Xs(Kt.layout_symbol.visibility)})),paint:W5e||(W5e=new Eo({"icon-opacity":new nr(Kt.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new nr(Kt.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new nr(Kt.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new nr(Kt.paint_symbol["text-emissive-strength"]),"icon-color":new nr(Kt.paint_symbol["icon-color"]),"icon-halo-color":new nr(Kt.paint_symbol["icon-halo-color"]),"icon-halo-width":new nr(Kt.paint_symbol["icon-halo-width"]),"icon-halo-blur":new nr(Kt.paint_symbol["icon-halo-blur"]),"icon-translate":new Xs(Kt.paint_symbol["icon-translate"]),"icon-translate-anchor":new Xs(Kt.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Xs(Kt.paint_symbol["icon-image-cross-fade"]),"text-opacity":new nr(Kt.paint_symbol["text-opacity"]),"text-occlusion-opacity":new nr(Kt.paint_symbol["text-occlusion-opacity"]),"text-color":new nr(Kt.paint_symbol["text-color"],{runtimeType:lh,getOverride:x=>x.textColor,hasOverride:x=>!!x.textColor}),"text-halo-color":new nr(Kt.paint_symbol["text-halo-color"]),"text-halo-width":new nr(Kt.paint_symbol["text-halo-width"]),"text-halo-blur":new nr(Kt.paint_symbol["text-halo-blur"]),"text-translate":new Xs(Kt.paint_symbol["text-translate"]),"text-translate-anchor":new Xs(Kt.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Xs(Kt.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Xs(Kt.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Xs(Kt.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Xs(Kt.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new nr(Kt.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},Qpe);class s7 extends Fu{constructor(d,m,v,S){super(d,Jpe(),m,v,S,d.layout?d.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=w([]),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(S=>{S.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 v=this.layout.get("text-writing-mode");if(v){const S=[];for(const E of v)S.indexOf(E)<0&&S.push(E);this.layout._values["text-writing-mode"]=S}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getColorAdjustmentMatrix(d,m,v,S){return this._saturation===d&&this._contrast===m&&this._brightnessMin===v&&this._brightnessMax===S||(this._colorAdjustmentMatrix=function(E,P,O,$){E=lo(E),P=Ea(P);const G=_(),ee=E/3,se=1-2*ee,ie=[se,ee,ee,0,ee,se,ee,0,ee,ee,se,0,0,0,0,1],de=.5-.5*P,ue=$-O;return C(G,[ue,0,0,0,0,ue,0,0,0,0,ue,0,O,O,O,1],[P,0,0,0,0,P,0,0,0,0,P,0,de,de,de,1]),C(G,G,ie),G}(d,m,v,S),this._saturation=d,this._contrast=m,this._brightnessMin=v,this._brightnessMax=S),this._colorAdjustmentMatrix}getValueAndResolveTokens(d,m,v,S){const E=this.layout.get(d).evaluate(m,{},v,S),P=this._unevaluatedLayout._values[d];return P.isDataDriven()||o2(P.value)||!E?E:V5e(m.properties,E)}getAppearanceValueAndResolveTokens(d,m,v,S,E){const P=d.getProperty(m);if(!P)return;const O=P.evaluate(v,{},S,E),$=d.getUnevaluatedProperties()._values[m];return $.isDataDriven()||o2($.value)||!O||typeof O!="string"?O:V5e(v.properties,O)}createBucket(d){return new t7(d)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const d of Jpe().paint.overridableProperties){if(!s7.hasPaintOverride(this.layout,d))continue;const m=this.paint.get(d),v=new G5e(m),S=new n3(v,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 lb("source",S):new nv("composite",S,m.value.zoomStops,m.value.interpolationType),this.paint._values[d]=new iv(m.property,E,m.parameters)}}_handleOverridablePaintPropertyUpdate(d,m,v){return!(!this.layout||m.isDataDriven()||v.isDataDriven())&&s7.hasPaintOverride(this.layout,d)}static hasPaintOverride(d,m){const v=d.get("text-field"),S=Jpe().paint.properties[m];let E=!1;const P=O=>{for(const $ of O)if(S.overrides&&S.overrides.hasOverride($))return void(E=!0)};if(v.value.kind==="constant"&&v.value.value instanceof Lu)P(v.value.value.sections);else if(v.value.kind==="source"){const O=G=>{E||(G instanceof Jx&&kc(G.value)===Ww?P(G.value.sections):G instanceof zf?P(G.sections):G.eachChild(O))},$=v.value;$._styleExpression&&O($._styleExpression.expression)}return E}getProgramIds(){return["symbol"]}getDefaultProgramParams(d,m,v){return{config:new Ly(this,{zoom:m,lut:v}),overrideFog:!1}}hasElevation(){return this.layout&&this.layout.get("symbol-elevation-reference")==="hd-road-markup"}}let K5e,Z5e,Y5e,X5e;var efe=ua([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function r7(x,d,m,v,S,E,P,O){const $=[x,d,1,m,v,1,S,E,1],G=[P,O,1],ee=g([],$),[se,ie,de]=me(G,G,ee);return b($,$,[se,0,0,0,ie,0,0,0,de])}function Q5e(x,d,m,v,S,E,P,O){const $=function(G,ee,se,ie,de,ue,ke,Oe){const De=r7(0,0,1,0,1,1,0,1),Ke=r7(G,ee,se,ie,de,ue,ke,Oe);return b(Ke,Ke,g([],De))}(x,d,m,v,S,E,P,O);return[$[2]/$[8]/tr,$[5]/$[8]/tr]}function n7(x){return[x[0],Math.min(Math.max(x[1],-be),be)]}class J5e extends Ms{constructor(d,m,v,S){super(),this.id=d,this.dispatcher=v,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(S),this.options=m,this._dirty=!1}load(d,m){if(this._loaded=m||!1,this.fire(new Ym("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return d&&(this.coordinates=d),this._loaded=!0,void this._finishLoading();this._imageRequest=yy(this.map._requestManager.transformRequest(this.url,Zx.Image),(v,S)=>{this._imageRequest=null,this._loaded=!0,v?this.fire(new vy(v)):S&&(this.image=S instanceof HTMLImageElement?Fl.getImageData(S):S,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 sP(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 Ym("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 sP||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],v=d[0][1];for(const E of d)E[1]>v&&(v=E[1]),E[1]be?this.onNorthPole=!0:S<-be&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const E=d.map(st.fromLngLat);this.tileID=function(P){let O=1/0,$=1/0,G=-1/0,ee=-1/0;for(const ke of P)O=Math.min(O,ke.x),$=Math.min($,ke.y),G=Math.max(G,ke.x),ee=Math.max(ee,ke.y);const se=Math.max(G-O,ee-$),ie=Math.max(0,Math.floor(-Math.log2(se))),de=Math.pow(2,ie);let ue=Math.floor((O+G)/2*de);return ue>1&&(ue-=1),new Oi(ie,ue,Math.floor(($+ee)/2*de))}(E),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Ym("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof sP||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(d){for(const De in this.tiles){const Ke=this.tiles[De];Ke.state!=="loaded"&&(Ke.state="loaded",Ke.texture=this.texture)}if(this._boundsArray||this.onNorthPole||this.onSouthPole||this._unsupportedCoords)return;const m=uP(new Oi(0,0,0),this.map.transform.projection),v=[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(De){const Ke=De[1].x-De[0].x,Xe=De[1].y-De[0].y,ot=De[2].x-De[1].x,Nt=De[2].y-De[1].y,yt=De[3].x-De[2].x,At=De[3].y-De[2].y,Ft=De[0].x-De[3].x,qt=De[0].y-De[3].y,ns=Ke*Nt-ot*Xe,Gt=ot*At-yt*Nt,ds=yt*qt-Ft*At,js=Ft*Xe-Ke*qt;return ns>0&&Gt>0&&ds>0&&js>0||ns<0&&Gt<0&&ds<0&&js<0}(v))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const S=uP(this.tileID,this.map.transform.projection),[E,P,O,$]=this.coordinates.map(De=>{const Ke=S.projection.project(De[0],De[1]);return F5e(S,Ke)._round()});this.perspectiveTransform=Q5e(E.x,E.y,P.x,P.y,O.x,O.y,$.x,$.y);const G=this._boundsArray=new hb;G.emplaceBack(E.x,E.y,0,0),G.emplaceBack(P.x,P.y,tr,0),G.emplaceBack($.x,$.y,0,tr),G.emplaceBack(O.x,O.y,tr,tr),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=d.createVertexBuffer(G,efe.members),this.boundsSegments=bo.simpleSegment(0,0,4,2);const ee=[],se=[n7((ie=this.coordinates)[0]),n7(ie[1]),n7(ie[2]),n7(ie[3])];var ie;const[de,ue,ke,Oe]=function(De){let Ke=De[0][0],Xe=Ke,ot=De[0][1],Nt=ot;for(let yt=1;ytXe&&(Xe=De[yt][0]),De[yt][1]Nt&&(Nt=De[yt][1]);return[Ke,ot,Xe-Ke,Nt-ot]}(se);{const De=new hb,[Ke,Xe,ot,Nt]=function(Is){let Ls=Is[0].x,cs=Ls,as=Is[0].y,Os=as;for(let sr=1;srcs&&(cs=Is[sr].x),Is[sr].yOs&&(Os=Is[sr].y);return[Ls,as,cs-Ls,Os-as]}(v),yt=Is=>[(Is.x-Ke)/ot,(Is.y-Xe)/Nt],[At,Ft,qt,ns]=v.map(yt),Gt=function(Is,Ls,cs,as,Os,sr,Hs,Fr){const hr=r7(0,0,1,0,1,1,0,1);return b(hr,hr,g([],r7(Is,Ls,cs,as,Os,sr,Hs,Fr)))}(At[0],At[1],Ft[0],Ft[1],qt[0],qt[1],ns[0],ns[1]);this.elevatedGlobePerspectiveTransform=Q5e(At[0],At[1],Ft[0],Ft[1],qt[0],qt[1],ns[0],ns[1]);const ds=(Is,Ls)=>{ee.push(Is.lng);const cs=Math.round((Is.lng-de)/ke*tr),as=Math.round((Is.lat-ue)/Oe*tr),Os=yt(Ls),sr=me([],[Os[0],Os[1],1],Gt),Hs=Math.round(sr[0]/sr[2]*tr),Fr=Math.round(sr[1]/sr[2]*tr);De.emplaceBack(cs,as,Hs,Fr)},js=v[3].x-v[0].x,Ns=v[3].y-v[0].y,Fs=v[2].x-v[1].x,Bs=v[2].y-v[1].y;for(let Is=0;Is<65;Is++){const Ls=Is/64,cs=[v[0].x+Ls*js,v[0].y+Ls*Ns],as=[v[1].x+Ls*Fs,v[1].y+Ls*Bs],Os=as[0]-cs[0],sr=as[1]-cs[1];for(let Hs=0;Hs<65;Hs++){const Fr=Hs/64,hr={x:cs[0]+Os*Fr,y:cs[1]+sr*Fr};ds(m.projection.unproject(hr.x,hr.y),hr)}}this.elevatedGlobeVertexBuffer=d.createVertexBuffer(De,efe.members)}{this.maxLongitudeTriangleSize=0;let De=[],Ke=new zl;const Xe=(ot,Nt,yt)=>{Ke.emplaceBack(ot,Nt,yt);const At=ee[ot],Ft=ee[Nt],qt=ee[yt],ns=Math.min(Math.min(At,Ft),qt),Gt=Math.max(Math.max(At,Ft),qt)-ns;Gt>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=Gt),De.push(ns+Gt/2)};for(let ot=0;ot<64;ot++)for(let Nt=0;Nt<64;Nt++){const yt=65*ot+Nt,At=yt+1,Ft=yt+65,qt=Ft+1;Xe(yt,Ft,At),Xe(At,Ft,qt)}[De,Ke]=function(ot,Nt){const yt=Array.from({length:ot.length},(qt,ns)=>ns);yt.sort((qt,ns)=>ot[qt]-ot[ns]);const At=[],Ft=new zl;for(let qt=0;qt{P.segments.push({vertexOffset:0,primitiveOffset:se,vertexLength:m.segments[0].vertexLength,primitiveLength:ie,sortKey:void 0,vaos:{}})},$=.51*this.maxLongitudeTriangleSize;if(Math.abs(v[0]-S)<=$){const se=oo(v,0,v.length,S+$);return se===v.length||O(se,dl(v,se+1,v.length,S+360-$)-se),P}Str?S-tr:S,new pt(Math.trunc(S),Math.trunc(v[m+1]))}translationForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+4],v[m+5],v[m+6]]}rotationScaleForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+10],v[m+11],v[m+12],v[m+13],v[m+14],v[m+15]]}transformForInstance(d){const m=16*d,v=this.instancedDataArray.float32;return[v[m+7],v[m+8],v[m+9],v[m+4],v[m+10],v[m+11],v[m+12],v[m+5],v[m+13],v[m+14],v[m+15],v[m+6],0,0,0,1]}}class rfe{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,v,S){}populate(d,m,v,S){this.tileToMeter=Ue(v);const E=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:P,id:O,index:$,sourceLayerIndex:G}of d){const ee=O??(P.properties&&P.properties.hasOwnProperty("id")?P.properties.id:void 0),se=Wt(P,E);if(!this.layers[0]._featureFilter.filter(new Ki(this.zoom,{worldview:this.worldview,activeFloors:m.activeFloors}),se,v))continue;const ie={id:ee,sourceLayerIndex:G,index:$,geometry:E?se.geometry:Ot(P,v,S),properties:P.properties,type:P.type,patterns:{}},de=this.addFeature(ie,ie.geometry,se);de&&m.featureIndex.insert(P,ie.geometry,$,G,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 v=0;for(const S of this.modelUris){const E=d.getModel(S,m);if(!E)continue;const P=this.instancesPerModel[S];if(P){const O=.5*Ne(E.aabb.max,E.aabb.min)*P.maxScale+P.maxXYTranslationDistance,$=Math.min(tr,Math.max(O/this.tileToMeter,tr/32));v=Math.max($,v)}}return v}update(d,m,v,S){for(const E in this.instancesPerModel){const P=this.instancesPerModel[E];for(const O in d)P.idToFeaturesIndex.hasOwnProperty(O)&&(this.evaluate(P.features[P.idToFeaturesIndex[O]],d[O],P,!0),this.uploaded=!1)}this.maxHeight=0}updateZoomBasedPaintProperties(){if(!this.hasZoomDependentProperties)return!1;let d=!1;for(const m in this.instancesPerModel){const v=this.instancesPerModel[m];for(const S of v.features){const E=this.layers[0],P=S.feature,O=this.canonical,$=E.paint.get("model-rotation").evaluate(P,{},O),G=E.paint.get("model-scale").evaluate(P,{},O),ee=E.paint.get("model-translation").evaluate(P,{},O);et(S.rotation,$)&&et(S.scale,G)&&et(S.translation,ee)||(this.evaluate(S,S.featureStates,v,!0),d=!0)}}return d}updateReplacement(d,m,v,S){if(m.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=m.updateTime;const E=m.getReplacementRegionsForTile(d.toUnwrapped(),!0);if(TF(this.activeReplacements,E))return!1;this.activeReplacements=E;let P=!1;for(const O in this.instancesPerModel){const $=this.instancesPerModel[O],G=$.instancedDataArray;for(const ee of $.features){const se=ee.instancedDataOffset,ie=ee.instancedDataCount;for(let de=0;detr;ke=Oe?ke-tr:ke;const De=Math.floor(ke),Ke=Math.floor(G.float32[ue+1]);let Xe=!1;for(const ot of this.activeReplacements)if(!ZCe(ot,v,oMe.Model,S)&&!(ot.min.x>De||De>ot.max.x||ot.min.y>Ke||Ke>ot.max.y)&&(Xe=e3e(JCe(De,Ke,d.canonical,ot.footprintTileId.canonical),ot.footprint),Xe))break;G.float32[ue]=Xe?ke+tr:ke,P=P||Xe!==Oe}}}return P}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 v=this.instancesPerModel[m];v.instancedDataArray.length<0||v.instancedDataArray.length===0||(v.instancedDataBuffer?v.instancedDataBuffer.updateData(v.instancedDataArray):v.instancedDataBuffer=d.createVertexBuffer(v.instancedDataArray,kdt.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(d){for(const v in this.instancesPerModel){const S=this.instancesPerModel[v];S.instancedDataArray.length!==0&&S.instancedDataBuffer&&S.instancedDataBuffer.destroy()}const m=this.layers[0].modelManager;if(d&&m&&this.modelUris&&this.modelsRequested)for(const v of this.modelUris)m.removeModel(v,"",!0)}addFeature(d,m,v){const S=this.layers[0],E=S.layout.get("model-id").evaluate(v,{},this.canonical);if(!E)return fr(`modelId is not evaluated for layer ${S.id} and it is not going to get rendered.`),E;(sfe(E,!1)||this.styleDefinedModelURLs[E]!==void 0)&&(this.modelUris.includes(E)||this.modelUris.push(E)),this.instancesPerModel[E]||(this.instancesPerModel[E]=new cMe);const P=this.instancesPerModel[E],O=P.instancedDataArray,$=new lMe(v,O.length);for(const G of m)for(const ee of G){if(ee.x<0||ee.x>=tr||ee.y<0||ee.y>=tr)continue;if(this.lookupDim!==0){const ie=(this.lookupDim-1)/tr,de=this.lookupDim*(ee.y*ie|0)+ee.x*ie|0;if(this.lookup){if(this.lookup[de]!==0)continue;this.lookup[de]=1}}this.instanceCount++;const se=O.length;O.resize(se+1),P.instancesEvaluatedElevation.push(0),O.float32[16*se]=ee.x,O.float32[16*se+1]=ee.y}return $.instancedDataCount=P.instancedDataArray.length-$.instancedDataOffset,$.instancedDataCount>0&&(d.id&&(P.idToFeaturesIndex[d.id]=P.features.length),P.features.push($),this.evaluate($,{},P,!1)),E}getModelUris(){return this.modelUris}evaluate(d,m,v,S){const E=this.layers[0],P=d.feature,O=this.canonical,$=d.rotation=E.paint.get("model-rotation").evaluate(P,m,O),G=d.scale=E.paint.get("model-scale").evaluate(P,m,O),ee=d.translation=E.paint.get("model-translation").evaluate(P,m,O),se=Object.assign({},E.paint.get("model-color").evaluate(P,m,O));se.a=E.paint.get("model-color-mix-intensity").evaluate(P,m,O);const ie=[];this.maxVerticalOffset0?Math.sqrt(de):0;v.maxScale=Math.max(Math.max(v.maxScale,G[0]),Math.max(G[1],G[2])),v.maxXYTranslationDistance=Math.max(v.maxXYTranslationDistance,ue),this.maxScale=Math.max(Math.max(this.maxScale,G[0]),Math.max(G[1],G[2])),B3e(ie,$,G);const ke=Math.round(100*se.a)+se.b/1.05;for(let Oe=0;Oe10?this.tileToMeter:Ue(O,Nt)),Xe[Ke+4]=ee[0],Xe[Ke+5]=ee[1],Xe[Ke+6]=ee[2]+ot,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],v.instancesEvaluatedElevation[De]=ee[2]}}}let dMe,uMe;Sr(rfe,"ModelBucket",{omit:["layers"]}),Sr(cMe,"PerModelAttributes"),Sr(lMe,"ModelFeature");class Q3{constructor(d,m,v){this._demTile=d,this._dem=this._demTile.dem,this._scale=m,this._offset=v}static create(d,m,v){const S=v||d.findDEMTileFor(m);if(!S||!S.dem)return;const E=S.dem,P=S.tileID,O=1<G.fqid),this.stateDependentLayerIds=this.layers.filter(G=>G.isStateDependent()).map(G=>G.id),this.modelTraits|=U3.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,S&&(this.modelTraits|=U3.HasMapboxMeshFeatures),E&&(this.modelTraits|=U3.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=P,this.worldview=$,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const G of m)this.nodesInfo.push(new fMe(G)),mMe(G,O.featureIndexArray.length,O.grid),O.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,O.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(d,m){for(const v of this.getNodesInfo()){const S=v.node;S.footprint&&m.push({footprint:S.footprint,id:d})}}updateAppearances(d,m,v,S){}update(d){const m=Object.keys(d).length!==0;if(m&&!this.stateDependentLayers.length)return;const v=m?this.stateDependentLayers:this.layers;if(!ir(d,this.states))for(const S of v)this.evaluate(S,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 v of m){const S=v.node;this.uploaded?this.updatePbrBuffer(S):Mpe(S,d,!0)}for(const v of m)$F(v.node);this.uploaded=!0,this.needsUpload=!1}updatePbrBuffer(d){let m=!1;if(!d.meshes)return m;for(const v of d.meshes)v.pbrBuffer&&(v.pbrBuffer.updateData(v.featureArray),m=!0);return m}needsReEvaluation(d,m,v){const S=d.transform.projectionOptions,E=d.style.getBrightness(),P=this.brightness!==E;if(!this.uploaded||this.dirty||S.name!==this.projection.name||vP(v.paint.get("model-color").value,P)||vP(v.paint.get("model-color-mix-intensity").value,P)||vP(v.paint.get("model-roughness").value,P)||vP(v.paint.get("model-emissive-strength").value,P)||vP(v.paint.get("model-height-based-emissive-strength-multiplier").value,P)){this.projection=S,this.brightness=E;const O=this.getNodesInfo();for(const $ of O)$.state=null;return!0}return!1}evaluateTransform(d,m){if(d.transform.zoom===this.zoom)return;this.zoom=d.transform.zoom;const v=this.getNodesInfo(),S=this.id.canonical;for(const E of v){const P=E.feature;E.evaluatedTranslation=m.paint.get("model-translation").evaluate(P,{},S),E.evaluatedScale=m.paint.get("model-scale").evaluate(P,{},S)}}evaluate(d,m){const v=this.getNodesInfo();for(const S of v){if(!S.node.meshes)continue;const E=S.feature,P=m&&m[E.id];if(ir(P,S.state))continue;S.state=structuredClone(P);const O=S.node.meshes&&S.node.meshes[0].featureData,$=S.evaluatedColor[2],G=S.evaluatedRMEA[2],ee=this.id.canonical;if(S.hasTranslucentParts=!1,O){for(let se=0;se=yt)continue;const Is=nfe[Bs],Ls=Math.abs(Is);Ls>Gt&&(ns=Is,Gt=Ls,ds=Fs,js=Ns)}if(Gt>.1){const Ns=1-(yt+.5*Math.abs(ds*js))/ue;let Fs=m._dem.get(Ft,At)+ns*Ns;const Bs=m._dem.get(Ft+ds,At+js),Is=m._dem.get(Ft-ds,At-js,!0);(Fs-Bs)*(Fs-Is)>0&&(Fs=(Bs+Is)/2),nfe[qt]=m._dem.set(Ft,At,Fs),T2[qt]=yt}}}}}O&&(m._demTile.needsDEMTextureUpload=!0,m._dem._timestamp=Fl.now())}setFilter(d){this.filter=d?m3(d):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(d=>this.filter.filter(new Ki(this.id.overscaledZ,{worldview:this.worldview}),d.feature,this.id.canonical)):this.nodesInfo}destroy(){const d=this.getNodesInfo();for(const m of d)$F(m.node),Tpe(m.node)}isEmpty(){return!this.nodesInfo.length}updateReplacement(d,m){if(m.updateTime===this.replacementUpdateTime)return;this.replacementUpdateTime=m.updateTime;const v=m.getReplacementRegionsForTile(d.toUnwrapped());for(const S of this.getNodesInfo()){const E=S.node.footprint;S.hiddenByReplacement=!!E&&!v.find(P=>P.footprint===E)}}getHeightAtTileCoord(d,m){const v=[],S=[0,0,0],E=w([]);for(const P of this.getNodesInfo()){const O=P.node.meshes[0],$=O.transformedAabb;if(d<$.min[0]||m<$.min[1]||d>$.max[0]||m>$.max[1])continue;if(P.node.hidden===!0)return{height:1/0,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};N(E,P.node.globalMatrix),S[0]=d,S[1]=m,ft(S,S,E);const G=(S[0]-O.aabb.min[0])/(O.aabb.max[0]-O.aabb.min[0])*S2|0,ee=Math.min(63,(S[1]-O.aabb.min[1])/(O.aabb.max[1]-O.aabb.min[1])*S2|0)*S2+Math.min(63,G),se=O.heightmap[ee];if(!(se<0&&P.node.footprint))return P.hiddenByReplacement?void 0:{height:se,maxHeight:P.feature.properties.height,hidden:!1,verticalScale:P.evaluatedScale[2]};if(P.node.footprint.grid.query(new pt(d,m),new pt(d,m),v),v.length>0)return{height:void 0,maxHeight:P.feature.properties.height,hidden:P.hiddenByReplacement,verticalScale:P.evaluatedScale[2]}}}}function vP(x,d){return x instanceof lb&&!x.isLightConstant&&d}function rht(x,d,m,v,S,E,P,O){let $=(61440&d|(61440&d)>>4)>>8,G=(3840&d|(3840&d)>>4)>>4,ee=240&d|(240&d)>>4;m[3]>0&&($=Kr($,255*m[0],m[3]),G=Kr(G,255*m[1],m[3]),ee=Kr(ee,255*m[2],m[3]));const se=$<<8|G,ie=ee<<8|Math.floor(255*v[3]),de=function(yt){const At=je(yt,0,2);return Math.min(Math.round(.5*At*255),255)}(v[2])<<8|15*v[0]<<4|15*v[1],ue=je(S[0],0,1),ke=je(S[1],0,1),Oe=je(S[2],0,1),De=je(S[3],0,1);let Ke,Xe,ot,Nt;if(ue!==ke&&P!==E&&ke!==ue){const yt=P-E;Xe=1/(yt*(ke-ue)),ot=-(E+yt*ue)/(yt*(ke-ue));const At=je(S[4],-1,1);Nt=Math.pow(10,At),Ke=255*Oe<<8|255*De}else Ke=65535,Xe=0,ot=1,Nt=1;if(x.emplaceBack(se,ie,de,Ke,Xe,ot,Nt),O){const yt=O.length;O.clear();for(let At=0;At>16&65535,ee=E?$>>16&65535:65535&$,se=(15&ee)<8?15&ee:0,ie=x.evaluatedRMEA[se],de=x.evaluatedColor[se],ue=x.emissionHeightBasedParams[se];let ke;if(O&&se===2&&v.lights&&(ke=new N3,ke.resize(10*v.lights.length)),rht(P.featureArray,G,de,ie,ue,P.aabb.min[2],P.aabb.max[2],ke),ke&&O){O=!1;const Oe=v.meshes[v.lightMeshIndex];Oe.featureArray=ke,Oe.featureArray._trim()}}P.featureArray._trim(),S++}}Sr(i7,"Tiled3dModelBucket",{omit:["layers"]}),Sr(fMe,"Tiled3dModelFeature");const aht=["id","tile","layer","source","sourceLayer","state"];class A2{constructor(d,m,v,S,E){this.type="Feature",this._vectorTileFeature=d,this._z=m,this._x=v,this._y=S,this.properties=d?d.properties:{},this.id=E}clone(){const d=new A2(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 aht)this[m]!==void 0&&(d[m]=this[m]);return d}}class E2 extends Ms{constructor(d,m,v,S){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 v=this._options.models[m],S=this._modelsInfo.get(m);if(S){const E=S.model;E.position=v.position!=null?new y(v.position[0],v.position[1]):new y(0,0),E.orientation=v.orientation!=null?v.orientation:[0,0,0],S.modelSpec=v,E2.applyModelSpecification(E,v),E.computeBoundsAndApplyParent(),this.models.push(E)}else{const E=O3e(this.map._requestManager.transformRequest(v.uri,Zx.Model).url).then(P=>{if(!P)return;const O=Epe(P),$=new $3e(m,v.uri,v.position,v.orientation,O);E2.applyModelSpecification($,v),$.computeBoundsAndApplyParent(),this.models.push($),this._modelsInfo.set(m,{modelSpec:v,model:$})}).catch(P=>{this.fire(new vy(new Error(`Could not load model ${m} from ${v.uri}: ${P.message}`)))});d.push(E)}}Promise.allSettled(d).then(()=>{this._loaded=!0,this.fire(new Ym("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(m=>{this._loaded=!0,this.fire(new vy(new Error(`Could not load models: ${m.message}`)))})}static applyModelSpecification(d,m){m.nodeOverrides&&E2.convertNodeOverrides(d,m.nodeOverrides),m.materialOverrides&&E2.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(v=>typeof v=="string")){d.nodeOverrideNames=[];for(const v of m)d.nodeOverrideNames.push(v)}else Object.entries(m).forEach(([v,S])=>{const E={orientation:[0,0,0]};if(S.hasOwnProperty("orientation")){const P=S.orientation;P&&(E.orientation=P)}d.nodeOverrides.set(v,E)})}static convertMaterialOverrides(d,m){if(Array.isArray(m)&&m.every(v=>typeof v=="string")){d.materialOverrideNames=[];for(const v of m)d.materialOverrideNames.push(v)}else Object.entries(m).forEach(([v,S])=>{const E={color:new qr(1,1,1),colorMix:0,emissionStrength:0,opacity:1},P=S["model-color"];P!==void 0&&(E.color.r=P[0],E.color.g=P[1],E.color.b=P[2]);const O=S["model-color-mix-intensity"];O!==void 0&&(E.colorMix=O);const $=S["model-emissive-strength"];$!==void 0&&(E.emissionStrength=$);const G=S["model-opacity"];G!==void 0&&(E.opacity=G),d.materialOverrides.set(v,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 v in d){const S=d[v];if(this._modelsInfo.has(v)){const E=this._modelsInfo.get(v);E&&E.modelSpec.uri===S.uri&&m.set(v,E)}}this._modelsInfo=m,this._options.models=d,this._loaded=!1,this.load()}}function afe(x,d,m,v){const S=1<ot.polygon).flat());const Oe=de?O:null,[De,Ke]=N3e(E,v,se,ee,G,P,Oe,ie,ue,E.center.lat,x.tileID.canonical),Xe=x.queryGeometry;return j3e(De,Ke,Xe.isPointQuery()?Xe.screenBounds:Xe.screenGeometry)}},building:class extends Fu{constructor(x,d,m,v){super(x,{layout:K3e||(K3e=new Eo({visibility:new Xs(Kt.layout_building.visibility),"building-facade":new nr(Kt.layout_building["building-facade"]),"building-facade-floors":new nr(Kt.layout_building["building-facade-floors"]),"building-facade-unit-width":new nr(Kt.layout_building["building-facade-unit-width"]),"building-facade-window":new nr(Kt.layout_building["building-facade-window"]),"building-roof-shape":new nr(Kt.layout_building["building-roof-shape"]),"building-height":new nr(Kt.layout_building["building-height"]),"building-base":new nr(Kt.layout_building["building-base"]),"building-flood-light-wall-radius":new nr(Kt.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new nr(Kt.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new nr(Kt.layout_building["building-flip-roof-orientation"])})),paint:Z3e||(Z3e=new Eo({"building-opacity":new Xs(Kt.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Xs(Kt.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Xs(Kt.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Xs(Kt.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Xs(Kt.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Xs(Kt.paint_building["building-vertical-scale"]),"building-cast-shadows":new Xs(Kt.paint_building["building-cast-shadows"]),"building-color":new nr(Kt.paint_building["building-color"]),"building-emissive-strength":new nr(Kt.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Xs(Kt.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Xs(Kt.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Xs(Kt.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Xs(Kt.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Xs(Kt.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new nr({type:"string",default:"default","property-type":"data-driven"})}))},d,m,v),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(x){return new G3e(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,v,S,E,P,O,$){let G=this.layout.get("building-height").evaluate(d,m);const ee=this.layout.get("building-base").evaluate(d,m),se=x.tile.getBucket(this).getFootprint(d);if(se){if(se.hiddenFlags!==0)return!1;G=se.height}const[ie,de]=N3e(E,v,ee,G,new pt(0,0),P,null,[0,0],1,E.center.lat,x.tileID.canonical),ue=x.queryGeometry;return j3e(ie,de,ue.isPointQuery()?ue.screenBounds:ue.screenGeometry)}},line:class extends Fu{constructor(x,d,m,v){const S=a5e();super(x,S,d,m,v),S.layout&&(this.layout=new ov(S.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 t2,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(nP)return nP;const m=a5e();return nP=new tut(m.paint.properties["line-width"].specification),nP.useIntegerZoom=!0,nP})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,x)}createBucket(x){return new Lpe(x)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(x,d,m){const v=r5e(this);return{config:new Ly(this,{zoom:d,lut:m}),defines:v,overrideFog:!1}}queryRadius(x){const d=x,m=i5e(Vd("line-width",this,d),Vd("line-gap-width",this,d)),v=Vd("line-offset",this,d);return m/2+Math.abs(v)+ad(this.paint.get("line-translate"))}queryIntersectsFeature(x,d,m,v,S,E){if(x.queryGeometry.isAboveHorizon)return!1;const P=um(x.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),E.angle,x.pixelToTileUnitsFactor),O=x.pixelToTileUnitsFactor/2*i5e(this.paint.get("line-width").evaluate(d,m),this.paint.get("line-gap-width").evaluate(d,m)),$=this.paint.get("line-offset").evaluate(d,m);return $&&(v=function(G,ee){const se=[],ie=new pt(0,0);for(let de=0;de=3){for(let ue=0;ue>16&255)/255,(x>>8&255)/255,(255&x)/255,1)}function bht(x,d,m){x===1?(d.rgb_color=d7(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 _ht(x,d,m){x===1?d.transform=c7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(vMe(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 vMe(x,d){return x.readFields(wht,{offset:0,opacity:255,rgb_color:ife},d)}function wht(x,d,m){x===1?d.offset=m.readFloat():x===2?d.opacity=m.readVarint():x===3&&(d.rgb_color=d7(m.readVarint()))}function jht(x,d,m){x===1?d.transform=c7(m,m.readVarint()+m.pos):x===2?d.spread_method=m.readVarint():x===3?d.stops.push(vMe(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 Nht(x,d,m){x===1?d.transform=c7(m,m.readVarint()+m.pos):x===2?d.clip_path_idx=m.readVarint():x===3&&d.children.push(l7(m,m.readVarint()+m.pos))}function kht(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(l7(m,m.readVarint()+m.pos))}class Sht{static calculate(d={},m=[]){const v=new Map,S=new Map;if(Object.keys(d).length===0)return v;m.forEach(E=>{S.set(E.name,E.rgb_color||new qr(0,0,0))});for(const[E,P]of Object.entries(d))S.has(E)?v.set(S.get(E).toString(),P):console.warn(`Ignoring unknown image variable "${E}"`);return v}}function J3(x,d=255,m){const v=d/255,S=x.toString(),E=m.has(S)?m.get(S).clone():x.clone();return E.a*=v,E.toString()}function _P(x,d){if(!Gm()){const m=document.createElement("canvas");return m.width=x,m.height=d,m}return new OffscreenCanvas(x,d)}let cfe,wP=null;function dfe(x,d,m,v,S){for(const E of v.children)bMe(x,d,m,E,S)}function bMe(x,d,m,v,S){v.group?(x.save(),function(E,P,O,$,G){const ee=$.mask_idx!=null?O.masks[$.mask_idx]:null,se=$.clip_path_idx!=null?O.clip_paths[$.clip_path_idx]:null;if($.transform&&(P=e5($.transform).preMultiplySelf(P)),!function(ue,ke,Oe){return ue.opacity!==255||ke||Oe}($,se!=null,ee!=null))return void dfe(E,P,O,$,G);const ie=_P(E.canvas.width,E.canvas.height),de=ie.getContext("2d");dfe(de,P,O,$,G),se&&CMe(de,P,O,se),ee&&MMe(de,P,O,ee,G),E.globalAlpha=$.opacity/255,E.drawImage(ie,0,0)}(x,d,m,v.group,S),x.restore()):v.path&&(x.save(),function(E,P,O,$,G){E.setTransform(P),$.paint_order===lht.PAINT_ORDER_FILL_AND_STROKE?(_Me(E,O,$,G),jMe(E,O,$,G)):(jMe(E,O,$,G),_Me(E,O,$,G))}(x,d,m,v.path,S),x.restore())}function _Me(x,d,m,v){const S=m.fill;if(!S)return;const E=S.opacity/255;switch(x.save(),x.beginPath(),TMe(m,x),S.paint){case"rgb_color":x.fillStyle=J3(S.rgb_color,S.opacity,v);break;case"linear_gradient_idx":{const P=d.linear_gradients[S.linear_gradient_idx];P.transform&&x.setTransform(e5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=NMe(x,P,E,v);break}case"radial_gradient_idx":{const P=d.radial_gradients[S.radial_gradient_idx];P.transform&&x.setTransform(e5(P.transform).preMultiplySelf(x.getTransform())),x.fillStyle=kMe(x,P,E,v)}}x.fill(wMe(m)),x.restore()}function wMe(x){return x.rule===ofe.PATH_RULE_NON_ZERO?"nonzero":x.rule===ofe.PATH_RULE_EVEN_ODD?"evenodd":void 0}function jMe(x,d,m,v){const S=m.stroke;if(!S)return;const E=AMe(m);x.lineWidth=S.width,x.miterLimit=S.miterlimit,x.setLineDash(S.dasharray),x.lineDashOffset=S.dashoffset;const P=S.opacity/255;switch(S.paint){case"rgb_color":x.strokeStyle=J3(S.rgb_color,S.opacity,v);break;case"linear_gradient_idx":x.strokeStyle=NMe(x,d.linear_gradients[S.linear_gradient_idx],P,v,!0);break;case"radial_gradient_idx":x.strokeStyle=kMe(x,d.radial_gradients[S.radial_gradient_idx],P,v,!0)}switch(S.linejoin){case o7.LINE_JOIN_MITER_CLIP:case o7.LINE_JOIN_MITER:x.lineJoin="miter";break;case o7.LINE_JOIN_ROUND:x.lineJoin="round";break;case o7.LINE_JOIN_BEVEL:x.lineJoin="bevel"}switch(S.linecap){case lfe.LINE_CAP_BUTT:x.lineCap="butt";break;case lfe.LINE_CAP_ROUND:x.lineCap="round";break;case lfe.LINE_CAP_SQUARE:x.lineCap="square"}x.stroke(E)}function NMe(x,d,m,v,S=!1){if(d.stops.length===1){const ie=d.stops[0];return J3(ie.rgb_color,ie.opacity*m,v)}const{x1:E,y1:P,x2:O,y2:$}=d;let G=new DOMPoint(E,P),ee=new DOMPoint(O,$);if(S){const ie=e5(d.transform);G=ie.transformPoint(G),ee=ie.transformPoint(ee)}const se=x.createLinearGradient(G.x,G.y,ee.x,ee.y);for(const ie of d.stops)se.addColorStop(ie.offset,J3(ie.rgb_color,ie.opacity*m,v));return se}function kMe(x,d,m,v,S=!1){if(d.stops.length===1){const De=d.stops[0];return J3(De.rgb_color,De.opacity*m,v)}const E=e5(d.transform),{fx:P,fy:O,fr:$,cx:G,cy:ee,r:se}=d;let ie=new DOMPoint(P,O),de=new DOMPoint(G,ee),ue=$,ke=se;if(S){ie=E.transformPoint(ie),de=E.transformPoint(de);const De=(E.a+E.d)/2;ue=$*De,ke=d.r*De}const Oe=x.createRadialGradient(ie.x,ie.y,ue,de.x,de.y,ke);for(const De of d.stops)Oe.addColorStop(De.offset,J3(De.rgb_color,De.opacity*m,v));return Oe}function SMe(x,d,m,v){const S=v.transform?e5(v.transform).preMultiplySelf(d):d,E=_P(x.canvas.width,x.canvas.height),P=E.getContext("2d");for(const $ of v.children)if($.group)SMe(P,S,m,$.group);else if($.path){const G=$.path,ee=new Path2D;ee.addPath(AMe(G),S),P.fill(ee,wMe(G))}const O=v.clip_path_idx!=null?m.clip_paths[v.clip_path_idx]:null;O&&CMe(P,S,m,O),x.globalCompositeOperation="source-over",x.drawImage(E,0,0)}function CMe(x,d,m,v){const S=_P(x.canvas.width,x.canvas.height);SMe(S.getContext("2d"),d,m,v),x.globalCompositeOperation="destination-in",x.drawImage(S,0,0)}function MMe(x,d,m,v,S){if(v.children.length===0)return;const E=v.mask_idx!=null?m.masks[v.mask_idx]:null;E&&MMe(x,d,m,E,S);const P=x.canvas.width,O=x.canvas.height,$=_P(P,O),G=$.getContext("2d"),ee=v.width,se=v.height,ie=v.left,de=v.top,ue=new Path2D,ke=new Path2D;ke.rect(ie,de,ee,se),ue.addPath(ke,d),G.clip(ue);for(const Ke of v.children)bMe(G,d,m,Ke,S);const Oe=G.getImageData(0,0,P,O),De=Oe.data;if(v.mask_type===xMe.MASK_TYPE_LUMINANCE)for(let Ke=0;Ked[P])return null}else{const O=1/v[P];let $=(x[P]-m[P])*O,G=(d[P]-m[P])*O;if($>G){const ee=$;$=G,G=ee}if($>S&&(S=$),GE)return null}return S}function IMe(x,d,m,v,S,E,P,O,$,G,ee){const se=v-x,ie=S-d,de=E-m,ue=P-x,ke=O-d,Oe=$-m,De=ee[1]*Oe-ee[2]*ke,Ke=ee[2]*ue-ee[0]*Oe,Xe=ee[0]*ke-ee[1]*ue,ot=se*De+ie*Ke+de*Xe;if(Math.abs(ot)<1e-15)return null;const Nt=1/ot,yt=G[0]-x,At=G[1]-d,Ft=G[2]-m,qt=(yt*De+At*Ke+Ft*Xe)*Nt;if(qt<0||qt>1)return null;const ns=At*de-Ft*ie,Gt=Ft*se-yt*de,ds=yt*ie-At*se,js=(ee[0]*ns+ee[1]*Gt+ee[2]*ds)*Nt;return js<0||qt+js>1?null:(ue*ns+ke*Gt+Oe*ds)*Nt}function LMe(x,d,m){return(x-d)/(m-d)}function DMe(x,d,m,v,S,E,P,O,$){const G=1<{const Ke=Oe?1:0,Xe=(de+1)*ke-Ke,ot=ue*ke,Nt=(ue+1)*ke-Ke;De[0]=de*ke,De[1]=ot,De[2]=Xe,De[3]=Nt};let se=new EMe($);const ie=[];for(let de=0;de<$*$;de++){ee(de%$,Math.floor(de/$),G,!1,ie);const ue=kb(ie[0],ie[1],E),ke=kb(ie[2],ie[1],E),Oe=kb(ie[2],ie[3],E),De=kb(ie[0],ie[3],E);se.minimums.push(Math.min(ue,ke,Oe,De)),se.maximums.push(Math.max(ue,ke,Oe,De)),se.leaves.push(1)}for(O.push(se),$/=2;$>=1;$/=2){const de=O[O.length-1];se=new EMe($);for(let ue=0;ue<$*$;ue++){ee(ue%$,Math.floor(ue/$),2,!0,ie);const ke=de.getElevation(ie[0],ie[1]),Oe=de.getElevation(ie[2],ie[1]),De=de.getElevation(ie[2],ie[3]),Ke=de.getElevation(ie[0],ie[3]),Xe=de.isLeaf(ie[0],ie[1]),ot=de.isLeaf(ie[2],ie[1]),Nt=de.isLeaf(ie[2],ie[3]),yt=de.isLeaf(ie[0],ie[3]),At=Math.min(ke.min,Oe.min,De.min,Ke.min),Ft=Math.max(ke.max,Oe.max,De.max,Ke.max),qt=Xe&&ot&&Nt&&yt;se.maximums.push(Ft),se.minimums.push(At),se.leaves.push(Ft-At<=5&&qt?1:0)}O.push(se)}return O}(this.dem),v=m.length-1,S=m[v];this._addNode(S.minimums[0],S.maximums[0],S.leaves[0]),this._construct(m,0,0,v,0)}raycastRoot(d,m,v,S,E,P,O=1){return PMe([d,m,-100],[v,S,this.maximums[0]*O],E,P)}raycast(d,m,v,S,E,P,O=1){if(!this.nodeCount)return null;const $=this.raycastRoot(d,m,v,S,E,P,O);if($==null)return null;const G=[],ee=[],se=[],ie=[],de=[{idx:0,t:$,nodex:0,nodey:0,depth:0}];for(;de.length>0;){const{idx:ue,t:ke,nodex:Oe,nodey:De,depth:Ke}=de.pop();if(this.leaves[ue]){DMe(Oe,De,Ke,d,m,v,S,se,ie);const ot=1<=Bs[2])return ke}continue}let Xe=0;for(let ot=0;ot=G[ee[Ft]]&&(ee.splice(Ft,0,ot),At=!0);At||(ee[Xe]=ot),Xe++}}for(let ot=0;ot=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 v=[0,0,0,0],S=h7.getUnpackVector(m);let E=Math.floor((d+S[3])/S[2]);return v[2]=E%256,E=Math.floor(E/256),v[1]=E%256,E=Math.floor(E/256),v[0]=E,v}getPixels(){return new ECe({width:this.stride,height:this.stride},this.pixels)}backfillBorder(d,m,v){if(this.dim!==d.dim)throw new Error("dem dimension mismatch");let S=m*this.dim,E=m*this.dim+this.dim,P=v*this.dim,O=v*this.dim+this.dim;switch(m){case-1:S=E-1;break;case 1:E=S+1}switch(v){case-1:P=O-1;break;case 1:O=P+1}const $=-m*this.dim,G=-v*this.dim;for(let ee=P;ee=1;v--){const S=v===1?1:0,E=v===2?1:0;for(let P=0;P>>1^-(1&x[d]);return x}function Bht(x,d){switch(d){case"uint32":return x;case"uint16":for(let m=0;m>4|(61440&v)>>8|(240&S)<<4|61440&S,x[m+1]=15&v|(3840&v)>>4|(15&S)<<8|(3840&S)<<4}return x;case"uint8":for(let m=0;m>6|(192&S)>>4|(192&E)>>2|192&P,x[m+1]=(48&v)>>4|(48&S)>>2|48&E|(48&P)<<2,x[m+2]=(12&v)>>2|12&S|(12&E)<<2|(12&P)<<4,x[m+3]=3&v|(3&S)<<2|(3&E)<<4|(3&P)<<6}return x;default:throw new Error(`Invalid pixel format, "${d}"`)}}Sr(h7,"DEMData"),Sr(OMe,"DemMinMaxQuadTree",{omit:["dem"]});var Hp=Uint8Array,jP=Uint16Array,$ht=Int32Array,FMe=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]),zMe=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]),qht=new Hp([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),BMe=function(x,d){for(var m=new jP(31),v=0;v<31;++v)m[v]=d+=1<>1|(21845&oc)<<1;UMe[oc]=((65280&(t5=(61680&(t5=(52428&t5)>>2|(13107&t5)<<2))>>4|(3855&t5)<<4))>>8|(255&t5)<<8)>>1}var NP=function(x,d,m){for(var v=x.length,S=0,E=new jP(d);S>$]=G;return P},kP=new Hp(288);for(oc=0;oc<144;++oc)kP[oc]=8;for(oc=144;oc<256;++oc)kP[oc]=9;for(oc=256;oc<280;++oc)kP[oc]=7;for(oc=280;oc<288;++oc)kP[oc]=8;var VMe=new Hp(32);for(oc=0;oc<32;++oc)VMe[oc]=5;var Hht=NP(kP,9),Wht=NP(VMe,5),hfe=function(x){for(var d=x[0],m=1;md&&(d=x[m]);return d},gg=function(x,d,m){var v=d/8|0;return(x[v]|x[v+1]<<8)>>(7&d)&m},mfe=function(x,d){var m=d/8|0;return(x[m]|x[m+1]<<8|x[m+2]<<16)>>(7&d)},Ght=["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"],yg=function(x,d,m){var v=new Error(d||Ght[x]);if(v.code=x,Error.captureStackTrace&&Error.captureStackTrace(v,yg),!m)throw v;return v},Kht=new Hp(0),Zht=typeof TextDecoder<"u"&&new TextDecoder;try{Zht.decode(Kht,{stream:!0})}catch{}const Yht={gzip_data:"gzip"};class Kf extends Error{constructor(d){super(d),this.name="MRTError"}}const Xht={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},HMe={uint32:1,uint16:2,uint8:4},Qht={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let pfe;class m7{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 Kf(`Layer '${d}' not found`);return m}getHeaderLength(d){const m=new Uint8Array(d),v=new DataView(d);if(m[0]!==13)throw new Kf("File is not a valid MRT.");return v.getUint32(1,!0)}parseHeader(d){const m=new Uint8Array(d),v=this.getHeaderLength(d);if(m.length= ${v} but got buffer of length ${m.length}`);const S=new pfe(m.subarray(0,v)).readFields(Aht,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==S.x||this.y!==S.y||this.z!==S.z))throw new Kf(`Invalid attempt to parse header ${S.z}/${S.x}/${S.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=S.x,this.y=S.y,this.z=S.z;for(const E of S.layers)this.layers[E.name]=new WMe(E,{cacheSize:this._cacheSize});return this}createDecodingTask(d){const m=[],v=this.getLayer(d.layerName);for(let S of d.blockIndices){const E=v.dataIndex[S],P=E.firstByte-d.firstByte,O=E.lastByte-d.firstByte;if(v._blocksInProgress.has(S))continue;const $={layerName:v.name,firstByte:P,lastByte:O,pixelFormat:v.pixelFormat,blockIndex:S,blockShape:[E.bands.length].concat(v.bandShape),buffer:v.buffer,codec:E.codec.codec,filters:E.filters.map(G=>G.filter)};v._blocksInProgress.add(S),m.push($)}return new GMe(m,()=>{m.forEach(S=>v._blocksInProgress.delete(S.blockIndex))},(S,E)=>{if(m.forEach(P=>v._blocksInProgress.delete(P.blockIndex)),S)throw S;E.forEach(P=>{this.getLayer(P.layerName).processDecodedData(P)})})}}class WMe{constructor({version:d,name:m,units:v,tileSize:S,pixelFormat:E,buffer:P,dataIndex:O},$){if(this.version=d,this.version!==1)throw new Kf(`Cannot parse raster layer encoded with MRT version ${d}`);this.name=m,this.units=v,this.tileSize=S,this.buffer=P,this.pixelFormat=Xht[E],this.dataIndex=O,this.bandShape=[S+2*P,S+2*P,HMe[this.pixelFormat]],this._decodedBlocks=new u7($?$.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return HMe[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[v,S]of this.dataIndex.entries()){for(const[E,P]of S.bands.entries())if(P===d)return{bandIndex:m+E,blockIndex:v,blockBandIndex:E};m+=S.bands.length}break;case"number":for(const[v,S]of this.dataIndex.entries()){if(d>=m&&dthis.cacheSize)throw new Kf(`Number of blocks to decode (${E.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:m,lastByte:v,blockIndices:S}}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:v}=this.getBlockForBand(d);if(m<0)throw new Kf(`Band not found: ${JSON.stringify(d)}`);const S=this._decodedBlocks.get(m.toString());if(!S)throw new Kf(`Data for band ${JSON.stringify(d)} of layer "${this.name}" not decoded.`);const E=this.dataIndex[m],P=this.bandShape.reduce((G,ee)=>G*ee,1),O=v*P,$=S.subarray(O,O+P);return{data:$,bytes:new Uint8Array($.buffer).subarray($.byteOffset,$.byteOffset+$.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:E.offset,scale:E.scale}}}m7.setPbf=function(x){pfe=x};class GMe{constructor(d,m,v){this.tasks=d,this._onCancel=m,this._onComplete=v,this._finalized=!1}cancel(){this._finalized||(this._onCancel(),this._finalized=!0)}complete(d,m){this._finalized||(this._onComplete(d,m),this._finalized=!0)}}m7.performDecoding=function(x,d){const m=new Uint8Array(x);return Promise.all(d.tasks.map(v=>{const{layerName:S,firstByte:E,lastByte:P,pixelFormat:O,blockShape:$,blockIndex:G,filters:ee,codec:se}=v,ie=m.subarray(E,P+1),de=new Uint32Array($[0]*$[1]*$[2]);let ue;if(se!=="gzip_data")throw new Kf(`Unhandled codec: ${se}`);return ue=function(ke,Oe){if(!globalThis.DecompressionStream&&Oe==="gzip_data")return Promise.resolve(((ot=function(At){At[0]==31&&At[1]==139&&At[2]==8||yg(6,"invalid gzip data");var Ft=At[3],qt=10;4&Ft&&(qt+=2+(At[10]|At[11]<<8));for(var ns=(Ft>>3&1)+(Ft>>4&1);ns>0;ns-=!At[qt++]);return qt+(2&Ft)}(Xe=ke))+8>Xe.length&&yg(6,"invalid gzip data"),function(At,Ft,qt,ns){var Gt=At.length;if(!Gt||Ft.f&&!Ft.l)return qt||new Hp(0);var ds=!qt,js=ds||Ft.i!=2,Ns=Ft.i;ds&&(qt=new Hp(3*Gt));var Fs,Bs,Is=function(Ai){var ti=qt.length;if(Ai>ti){var ui=new Hp(Math.max(2*ti,Ai));ui.set(qt),qt=ui}},Ls=Ft.f||0,cs=Ft.p||0,as=Ft.b||0,Os=Ft.l,sr=Ft.d,Hs=Ft.m,Fr=Ft.n,hr=8*Gt;do{if(!Os){Ls=gg(At,cs,1);var _r=gg(At,cs+1,3);if(cs+=3,!_r){var Tr=At[(ms=4+((cs+7)/8|0))-4]|At[ms-3]<<8,Qn=ms+Tr;if(Qn>Gt){Ns&&yg(0);break}js&&Is(as+Tr),qt.set(At.subarray(ms,Qn),as),Ft.b=as+=Tr,Ft.p=cs=8*Qn,Ft.f=Ls;continue}if(_r==1)Os=Hht,sr=Wht,Hs=9,Fr=5;else if(_r==2){var Zs=gg(At,cs,31)+257,Ar=gg(At,cs+10,15)+4,yn=Zs+gg(At,cs+5,31)+1;cs+=14;for(var ba=new Hp(yn),Sa=new Hp(19),Fn=0;Fn>4)<16)ba[Fn++]=ms;else{var or=0,lr=0;for(ms==16?(lr=3+gg(At,cs,3),cs+=2,or=ba[Fn-1]):ms==17?(lr=3+gg(At,cs,7),cs+=3):ms==18&&(lr=11+gg(At,cs,127),cs+=7);lr--;)ba[Fn++]=or}}var zr=ba.subarray(0,Zs),Ur=ba.subarray(Zs);Hs=hfe(zr),Fr=hfe(Ur),Os=NP(zr,Hs),sr=NP(Ur,Fr)}else yg(1);if(cs>hr){Ns&&yg(0);break}}js&&Is(as+131072);for(var An=(1<>4;if((cs+=15&or)>hr){Ns&&yg(0);break}if(or||yg(2),ha<256)qt[as++]=ha;else{if(ha==256){Yn=cs,Os=null;break}var rn=ha-254;ha>264&&(rn=gg(At,cs,(1<<(Za=FMe[Fn=ha-257]))-1)+qMe[Fn],cs+=Za);var gn=sr[mfe(At,cs)&Wn],Ua=gn>>4;if(gn||yg(3),cs+=15&gn,Ur=Vht[Ua],Ua>3){var Za=zMe[Ua];Ur+=mfe(At,cs)&(1<hr){Ns&&yg(0);break}js&&Is(as+131072);var Ya=as+rn;if(asFs.length)&&(Bs=Fs.length),new Hp(Fs.subarray(0,Bs))):qt.subarray(0,as)}(Xe.subarray(ot,-8),{i:2},new Hp(((De=Xe)[(Ke=De.length)-4]|De[Ke-3]<<8|De[Ke-2]<<16|De[Ke-1]<<24)>>>0))));var De,Ke,Xe,ot;const Nt=Yht[Oe];if(!Nt)throw new Error(`Unhandled codec: ${Oe}`);const yt=new globalThis.DecompressionStream(Nt);return new Response(new Blob([ke]).stream().pipeThrough(yt)).arrayBuffer().then(At=>new Uint8Array(At))}(ie,se).then(ke=>(function(Oe,De){Oe.readFields(Oht,De)}(new pfe(ke),de),new Qht[O](de.buffer))),ue.then(ke=>{for(let Oe=ee.length-1;Oe>=0;Oe--)switch(ee[Oe]){case"delta_filter":Fht(ke,$);break;case"zigzag_filter":zht(ke);break;case"bitshuffle_filter":Bht(ke,O);break;default:throw new Kf(`Unhandled filter "${ee[Oe]}"`)}return{layerName:S,blockIndex:G,data:ke}}).catch(ke=>{throw ke})}))},Sr(GMe,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),Sr(m7,"MapboxRasterTile"),Sr(WMe,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class KMe{constructor(d){this._stringToNumber={},this._numberToString=[];for(let m=0;m=0&&ie[3]>=0&&G.insert($,ie[0],ie[1],ie[2],ie[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Xt(new UF(this.rawTileData)).layers,this.sourceLayerCoder=new KMe(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:v,transform:S,tileTransform:E,pixelPosMatrix:P,availableImages:O,worldview:$}=m;this.loadVTLayers(),this.serializedLayersCache.clear();const G=m.queryRadius?m.queryRadius:0,ee=v.bufferedTilespaceBounds,se=this.grid.query(ee.min.x,ee.min.y,ee.max.x,ee.max.y,(ke,Oe,De,Ke)=>zu(v.bufferedTilespaceGeometry,ke-G,Oe-G,De+G,Ke+G));se.sort(Jht);let ie=null;S.elevation&&se.length>0&&(ie=Q3.create(S.elevation,this.tileID));const de={};let ue;for(let ke=0;ke(Ke||(Ke=Ot(Xe,this.tileID.canonical,E)),ot.queryIntersectsFeature(v,Xe,Nt,Ke,this.z,S,P,ie,yt)))}return de}loadMatchingFeature(d,m,v,S,E,P){const{featureIndex:O,bucketIndex:$,sourceLayerIndex:G,layoutVertexArrayOffset:ee}=m,se=this.bucketLayerIDs[$],ie=v.layers,de=Object.keys(ie);if(de.length&&!yr(de,se))return;const ue=v.sourceCache,ke=this.sourceLayerCoder.decode(G),Oe=this.vtLayers[ke].feature(O),De=this.getId(Oe,ke);for(let Ke=0;Ke`${O.key}: ${O.message}`).join(", ");return void fr(`Failed to create expression for promoteId: ${P}`)}this.promoteIdExpression=E.value}v=this.promoteIdExpression.evaluate({zoom:0},d)}else v=d.properties[S];typeof v=="boolean"&&(v=Number(v))}return v}}function YMe(x,d,m,v,S){return Qt(x,(E,P)=>{const O=d instanceof ov?d.get(P):null;return O&&O.evaluate?O.evaluate(m,v,void 0,S):O})}function Jht(x,d){return d-x}Sr(ZMe,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const XMe=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class ffe{static from(d){if(!(d instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[m,v]=new Uint8Array(d,0,2);if(m!==219)throw new Error("Data does not appear to be in a KDBush format.");const S=v>>4;if(S!==1)throw new Error(`Got v${S} data when expected v1.`);const E=XMe[15&v];if(!E)throw new Error("Unrecognized array type.");const[P]=new Uint16Array(d,2,1),[O]=new Uint32Array(d,4,1);return new ffe(O,P,E,d)}constructor(d,m=64,v=Float64Array,S){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=v,this.IndexArrayType=d<65536?Uint16Array:Uint32Array;const E=XMe.indexOf(this.ArrayType),P=2*d*this.ArrayType.BYTES_PER_ELEMENT,O=d*this.IndexArrayType.BYTES_PER_ELEMENT,$=(8-O%8)%8;if(E<0)throw new Error(`Unexpected typed array class: ${v}.`);S&&S instanceof ArrayBuffer?(this.data=S,this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+O+$,2*d),this._pos=2*d,this._finished=!0):(this.data=new ArrayBuffer(8+P+O+$),this.ids=new this.IndexArrayType(this.data,8,d),this.coords=new this.ArrayType(this.data,8+O+$,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 v=this._pos>>1;return this.ids[v]=v,this.coords[this._pos++]=d,this.coords[this._pos++]=m,v}finish(){const d=this._pos>>1;if(d!==this.numItems)throw new Error(`Added ${d} items when expected ${this.numItems}.`);return xfe(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(d,m,v,S){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:E,coords:P,nodeSize:O}=this,$=[0,E.length-1,0],G=[];for(;$.length;){const ee=$.pop()||0,se=$.pop()||0,ie=$.pop()||0;if(se-ie<=O){for(let Oe=ie;Oe<=se;Oe++){const De=P[2*Oe],Ke=P[2*Oe+1];De>=d&&De<=v&&Ke>=m&&Ke<=S&&G.push(E[Oe])}continue}const de=ie+se>>1,ue=P[2*de],ke=P[2*de+1];ue>=d&&ue<=v&&ke>=m&&ke<=S&&G.push(E[de]),(ee===0?d<=ue:m<=ke)&&($.push(ie),$.push(de-1),$.push(1-ee)),(ee===0?v>=ue:S>=ke)&&($.push(de+1),$.push(se),$.push(1-ee))}return G}within(d,m,v){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:S,coords:E,nodeSize:P}=this,O=[0,S.length-1,0],$=[],G=v*v;for(;O.length;){const ee=O.pop()||0,se=O.pop()||0,ie=O.pop()||0;if(se-ie<=P){for(let Oe=ie;Oe<=se;Oe++)JMe(E[2*Oe],E[2*Oe+1],d,m)<=G&&$.push(S[Oe]);continue}const de=ie+se>>1,ue=E[2*de],ke=E[2*de+1];JMe(ue,ke,d,m)<=G&&$.push(S[de]),(ee===0?d-v<=ue:m-v<=ke)&&(O.push(ie),O.push(de-1),O.push(1-ee)),(ee===0?d+v>=ue:m+v>=ke)&&(O.push(de+1),O.push(se),O.push(1-ee))}return $}}function xfe(x,d,m,v,S,E){if(S-v<=m)return;const P=v+S>>1;QMe(x,d,P,v,S,E),xfe(x,d,m,v,P-1,1-E),xfe(x,d,m,P+1,S,1-E)}function QMe(x,d,m,v,S,E){for(;S>v;){if(S-v>600){const G=S-v+1,ee=m-v+1,se=Math.log(G),ie=.5*Math.exp(2*se/3),de=.5*Math.sqrt(se*ie*(G-ie)/G)*(ee-G/2<0?-1:1);QMe(x,d,m,Math.max(v,Math.floor(m-ee*ie/G+de)),Math.min(S,Math.floor(m+(G-ee)*ie/G+de)),E)}const P=d[2*m+E];let O=v,$=S;for(SP(x,d,v,m),d[2*S+E]>P&&SP(x,d,v,S);O<$;){for(SP(x,d,O,$),O++,$--;d[2*O+E]P;)$--}d[2*v+E]===P?SP(x,d,v,$):($++,SP(x,d,$,S)),$<=m&&(v=$+1),m<=$&&(S=$-1)}}function SP(x,d,m,v){gfe(x,m,v),gfe(d,2*m,2*v),gfe(d,2*m+1,2*v+1)}function gfe(x,d,m){const v=x[d];x[d]=x[m],x[m]=v}function JMe(x,d,m,v){const S=x-m,E=d-v;return S*S+E*E}i.$=PC,i.A=Qx,i.B=$p,i.C=2,i.D=z3,i.E=Ms,i.F=oP,i.G=k5e,i.H=EC,i.I=Js,i.J=aF,i.K=Rr,i.L=Y1,i.M=s3,i.N=i2,i.O=WR,i.P=pt,i.Q=o2,i.R=Zx,i.S=h3,i.T=kpe,i.U=Ty,i.V=a7,i.W=p6,i.X=tb,i.Y=eb,i.Z=e2,i._=Ou,i.a=function(x){return ca.API_CDN_URL_REGEX.test(x)},i.a$=ve,i.a0=xn,i.a1=oa,i.a2=Uf,i.a3=class extends a7{},i.a4=r3,i.a5=HR,i.a6=Kt,i.a7=function(x){const d=x.value;return d?xn(d)?sfe(d,!0)?[]:[new a7(x.key,d,`invalid url "${d}"`)]:[new a7(x.key,d,`string expected, "${Rr(d)}" found`)]:[]},i.a8=tF,i.a9=Eo,i.aA=je,i.aB=C,i.aC=Je,i.aD=qd,i.aE=Di,i.aF=W,i.aG=it,i.aH=function(x,d){const m={};for(let v=0;v{v(E,P)},d):v(E,P),()=>{}}return S.callbacks.push(v),S.cancel||(S.cancel=m((E,P)=>{S.result=[E,P];for(const O of S.callbacks)this.scheduler?this.scheduler.add(()=>{O(E,P)},d):O(E,P);setTimeout(()=>delete this.entries[x],3e3)})),()=>{S.result||(S.callbacks=S.callbacks.filter(E=>E!==v),S.callbacks.length||(S.cancel(),delete this.entries[x]))}}},i.aL=function(x,d,m){const v=JSON.stringify(x.request);return x.data&&(this.deduped.entries[v]={result:[null,x.data]}),this.deduped.request(v,{type:"parseTile",isSymbolTile:x.isSymbolTile,zoom:x.tileZoom},S=>{const E=Ih(x.request,(P,O,$)=>{P?S(P):O&&S(null,{rawData:O,vectorTile:m?void 0:new Xt(new UF(O)),responseHeaders:new Map($.entries())})});return()=>{E.cancel(),S()}},d)},i.aM=function(x){return x?{cacheControl:x.get("Cache-Control"),expires:x.get("Expires")}:{cacheControl:void 0,expires:void 0}},i.aN=Ml,i.aO=function(x){Sd++,Sd>H1&&(x.getActor().send("enforceCacheSizeLimit",V1),Sd=0)},i.aP=function(x){return x<=1?1:Math.pow(2,Math.floor(Math.log2(x)))},i.aQ=So,i.aR=eMe,i.aS=iMe,i.aT=y,i.aU=J5e,i.aV=function(x,d){const m=document.createElement("video");m.muted=!0,m.onloadstart=function(){d(null,m)};for(let v=0;v{}}},i.aW=sP,i.aX=E2,i.aY=Vt,i.aZ=uP,i.a_=oe,i.aa=Xs,i.ab=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return Mn(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Kr(x.x,d.x,m),y:Kr(x.y,d.y,m),z:Kr(x.z,d.z,m),azimuthal:Kr(x.azimuthal,d.azimuthal,m),polar:Kr(x.polar,d.polar,m)}}},i.ac=Ki,i.ad=nv,i.ae=st,i.af=ft,i.ag=ce,i.ah=Be,i.ai=ov,i.aj=bb,i.ak=Kr,i.al=tr,i.am=X0,i.an=jr,i.ao=qr,i.ap=class{constructor(x){this.specification=x}possiblyEvaluate(x,d){return function([m,v]){const S=Mn([1,m,v]);return{x:S.x,y:S.y,z:S.z}}(x.expression.evaluate(d))}interpolate(x,d,m){return{x:Kr(x.x,d.x,m),y:Kr(x.y,d.y,m),z:Kr(x.z,d.z,m)}}},i.aq=function(x,d,m=0,v=!0){const S=new pt(m,m),E=x.sub(S),P=d.add(S),O=[E,new pt(P.x,E.y),P,new pt(E.x,P.y)];return v&&O.push(E.clone()),O},i.ar=function(x,d){const m=[];for(let v=0;v1)return!1;const m=d.getSource().maxzoom,v=1<1)return d;const S=v.getSource().maxzoom,E=1<{const O=this.getAtTileOffset(x,S,E,P),$=v.upVector(x.canonical,S.x,S.y);return we($,$,O*v.upVectorScale(x.canonical,d,m).metersToTile),$}}getForTilePoints(x,d,m,v){if(this.isUsingMockSource())return!1;const S=Q3.create(this,x,v);return!!S&&(d.forEach(E=>{E[2]=this.exaggeration()*S.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,v=d.tileID,S=1<0&&(v+=(x[S]-0)*(x[S]-0)),d[S]<0&&(v+=(0-d[S])*(0-d[S]));return v},i.c0=e3e,i.c1=Bpe,i.c2=P5e,i.c3=Kpe,i.c4=ffe,i.c5=we,i.c6=Ge,i.c7=Qe,i.c8=function(x,d,m){m*=.5;var v=d[0],S=d[1],E=d[2],P=d[3],O=Math.sin(m),$=Math.cos(m);return x[0]=v*$+S*O,x[1]=S*$-v*O,x[2]=E*$+P*O,x[3]=P*$-E*O,x},i.c9=at,i.cA=te,i.cB=ei,i.cC=F3e,i.cD=Oi,i.cE=fCe,i.cF=function(x,d,m,v,S,E,P,O,$){if($.name==="globe")return fCe(x,d,new Oi(m,v,S),!1);const G=uP({z:m,x:v,y:S},$);return new Dr([(E+G.x/G.scale)*d,d*(G.y/G.scale),P],[(E+G.x2/G.scale)*d,d*(G.y2/G.scale),O])},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 Aa[d]},i.cJ=be,i.cK=qe,i.cL=O3,i.cM=function(x){const d=w(new Float64Array(16));C(d,x.pixelMatrix,x.globeMatrix);const m=[0,sp,0],v=[0,rp,0];return ft(m,m,d),ft(v,v,d),[m[0]>0&&m[0]<=x.width&&m[1]>0&&m[1]<=x.height&&!spe(x,new y(x.center.lat,90)),v[0]>0&&v[0]<=x.width&&v[1]>0&&v[1]<=x.height&&!spe(x,new y(x.center.lat,-90))]},i.cN=function(x,d){const{scale:m}=x.tileTransform,v=m*tr/(x.tileSize*Math.pow(2,d.zoom-x.tileID.overscaledZ+x.tileID.canonical.z));return function(S,E,P){var O=E[1],$=E[2],G=E[3],ee=P[0],se=P[1];return S[0]=E[0]*ee,S[1]=O*ee,S[2]=$*se,S[3]=G*se,S}(new Float32Array(4),d.inverseAdjustmentMatrix,[v,v])},i.cO=RF,i.cP=J,i.cQ=R3e,i.cR=function(x){const d=R3e(x,!0);return p([],[d[0],d[1],d[4],d[5]])},i.cS=I,i.cT=ur,i.cU=L,i.cV=function(x){const{x:d,y:m}=x.point,{lng:v,lat:S}=x._center;return yCe(d,m,x.worldSize,v,S)},i.cW=xe,i.cX=Xn,i.cY=wo,i.cZ=Md,i.c_=tp,i.ca=Ja,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=Y,i.cd=function(x,d,m,v,S){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,S!=null&&S!==1/0){var P=1/(v-S);x[10]=(S+v)*P,x[14]=2*S*v*P}else x[10]=-1,x[14]=-2*v;return x},i.ce=function(x,d,m,v,S,E,P){var O=1/(d-m),$=1/(v-S),G=1/(E-P);return x[0]=-2*O,x[1]=0,x[2]=0,x[3]=0,x[4]=0,x[5]=-2*$,x[6]=0,x[7]=0,x[8]=0,x[9]=0,x[10]=2*G,x[11]=0,x[12]=(d+m)*O,x[13]=(S+v)*$,x[14]=(P+E)*G,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=P3,i.ci=x2,i.cj=Bl,i.ck=Wf,i.cl=y2,i.cm=U5e,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 v=d[0],S=d[1],E=d[2],P=d[3],O=Math.sin(m),$=Math.cos(m);return x[0]=v*$+E*O,x[1]=S*$+P*O,x[2]=v*-O+E*$,x[3]=S*-O+P*$,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=et,i.cr=function(x){var d=x[0],m=x[1],v=x[2],S=x[3];return Math.sqrt(d*d+m*m+v*v+S*S)},i.cs=ts,i.ct=Ve,i.cu=ul,i.cv=3,i.cw=2,i.cx=7,i.cy=6,i.cz=Te,i.d=function(x){return ca.API_TILEJSON_REGEX.test(x)},i.d$=class{constructor(x,d,m,v){this.context=x,this.format=v,this.size=m,this.texture=x.gl.createTexture();const[S,E,P]=this.size,{gl:O}=x;O.bindTexture(O.TEXTURE_3D,this.texture),x.pixelStoreUnpackFlipY.set(!1),x.pixelStoreUnpack.set(1),x.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in d&&d.data&&O.texImage3D(O.TEXTURE_3D,0,this.format,S,E,P,0,jpe(this.format),Npe(this.format),d.data)}bind(x,d){const{context:m}=this,{gl:v}=m;v.bindTexture(v.TEXTURE_3D,this.texture),x!==this.minFilter&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MAG_FILTER,x),v.texParameteri(v.TEXTURE_3D,v.TEXTURE_MIN_FILTER,x),this.minFilter=x),d!==this.wrapS&&(v.texParameteri(v.TEXTURE_3D,v.TEXTURE_WRAP_S,d),v.texParameteri(v.TEXTURE_3D,v.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=I3,i.d4=function(x,d,m){const v=Math.sqrt(x*x+d*d+m*m),S=v>0?Math.acos(m/v)*Cr:0;let E=x!==0||d!==0?Math.atan2(-d,-x)*Cr+90:0;return E<0&&(E+=360),[v,E,S]},i.d5=ne,i.d6=Mn,i.d7=Ue,i.d8=le,i.d9=Dr,i.dA=function(x){return x({pluginStatus:Ru,pluginURL:ng}),d3.on("pluginStateChange",x),x},i.dB=g2,i.dC=class extends og{constructor(x){super(x),this.current=L3}set(x,d,m){if(this.fetchUniformLocation(x,d)){for(let v=0;v<9;v++)if(m[v]!==this.current[v]){this.current=m,this.gl.uniformMatrix3fv(this.location,!1,m);break}}}},i.dD=Pi,i.dE=function(x,d,m){const v=bb(m.zoom),S=x.style.map._antialias,E=x.terrain&&x.terrain.exaggeration()>0;return v===0&&!S&&!E},i.dF=function(x){const d=x.pixelsPerMeter,m=d/ae(1,x.center.lat),v=w(new Float64Array(16));return M(v,v,[x.point.x,x.point.y,0]),I(v,v,[m,m,d]),Float32Array.from(v)},i.dG=_F,i.dH=function(x){const d=be-5;x=je(x,-d,d)/d*90;const m=Math.pow(Math.abs(Math.sin(jr(x))),3);return Math.round(m*(z6.length-1))},i.dI=function(x,d,m,v){const S=d.getNorth(),E=d.getSouth(),P=d.getWest(),O=d.getEast(),$=1<0){const ue=180/v;b(de,de,[ue/G+1,0,0,0,ue/ee+1,0,-.5*ue/se,.5*ue/ie,1])}return de[2]=$,de[5]=x.x,de[8]=x.y,de},i.dJ=Vp,i.dK=function(x,d,m){const v=w(new Float64Array(16)),S=(d/(1<({u_matrix:new y2(x),u_texsize:new Wf(x),u_pixels_to_tile_units:new D3(x),u_device_pixel_ratio:new Bl(x),u_width_scale:new Bl(x),u_floor_width_scale:new Bl(x),u_image:new P3(x),u_units_to_pixels:new Wf(x),u_tile_units_to_pixels:new Bl(x),u_alpha_discard_threshold:new Bl(x),u_trim_offset:new Wf(x),u_trim_fade_range:new Wf(x),u_trim_color:new I3(x),u_zbias_factor:new Bl(x),u_tile_to_meter:new Bl(x),u_ground_shadow_factor:new x2(x),u_pattern_transition:new Bl(x)}),i.dX=x=>({u_matrix:new y2(x),u_pixels_to_tile_units:new D3(x),u_device_pixel_ratio:new Bl(x),u_width_scale:new Bl(x),u_floor_width_scale:new Bl(x),u_units_to_pixels:new Wf(x),u_dash_image:new P3(x),u_gradient_image:new P3(x),u_image_height:new Bl(x),u_texsize:new Wf(x),u_tile_units_to_pixels:new Bl(x),u_alpha_discard_threshold:new Bl(x),u_trim_offset:new Wf(x),u_trim_fade_range:new Wf(x),u_trim_color:new I3(x),u_zbias_factor:new Bl(x),u_tile_to_meter:new Bl(x),u_ground_shadow_factor:new x2(x)}),i.dY=x=>({u_camera_to_center_distance:new Bl(x),u_extrude_scale:new D3(x),u_device_pixel_ratio:new Bl(x),u_matrix:new y2(x),u_inv_rot_matrix:new y2(x),u_merc_center:new Wf(x),u_tile_id:new x2(x),u_zoom_transition:new Bl(x),u_up_dir:new x2(x),u_emissive_strength:new Bl(x)}),i.dZ=j3,i.d_=dut,i.da=pe,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=O3e,i.dd=Epe,i.de=$3e,i.df=sfe,i.dg=function(x,d){return x.readFields(cht,{icons:[]},d)},i.dh=IF,i.di=K3,i.dj=Hpe,i.dk=W1,i.dl=d2,i.dm=gy,i.dn=G1,i.dp=ys,i.dq=function(x){const d=x.indexOf(dv);return d>=0?x.slice(0,d):x},i.dr=function(x){return x.indexOf(dv)>=0},i.ds=function(x){const d=x.lastIndexOf(dv);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,v){return x.type==="custom"?new sht(x,d):new oht[x.type](x,d,m,v)},i.dv=Es,i.dw=function(x){const d=x.indexOf(dv);return d>=0?x.slice(d+1):""},i.dx=class extends A2{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=d3,i.dz=Yx,i.e=ca,i.e$=re,i.e0=_Ce,i.e1=(x,d,m,v,S,E)=>{const P=x.transform,O=P.projection.name==="globe";let $;if(E.paint.get("circle-pitch-alignment")==="map")if(O){const ee=gCe(P.zoom,d.canonical)*P._pixelsPerMercatorPixel;$=Float32Array.from([ee,0,0,ee])}else $=P.calculatePixelsToTileUnitsMatrix(m);else $=new Float32Array([P.pixelsToGLUnits[0],0,0,P.pixelsToGLUnits[1]]);const G={u_camera_to_center_distance:x.transform.getCameraToCenterDistance(P.projection),u_matrix:x.translatePosMatrix(d.projMatrix,m,E.paint.get("circle-translate"),E.paint.get("circle-translate-anchor")),u_device_pixel_ratio:Fl.devicePixelRatio,u_extrude_scale:$,u_inv_rot_matrix:Sct,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(O){G.u_inv_rot_matrix=v,G.u_merc_center=S,G.u_tile_id=[d.canonical.x,d.canonical.y,1<{const ee=x.transform,se=ee.pitch<15?e5e(.07,.7,je((14-ee.zoom)/5,0,1)):.07,ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none";return{u_matrix:s5e(x,d,m,v),u_texsize:d.imageAtlasTexture?d.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:ee.calculatePixelsToTileUnitsMatrix(d),u_device_pixel_ratio:S,u_width_scale:E,u_floor_width_scale:P,u_image:0,u_tile_units_to_pixels:t5e(d,ee),u_units_to_pixels:[1/ee.pixelsToGLUnits[0],1/ee.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:O,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:Ue(d.tileID.canonical,0),u_ground_shadow_factor:$,u_pattern_transition:G}},i.e5=(x,d,m,v,S,E,P,O,$,G)=>{const ee=x.transform,se=ee.calculatePixelsToTileUnitsMatrix(d),ie=m.paint.get("line-trim-color-use-theme").constantOr("default")==="none",de=ee.pitch<15?e5e(.07,.7,je((14-ee.zoom)/5,0,1)):.07;return{u_matrix:s5e(x,d,m,v),u_pixels_to_tile_units:se,u_device_pixel_ratio:E,u_width_scale:P,u_floor_width_scale:O,u_units_to_pixels:[1/ee.pixelsToGLUnits[0],1/ee.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:S,u_texsize:n5e(m)&&d.lineAtlasTexture?d.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:t5e(d,x.transform),u_alpha_discard_threshold:0,u_trim_offset:$,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:Ue(d.tileID.canonical,0),u_ground_shadow_factor:G}},i.e6=Zt,i.e7=$6,i.e8=ge,i.e9=ap,i.eA=function(x,d){var m=2*Math.acos(d[3]),v=Math.sin(m/2);return v>c?(x[0]=d[0]/v,x[1]=d[1]/v,x[2]=d[2]/v):(x[0]=1,x[1]=0,x[2]=0),m},i.eB=afe,i.eC=BF,i.eD=zF,i.eE=[1,1,1],i.eF=Q3,i.eG=lt,i.eH=function(x,d,m,v){var S=d[0],E=d[1],P=d[2],O=d[3];return x[0]=S+v*(m[0]-S),x[1]=E+v*(m[1]-E),x[2]=P+v*(m[2]-P),x[3]=O+v*(m[3]-O),x},i.eI=U3,i.eJ=dm,i.eK=Hf,i.eL=function(x,d,m,v,S,E,P,O,$,G,ee,se,ie,de,ue,ke){var Oe=new u(16);return Oe[0]=x,Oe[1]=d,Oe[2]=m,Oe[3]=v,Oe[4]=S,Oe[5]=E,Oe[6]=P,Oe[7]=O,Oe[8]=$,Oe[9]=G,Oe[10]=ee,Oe[11]=se,Oe[12]=ie,Oe[13]=de,Oe[14]=ue,Oe[15]=ke,Oe},i.eM=T,i.eN=pb,i.eO=T6,i.eP=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new pt(1/0,1/0),max:new pt(-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 pt(0,0),new pt(tr,tr),x),v=[];if(d&&!upe(m,this._globalClipBounds))return v;for(const S of this._activeRegions){if(S.hiddenByOverlap||!upe(m,S))continue;const E=tdt(S.min,S.max,x);v.push({min:E.min,max:E.max,sourceId:this._sourceIds[S.priority],footprint:S.footprint,footprintTileId:S.tileId,order:S.order,clipMask:S.clipMask,clipScope:S.clipScope})}return v}setSources(x){this._setSources(x.map(d=>({getSourceId:()=>d.cache.id,getFootprints:()=>{const m=[];for(const v of d.cache.getVisibleCoordinates()){const S=d.cache.getTile(v).buckets[d.layer];S&&S.updateFootprints(v.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(),v=x.getClipMask(),S=x.getClipScope();for(const E of d){if(!E.footprint)continue;const P=XCe(E.footprint.min,E.footprint.max,E.id);this._activeRegions.push({min:P.min,max:P.max,hiddenByOverlap:!1,priority:this._sourceIds.length,tileId:E.id,footprint:E.footprint,order:m,clipMask:v,clipScope:S})}this._sourceIds.push(x.getSourceId())}_computeReplacement(){this._activeRegions.sort((d,m)=>d.priority-m.priority||MF(d.min,m.min)||MF(d.max,m.max)||d.order-m.order||d.clipMask-m.clipMask||function(v,S){const E=(P,O)=>P+O;return v.length-S.length||v.reduce(E,"").localeCompare(S.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],v=this._prevRegions[d];x=m.priority!==v.priority||!YCe(m,v)||m.order!==v.order||m.clipMask!==v.clipMask||!ir(m.clipScope,v.clipScope),this._activeRegions[d].hiddenByOverlap=v.hiddenByOverlap,++d}}if(x){++this._updateTime;for(const m of this._activeRegions)m.order!==G6&&(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 v=this._activeRegions;if(m>=v.length)return m;const S=v[m].priority;for(;m1){let m=0,v=d(m);for(;m!==v;){let S=m;const E=m;for(;S!==v;){const P=this._activeRegions[S];P.hiddenByOverlap=!1;for(let O=0;O=0;d--)this._addSource(x[d]);this._computeReplacement()}},i.eQ=G6,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 Ey,v=new zl,S=[],E=x+1+2,P=d[0]+1,O=d[0]+1+(1+d.length),$=(G,ee,se)=>{let ie=G===E-1?G-2:G===0?G:G-1;return ie+=se?24575:0,[ie,ee]};for(let G=0;G0?(Oe=2*Math.sqrt(ke+1),x[3]=.25*Oe,x[0]=(se-de)/Oe,x[1]=(ie-$)/Oe,x[2]=(O-G)/Oe):P>ee&&P>ue?(Oe=2*Math.sqrt(1+P-ee-ue),x[3]=(se-de)/Oe,x[0]=.25*Oe,x[1]=(O+G)/Oe,x[2]=(ie+$)/Oe):ee>ue?(Oe=2*Math.sqrt(1+ee-P-ue),x[3]=(ie-$)/Oe,x[0]=(O+G)/Oe,x[1]=.25*Oe,x[2]=(se+de)/Oe):(Oe=2*Math.sqrt(1+ue-P-ee),x[3]=(O-G)/Oe,x[0]=(ie+$)/Oe,x[1]=(se+de)/Oe,x[2]=.25*Oe),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 v=Math.hypot(x,d,m),S=Math.atan2(x,m),E=.5*Math.PI-Math.acos(-d/v);return new y(Xn(S),Xn(E))},i.f1=Ze,i.f2=Spe,i.f3=function(x){const d=x.navigator?x.navigator.userAgent:null;return!!function(m){if(al==null){const v=m.navigator?m.navigator.userAgent:null;al=!!m.safari||!(!v||!(/\b(iPad|iPhone|iPod)\b/.test(v)||v.match("Safari")&&!v.match("Chrome")))}return al}(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){V1=x,H1=d},i.f5=spe,i.f6=vCe,i.f7=function(x){const d=[0,0,0],m=w(new Float64Array(16));return C(m,x.pixelMatrix,x.globeMatrix),ft(d,d,m),new pt(d[0],d[1])},i.f8=function(){const x=J6;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(gpe),J6=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(){IF().acquire(gpe)},i.fA=h7,i.fB=Ht,i.fC=function(x){let d=0;if(new Uint32Array(x,0,1)[0]!==E3e){const m=new Uint32Array(x,0,7),[,,v,S,E,P]=m;d=m.byteLength+S+E+P+E,(v!==x.byteLength||d>=x.byteLength)&&fr("Invalid b3dm header information.")}return D3e(x,d)},i.fD=function(x,d){const m=Epe(x);for(const v of m){for(const S of v.meshes)Pdt(S);v.lights&&(v.lightMeshIndex=v.meshes.length,v.meshes.push(Idt(v.lights,d)))}return m},i.fE=i7,i.fF=ya,i.fG=S3e,i.fH=ag,i.fI=Lh,i.fJ=function(x){Bd(),nm!=null&&nm.then(d=>{d.keys().then(m=>{for(let v=0;vfr(S.message))}).catch(m=>fr(m.message))}).catch(d=>fr(d.message))},i.fa=u2,i.fb=function(x,d,m=!1){if(Ru===Lh.deferred||Ru===Lh.loading||Ru===Lh.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");ng=Fl.resolveURL(x),Ru=Lh.deferred,y6=d,c3(),m||eF()},i.fc=function(x){B3=Fl.resolveURL(x),$3||($3=new z3(IF(),new Ms)),$3.broadcast("setMeshoptUrl",B3)},i.fd=T3e,i.fe=function(x){bpe=Fl.resolveURL(x),$3||($3=new z3(IF(),new Ms)),$3.broadcast("setDracoUrl",bpe)},i.ff=M3e,i.fg=Q6,i.fh=function(x){const d=am();if(!d)return;const m=d.delete(U1);x&&m.then(()=>x()).catch(x)},i.fi=k2,i.fj=Sr,i.fk=_b,i.fl=xg,i.fm=KMe,i.fn=ZMe,i.fo=Y3e,i.fp=is,i.fq="hd_road_elevation",i.fr=ci,i.fs=Qt,i.ft=pv,i.fu=Vpe,i.fv=M2,i.fw=function(x,d,m,v,S,E,P,O=1,$,G,ee){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=O,de.textSizeScaleRange=se.get("text-size-scale-range"),de.iconSizeScaleRange=se.get("icon-size-scale-range");const[ue,ke]=de.textSizeScaleRange,[Oe,De]=de.iconSizeScaleRange;de.textScaleFactor=je(de.scaleFactor,ue,ke),de.iconScaleFactor=je(de.scaleFactor,Oe,De);const Ke=ie["text-size"],Xe=ie["icon-size"];if(x.textSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ns}=x.textSizeData;de.compositeTextSizes=[Ke.possiblyEvaluate(new Ki(qt,{worldview:ee}),E),Ke.possiblyEvaluate(new Ki(ns,{worldview:ee}),E)]}if(x.iconSizeData.kind==="composite"){const{minZoom:qt,maxZoom:ns}=x.iconSizeData;de.compositeIconSizes=[Xe.possiblyEvaluate(new Ki(qt,{worldview:ee}),E),Xe.possiblyEvaluate(new Ki(ns,{worldview:ee}),E)]}de.layoutTextSize=Ke.possiblyEvaluate(new Ki(P+1,{worldview:ee}),E),de.layoutIconSize=Xe.possiblyEvaluate(new Ki(P+1,{worldview:ee}),E),de.textMaxSize=Ke.possiblyEvaluate(new Ki(18,{worldview:ee}),E);const ot=se.get("symbol-placement"),Nt=se.get("text-rotation-alignment")==="map"&&ot!=="point",yt=se.get("text-size");let At=!1;const Ft=[];for(const qt of x.features){const ns=se.get("text-font").evaluate(qt,{},E).join(","),Gt=yt.evaluate(qt,{},E)*de.textScaleFactor,ds=de.layoutTextSize.evaluate(qt,{},E)*de.textScaleFactor,js=de.layoutIconSize.evaluate(qt,{},E)*de.iconScaleFactor,Ns={horizontal:{},vertical:void 0},Fs=qt.text;let Bs,Is=[0,0];if(Fs){const Fn=Fs.toString(),Ti=se.get("text-letter-spacing").evaluate(qt,{},E)*Sc,bt=se.get("text-line-height").evaluate(qt,{},E)*Sc,St=x6(Fn)?Ti:0,ms=se.get("text-anchor").evaluate(qt,{},E),zs=se.get("text-variable-anchor");if(!zs){const An=se.get("text-radial-offset").evaluate(qt,{},E);if(An)Is=P5e(ms,[An*Sc,Gpe]);else{const Wn=se.get("text-offset").evaluate(qt,{},E);Is=[Wn[0]*Sc,Wn[1]*Sc]}}let or=Nt?"center":se.get("text-justify").evaluate(qt,{},E);const lr=ot==="point",zr=lr?se.get("text-max-width").evaluate(qt,{},E)*Sc:1/0,Ur=An=>{x.allowVerticalPlacement&&c2(Fn)&&(Ns.vertical=zpe(Fs,d,m,S,ns,zr,bt,ms,An,St,Is,mm.vertical,!0,ds,Gt,$))};if(!Nt&&zs){const An=or==="auto"?zs.map(Yn=>Kpe(Yn)):[or];let Wn=!1;for(let Yn=0;Yn=0||!c2(Fn)){const An=zpe(Fs,d,m,S,ns,zr,bt,ms,or,St,Is,mm.horizontal,!1,ds,Gt,$);An&&(Ns.horizontal[or]=An)}Ur(lr?"left":or)}}let Ls,cs,as,Os,sr,Hs,Fr=!1;const hr=se.get("icon-text-fit").evaluate(qt,{},E);if(qt.icon&&qt.icon.hasPrimary()){const Fn=cP(qt.icon,x.iconSizeData,ie["icon-size"],E,x.zoom,qt,$,de.iconScaleFactor,ee);Ls=Fn.iconPrimary,as=Fn.iconSecondary;const Ti=Ls.toString();if(cs=v.get(Ti),cs&&(sr=se.get("icon-offset").evaluate(qt,{},E),Hs=se.get("icon-anchor").evaluate(qt,{},E),Bs=HF(S.get(Ti),as?S.get(as.toString()):void 0,sr,Hs),Fr=cs.sdf,x.sdfIcons===void 0?x.sdfIcons=cs.sdf:x.sdfIcons!==cs.sdf&&fr("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(cs.pixelRatio!==x.pixelRatio||se.get("icon-rotate").constantOr(1)!==0)&&(x.iconsNeedLinear=!0)),as){const bt=as.toString();Os=v.get(bt)}}At=At||!(!qt.icon||!qt.icon.hasSecondary());const _r=YF(Ns.horizontal)||Ns.vertical;x.iconsInText||(x.iconsInText=!!_r&&_r.iconsInText);const Tr=ds*de.textScaleFactor/Sc,{defaultShapedIcon:Qn,verticallyShapedIcon:Zs}=$ut(x,Bs,se,qt,E,Ns,Tr,sr,hr);hr!=="none"&&Bs&&(g5e(Bs)||y5e(Bs))&&(ZF(0,cs,Ls,Bs,Qn,hr,G,v,S),ZF(0,Os,as,Bs,Qn,hr,G,v,S),Zs&&(ZF(0,cs,Ls,Bs,Zs,hr,G,v,S),ZF(0,Os,as,Bs,Zs,hr,G,v,S))),Bs=Qn;const{iconBBox:Ar,iconVerticalBBox:yn,textBBox:ba,textVerticalBBox:Sa}=Out(x,Bs,Zs,se,qt,E,js,sr,de,S,Hs,Ns,ds,Is);Ft.push({feature:qt,shapedTextOrientations:Ns,shapedText:_r,shapedIcon:Bs,iconPrimary:Ls,iconSecondary:as,iconOffset:sr,iconAnchor:Hs,verticallyShapedIcon:Zs,layoutTextSize:ds,layoutIconSize:js,textOffset:Is,isSDFIcon:Fr,iconTextFit:hr,iconCollisionBounds:Ar,iconVerticalCollisionBounds:yn,textCollisionBounds:ba,textVerticalCollisionBounds:Sa})}return{featureData:Ft,sizes:de,hasAnySecondaryIcon:At,textAlongLine:Nt,symbolPlacement:ot}},i.fx=S5e,i.fy=function(x,d,m,v,S,E,P,O,$,G){x.iconAtlasPositions=G.iconPositions;const{featureData:ee,hasAnySecondaryIcon:se,sizes:ie,textAlongLine:de,symbolPlacement:ue}=d;for(const ke of ee){const{shapedIcon:Oe,verticallyShapedIcon:De,feature:Ke,shapedTextOrientations:Xe,shapedText:ot,layoutTextSize:Nt,textOffset:yt,isSDFIcon:At,iconPrimary:Ft,iconSecondary:qt,iconTextFit:ns,iconOffset:Gt,iconCollisionBounds:ds,iconVerticalCollisionBounds:js,textCollisionBounds:Ns}=ke;L5e(Oe,G.iconPositions,Ft,qt),L5e(De,G.iconPositions,Ft,qt),But(Xe,G.iconPositions),zut(Ft,qt,G.iconPositions),(ot||Oe)&&qut(x,Ke,Xe,Oe,De,$,ie,Nt,0,yt,At,v,S,P,O,se,ns,Gt,de,ue,ds,js,Ns)}m&&x.generateCollisionDebugBuffers(E,x.collisionBoxArray,ie.textScaleFactor)},i.fz=Xt,i.g=function(x,d){return Yx(Object.assign(x,{method:"GET"}),d)},i.h=function(x){return x.indexOf("mapbox:")===0},i.i=function(x){return ca.API_STYLE_REGEX.test(x)&&!Nc(x)},i.j=co,i.k=cu,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 Yx(Object.assign(x,{type:"json"}),d)},i.n=yy,i.o=Fl,i.p=function(x,d){return Yx(Object.assign(x,{method:"POST"}),d)},i.q=Hd,i.r=Gm,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 ype||(ype=new k2("ImageRasterizer")),ype},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=fr,i.x=ufe,i.y=vy,i.z=Ym}),o(["./shared"],function(i){function c($t){const je=$t?$t.url.toString():void 0;return je?performance.getEntriesByName(je):[]}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 je="{";for(const Be of Object.keys($t).sort())je+=`${Be}:${u($t[Be])},`;return`${je}}`}function p($t){let je="";for(const Be of i.bx)je+=`/${u($t[Be])}`;return je}class f{constructor(je){this.keyCache={},this._layers={},this._layerConfigs={},je&&this.replace(je)}replace(je,Be){this._layerConfigs={},this._layers={},this.update(je,[],Be)}update(je,Be,Ye){this._options=Ye;for(const xt of je)this._layerConfigs[xt.id]=xt,(this._layers[xt.id]=i.du(xt,this.scope,null,this._options)).compileFilter(Ye),this.keyCache[xt.id]&&delete this.keyCache[xt.id];for(const xt of Be)delete this.keyCache[xt],delete this._layerConfigs[xt],delete this._layers[xt];this.familiesBySource={};const vt=function(xt,Rt){const Zt={};for(let Qt=0;Qtthis._layers[yr.id]),Zt=Rt[0];if(Zt.visibility==="none")continue;const Vt=Zt.source||"";let Qt=this.familiesBySource[Vt];Qt||(Qt=this.familiesBySource[Vt]={});const Es=Zt.sourceLayer||"_geojsonTileLayer";let ys=Qt[Es];ys||(ys=Qt[Es]=[]),ys.push(Rt)}}}const g=1*i.fl;class b{constructor(je){const Be={},Ye=[];for(const Zt in je){const Vt=je[Zt],Qt=Be[Zt]={};for(const Es in Vt.glyphs){const ys=Vt.glyphs[+Es];if(!ys||ys.bitmap.width===0||ys.bitmap.height===0)continue;const yr=ys.metrics.localGlyph?g:1,Vr={x:0,y:0,w:ys.bitmap.width+2*yr,h:ys.bitmap.height+2*yr};Ye.push(Vr),Qt[Es]=Vr}}const{w:vt,h:xt}=i.G(Ye),Rt=new i.fk({width:vt||1,height:xt||1});for(const Zt in je){const Vt=je[Zt];for(const Qt in Vt.glyphs){const Es=Vt.glyphs[+Qt];if(!Es||Es.bitmap.width===0||Es.bitmap.height===0)continue;const ys=Be[Zt][Qt],yr=Es.metrics.localGlyph?g:1;i.fk.copy(Es.bitmap,Rt,{x:0,y:0},{x:ys.x+yr,y:ys.y+yr},Es.bitmap)}}this.image=Rt,this.positions=Be}}function _($t,je,Be){$t[je]?Be&&($t[je].center=Be):$t[je]={floorIds:new Set,center:Be||[0,0],floors:{}}}function j($t,je,Be,Ye){for(const vt of je)_($t,vt),$t[vt].floors[Be]=Ye,$t[vt].floorIds.add(Be)}function w($t){return{id:$t.properties.id.toString(),center:$t.properties.center.toString().split(";").map(Number)}}function N($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 C($t,je){return je.every(Be=>$t.properties&&$t.properties[Be]!=null)}function M($t){return C($t,["type","id","name"])&&$t.properties.type==="building"}function I($t){return C($t,["type","id","name","z_index"])&&$t.properties.type==="floor"}i.fj(b,"GlyphAtlas");class L{constructor(je){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.lut=je.lut,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.scope=je.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=je.showCollisionBoxes,this.collectResourceTiming=!!je.request&&je.request.collectResourceTiming,this.promoteId=je.promoteId,this.isSymbolTile=je.isSymbolTile,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.projection=je.projection,this.worldview=je.worldview,this.localizableLayerIds=je.localizableLayerIds,this.brightness=je.brightness,this.extraShadowCaster=!!je.extraShadowCaster,this.tessellationStep=je.tessellationStep,this.scaleFactor=je.scaleFactor,this.worldview=je.worldview,this.indoor=je.indoor}parse(je,Be,Ye,vt,xt,Rt){this.status="parsing",this.data=je,this.collisionBoxArray=new i.b3;const Zt=new i.fm(Object.keys(je.layers).sort()),Vt=new i.fn(this.tileID,this.promoteId);Vt.bucketLayerIDs=[];const Qt={},Es=new i.fo(256,256),ys={featureIndex:Vt,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:Es,availableImages:Ye,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const Pn=this.indoor.indoorState.activeFloorsVisible,In=function(Mn,ya,vo){const al=function(oo,Ea){if(!oo)return i.w("No source layers defined in indoor specification"),Ea;if(oo.size===0)return Ea;const lo=oo.difference(Ea);for(const Mi of lo)i.w(`Missing source layer required in indoor specification: ${Mi}`);return Ea.intersection(Ea)}(ya.sourceLayers,new Set(Object.keys(Mn.layers))),Ja=ya.indoorState,dl=function(oo,Ea,lo,Mi){const ca=new Set,co=new Set,Nc=new Set,Uc=new Map,ou={},Df=Rl=>{const oh=Uc.get(Rl)||new Set;for(const kd of ca)if((Uc.get(kd)||new Set).has(Rl)||oh.has(kd))return!0;return!1};for(const Rl of Ea){const oh=oo.layers[Rl];if(oh)for(let kd=0;kd=lo.maxzoom||lo.visibility==="none")continue;R(Ea,this.zoom,ys.brightness,Ye,this.worldview);const Mi=Qt[lo.id]=lo.createBucket({index:Vt.bucketLayerIDs.length,layers:Ea,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:al,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:vt,worldview:this.worldview,localizable:dl});Vt.bucketLayerIDs.push(Ea.map(co=>i.B(co.id,co.scope)));let ca=Mi.prepare?Mi.prepare():null;ca!=null?(ca=ca.then(()=>Mi.populate(Ja,ys,this.tileID.canonical,this.tileTransform)),yr.push(ca)):Mi.populate(Ja,ys,this.tileID.canonical,this.tileTransform)}}const fr=()=>{let Pn,In,Mn,ya,vo,al;Es.trim();const Ja={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},dl=()=>{if(Pn)return this.status="done",Rt(Pn);if(this.extraShadowCaster)this.status="done",Rt(null,{buckets:Object.values(Qt).filter(Ea=>!Ea.isEmpty()),featureIndex:Vt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:ys.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(In&&Mn&&ya){const Ea=new b(In),lo=new Map;for(const[co,Nc]of Mn.entries()){const{imagePosition:Uc}=i.fu(co,Nc,i.fv);lo.set(co,Uc)}const Mi={};for(const co in Qt){const Nc=Qt[co];Nc instanceof i.b4&&(R(Nc.layers,this.zoom,ys.brightness,Ye,this.worldview),Mi[co]=i.fw(Nc,In,Ea.positions,Mn,lo,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,vo,this.worldview))}const ca={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(xt,Mn,vo,()=>{ca.iconsPending=!1,oo(Mi,Ea,ca)}),this.rasterizeIfNeeded(xt,ya,al,()=>{ca.patternsPending=!1,oo(Mi,Ea,ca)})}},oo=(Ea,lo,Mi,ca)=>{if(Mi.iconsPending||Mi.patternsPending)return;const co=new i.fx(Mn,ya,this.lut);for(const Nc in Qt){const Uc=Qt[Nc];if(Nc in Ea)i.fy(Uc,Ea[Nc],this.showCollisionBoxes,Ye,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,Mn,co);else if(Uc.hasPattern&&(Uc instanceof i.ba||Uc instanceof i.bb||Uc instanceof i.ea)){R(Uc.layers,this.zoom,ys.brightness,Ye,this.worldview);const ou=Object.fromEntries(co.patternPositions);Uc.addFeatures(ys,this.tileID.canonical,ou,Ye,this.tileTransform,this.brightness)}}this.status="done",Rt(null,{buckets:Object.values(Qt).filter(Nc=>!Nc.isEmpty()),featureIndex:Vt,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:lo.image,lineAtlas:Es,imageAtlas:co,brightness:ys.brightness})};if(!this.extraShadowCaster){const Ea=i.fs(ys.glyphDependencies,ca=>Object.keys(ca).map(Number));Object.keys(Ea).length?xt.send("getGlyphs",{uid:this.uid,stacks:Ea},(ca,co)=>{Pn||(Pn=ca,In=co,dl())},void 0,!1,Ja):In={};const lo=Array.from(ys.iconDependencies.keys()).map(ca=>i.I.parse(ca));lo.length?xt.send("getImages",{images:lo,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(ca,co)=>{Pn||(Pn=ca,Mn=new Map,vo=this.updateImageMapAndGetImageTaskQueue(Mn,co,ys.iconDependencies),dl())},void 0,!1,Ja):(Mn=new Map,vo=new Map);const Mi=Array.from(ys.patternDependencies.keys()).map(ca=>i.I.parse(ca));Mi.length?xt.send("getImages",{images:Mi,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(ca,co)=>{Pn||(Pn=ca,ya=new Map,al=this.updateImageMapAndGetImageTaskQueue(ya,co,ys.patternDependencies),dl())},void 0,!1,Ja):(ya=new Map,al=new Map)}if(ys.elevationFeatures&&ys.elevationFeatures.length>0){const Ea=[];for(const Mi of Object.values(Qt))if(Mi instanceof i.bb){const ca=Mi.getUnevaluatedPortalGraph();ca&&Ea.push(ca)}const lo=i.ft.evaluate(Ea);for(const Mi of Object.values(Qt))if(Mi instanceof i.bb){const ca=je.layers[Zt.decode(Mi.sourceLayerIndex)];Mi.setEvaluatedPortalGraph(lo,ca,this.tileID.canonical,ys.availableImages,ys.brightness)}}dl()};yr.length>0?Promise.allSettled(yr).then(fr).catch(Rt):fr()}updateParameters(je){this.scaleFactor=je.scaleFactor,this.showCollisionBoxes=je.showCollisionBoxes,this.projection=je.projection,this.brightness=je.brightness,this.tileTransform=i.aZ(je.tileID.canonical,je.projection),this.extraShadowCaster=je.extraShadowCaster,this.lut=je.lut,this.worldview=je.worldview,this.indoor=je.indoor}rasterizeIfNeeded(je,Be,Ye,vt){Array.from(Be.values()).some(xt=>xt.usvg)?this.rasterize(je,Be,Ye,vt):vt()}updateImageMapAndGetImageTaskQueue(je,Be,Ye){const vt=new Map;for(const xt of Be.keys()){const Rt=Ye.get(xt)||[];for(const Zt of Rt){const Vt=Zt.toString(),Qt=Be.get(Zt.id.toString());Qt.usvg?vt.has(Vt)||(vt.set(Vt,Zt),je.set(Vt,Object.assign({},Qt))):je.set(Vt,Qt)}}return vt}rasterize(je,Be,Ye,vt){this.rasterizeTask=je.send("rasterizeImages",{scope:this.scope,tasks:Ye},(xt,Rt)=>{if(!xt)for(const[Zt,Vt]of Rt.entries()){const Qt=Object.assign(Be.get(Zt),{data:Vt});Be.set(Zt,Qt)}vt()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function R($t,je,Be,Ye,vt){const xt=new i.ac(je,{brightness:Be,worldview:vt});for(const Rt of $t)Rt.recalculate(xt,Ye)}class q extends i.E{constructor(je,Be,Ye,vt,xt,Rt,Zt){super(),this.actor=je,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=vt,this.loadVectorData=Rt||i.aL,this.loading={},this.loaded={},this.deduped=new i.aK(je.scheduler),this.isSpriteLoaded=xt,this.scheduler=je.scheduler,this.brightness=Zt}loadTile(je,Be){const Ye=je.uid,vt=je&&je.request,xt=vt&&vt.collectResourceTiming,Rt=this.loading[Ye]=new L(je);Rt.abort=this.loadVectorData(je,(Zt,Vt)=>{const Qt=!this.loading[Ye];if(delete this.loading[Ye],Rt.cancelRasterize(),Qt||Zt||!Vt)return Rt.status="done",Qt||(this.loaded[Ye]=Rt),Be(Zt);const Es=Vt.rawData,ys={},yr=i.aM(Vt.responseHeaders);yr&&yr.expires&&(ys.expires=yr.expires),yr&&yr.cacheControl&&(ys.cacheControl=yr.cacheControl),Rt.vectorTile=Vt.vectorTile||new i.fz(new i.bt(Es));const Vr=()=>{Rt.parse(Rt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(fr,Pn)=>{if(fr||!Pn)return Be(fr);const In={};if(xt){const Mn=c(vt);Mn.length>0&&(In.resourceTiming=JSON.parse(JSON.stringify(Mn)))}Be(null,Object.assign({rawTileData:Es.slice(0),responseHeaders:Vt.responseHeaders},Pn,ys,In))})};this.isSpriteLoaded?Vr():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(Vr,{type:"parseTile",isSymbolTile:je.isSymbolTile,zoom:je.tileZoom}):Vr()}),this.loaded=this.loaded||{},this.loaded[Ye]=Rt})}reloadTile(je,Be){const Ye=this.loaded,vt=je.uid;if(Ye&&Ye[vt]){const xt=Ye[vt];xt.updateParameters(je);const Rt=(Zt,Vt)=>{const Qt=xt.reloadCallback;Qt&&(delete xt.reloadCallback,xt.parse(xt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Qt)),Be(Zt,Vt)};xt.status==="parsing"?xt.reloadCallback=Rt:xt.status==="done"&&(xt.vectorTile?xt.parse(xt.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,Rt):Rt())}else Be(null,void 0)}abortTile(je,Be){const Ye=je.uid,vt=this.loading[Ye];vt&&(vt.abort&&vt.abort(),delete this.loading[Ye]),Be()}removeTile(je,Be){const Ye=this.loaded,vt=je.uid;Ye&&Ye[vt]&&delete Ye[vt],Be()}}class U{loadTile(je,Be){const{uid:Ye,encoding:vt,rawImageData:xt,padding:Rt}=je,Zt=ImageBitmap&&xt instanceof ImageBitmap?this.getImageData(xt,Rt):xt;Be(null,new i.fA(Ye,Zt,vt,Rt<1))}reloadTile(je,Be){Be(null,null)}abortTile(je,Be){Be()}removeTile(je,Be){Be()}getImageData(je,Be){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(je.width,je.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=je.width,this.offscreenCanvas.height=je.height,this.offscreenCanvasContext.drawImage(je,0,0,je.width,je.height);const Ye=this.offscreenCanvasContext.getImageData(-Be,-Be,je.width+2*Be,je.height+2*Be);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),Ye}}i.bs.setPbf(i.bt);class B{constructor(je){this._mrt=new i.bs(je.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=je.uid,this.tileID=je.tileID,this.source=je.source}parse(je,Be){const Ye=this._mrt;this.status="parsing",this._entireBuffer=je;try{Ye.parseHeader(je),this._isHeaderLoaded=!0;const vt=[];for(const xt in Ye.layers){const Rt=Ye.getLayer(xt),Zt=Rt.getDataRange(Rt.getBandList()),Vt=Ye.createDecodingTask(Zt),Qt=je.slice(Zt.firstByte,Zt.lastByte+1),Es=i.bs.performDecoding(Qt,Vt).then(ys=>Vt.complete(null,ys)).catch(ys=>Vt.complete(ys,null));vt.push(Es)}Promise.allSettled(vt).then(()=>Be(null,Ye)).catch(xt=>Be(xt))}catch(vt){Be(vt)}}}class V{constructor(je){this.actor=je,this.loading={},this.loaded={}}loadTile(je,Be){const Ye=je.uid,vt=je.request,xt=this.loading[Ye]=new B(je),{cancel:Rt}=i.bu(vt,(Zt,Vt,Qt)=>{const Es=!this.loading[Ye];if(delete this.loading[Ye],Es||Zt||!Vt)return xt.status="done",Es||(this.loaded[Ye]=xt),Be(Zt);xt.parse(Vt,(ys,yr)=>{if(ys||!yr)return Be(ys);Be(null,yr,Qt)}),this.loaded[Ye]=xt});xt.abort=Rt}reloadTile(je,Be){Be(null,void 0)}abortTile(je,Be){const Ye=je.uid,vt=this.loading[Ye];vt&&(vt.abort&&vt.abort(),delete this.loading[Ye]),Be()}removeTile(je,Be){const Ye=je.uid;this.loaded[Ye]&&delete this.loaded[Ye],Be()}decodeRasterArray(je,Be){i.bs.performDecoding(je.buffer,je.task).then(Ye=>Be(null,Ye)).catch(Ye=>Be(Ye))}}const Y=i.fB.prototype.toGeoJSON;class J{constructor(je){this._feature=je,this.extent=i.al,this.type=je.type,this.properties=je.tags,"id"in je&&!isNaN(je.id)&&(this.id=parseInt(je.id,10))}loadGeometry(){if(this._feature.type===1){const je=[];for(const Be of this._feature.geometry)je.push([new i.P(Be[0],Be[1])]);return je}{const je=[];for(const Be of this._feature.geometry){const Ye=[];for(const vt of Be)Ye.push(new i.P(vt[0],vt[1]));je.push(Ye)}return je}}toGeoJSON(je,Be,Ye){return Y.call(this,je,Be,Ye)}}class te{constructor(je,Be){this.name=je,this.extent=i.al,this.length=Be.length,this._jsonFeatures=Be}feature(je){return new J(this._jsonFeatures[je])}}class X{constructor(je){this.layers={},this.extent=i.al;for(const Be of Object.keys(je))this.layers[Be]=new te(Be,je[Be])}}const ce=64/4096,ne=128;class re{constructor(){this.features=new Map}clear(){this.features.clear()}load(je=[],Be){for(const Ye of je){const vt=Ye.id;if(vt==null)continue;let xt=this.features.get(vt);xt&&this.updateCache(xt,Be),Ye.geometry?(xt=pe(Ye),this.updateCache(xt,Be),this.features.set(vt,xt)):this.features.delete(vt),this.updateCache(xt,Be)}}updateCache(je,Be){for(const{canonical:Ye,uid:vt}of Object.values(Be)){const{z:xt,x:Rt,y:Zt}=Ye;le(je,Math.pow(2,xt),Rt,Zt)&&delete Be[vt]}}getTile(je,Be,Ye){const vt=Math.pow(2,je),xt=[];for(const Rt of this.features.values())le(Rt,vt,Be,Ye)&&xt.push(we(Rt,vt,Be,Ye));return{features:xt}}getFeatures(){return[...this.features.values()]}}function le({minX:$t,minY:je,maxX:Be,maxY:Ye},vt,xt,Rt){return $t<(xt+1+ce)/vt&&je<(Rt+1+ce)/vt&&Be>(xt-ce)/vt&&Ye>(Rt-ce)/vt}function pe($t){const{id:je,geometry:Be,properties:Ye}=$t;if(!Be)return;if(Be.type==="GeometryCollection")throw new Error("GeometryCollection not supported in dynamic mode.");const{type:vt,coordinates:xt}=Be,Rt={id:je,type:1,geometry:[],tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Zt=Rt.geometry;if(vt==="Point")xe(xt,Zt,Rt);else if(vt==="MultiPoint")for(const Vt of xt)xe(Vt,Zt,Rt);else if(vt==="LineString")Rt.type=2,_e(xt,Zt,Rt);else if(vt==="MultiLineString")Rt.type=2,fe(xt,Zt,Rt);else if(vt==="Polygon")Rt.type=3,fe(xt,Zt,Rt,!0);else{if(vt!=="MultiPolygon")throw new Error("Input data is not a valid GeoJSON object.");Rt.type=3;for(const Vt of xt)fe(Vt,Zt,Rt,!0)}return Rt}function xe([$t,je],Be,Ye){const vt=i.aF($t);let xt=i.aJ(je);xt=xt<0?0:xt>1?1:xt,Be.push(vt,xt),Ye.minX=Math.min(Ye.minX,vt),Ye.minY=Math.min(Ye.minY,xt),Ye.maxX=Math.max(Ye.maxX,vt),Ye.maxY=Math.max(Ye.maxY,xt)}function _e($t,je,Be,Ye=!1,vt=!1){const xt=[];for(const Rt of $t)xe(Rt,xt,Be);je.push(xt),Ye&&function(Rt,Zt){let Vt=0;for(let Qt=0,Es=Rt.length,ys=Es-2;Qt0===Zt)for(let Qt=0,Es=Rt.length;Qt=Rt&&ys>=Rt||(Qt>=Rt?(Es+=Math.round(fr*((Rt-Qt)/Vr)),Qt=Rt):ys>=Rt&&(yr=Es+Math.round(fr*((Rt-Qt)/Vr)),ys=Rt),Es>=Rt&&yr>=Rt||(Es>=Rt?(Qt+=Math.round(Vr*((Rt-Es)/fr)),Es=Rt):yr>=Rt&&(ys=Qt+Math.round(Vr*((Rt-Es)/fr)),yr=Rt),Zt&&Qt===Zt[Zt.length-1][0]&&Es===Zt[Zt.length-1][1]||(Zt=[[Qt,Es]],vt.push(Zt)),Zt.push([ys,yr])))))}}function Ne($t,je,Be,Ye,vt){const xt=(Be-ce)/je,Rt=(Ye-ce)/je,Zt=(Be+1+ce)/je,Vt=(Ye+1+ce)/je;function Qt(yr,Vr){let fr=0;return yrZt&&(fr|=2),VrVt&&(fr|=8),fr}let Es=[];for(let yr=1;yr<=8;yr*=2){let Vr=$t[$t.length-2],fr=$t[$t.length-1],Pn=!(Qt(Vr,fr)&yr);for(let In=0;In<$t.length;In+=2){const Mn=$t[In],ya=$t[In+1],vo=!(Qt(Mn,ya)&yr);vo!==Pn&&(8&yr?Es.push(Vr+(Mn-Vr)*(Vt-fr)/(ya-fr),Vt):4&yr?Es.push(Vr+(Mn-Vr)*(Rt-fr)/(ya-fr),Rt):2&yr?Es.push(Zt,fr+(ya-fr)*(Zt-Vr)/(Mn-Vr)):1&yr&&Es.push(xt,fr+(ya-fr)*(xt-Vr)/(Mn-Vr))),vo&&Es.push(Mn,ya),Vr=Mn,fr=ya,Pn=vo}if(!($t=Es).length||yr===8)break;Es=[]}const ys=[];for(let yr=0;yr>31}function ct($t,je){const{geometry:Be,type:Ye}=$t;let vt=0,xt=0;if(Ye===1){je.writeVarint(Me(1,Be.length));for(const Rt of Be){const Zt=Rt[0]-vt,Vt=Rt[1]-xt;je.writeVarint($e(Zt)),je.writeVarint($e(Vt)),vt+=Zt,xt+=Vt}}else for(const Rt of Be){je.writeVarint(Me(1,1));const Zt=Rt.length-(Ye===3?1:0);for(let Vt=0;Vt$t},me=Math.fround||(Ve=new Float32Array(1),$t=>(Ve[0]=+$t,Ve[0]));var Ve;const nt=3,et=5,Se=6;class rt{constructor(je){this.options=Object.assign(Object.create(ft),je),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(je){const{log:Be,minZoom:Ye,maxZoom:vt}=this.options;Be&&console.time("total time");const xt=`prepare ${je.length} points`;Be&&console.time(xt),this.points=je;const Rt=[];for(let Vt=0;Vt=Ye;Vt--){const Qt=+Date.now();Zt=this.trees[Vt]=this._createTree(this._cluster(Zt,Vt)),Be&&console.log("z%d: %d clusters in %dms",Vt,Zt.numItems,+Date.now()-Qt)}return Be&&console.timeEnd("total time"),this}getClusters(je,Be){let Ye=((je[0]+180)%360+360)%360-180;const vt=Math.max(-90,Math.min(90,je[1]));let xt=je[2]===180?180:((je[2]+180)%360+360)%360-180;const Rt=Math.max(-90,Math.min(90,je[3]));if(je[2]-je[0]>=360)Ye=-180,xt=180;else if(Ye>xt){const ys=this.getClusters([Ye,vt,180,Rt],Be),yr=this.getClusters([-180,vt,xt,Rt],Be);return ys.concat(yr)}const Zt=this.trees[this._limitZoom(Be)],Vt=Zt.range(qe(Ye),Ze(Rt),qe(xt),Ze(vt)),Qt=Zt.data,Es=[];for(const ys of Vt){const yr=this.stride*ys;Es.push(Qt[yr+et]>1?Ge(Qt,yr,this.clusterProps):this.points[Qt[yr+nt]])}return Es}getChildren(je){const Be=this._getOriginId(je),Ye=this._getOriginZoom(je),vt="No cluster with the specified id.",xt=this.trees[Ye];if(!xt)throw new Error(vt);const Rt=xt.data;if(Be*this.stride>=Rt.length)throw new Error(vt);const Zt=this.options.radius/(this.options.extent*Math.pow(2,Ye-1)),Vt=xt.within(Rt[Be*this.stride],Rt[Be*this.stride+1],Zt),Qt=[];for(const Es of Vt){const ys=Es*this.stride;Rt[ys+4]===je&&Qt.push(Rt[ys+et]>1?Ge(Rt,ys,this.clusterProps):this.points[Rt[ys+nt]])}if(Qt.length===0)throw new Error(vt);return Qt}getLeaves(je,Be,Ye){const vt=[];return this._appendLeaves(vt,je,Be=Be||10,Ye=Ye||0,0),vt}getTile(je,Be,Ye){const vt=this.trees[this._limitZoom(je)],xt=Math.pow(2,je),{extent:Rt,radius:Zt}=this.options,Vt=Zt/Rt,Qt=(Ye-Vt)/xt,Es=(Ye+1+Vt)/xt,ys={features:[]};return this._addTileFeatures(vt.range((Be-Vt)/xt,Qt,(Be+1+Vt)/xt,Es),vt.data,Be,Ye,xt,ys),Be===0&&this._addTileFeatures(vt.range(1-Vt/xt,Qt,1,Es),vt.data,xt,Ye,xt,ys),Be===xt-1&&this._addTileFeatures(vt.range(0,Qt,Vt/xt,Es),vt.data,-1,Ye,xt,ys),ys.features.length?ys:null}getClusterExpansionZoom(je){let Be=this._getOriginZoom(je)-1;for(;Be<=this.options.maxZoom;){const Ye=this.getChildren(je);if(Be++,Ye.length!==1)break;je=Ye[0].properties.cluster_id}return Be}_appendLeaves(je,Be,Ye,vt,xt){const Rt=this.getChildren(Be);for(const Zt of Rt){const Vt=Zt.properties;if(Vt&&Vt.cluster?xt+Vt.point_count<=vt?xt+=Vt.point_count:xt=this._appendLeaves(je,Vt.cluster_id,Ye,vt,xt):xt1;let Es,ys,yr;if(Qt)Es=lt(Be,Vt,this.clusterProps),ys=Be[Vt],yr=Be[Vt+1];else{const Pn=this.points[Be[Vt+nt]];Es=Pn.properties;const[In,Mn]=Pn.geometry.coordinates;ys=qe(In),yr=Ze(Mn)}const Vr={type:1,geometry:[[Math.round(this.options.extent*(ys*xt-Ye)),Math.round(this.options.extent*(yr*xt-vt))]],tags:Es};let fr;fr=Qt||this.options.generateId?Be[Vt+nt]:this.points[Be[Vt+nt]].id,fr!==void 0&&(Vr.id=fr),Rt.features.push(Vr)}}_limitZoom(je){return Math.max(this.options.minZoom,Math.min(Math.floor(+je),this.options.maxZoom+1))}_cluster(je,Be){const{radius:Ye,extent:vt,reduce:xt,minPoints:Rt}=this.options,Zt=Ye/(vt*Math.pow(2,Be)),Vt=je.data,Qt=[],Es=this.stride;for(let ys=0;ysBe&&(In+=Vt[ya+et])}if(In>Pn&&In>=Rt){let Mn,ya=yr*Pn,vo=Vr*Pn,al=-1;const Ja=(ys/Es<<5)+(Be+1)+this.points.length;for(const dl of fr){const oo=dl*Es;if(Vt[oo+2]<=Be)continue;Vt[oo+2]=Be;const Ea=Vt[oo+et];ya+=Vt[oo]*Ea,vo+=Vt[oo+1]*Ea,Vt[oo+4]=Ja,xt&&(Mn||(Mn=this._map(Vt,ys,!0),al=this.clusterProps.length,this.clusterProps.push(Mn)),xt(Mn,this._map(Vt,oo)))}Vt[ys+4]=Ja,Qt.push(ya/In,vo/In,1/0,Ja,-1,In),xt&&Qt.push(al)}else{for(let Mn=0;Mn1)for(const Mn of fr){const ya=Mn*Es;if(!(Vt[ya+2]<=Be)){Vt[ya+2]=Be;for(let vo=0;vo>5}_getOriginZoom(je){return(je-this.points.length)%32}_map(je,Be,Ye){if(je[Be+et]>1){const Rt=this.clusterProps[je[Be+Se]];return Ye?Object.assign({},Rt):Rt}const vt=this.points[je[Be+nt]].properties,xt=this.options.map(vt);return Ye&&xt===vt?Object.assign({},xt):xt}}function Ge($t,je,Be){return{type:"Feature",id:$t[je+nt],properties:lt($t,je,Be),geometry:{type:"Point",coordinates:[(Ye=$t[je],360*(Ye-.5)),Je($t[je+1])]}};var Ye}function lt($t,je,Be){const Ye=$t[je+et],vt=Ye>=1e4?`${Math.round(Ye/1e3)}k`:Ye>=1e3?Math.round(Ye/100)/10+"k":Ye,xt=$t[je+Se],Rt=xt===-1?{}:Object.assign({},Be[xt]);return Object.assign(Rt,{cluster:!0,cluster_id:$t[je+nt],point_count:Ye,point_count_abbreviated:vt})}function qe($t){return $t/360+.5}function Ze($t){const je=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return Be<0?0:Be>1?1:Be}function Je($t){const je=(180-360*$t)*Math.PI/180;return 360*Math.atan(Math.exp(je))/Math.PI-90}function He($t,je,Be,Ye){let vt=Ye;const xt=je+(Be-je>>1);let Rt,Zt=Be-je;const Vt=$t[je],Qt=$t[je+1],Es=$t[Be],ys=$t[Be+1];for(let yr=je+3;yrvt)Rt=yr,vt=Vr;else if(Vr===vt){const fr=Math.abs(yr-xt);frYe&&(Rt-je>3&&He($t,je,Rt,Ye),$t[Rt+2]=vt,Be-Rt>3&&He($t,Rt,Be,Ye))}function Qe($t,je,Be,Ye,vt,xt){let Rt=vt-Be,Zt=xt-Ye;if(Rt!==0||Zt!==0){const Vt=(($t-Be)*Rt+(je-Ye)*Zt)/(Rt*Rt+Zt*Zt);Vt>1?(Be=vt,Ye=xt):Vt>0&&(Be+=Rt*Vt,Ye+=Zt*Vt)}return Rt=$t-Be,Zt=je-Ye,Rt*Rt+Zt*Zt}function at($t,je,Be,Ye){const vt={id:$t??null,type:je,geometry:Be,tags:Ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if(je==="Point"||je==="MultiPoint"||je==="LineString")It(vt,Be);else if(je==="Polygon")It(vt,Be[0]);else if(je==="MultiLineString")for(const xt of Be)It(vt,xt);else if(je==="MultiPolygon")for(const xt of Be)It(vt,xt[0]);return vt}function It($t,je){for(let Be=0;Be0&&(Rt+=Ye?(vt*Es-Qt*xt)/2:Math.sqrt(Math.pow(Qt-vt,2)+Math.pow(Es-xt,2))),vt=Qt,xt=Es}const Zt=je.length-3;je[2]=1,He(je,0,Zt,Be),je[Zt+2]=1,je.size=Math.abs(Rt),je.start=0,je.end=je.size}function ts($t,je,Be,Ye){for(let vt=0;vt<$t.length;vt++){const xt=[];Yt($t[vt],xt,Be,Ye),je.push(xt)}}function Ds($t){return $t/360+.5}function vr($t){const je=Math.sin($t*Math.PI/180),Be=.5-.25*Math.log((1+je)/(1-je))/Math.PI;return Be<0?0:Be>1?1:Be}function Ct($t,je,Be,Ye,vt,xt,Rt,Zt){if(Ye/=je,xt>=(Be/=je)&&Rt=Ye)return null;const Vt=[];for(const Qt of $t){const Es=Qt.geometry;let ys=Qt.type;const yr=vt===0?Qt.minX:Qt.minY,Vr=vt===0?Qt.maxX:Qt.maxY;if(yr>=Be&&Vr=Ye)continue;let fr=[];if(ys==="Point"||ys==="MultiPoint")As(Es,fr,Be,Ye,vt);else if(ys==="LineString")Us(Es,fr,Be,Ye,vt,!1,Zt.lineMetrics);else if(ys==="MultiLineString")ta(Es,fr,Be,Ye,vt,!1);else if(ys==="Polygon")ta(Es,fr,Be,Ye,vt,!0);else if(ys==="MultiPolygon")for(const Pn of Es){const In=[];ta(Pn,In,Be,Ye,vt,!0),In.length&&fr.push(In)}if(fr.length){if(Zt.lineMetrics&&ys==="LineString"){for(const Pn of fr)Vt.push(at(Qt.id,ys,Pn,Qt.tags));continue}ys!=="LineString"&&ys!=="MultiLineString"||(fr.length===1?(ys="LineString",fr=fr[0]):ys="MultiLineString"),ys!=="Point"&&ys!=="MultiPoint"||(ys=fr.length===3?"Point":"MultiPoint"),Vt.push(at(Qt.id,ys,fr,Qt.tags))}}return Vt.length?Vt:null}function As($t,je,Be,Ye,vt){for(let xt=0;xt<$t.length;xt+=3){const Rt=$t[xt+vt];Rt>=Be&&Rt<=Ye&&ka(je,$t[xt],$t[xt+1],$t[xt+2])}}function Us($t,je,Be,Ye,vt,xt,Rt){let Zt=kr($t);const Vt=vt===0?Li:Wa;let Qt,Es,ys=$t.start;for(let In=0;In<$t.length-3;In+=3){const Mn=$t[In],ya=$t[In+1],vo=$t[In+2],al=$t[In+3],Ja=$t[In+4],dl=vt===0?Mn:ya,oo=vt===0?al:Ja;let Ea=!1;Rt&&(Qt=Math.sqrt(Math.pow(Mn-al,2)+Math.pow(ya-Ja,2))),dlBe&&(Es=Vt(Zt,Mn,ya,al,Ja,Be),Rt&&(Zt.start=ys+Qt*Es)):dl>Ye?oo=Be&&(Es=Vt(Zt,Mn,ya,al,Ja,Be),Ea=!0),oo>Ye&&dl<=Ye&&(Es=Vt(Zt,Mn,ya,al,Ja,Ye),Ea=!0),!xt&&Ea&&(Rt&&(Zt.end=ys+Qt*Es),je.push(Zt),Zt=kr($t)),Rt&&(ys+=Qt)}let yr=$t.length-3;const Vr=$t[yr],fr=$t[yr+1],Pn=vt===0?Vr:fr;Pn>=Be&&Pn<=Ye&&ka(Zt,Vr,fr,$t[yr+2]),yr=Zt.length-3,xt&&yr>=3&&(Zt[yr]!==Zt[0]||Zt[yr+1]!==Zt[1])&&ka(Zt,Zt[0],Zt[1],Zt[2]),Zt.length&&je.push(Zt)}function kr($t){const je=[];return je.size=$t.size,je.start=$t.start,je.end=$t.end,je}function ta($t,je,Be,Ye,vt,xt){for(const Rt of $t)Us(Rt,je,Be,Ye,vt,xt,!1)}function ka($t,je,Be,Ye){$t.push(je,Be,Ye)}function Li($t,je,Be,Ye,vt,xt){const Rt=(xt-je)/(Ye-je);return ka($t,xt,Be+(vt-Be)*Rt,1),Rt}function Wa($t,je,Be,Ye,vt,xt){const Rt=(xt-Be)/(vt-Be);return ka($t,je+(Ye-je)*Rt,xt,1),Rt}function cr($t,je){const Be=[];for(let Ye=0;Ye<$t.length;Ye++){const vt=$t[Ye],xt=vt.type;let Rt;if(xt==="Point"||xt==="MultiPoint"||xt==="LineString")Rt=Qr(vt.geometry,je);else if(xt==="MultiLineString"||xt==="Polygon"){Rt=[];for(const Zt of vt.geometry)Rt.push(Qr(Zt,je))}else if(xt==="MultiPolygon"){Rt=[];for(const Zt of vt.geometry){const Vt=[];for(const Qt of Zt)Vt.push(Qr(Qt,je));Rt.push(Vt)}}Be.push(at(vt.id,xt,Rt,vt.tags))}return Be}function Qr($t,je){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]+je,$t[Ye+1],$t[Ye+2]);return Be}function Hr($t,je){if($t.transformed)return $t;const Be=1<<$t.z,Ye=$t.x,vt=$t.y;for(const xt of $t.features){const Rt=xt.geometry,Zt=xt.type;if(xt.geometry=[],Zt===1)for(let Vt=0;Vt0&&je.size<(vt?Rt:Ye))return void(Be.numPoints+=je.length/3);const Zt=[];for(let Vt=0;VtRt)&&(Be.numSimplified++,Zt.push(je[Vt],je[Vt+1])),Be.numPoints++;vt&&function(Vt,Qt){let Es=0;for(let ys=0,yr=Vt.length,Vr=yr-2;ys0===Qt)for(let ys=0,yr=Vt.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 vt=function(xt,Rt){const Zt=[];if(xt.type==="FeatureCollection")for(let Vt=0;Vt1&&console.time("creation"),Vr=this.tiles[yr]=Zr(je,Be,Ye,vt,Qt),this.tileCoords.push({z:Be,x:Ye,y:vt}),Es)){Es>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",Be,Ye,vt,Vr.numFeatures,Vr.numPoints,Vr.numSimplified),console.timeEnd("creation"));const Ea=`z${Be}`;this.stats[Ea]=(this.stats[Ea]||0)+1,this.total++}if(Vr.source=je,xt==null){if(Be===Qt.indexMaxZoom||Vr.numPoints<=Qt.indexMaxPoints)continue}else{if(Be===Qt.maxZoom||Be===xt)continue;if(xt!=null){const Ea=xt-Be;if(Ye!==Rt>>Ea||vt!==Zt>>Ea)continue}}if(Vr.source=null,je.length===0)continue;Es>1&&console.time("clipping");const fr=.5*Qt.buffer/Qt.extent,Pn=.5-fr,In=.5+fr,Mn=1+fr;let ya=null,vo=null,al=null,Ja=null,dl=Ct(je,ys,Ye-fr,Ye+In,0,Vr.minX,Vr.maxX,Qt),oo=Ct(je,ys,Ye+Pn,Ye+Mn,0,Vr.minX,Vr.maxX,Qt);je=null,dl&&(ya=Ct(dl,ys,vt-fr,vt+In,1,Vr.minY,Vr.maxY,Qt),vo=Ct(dl,ys,vt+Pn,vt+Mn,1,Vr.minY,Vr.maxY,Qt),dl=null),oo&&(al=Ct(oo,ys,vt-fr,vt+In,1,Vr.minY,Vr.maxY,Qt),Ja=Ct(oo,ys,vt+Pn,vt+Mn,1,Vr.minY,Vr.maxY,Qt),oo=null),Es>1&&console.timeEnd("clipping"),Vt.push(ya||[],Be+1,2*Ye,2*vt),Vt.push(vo||[],Be+1,2*Ye,2*vt+1),Vt.push(al||[],Be+1,2*Ye+1,2*vt),Vt.push(Ja||[],Be+1,2*Ye+1,2*vt+1)}}getTile(je,Be,Ye){je=+je,Be=+Be,Ye=+Ye;const vt=this.options,{extent:xt,debug:Rt}=vt;if(je<0||je>24)return null;const Zt=1<1&&console.log("drilling down to z%d-%d-%d",je,Be,Ye);let Qt,Es=je,ys=Be,yr=Ye;for(;!Qt&&Es>0;)Es--,ys>>=1,yr>>=1,Qt=this.tiles[Cr(Es,ys,yr)];return Qt&&Qt.source?(Rt>1&&(console.log("found parent tile z%d-%d-%d",Es,ys,yr),console.time("drilling down")),this.splitTile(Qt.source,Es,ys,yr,je,Be,Ye),Rt>1&&console.timeEnd("drilling down"),this.tiles[Vt]?Hr(this.tiles[Vt],xt):null):null}}function Cr($t,je,Be){return 32*((1<<$t)*Be+je)+$t}function jr($t,je){const Be=$t.tileID.canonical;if(!this._geoJSONIndex)return void je(null,null);const Ye=this._geoJSONIndex.getTile(Be.z,Be.x,Be.y);if(!Ye)return void je(null,null);const vt=Qt=>Qt.tags&&"3d_elevation_id"in Qt.tags&&"source"in Qt.tags&&Qt.tags.source==="elevation",xt=Ye.features.filter(Qt=>vt(Qt));let Rt={_geojsonTileLayer:Ye.features};xt.length>0&&(Rt={_geojsonTileLayer:Ye.features.filter(Qt=>!vt(Qt)),hd_road_elevation:xt});const Zt=new X(Rt),Vt=function(Qt){const Es=new i.bt;for(const ys of Object.keys(Qt))Es.writeMessage(3,Ae,{name:ys,features:Qt[ys]});return Es.finish()}(Rt).buffer;je(null,{vectorTile:Zt,rawData:Vt})}class Xn extends q{constructor(je,Be,Ye,vt,xt,Rt,Zt){super(je,Be,Ye,vt,xt,jr,Zt),Rt&&(this.loadGeoJSON=Rt),this._dynamicIndex=new re}loadData(je,Be){const Ye=je&&je.request,vt=Ye&&Ye.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(je,(xt,Rt)=>{if(xt||!Rt)return Be(xt);if(typeof Rt!="object")return Be(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));{try{if(je.filter){const Vt=i.U(je.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(Vt.result==="error")throw new Error(Vt.value.map(Qt=>`${Qt.key}: ${Qt.message}`).join(", "));Rt.features=Rt.features.filter(Qt=>Vt.value.evaluate({zoom:0},Qt))}je.dynamic?(Rt.type==="Feature"&&(Rt={type:"FeatureCollection",features:[Rt]}),je.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(Rt.features,this.loaded),je.cluster&&(Rt.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=je.cluster?new rt(function({superclusterOptions:Vt,clusterProperties:Qt}){if(!Qt||!Vt)return Vt;const Es={},ys={},yr={accumulated:null,zoom:0},Vr={properties:null},fr=Object.keys(Qt);for(const Pn of fr){const[In,Mn]=Qt[Pn],ya=i.U(Mn),vo=i.U(typeof In=="string"?[In,["accumulated"],["get",Pn]]:In);Es[Pn]=ya.value,ys[Pn]=vo.value}return Vt.map=Pn=>{Vr.properties=Pn;const In={};for(const Mn of fr)In[Mn]=Es[Mn].evaluate(yr,Vr);return In},Vt.reduce=(Pn,In)=>{Vr.properties=In;for(const Mn of fr)yr.accumulated=Pn[Mn],Pn[Mn]=ys[Mn].evaluate(yr,Vr)},Vt}(je)).load(Rt.features):je.dynamic?this._dynamicIndex:function(Vt,Qt){return new Bn(Vt,Qt)}(Rt,je.geojsonVtOptions)}catch(Vt){return Be(Vt)}const Zt={};if(vt){const Vt=c(Ye);Vt&&(Zt.resourceTiming={},Zt.resourceTiming[je.source]=JSON.parse(JSON.stringify(Vt)))}Be(null,Zt)}})}reloadTile(je,Be){const Ye=this.loaded;return Ye&&Ye[je.uid]?je.partial?Be(null,void 0):super.reloadTile(je,Be):this.loadTile(je,Be)}loadGeoJSON(je,Be){if(je.request)i.m(je.request,Be);else{if(typeof je.data!="string")return Be(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return Be(null,JSON.parse(je.data))}catch{return Be(new Error(`Input data given to '${je.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(je,Be){try{Be(null,this._geoJSONIndex.getClusterExpansionZoom(je.clusterId))}catch(Ye){Be(Ye)}}getClusterChildren(je,Be){try{Be(null,this._geoJSONIndex.getChildren(je.clusterId))}catch(Ye){Be(Ye)}}getClusterLeaves(je,Be){try{Be(null,this._geoJSONIndex.getLeaves(je.clusterId,je.limit,je.offset))}catch(Ye){Be(Ye)}}}class Aa{constructor(je,Be,Ye){this.tileID=new i.aQ(je.tileID.overscaledZ,je.tileID.wrap,je.tileID.canonical.z,je.tileID.canonical.x,je.tileID.canonical.y),this.tileZoom=je.tileZoom,this.uid=je.uid,this.zoom=je.zoom,this.canonical=je.tileID.canonical,this.pixelRatio=je.pixelRatio,this.tileSize=je.tileSize,this.source=je.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=je.projection,this.brightness=Be,this.worldview=Ye}parse(je,Be,Ye,vt){this.status="parsing";const xt=new i.aQ(Ye.tileID.overscaledZ,Ye.tileID.wrap,Ye.tileID.canonical.z,Ye.tileID.canonical.x,Ye.tileID.canonical.y),Rt=[],Zt=Be.familiesBySource[Ye.source],Vt=new i.fn(xt,Ye.promoteId);Vt.bucketLayerIDs=[],Vt.is3DTile=!0,i.fC(je).then(Qt=>{if(!Qt)return vt(new Error("Could not parse tile"));const Es=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"),yr=new i.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const Vr in Zt)for(const fr of Zt[Vr]){const Pn=fr[0];Vt.bucketLayerIDs.push(fr.map(ya=>i.B(ya.id,ya.scope))),Pn.recalculate(yr,[]);const In=i.fD(Qt,1/i.d7(Ye.tileID.canonical)),Mn=new i.fE(fr,In,xt,Es,ys,this.brightness,Vt,this.worldview);Es||(Mn.needsUpload=!0),Rt.push(Mn),Mn.evaluate(Pn)}this.status="done",vt(null,{buckets:Rt,featureIndex:Vt,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(Qt=>vt(new Error(Qt.message)))}}class Pi{constructor(je,Be,Ye,vt,xt,Rt,Zt,Vt){this.actor=je,this.layerIndex=Be,this.availableImages=Ye,this.availableModels=vt,this.brightness=Zt,this.loading={},this.loaded={},this.worldview=Vt}loadTile(je,Be){const Ye=je.uid,vt=this.loading[Ye]=new Aa(je,this.brightness,this.worldview);i.bu(je.request,(xt,Rt)=>{const Zt=!this.loading[Ye];return delete this.loading[Ye],Zt||xt?(vt.status="done",Zt||(this.loaded[Ye]=vt),Be(xt)):Rt&&Rt.byteLength!==0?void vt.parse(Rt,this.layerIndex,je,(Vt,Qt)=>{vt.status="done",this.loaded=this.loaded||{},this.loaded[Ye]=vt,Vt||!Qt?Be(Vt):Be(null,Qt)}):(vt.status="done",this.loaded[Ye]=vt,Be())})}reloadTile(je,Be){const Ye=this.loaded,vt=je.uid;if(Ye&&Ye[vt]){const xt=Ye[vt];xt.projection=je.projection,xt.brightness=je.brightness;const Rt=(Zt,Vt)=>{xt.reloadCallback&&(delete xt.reloadCallback,this.loadTile(je,Be)),Be(Zt,Vt)};xt.status==="parsing"?xt.reloadCallback=Rt:xt.status==="done"&&this.loadTile(je,Be)}}abortTile(je,Be){const Ye=je.uid;this.loading[Ye]&&delete this.loading[Ye],Be()}removeTile(je,Be){const Ye=this.loaded,vt=je.uid;Ye&&Ye[vt]&&delete Ye[vt],Be()}}class Oo{constructor(je){this.self=je,this.actor=new i.fG(je,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:q,geojson:Xn,"raster-dem":U,"raster-array":V,"batched-model":Pi},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(je,Be,Ye){delete this.layerIndexes[je],delete this.availableImages[je],delete this.availableModels[je],delete this.workerSources[je],Ye()}checkIfReady(je,Be,Ye){Ye()}setReferrer(je,Be){this.referrer=Be}spriteLoaded(je,Be){this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={});const{scope:Ye,isLoaded:vt}=Be;if(this.isSpriteLoaded[je][Ye]=vt,this.workerSources[je]&&this.workerSources[je][Ye])for(const xt in this.workerSources[je][Ye]){const Rt=this.workerSources[je][Ye][xt];for(const Zt in Rt){const Vt=Rt[Zt];Vt instanceof q&&(Vt.isSpriteLoaded=vt,Vt.fire(new i.z("isSpriteLoaded")))}}}setImages(je,Be,Ye){this.availableImages[je]||(this.availableImages[je]={});const{scope:vt,images:xt}=Be;if(this.availableImages[je][vt]=xt,this.workerSources[je]&&this.workerSources[je][vt]){for(const Rt in this.workerSources[je][vt]){const Zt=this.workerSources[je][vt][Rt];for(const Vt in Zt)Zt[Vt].availableImages=xt}Ye()}else Ye()}setModels(je,{scope:Be,models:Ye},vt){if(this.availableModels[je]||(this.availableModels[je]={}),this.availableModels[je][Be]=Ye,this.workerSources[je]&&this.workerSources[je][Be]){for(const xt in this.workerSources[je][Be]){const Rt=this.workerSources[je][Be][xt];for(const Zt in Rt)Rt[Zt].availableModels=Ye}vt()}else vt()}setProjection(je,Be){this.projections[je]=i.cm(Be)}setBrightness(je,Be,Ye){this.brightness=Be,Ye()}setWorldview(je,Be,Ye){this.worldview=Be,Ye()}setLayers(je,Be,Ye){this.getLayerIndex(je,Be.scope).replace(Be.layers,Be.options),Ye()}updateLayers(je,Be,Ye){this.getLayerIndex(je,Be.scope).update(Be.layers,Be.removedIds,Be.options),Ye()}loadTile(je,Be,Ye){Be.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,Be.type,Be.source,Be.scope).loadTile(Be,Ye)}decodeRasterArray(je,Be,Ye){this.getWorkerSource(je,Be.type,Be.source,Be.scope).decodeRasterArray(Be,Ye)}reloadTile(je,Be,Ye){Be.projection=this.projections[je]||this.defaultProjection,this.getWorkerSource(je,Be.type,Be.source,Be.scope).reloadTile(Be,Ye)}abortTile(je,Be,Ye){this.getWorkerSource(je,Be.type,Be.source,Be.scope).abortTile(Be,Ye)}removeTile(je,Be,Ye){this.getWorkerSource(je,Be.type,Be.source,Be.scope).removeTile(Be,Ye)}removeSource(je,Be,Ye){if(!(this.workerSources[je]&&this.workerSources[je][Be.scope]&&this.workerSources[je][Be.scope][Be.type]&&this.workerSources[je][Be.scope][Be.type][Be.source]))return;const vt=this.workerSources[je][Be.scope][Be.type][Be.source];delete this.workerSources[je][Be.scope][Be.type][Be.source],vt.removeSource!==void 0?vt.removeSource(Be,Ye):Ye()}loadWorkerSource(je,Be,Ye){try{this.self.importScripts(Be.url),Ye()}catch(vt){Ye(vt)}}syncRTLPluginState(je,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 vt=i.fH.getPluginURL();!i.fH.isLoaded()||i.fH.isParsed()||i.fH.isParsing()||vt==null||(i.fH.setState({pluginStatus:i.fI.parsing,pluginURL:i.fH.getPluginURL()}),this.self.importScripts(vt),i.fH.isParsed()?Ye(null,!0):this.rtlPluginParsingListeners.push(Ye))}catch(vt){Ye(vt)}}setDracoUrl(je,Be){this.dracoUrl=Be}getAvailableImages(je,Be){this.availableImages[je]||(this.availableImages[je]={});let Ye=this.availableImages[je][Be];return Ye||(Ye=[]),Ye}getAvailableModels(je,Be){this.availableModels[je]||(this.availableModels[je]={});let Ye=this.availableModels[je][Be];return Ye||(Ye={}),Ye}getLayerIndex(je,Be){this.layerIndexes[je]||(this.layerIndexes[je]={});let Ye=this.layerIndexes[je][Be];return Ye||(Ye=this.layerIndexes[je][Be]=new f,Ye.scope=Be),Ye}getWorkerSource(je,Be,Ye,vt){const xt=this.workerSources;return xt[je]||(xt[je]={}),xt[je][vt]||(xt[je][vt]={}),xt[je][vt][Be]||(xt[je][vt][Be]={}),this.isSpriteLoaded[je]||(this.isSpriteLoaded[je]={}),xt[je][vt][Be][Ye]||(xt[je][vt][Be][Ye]=new this.workerSourceTypes[Be]({send:(Rt,Zt,Vt,Qt,Es,ys)=>this.actor.send(Rt,Zt,Vt,je,Es,ys),scheduler:this.actor.scheduler},this.getLayerIndex(je,vt),this.getAvailableImages(je,vt),this.getAvailableModels(je,vt),this.isSpriteLoaded[je][vt],void 0,this.brightness,this.worldview)),xt[je][vt][Be][Ye]}rasterizeImagesWorker(je,Be,Ye){const vt=new Map;for(const[xt,{image:Rt,imageVariant:Zt}]of Be.tasks.entries()){const Vt=this.imageRasterizer.rasterize(Zt,Rt,Be.scope,je);vt.set(xt,Vt)}Ye(void 0,vt)}removeRasterizedImages(je,Be,Ye){this.imageRasterizer.removeImagesFromCacheByIds(Be.imageIds,Be.scope,je),Ye()}enforceCacheSizeLimit(je,Be){i.fJ(Be)}getWorkerPerformanceMetrics(je,Be,Ye){Ye(void 0,void 0)}}return i.fF(self)&&(self.worker=new Oo(self)),Oo}),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,b={},_=function(){if(g)return b;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,W=new Blob([""],{type:"text/javascript"}),Q=URL.createObjectURL(W);try{z=new Worker(Q),F=!0}catch{F=!1}return z&&z.terminate(),URL.revokeObjectURL(Q),F}()?function(){var F=document.createElement("canvas");F.width=F.height=1;var z=F.getContext("2d");if(!z)return!1;var W=z.getImageData(0,0,1,1);return W&&W.width===F.width}()?(y[D=A&&A.failIfMajorPerformanceCaveat]===void 0&&(y[D]=function(F){var z,W=function(Q){var ae=document.createElement("canvas"),oe=Object.create(T.webGLContextAttributes);return oe.failIfMajorPerformanceCaveat=Q,ae.getContext("webgl2",oe)}(F);if(!W)return!1;try{z=W.createShader(W.VERTEX_SHADER)}catch{return!1}return!(!z||W.isContextLost())&&(W.shaderSource(z,"void main() {}"),W.compileShader(z),W.getShaderParameter(z,W.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,b.supported=T,b.notSupportedReason=h;var y={};return T.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},b}();function j(T,h,y){const A=document.createElement(T);return h!=null&&(A.className=h),y&&y.appendChild(A),A}function w(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 N=typeof document<"u"?document.documentElement&&document.documentElement.style:null,C=N&&N.userSelect!==void 0?"userSelect":"WebkitUserSelect";let M;function I(){N&&C&&(M=N[C],N[C]="none")}function L(){N&&C&&(N[C]=M)}function R(T){T.preventDefault(),T.stopPropagation(),window.removeEventListener("click",R,!0)}function q(){window.addEventListener("click",R,!0),window.setTimeout(()=>{window.removeEventListener("click",R,!0)},0)}function U(T,h){const y=T.getBoundingClientRect();return Y(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 W of z){const Q=W.match(/^access_token=(.*)$/);if(Q)return Q[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 le="mapbox.eventData";function pe(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 xe{constructor(h){this.type=h,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(h){const y=pe(i.e.ACCESS_TOKEN);let A="";return A=y&&y.u?i.f(y.u):i.e.ACCESS_TOKEN||"",h?`${le}.${h}:${A}`:`${le}:${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 W=localStorage.getItem(D);W&&(this.anonIdTimestamp=Number(W));const Q=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()},W=y?Object.assign(z,y):z,Q={url:re(F),headers:{"Content-Type":"text/plain"},body:JSON.stringify([W])};this.pendingRequest=i.p(Q,ae=>{this.pendingRequest=null,A(ae),this.saveEventData(),this.processRequests(D)})}queueRequest(h,y){this.queue.push(h),this.processRequests(y)}}class _e extends xe{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 fe=new class extends xe{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=pe(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),W=(D-this.eventData.lastSuccess)/864e5;A=A||W>=1||W<-1||F.getDate()!==z.getDate()}else A=!0;A?this.postEvent(D,{sdkIdentifier:"mapbox-gl-js",sdkVersion:c,skuId:J,"enabled.telemetry":!1,userId:this.anonId},F=>{F||(this.eventData.lastSuccess=D,this.eventData.tokenU=y)},T):this.processRequests()}},we=fe.postTurnstileEvent.bind(fe),Ie=new class extends xe{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(te)))}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:J,skuToken:this.skuToken,userId:this.anonId},A=>{A?this.errorCb(A):h&&(this.success[h]=!0)},T))}remove(){this.errorCb=null}},Ne=Ie.postMapLoadEvent.bind(Ie),Ae=new class extends xe{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)}},Fe=Ae.postStyleLoadEvent.bind(Ae),Ce=new _e({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),Me=Ce.postMetricsEvent.bind(Ce),$e=new _e({attributes:[{name:"maps/js/layer-animations/runtime-appearances"}]}),ct=$e.postMetricsEvent.bind($e),Te=new class extends xe{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"),W=function(be){const Le={};if(be){for(const Ee in be)if(Ee!=="other")for(const We of be[Ee]){const Ue=`${Ee}ResolveRangeMin`,st=`${Ee}ResolveRangeMax`,ut=`${Ee}RequestCount`,it=`${Ee}RequestCachedCount`;Le[Ue]=Math.min(Le[Ue]||1/0,We.startTime),Le[st]=Math.max(Le[st]||-1/0,We.responseEnd);const Et=jt=>{Le[jt]===void 0&&(Le[jt]=0),++Le[jt]};We.transferSize!==void 0&&We.transferSize===0&&Et(it),Et(ut)}}return Le}(function(be,Le){const Ee={};if(be)for(const We of be){const Ue=Le(We);Ee[Ue]===void 0&&(Ee[Ue]=[]),Ee[Ue].push(We)}return Ee}(F,f)),Q=window.devicePixelRatio,ae=navigator.connection||navigator.mozConnection||navigator.webkitConnection,oe=ae?ae.effectiveType:void 0,ve={counters:[],metadata:[],attributes:[]},ge=(be,Le,Ee)=>{Ee!=null&&be.push({name:Le,value:Ee.toString()})};for(const be in W)ge(ve.counters,be,W[be]);if(D.interactionRange[0]!==1/0&&D.interactionRange[1]!==-1/0&&(ge(ve.counters,"interactionRangeMin",D.interactionRange[0]),ge(ve.counters,"interactionRangeMax",D.interactionRange[1])),z)for(const be of Object.values(u)){const Le=z.find(Ee=>Ee.name===be);Le&&ge(ve.counters,be,Le.startTime)}return ge(ve.counters,"visibilityHidden",D.visibilityHidden),ge(ve.attributes,"style",function(be){if(be)for(const Le of be){const Ee=Le.name.split("?")[0];if(i.i(Ee)){const We=Ee.split("/").slice(-2);if(We.length===2)return`mapbox://styles/${We[0]}/${We[1]}`}}}(F)),ge(ve.attributes,"terrainEnabled",D.terrainEnabled?"true":"false"),ge(ve.attributes,"fogEnabled",D.fogEnabled?"true":"false"),ge(ve.attributes,"projection",D.projection),ge(ve.attributes,"zoom",D.zoom),ge(ve.metadata,"devicePixelRatio",Q),ge(ve.metadata,"connectionEffectiveType",oe),ge(ve.metadata,"navigatorUserAgent",navigator.userAgent),ge(ve.metadata,"screenWidth",window.screen.width),ge(ve.metadata,"screenHeight",window.screen.height),ge(ve.metadata,"windowWidth",window.innerWidth),ge(ve.metadata,"windowHeight",window.innerHeight),ge(ve.metadata,"mapWidth",D.width/Q),ge(ve.metadata,"mapHeight",D.height/Q),ge(ve.metadata,"webglRenderer",D.renderer),ge(ve.metadata,"webglVendor",D.vendor),ge(ve.metadata,"sdkVersion",c),ge(ve.metadata,"sdkIdentifier","mapbox-gl-js"),ve}(y);for(const D of A.metadata);for(const D of A.counters);for(const D of A.attributes);this.postEvent(h,A,()=>{},T)}},ft=Te.postPerformanceEvent.bind(Te),me=new class extends xe{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(te)))}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}},Ve=me.getSessionAPI.bind(me),nt=new Set;function et(T,h){h?nt.add(T):nt.delete(T)}class Se{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 Ge 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 oe of h){if(!oe.iconsetId){D.push(oe);continue}const ve=z.get(oe.iconsetId);ve&&(this.getImage(oe,y)?F.push(oe):ve.addPendingRequest(oe))}if(D.length===0)return void this._notify(F,y,A);let W=!0;const Q=!!this.loaded.get(y),ae=this.images.get(y);if(!Q)for(const oe of D)ae.has(oe.toString())||(W=!1);Q||W?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,W]of D.entries()){const Q=this.getImage(W.id,F);Q&&A.set(z,{image:Q,imageVariant:W})}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:W}]of y.entries())D.set(F,this.imageRasterizer.rasterize(W,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 W=D.get(z.toString());if(!W){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 Q={data:W.usvg?null:W.data.clone(),pixelRatio:W.pixelRatio,sdf:W.sdf,usvg:W.usvg,version:W.version,stretchX:W.stretchX,stretchY:W.stretchY,content:W.content,hasRenderCallback:!!(W.userImage&&W.userImage.render)};W.usvg&&Object.assign(Q,{width:W.icon.usvg_tree.width,height:W.icon.usvg_tree.height}),F.set(i.I.toString(z),Q)}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),W=this.getImage(h,y);if(!W)return null;if(z){if(z.position.version===W.version)return z.position;z.position.version=W.version}else{if(W.usvg&&!W.data){const Q=this.getPatternInFlightId(D,y);if(this.patternsInFlight.has(Q))return null;this.patternsInFlight.add(Q);const ae=new i.A(h).scaleSelf(i.o.devicePixelRatio),oe=new Map([[ae.toString(),{image:W,imageVariant:ae}]]);return this._rasterizeImages(y,oe,(ve,ge)=>this.storePatternImage(ae,y,W,A,ge)),null}this.storePattern(h,y,W)}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(),W=F?F.get(z):void 0;W&&(A.data=W,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),W=this.atlasImage.get(h);W.resize({width:F||1,height:z||1});const Q=this.images.get(h);for(const[ae,{bin:oe,position:ve}]of A.entries()){let ge=ve.padding;const be=oe.x+ge,Le=oe.y+ge,Ee=Q.get(ae).data,We=Ee.width,Ue=Ee.height;ge=ge>1?ge-1:ge,i.q.copy(Ee,W,{x:0,y:0},{x:be,y:Le},{width:We,height:Ue},y),i.q.copy(Ee,W,{x:0,y:Ue-ge},{x:be,y:Le-ge},{width:We,height:ge},y),i.q.copy(Ee,W,{x:0,y:0},{x:be,y:Le+Ue},{width:We,height:ge},y),i.q.copy(Ee,W,{x:We-ge,y:0},{x:be-ge,y:Le},{width:ge,height:Ue},y),i.q.copy(Ee,W,{x:0,y:0},{x:be+We,y:Le},{width:ge,height:Ue},y),i.q.copy(Ee,W,{x:We-ge,y:Ue-ge},{x:be-ge,y:Le-ge},{width:ge,height:ge},y),i.q.copy(Ee,W,{x:0,y:Ue-ge},{x:be+We,y:Le-ge},{width:ge,height:ge},y),i.q.copy(Ee,W,{x:0,y:0},{x:be+We,y:Le+Ue},{width:ge,height:ge},y),i.q.copy(Ee,W,{x:We-ge,y:0},{x:be-ge,y:Le+Ue},{width:ge,height:ge},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 lt(T){const h=T.value,y=T.valueSpec,A=T.style,D=T.styleSpec,F=T.key,z=T.arrayElementValidator||cr;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,W,Q={};const ae=D!=="categorical"&&y.property===void 0,oe=!ae,ve=function(Ee){const We=Ee.stops;return Array.isArray(We)&&Array.isArray(We[0])&&i.H(We[0][0])}(y),ge=Qr({key:T.key,value:T.value,valueSpec:T.styleSpec.function,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{stops:function(Ee){if(D==="identity")return[new i.V(Ee.key,Ee.value,'identity function may not have a "stops" property')];let We=[];const Ue=Ee.value;return We=We.concat(lt({key:Ee.key,value:Ue,valueSpec:Ee.valueSpec,style:Ee.style,styleSpec:Ee.styleSpec,arrayElementValidator:be})),Array.isArray(Ue)&&Ue.length===0&&We.push(new i.V(Ee.key,Ue,"array must have at least one stop")),We},default:function(Ee){return cr({key:Ee.key,value:Ee.value,valueSpec:A,style:Ee.style,styleSpec:Ee.styleSpec})}}});return D==="identity"&&ae&&ge.push(new i.V(T.key,T.value,'missing required property "property"')),D==="identity"||y.stops||ge.push(new i.V(T.key,T.value,'missing required property "stops"')),D==="exponential"&&A.expression&&!i.M(A)&&ge.push(new i.V(T.key,T.value,"exponential functions not supported")),T.styleSpec.$version>=8&&(oe&&!i.N(A)?ge.push(new i.V(T.key,T.value,"property functions not supported")):ae&&!i.O(A)&&ge.push(new i.V(T.key,T.value,"zoom functions not supported"))),D!=="categorical"&&!ve||y.property!==void 0||ge.push(new i.V(T.key,T.value,'"property" property is required')),ge;function be(Ee){let We=[];const Ue=Ee.value,st=Ee.key;if(!Array.isArray(Ue))return[new i.V(st,Ue,`array expected, ${i.K(Ue)} found`)];if(Ue.length!==2)return[new i.V(st,Ue,`array length 2 expected, length ${Ue.length} found`)];if(ve){if(!i.H(Ue[0]))return[new i.V(st,Ue,`object expected, ${i.K(Ue[0])} found`)];const ut=Ue[0];if(ut.zoom===void 0)return[new i.V(st,Ue,"object stop key must have zoom")];if(ut.value===void 0)return[new i.V(st,Ue,"object stop key must have value")];const it=i.J(ut.zoom);if(typeof it!="number")return[new i.V(st,ut.zoom,"stop zoom values must be numbers")];if(W&&W>it)return[new i.V(st,ut.zoom,"stop zoom values must appear in ascending order")];it!==W&&(W=it,z=void 0,Q={}),We=We.concat(Qr({key:`${st}[0]`,value:Ue[0],valueSpec:{zoom:{}},style:Ee.style,styleSpec:Ee.styleSpec,objectElementValidators:{zoom:qe,value:Le}}))}else We=We.concat(Le({key:`${st}[0]`,value:Ue[0],style:Ee.style,styleSpec:Ee.styleSpec},Ue));return i.Q(i.S(Ue[1]))?We.concat([new i.V(`${st}[1]`,Ue[1],"expressions are not allowed in function stops.")]):We.concat(cr({key:`${st}[1]`,value:Ue[1],valueSpec:A,style:Ee.style,styleSpec:Ee.styleSpec}))}function Le(Ee,We){const Ue=i.K(Ee.value),st=i.J(Ee.value),ut=Ee.value!==null?Ee.value:We;if(F){if(Ue!==F)return[new i.V(Ee.key,ut,`${Ue} stop domain type must match previous stop domain type ${F}`)]}else F=Ue;if(Ue!=="number"&&Ue!=="string"&&Ue!=="boolean"&&typeof st!="number"&&typeof st!="string"&&typeof st!="boolean")return[new i.V(Ee.key,ut,"stop domain value must be a number, string, or boolean")];if(Ue!=="number"&&D!=="categorical"){let it=`number expected, ${Ue} found`;return i.N(A)&&D===void 0&&(it+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new i.V(Ee.key,ut,it)]}return D!=="categorical"||Ue!=="number"||typeof st=="number"&&isFinite(st)&&Math.floor(st)===st?D!=="categorical"&&Ue==="number"&&typeof st=="number"&&typeof z=="number"&&z!==void 0&&stnew 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 He(y,T);if(T.expressionContext==="appearance")return Qe(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 He(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(...He(D,h))}),A)}function Qe(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(...Qe(D,h))}),A)}function at(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 It(T){return i.a2(i.S(T.value))?Je(Object.assign({},T,{expressionContext:"filter",valueSpec:T.styleSpec[`filter_${T.layerType||"fill"}`]})):Ut(T)}function Ut(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=at({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)===W&&(Q=ae)}),Q?Q.ref?h.push(new i.V(A,y.ref,"ref cannot reference another ref layer")):z=i.J(Q.type):typeof W=="string"&&h.push(new i.V(A,y.ref,`ref layer "${W}" not found`))}else if(z!=="background"&&z!=="sky"&&z!=="slot")if(y.source)if(i.a0(y.source)){const Q=D.sources&&D.sources[y.source],ae=Q&&i.J(Q.type);Q?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"&&!Q.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(Qr({key:A,value:y,valueSpec:F.layer,style:T.style,styleSpec:T.styleSpec,objectElementValidators:{"*":()=>[],type:()=>cr({key:`${A}.type`,value:y.type,valueSpec:F.layer.type,style:T.style,styleSpec:T.styleSpec,object:y,objectKey:"type"}),filter:Q=>It(Object.assign({layerType:z},Q)),layout:Q=>Qr({layer:y,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":ae=>ts(Object.assign({layerType:z},ae))}}),paint:Q=>Qr({layer:y,key:Q.key,value:Q.value,valueSpec:{},style:Q.style,styleSpec:Q.styleSpec,objectElementValidators:{"*":ae=>Yt(Object.assign({layerType:z,layer:y},ae))}}),appearances(Q){const ae=lt({key:Q.key,value:Q.value,valueSpec:Q.valueSpec,style:Q.style,styleSpec:Q.styleSpec,arrayElementValidator:ge=>function(be){const{key:Le,layer:Ee,layerType:We}=be,Ue=i.J(be.value),st=i.J(Ue.name),ut=i.J(Ue.condition),it=Qr({key:Le,value:Ue,valueSpec:be.styleSpec.appearance,style:be.style,styleSpec:be.styleSpec,objectElementValidators:{condition:Et=>function(jt){const Tt=[];return Tt.push(...Je({key:jt.key,value:jt.object.condition,valueSpec:i.a6.appearance.condition,expressionContext:"appearance"})),Tt}(Object.assign({layer:Ee,layerType:We},Et)),properties:Et=>function(jt){const Tt=[],{styleSpec:_t,layer:gt,layerType:Ot}=jt,Wt=_t[`paint_${Ot}`],Ht=_t[`layout_${Ot}`],ss=jt.object[jt.objectKey];for(const rs in ss){const gs=rs in Wt?"paint":rs in Ht?"layout":void 0;if(!gs){Tt.push(new i.V(jt.key,rs,`unknown property "${rs}" for layer type "${Ot}"`));continue}const $s=Object.assign({},jt,{key:`${jt.key}.${rs}`,object:ss,objectKey:rs,layer:gt,layerType:Ot,value:ss[rs],valueSpec:gs==="paint"?Wt[rs]:Ht[rs]});Tt.push(...hs($s,gs))}return Tt}(Object.assign({layer:Ee,layerType:We},Et))}});return st!=="hidden"&&ut===void 0&&it.push(new i.V(be.key,"name",'Appearance with name different than "hidden" must have a condition')),it}(Object.assign({layerType:z,layer:y},ge))}),oe=Array.isArray(Q.value)?Q.value:[],ve=new Set;return oe.forEach((ge,be)=>{const Le=i.J(ge.name);if(Le)if(ve.has(Le)){const Ee=i.J(y.id);ae.push(new i.V(Q.key,Le,`Duplicated appearance name "${Le}" for layer "${Ee}"`))}else ve.add(Le)}),ae}}})),h}function vr({key:T,value:h}){return i.a0(h)?[]:[new i.V(T,h,`string expected, ${i.K(h)} found`)]}const Ct={promoteId:function T({key:h,value:y}){if(i.a0(y))return vr({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(W=>{D.push(new i.V(`${h}${W.key}`,null,`${W.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 As(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(Qr({key:y,value:h,valueSpec:A[`source_${F.replace("-","_")}`],style:T.style,styleSpec:A,objectElementValidators:Ct})),z;case"geojson":if(z=Qr({key:y,value:h,valueSpec:A.source_geojson,style:D,styleSpec:A,objectElementValidators:Ct}),"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 W in h.clusterProperties){const Q=h.clusterProperties[W];if(!Array.isArray(Q))return[new i.V(`${y}.clusterProperties.${W}`,Q,"array expected")];const[ae,oe]=Q,ve=typeof ae=="string"?[ae,["accumulated"],["get",W]]:ae;z.push(...Je({key:`${y}.${W}.map`,value:oe,expressionContext:"cluster-map"})),z.push(...Je({key:`${y}.${W}.reduce`,value:ve,expressionContext:"cluster-reduce"}))}}return z;case"video":return Qr({key:y,value:h,valueSpec:A.source_video,style:D,styleSpec:A});case"image":return Qr({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 at({key:`${y}.type`,value:h.type,valueSpec:{values:Us(A)}})}}function Us(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 kr(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 W=z.match(/^(.*)-transition$/),Q=z.match(/^(.*)-use-theme$/);F=F.concat(Q&&A[Q[1]]?cr({key:z,value:h[z],valueSpec:{type:"string"},style:D,styleSpec:y}):W&&A[W[1]]&&A[W[1]].transition?cr({key:z,value:h[z],valueSpec:y.transition,style:D,styleSpec:y}):A[z]?cr({key:z,value:h[z],valueSpec:A[z],style:D,styleSpec:y}):[new i.V(z,h[z],`unknown property "${z}"`)])}return F}function ta(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,W=T.style.lights;for(const oe of["type","id"])if(!(oe in h))return A=A.concat([new i.V(y,h,`missing property "${oe}"`)]),A;if(!i.a0(h.type))return A=A.concat([new i.V(`${y}.type`,h.type,"string expected")]),A;if(W)for(let oe=0;oe[],array:lt,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:qe,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:at,filter:It,function:Ze,layer:Ds,object:Qr,source:As,model:i.a7,light:kr,"light-3d":ta,terrain:ka,fog:Li,string:vr,formatted:function(T){return vr(T).length===0?[]:Je(T)},resolvedImage:function(T){return vr(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(cr({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=Qr(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(ln(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(Qr({key:y,value:h,valueSpec:A[`iconset_${F}`],style:D,styleSpec:A})),function(W,Q){return!(W!=="source"||!Q.source)}(F,h)){const W=D.sources&&D.sources[h.source],Q=W&&i.J(W.type);W?Q!=="raster-array"&&z.push(new i.V(y,h.source,`iconset cannot be used with a source of type ${String(Q)}, 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 cr(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&&Wa[A.type]){const F=Wa[A.type](T);return h===!0&&F.length>0&&Array.isArray(T.value)?Je(T):F}return Qr(Object.assign({},T,{valueSpec:A.type?D[A.type]:A}))}function Qr(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 W=[];for(const Q in y){const ae=Q.split(".")[0];let oe;D[ae]?oe=D[ae]:A[ae]?oe=cr:D["*"]?oe=D["*"]:A["*"]&&(oe=cr),oe?W=W.concat(oe({key:(h&&`${h}.`)+Q,value:y[Q],valueSpec:A[ae]||A["*"],style:F,styleSpec:z,object:y,objectKey:Q},y)):W.push(new i.a3(h,y[Q],`unknown property "${Q}"`))}for(const Q in A){if(D[Q])continue;const ae=A[Q];ae.required&&ae.default===void 0&&y[Q]===void 0&&W.push(new i.V(h,y,`missing required property "${Q}"`))}return W}function Hr({key:T,value:h}){const y=vr({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 ln(T,h=i.a6,y={}){return Qr({key:y.key||"",value:T,valueSpec:Object.assign(h.$root,{"*":{type:"*"}}),styleSpec:h,style:T,objectElementValidators:{glyphs:Hr}})}function Zr(T,h=i.a6){return Be(ln(T,h))}const yi=T=>Be(As(T)),pt=T=>Be(kr(T)),ir=T=>Be(ta(T)),Bn=T=>Be(ka(T)),Cr=T=>Be(Li(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 W in y){const Q=W.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?cr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?cr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),Xn=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 W in y){const Q=W.match(/^(.*)-transition$/);z=z.concat(Q&&F[Q[1]]&&F[Q[1]].transition?cr({key:W,value:y[W],valueSpec:D.transition,style:A,styleSpec:D}):F[W]?cr({key:W,value:y[W],valueSpec:F[W],style:A,styleSpec:D}):[new i.a3(W,y[W],`unknown property "${W}"`)])}return z}(T)),Aa=T=>Be(Ds(T)),Pi=T=>Be(It(T)),Oo=T=>Be(Yt(T)),$t=T=>Be(ts(T)),je=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 vt=i.a6.light;let xt;class Rt extends i.E{constructor(h,y="flat"){super(),this._transitionable=new i.a8(xt||(xt=new i.a9({anchor:new i.aa(vt.anchor),position:new i.ab(vt.position),color:new i.aa(vt.color),intensity:new i.aa(vt.intensity)}))),this.setLight(h,y),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(h,y,A={}){this._validate(pt,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(Zr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}const Zt=i.a6.terrain;let Vt=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,Es=65,ys=.05;function yr(T,h,y,A){const D=i.ah(Qt,Es,y),[F,z]=Vr(T,A);let W=1-Math.min(1,Math.exp((h-F)/(z-F)*-6));return W*=W*W,W=Math.min(1,1.00747*W),W*D*T.alpha}function Vr(T,h){const y=.5/Math.tan(.5*h);return[T.range[0]+y,T.range[1]+y]}function fr(T,h,y,A,D){const F=i.af([],[h,y,A],D.mercatorFogMatrix);return yr(T,i.ag(F),D.pitch,D._fov)}function Pn(T,h,y,A,D,F,z){const W=[[y,A,0],[D,A,0],[D,F,0],[y,F,0]];let Q=Number.MAX_VALUE,ae=-Number.MAX_VALUE;for(const oe of W){const ve=i.af([],oe,h),ge=i.ag(ve);Q=Math.min(Q,ge),ae=Math.max(ae,ge)}return[yr(T,Q,z.pitch,z._fov),yr(T,ae,z.pitch,z._fov)]}const In=i.a6.fog;class Mn extends i.E{constructor(h,y,A,D){super();const F=new i.a9({range:new i.aa(In.range),color:new i.aa(In.color),"color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new i.aa(In["high-color"]),"high-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new i.aa(In["space-color"]),"space-color-use-theme":new i.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new i.aa(In["horizon-blend"]),"star-intensity":new i.aa(In["star-intensity"]),"vertical-range":new i.aa(In["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(Cr,h,A))return;const D=Object.assign({},h);for(const F of Object.keys(In))D[F]===void 0&&(D[F]=In[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,Es,h))*y.a}getOpacityAtLatLng(h,y){return this._transform.projection.supportsFog?function(A,D,F){const z=i.ae.fromLngLat(D),W=F.elevation?F.elevation.getAtPointOrZero(z):0;return fr(A,z.x,z.y,W,F)}(this.state,h,y):0}getOpacityForTile(h){if(!this._transform.projection.supportsFog)return[1,1];const y=this._transform.calculateFogTileMatrix(h.toUnwrapped());return Pn(this.state,y,0,0,i.al,i.al,this._transform)}getOpacityForBounds(h,y,A,D,F){return this._transform.projection.supportsFog?Pn(this.state,h,y,A,D,F,this._transform):[1,1]}getFovAdjustedRange(h){return this._transform.projection.supportsFog?Vr(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(fr(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(Zr,Object.assign({value:y,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}}let ya,vo,al,Ja,dl=class extends i.E{constructor(T,h,y,A){super();const D=ya||(ya=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"),W=this.properties.get("vignette-color");return W.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:W}}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(Zr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}},oo=class extends i.E{constructor(T,h,y,A){super();const D=vo||(vo=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(Xn,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(Zr,Object.assign({value:h,style:{glyphs:!0,sprite:!0},styleSpec:i.a6})))}};class Ea 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 lo{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]),W=F.add(z)._div(2);A=[F,z],D=i.aq(F,z).every(Q=>y.isPointAboveHorizon(Q))&&y.isPointAboveHorizon(W)}return new lo(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 W=h.tileID.wrap+(z.unwrapped?D:0);const Q=z.polygon.map(We=>i.as(h.tileTransform,We,W));if(!i.at(Q,0,0,i.al,i.al))return;W=h.tileID.wrap+(this.screenGeometryMercator.unwrapped?D:0);const ae=this.screenGeometryMercator.polygon.map(We=>i.au(h.tileTransform,We,W)),oe=ae.map(We=>new i.P(We[0],We[1])),ve=y.getFreeCameraOptions().position||new i.ae(0,0,0),ge=i.au(h.tileTransform,ve,W),be=ae.map(We=>{const Ue=i.av(We,We,ge);return i.aw(Ue,Ue),new i.ax(ge,Ue)}),Le=i.ay(h,1,y.zoom)*y._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:oe,tilespaceRays:be,bufferedTilespaceGeometry:Q,bufferedTilespaceBounds:(Ee=i.az(Q),Ee.min.x=i.aA(Ee.min.x,0,i.al),Ee.min.y=i.aA(Ee.min.y,0,i.al),Ee.max.x=i.aA(Ee.max.x,0,i.al),Ee.max.y=i.aA(Ee.max.y,0,i.al),Ee),tile:h,tileID:h.tileID,pixelToTileUnitsFactor:Le};var Ee}_bufferedScreenMercator(h,y){const A=co(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=co(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 W=i.aB([],z.pixelMatrix,z.globeMatrix),Q=[0,-i.aD,0,1],ae=[0,i.aD,0,1],oe=[0,0,0,1];i.aC(Q,Q,W),i.aC(ae,ae,W),i.aC(oe,oe,W);const ve=new i.P(Q[0]/Q[3],Q[1]/Q[3]),ge=new i.P(ae[0]/ae[3],ae[1]/ae[3]),be=i.aE(F,ve)&&Q[3]1?Mi(F.slice(0,We),z):[],ut=Wenew i.P(ca(Tt.x),Tt.y)),ut=ut.map(Tt=>new i.P(ca(Tt.x),Tt.y));const it=[...st];it.length===0&&it.push(ut[ut.length-1]);const Et=i.ak(it[it.length-1].y,(ut.length===0?st[0]:ut[0]).y,Ue);let jt;return jt=be?[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)],it.push(...jt),ut.length===0?it.push(st[0]):it.push(...ut),{polygon:it.map(Tt=>new i.ae(Tt.x,Tt.y)),unwrapped:!1}}(h,y);if(A)return A;const D=function(F,z){let W=!1,Q=-1/0,ae=0;for(let ve=0;veQ&&(Q=F[ve].x,ae=ve);for(let ve=0;ve.5&&(be.x{ve.x-=1}),{polygon:F,unwrapped:W}}(Mi(h,y).map(F=>new i.P(ca(F.x),F.y)),y);return{polygon:D.polygon.map(F=>new i.ae(F.x,F.y)),unwrapped:D.unwrapped}}}function Mi(T,h){return i.aG(T,y=>{const A=h.pointCoordinate3D(y);y.x=A.x,y.y=A.y},1/256)}function ca(T){return T<0?1+T%1:T%1}function co(T){return 100*T|0}function Nc(T,h,y,A,D){const F=function(W,Q){if(W)return D(W);if(Q){if(T.url&&Q.tiles&&T.tiles&&delete T.tiles,Q.variants){if(!Array.isArray(Q.variants))return D(new Error("variants must be an array"));for(const oe of Q.variants){if(oe==null||typeof oe!="object"||oe.constructor!==Object)return D(new Error("variant must be an object"));if(!Array.isArray(oe.capabilities))return D(new Error("capabilities must be an array"));if(oe.capabilities.length===1&&oe.capabilities[0]==="meshopt"){Q=Object.assign(Q,oe);break}}}const ae=i.aH(Object.assign({},Q,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(W,Q,ae){if(!W)return null;if(!Q&&!ae)return W;ae=ae||W.worldview_default;const oe=Object.values(W.language||{});if(oe.length===0)return null;const ve=Object.values(W.worldview||{});if(ve.length===0)return null;const ge=oe.every(Le=>Le===Q),be=ve.every(Le=>Le===ae);return ge&&be?W:Q in(W.language_options||{})||ae in(W.worldview_options||{})?null:W.language_options&&W.worldview_options?W: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:W,...Q}=T;F(null,Q)})}function Uc(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=ou.fromTileJSON(F),we(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,W=z?{image:z.image.clone()}:null,Q={request:F,data:void 0,uid:h.uid,tileID:h.tileID,tileZoom:h.tileZoom,zoom:h.tileID.overscaledZ,maxZoom:this.maxzoom,lut:W,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)&&(Q.localizableLayerIds=this.localizableLayerIds),Q.request.collectResourceTiming=this._collectResourceTiming,h.actor&&h.state!=="expired")h.state==="loading"?h.reloadCallback=y:h.request=h.actor.send("reloadTile",Q,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",Q,ae.bind(this),void 0,!0);else{const oe=i.aL.call({deduped:this._deduped},Q,(ve,ge)=>{if(ve||!ge)ae.call(this,ve);else{const be=i.aM(ge.responseHeaders);Q.data={rawData:ge.rawData.slice(0),expires:be.expires,cacheControl:be.cacheControl},h.actor&&h.actor.send("loadTile",Q,ae.bind(this),void 0,!0)}},!0);h.request={cancel:oe}}function ae(oe,ve){return delete h.request,h.aborted?y(null):oe&&oe instanceof i.aN&&oe.status!==404?y(oe):(ve&&ve.resourceTiming&&(h.resourceTiming=ve.resourceTiming),this.map._refreshExpiredTiles&&ve&&h.setExpiryData(ve),h.loadVectorData(ve,this.map.painter),i.aO(this.dispatcher),y(null,ve),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 Rl 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=Nc(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=ou.fromTileJSON(D),we(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,W)=>{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 Q=i.aM(W);this.map._refreshExpiredTiles&&h.setExpiryData(Q),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 oh([T,h],y,A,{scaled:D=!0}={}){const{tileSize:F,buffer:z}=A,{x:W,y:Q,z:ae}=y;if(!isFinite(W)||!isFinite(Q)||!isFinite(ae))throw new Error("Invalid MRT header");const oe=2**ae,ve=oe*i.aF(T),ge=oe*i.aJ(h);return function([be,Le],Ee,{scaled:We=!0}={}){if(!Ee)throw new Error("bandView is undefined");const{data:Ue,tileSize:st,buffer:ut,offset:it,scale:Et,dimension:jt}=Ee;if(be<-ut||be>st+ut||Le<-ut||Le>st+ut)throw new Error(`Point (${be}, ${Le}) out of bounds for tileSize=${st}, buffer=${ut}`);const Tt=(Le+ut)*(st+2*ut)+(be+ut);if(new Uint32Array(Ue.buffer)[Tt]===4294967295)return null;let _t=[];_t=We?[]:new Ee.data.constructor(jt);for(let gt=0;gt{if(delete h.request,h.aborted)return h.state="unloaded",y(null);if(W)return W.name==="AbortError"?void 0:(h.state="errored",y(W));if(this.map._refreshExpiredTiles&&Q){const oe=i.aM(ae);h.setExpiryData(oe)}if(this.partial&&h.state!=="expired")h.state="empty";else if(!this.partial){if(!Q)return y(null);h.state="loaded",h._isHeaderLoaded=!0,h._mrt=Q}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 W=h.textureDescriptorPerLayer.get(y.id);return Object.assign({},W,{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,W]=F.split("/"),Q=D.getLayer(z);if(!Q||!Q.hasBand(W)||!Q.hasDataForBand(W))continue;const{bytes:ae,tileSize:oe,buffer:ve}=Q.getBandView(W),ge=oe+2*ve,be={data:new i.q({width:ge,height:ge},ae),pixelRatio:2,sdf:!1,usvg:!1,version:0};A.set(F,be)}return A}queryRasterArrayValueByBandId(h,y,A){const D=y._mrt;return new Promise(F=>{const z={},W=new Set;for(const[Q,ae]of Object.entries(D.layers)){if(A.layerName&&Q!==A.layerName)continue;const oe={};z[Q]=oe;for(const{bands:ve}of ae.dataIndex)for(const ge of ve)A.bands&&!A.bands.includes(ge)||(W.add(i.B(Q,ge)),y.fetchBand(Q,null,ge,be=>{i.o.frame(()=>{oe[ge]=be?null:oh([h.lng,h.lat],D,ae.getBandView(ge)),W.delete(i.B(Q,ge)),W.size===0&&F(z)})},!1))}W.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,W)=>{if(F)return this._loadTilePending[h.uid].forEach(Q=>Q(F,null)),void delete this._loadTilePending[h.uid];if(!z)return this._loadTilePending[h.uid].forEach(Q=>Q(null,null)),void delete this._loadTilePending[h.uid];if(this.map._refreshExpiredTiles&&z){const Q=i.aM(W);h.setExpiryData(Q)}h._mrt=z,h._isHeaderLoaded=!0,h.state="loaded",this._loadTilePending[h.uid].forEach(Q=>Q(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,W)=>{z?F(z):D(W?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&&(W[new i.aQ(T.overscaledZ,D,h.z,A,h.y-1).key]={backfilled:!1},W[new i.aQ(T.overscaledZ,T.wrap,h.z,h.x,h.y-1).key]={backfilled:!1},W[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,(W,Q)=>F&&!Q?(T.state="loaded",h(null)):(delete T.request,T.destroy(!1),T.aborted?h(null):W?h(W):(T.loadVectorData(Q,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=Nc(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 ou(D.bounds,this.minzoom,this.maxzoom)),we(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 ou(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(W){return W instanceof ImageData||W instanceof HTMLCanvasElement||W instanceof ImageBitmap||W 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"}))}}},Fl=function(T,h,y,A){const D=new Gm[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 Kx(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 gy(T,h,y,A=""){if(T.uniqueFeatureID){const D=Kx(T,h,A);if(y.has(D))return!0;y.add(D)}return!1}function U1(T,h,y,A,D=!1){const F=h.sourceCache.transform,z=h.sourceCache.tilesIn(T,h.has3DLayers,D);z.sort(Dp);const W=[];for(const Q of z){const ae=Q.tile.queryRenderedFeatures(h,Q,y,A,F,D);Object.keys(ae).length&&W.push({wrappedTileID:Q.tile.tileID.wrapped().key,queryResults:ae})}for(const Q in h.layers){const ae=h.layers[Q];if(ae.styleLayer){const oe=ae.styleLayer.queryRenderedFeatures(T,h.sourceCache,A);Object.keys(oe).length&&W.push({wrappedTileID:0,queryResults:oe})}}return W.length===0?{}:function(Q){const ae={},oe={};for(const ve of Q){const ge=ve.queryResults,be=ve.wrappedTileID,Le=oe[be]=oe[be]||{};for(const Ee in ge){const We=ge[Ee],Ue=Le[Ee]=Le[Ee]||{},st=ae[Ee]=ae[Ee]||[];for(const ut of We)Ue[ut.featureIndex]||(Ue[ut.featureIndex]=!0,st.push(ut))}}return ae}(W)}function V1(T,h,y,A,D,F){const z={},W=A.queryRenderedSymbols(T),Q=[];for(const ae of Object.keys(W).map(Number))Q.push(D[ae]);Q.sort(Dp);for(const ae of Q){const oe=ae.featureIndex.lookupSymbolFeatures(W[ae.bucketInstanceId],ae.bucketIndex,ae.sourceLayerIndex,h,y,F);for(const ve in oe){const ge=z[ve]=z[ve]||[],be=oe[ve];be.sort((Le,Ee)=>{const We=ae.featureSortOrder;if(We){const Ue=We.indexOf(Le.featureIndex);return We.indexOf(Ee.featureIndex)-Ue}return Ee.featureIndex-Le.featureIndex});for(const Le of be)ge.push(Le)}}return z}function H1(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 lu=32,am=33,Bd=new Uint16Array(8184);for(let T=0;T<2046;T++){let h=T+2,y=0,A=0,D=0,F=0,z=0,W=0;for(1&h?D=F=z=lu:y=A=W=lu;(h>>=1)>1;){const ae=y+D>>1,oe=A+F>>1;1&h?(D=y,F=A,y=z,A=W):(y=D,A=F,D=z,F=W),z=ae,W=oe}const Q=4*T;Bd[Q+0]=y,Bd[Q+1]=A,Bd[Q+2]=D,Bd[Q+3]=F}const Sd=new Uint16Array(2178),cu=new Uint8Array(1089),Of=new Uint16Array(1089);function Rf(T){return T===0?-.03125:T===32?.03125:0}const Km={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 Zm{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],W=z.layers[0],Q=W.sourceLayer||"_geojsonTileLayer",ae=h.style.getLayerSourceCache(W);let oe={};ae&&(oe=ae._state.getState(Q,void 0));const ve=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},ge=Object.keys(oe).length>0&&!y;z.hasAppearances=z.layers.some(Ee=>Ee.appearances&&Ee.appearances.length>0);const be=ge?z.stateDependentLayers:z.layers;if(ge&&z.stateDependentLayers.length!==0||y){const Ee=this.latestFeatureIndex.loadVTLayers();z.update(oe,Ee[Q],A,ve,be,y,D)}if(ge&&z.stateDependentLayers.length!==0||y||z.hasAppearances){const Ee={zoom:h.transform.zoom,pitch:h.transform.pitch,brightness:h.style.getBrightness()||0,worldview:h.worldview};z.updateAppearances(this.tileID.canonical,oe,A,Ee)}(z instanceof i.ba||z instanceof i.bb)&&h._terrain&&h._terrain.enabled&&ae&&z.uploadPending()&&h._terrain._clearRenderCacheForTile(ae.id,this.tileID);const Le=h&&h.style&&h.style.getOwnLayer(F);Le&&(this.queryPadding=Math.max(this.queryPadding,Le.queryRadius(z)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;We--){const Ue=4*We,st=Bd[Ue+0],ut=Bd[Ue+1],it=Bd[Ue+2],Et=Bd[Ue+3],jt=st+it>>1,Tt=ut+Et>>1,_t=jt+Tt-ut,gt=Tt+st-jt,Ot=ut*am+st,Wt=Et*am+it,Ht=Tt*am+jt,ss=Math.hypot((Sd[2*Ot+0]+Sd[2*Wt+0])/2-Sd[2*Ht+0],(Sd[2*Ot+1]+Sd[2*Wt+1])/2-Sd[2*Ht+1])>=16;cu[Ht]=cu[Ht]||(ss?1:0),We<1022&&(cu[Ht]=cu[Ht]||cu[(ut+gt>>1)*am+(st+_t>>1)]||cu[(Et+gt>>1)*am+(it+_t>>1)])}const ve=new i.b1,ge=new i.b0;let be=0;function Le(We,Ue){const st=Ue*am+We;return Of[st]===0&&(ve.emplaceBack(Sd[2*st+0],Sd[2*st+1],We*i.al/lu,Ue*i.al/lu),Of[st]=++be),Of[st]-1}function Ee(We,Ue,st,ut,it,Et){const jt=We+st>>1,Tt=Ue+ut>>1;if(Math.abs(We-it)+Math.abs(Ue-Et)>1&&cu[Tt*am+jt])Ee(it,Et,We,Ue,jt,Tt),Ee(st,ut,it,Et,jt,Tt);else{const _t=Le(We,Ue),gt=Le(st,ut),Ot=Le(it,Et);ge.emplaceBack(_t,gt,Ot)}}return Ee(0,0,lu,lu,lu,0),Ee(lu,lu,0,0,0,lu),{vertices:ve,indices:ge}}(this.tileID.canonical,y);D=z.vertices,F=z.indices}else{D=new i.b1,F=new i.b0;for(const{x:W,y:Q}of A)D.emplaceBack(W,Q,0,0);const z=i.bh(D.int16.subarray(0,4*D.length),void 0,4);for(let W=0;W0&&(Q=i.bl(new Float64Array(16),y.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(h,D,y,z,Q,W),this._makeGlobeTileDebugTextBuffer(h,D,y,z,Q,W)}_globePoint(h,y,A,D,F,z,W){let Q=i.bm(h,y,A);if(z){const ae=1<.5?be=-1:ge<-.5&&(be=1);let Le=(h/i.al+A.x)/ae+be,Ee=(y/i.al+A.y)/ae;Le=(Le-oe)*D._pixelsPerMercatorPixel+oe,Ee=(Ee-ve)*D._pixelsPerMercatorPixel+ve;const We=[Le*D.worldSize,Ee*D.worldSize,0];i.af(We,We,z),Q=i.bn(Q,We,W)}return i.af(Q,Q,F)}_makeGlobeTileDebugBorderBuffer(h,y,A,D,F,z){const W=new i.bd,Q=new i.be,ae=new i.bo,oe=(ge,be,Le,Ee,We)=>{const Ue=(Le-ge)/(We-1),st=(Ee-be)/(We-1),ut=W.length;for(let it=0;itve*be+Le;for(let be=0;be{if(F)y(F);else try{const Q=A.getHeaderLength(z);if(Q>h)return void(this.request=this.fetchHeader(Q,y));A.parseHeader(z),this._isHeaderLoaded=!0;let ae=0;for(const oe of Object.values(A.layers))ae=Math.max(ae,oe.dataIndex[oe.dataIndex.length-1].lastByte);z.byteLength>=ae&&(this.entireBuffer=z),y(null,this.entireBuffer||z,W)}catch(Q){y(Q)}}),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 W=this.actor;if(!W)return void D(new Error("Can't fetch tile band without an actor"));let Q;const ae=i.B(String(A),i.B(this.tileID.key,h));let oe=this._taskQueue.get(ae);oe?oe.add(D):(oe=new Set,oe.add(D),this._taskQueue.set(ae,oe));const ve=(Ee,We)=>{Q.complete(Ee,We),Ee?D(Ee):(oe.forEach(Ue=>Ue(null,We)),this._taskQueue.delete(ae))},ge=(Ee,We)=>{if(Ee)return D(Ee);const Ue=W.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:We,task:Q},ve,void 0,!0);if(y!==null){const st=this._workQueuePerLayer.get(y)||[];st.push(()=>{Ue&&Ue.cancel(),Q.cancel()}),this._workQueuePerLayer.has(y)||this._workQueuePerLayer.set(y,st)}};let be;try{be=z.getLayer(h)}catch(Ee){if(this.state==="reloading")return;throw Ee}if(!be)return void D(new Error(`Unknown sourceLayer "${h}"`));if(be.hasDataForBand(A))return oe.forEach(Ee=>Ee(null,null)),void this._taskQueue.delete(ae);const Le=be.getDataRange([A]);if(Q=z.createDecodingTask(Le),!Q||Q.tasks.length)if(y!==null&&this.flushQueues(y),this.entireBuffer)ge(null,this.entireBuffer.slice(Le.firstByte,Le.lastByte+1));else{const Ee=Object.assign({},this.requestParams,{headers:{Range:`bytes=${Le.firstByte}-${Le.lastByte}`}}),We=i.bu(Ee,ge);if(y!==null){const Ue=this._fetchQueuePerLayer.get(y)||[];Ue.push(()=>{We.cancel(),Q.cancel()}),this._fetchQueuePerLayer.has(y)||this._fetchQueuePerLayer.set(y,Ue)}}}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:W,offset:Q,scale:ae}=D.getBandView(A),oe=z+2*W,ve=new i.q({width:oe,height:oe},F),ge=this.texturePerLayer.get(y);ge&&ge instanceof i.T&&ge.update(ve,{premultiply:!1}),this.textureDescriptorPerLayer.set(y,{layer:h,band:A,img:ve,buffer:W,offset:Q,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 G0{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 Zx{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 W=String(y),Q=Object.assign({},A[W],D[W]);if(F){const ae=F[y];if(ae===null)return{};for(const oe in ae)delete Q[oe]}return Q}const z=Object.assign({},A,D);if(F)for(const W in F)delete z[W];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 W of Object.keys(this.deletedStates[D][z]))delete this.state[D][z][W];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 Ml 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 G0(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 Zx,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(W1).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,W=F.tileID,Q=new i.P(z.canonical.x,z.canonical.y)._rotate(this.transform.angle),ae=new i.P(W.canonical.x,W.canonical.y)._rotate(this.transform.angle);return z.overscaledZ-W.overscaledZ||ae.y-Q.y||ae.x-Q.x}).map(D=>D.tileID.key):A.map(D=>D.tileID).sort(W1).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 W=this.map.painter.terrain;this.update(this.transform,W.getScaledDemTileSize(),!0),W.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+Q)===1?z+=Q:Math.abs(z-Q)===1&&(z-=Q)),F.dem&&D.dem&&(D.dem.backfillBorder(F.dem,z,W),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 W=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()&&(W=ae)}let Q=W;for(;Q.overscaledZ>y;)if(Q=Q.scaledTo(Q.overscaledZ-1),h[Q.key]){D[W.key]=W;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,W=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,z):z;this._cache.setMaxSize(W)}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 W,Q=this._source.maxzoom;const ae=this.map&&this.map.painter?this.map.painter._terrain:null;if(ae&&ae.sourceCache===this&&ae.attenuationRange()){const ge=ae.attenuationRange()[0],be=Math.floor(ge)-Math.log2(ae.getDemUpscale());Q>be&&(Q=be)}if(this.used||this.usedForTerrain){if(this._source.tileID)W=h.getVisibleUnwrappedCoordinates(this._source.tileID).map(ge=>new i.aQ(ge.canonical.z,ge.wrap,ge.canonical.z,ge.canonical.x,ge.canonical.y));else if(this.tileCoverLift!==0){const ge=h.clone();ge.tileCoverLift=this.tileCoverLift,W=ge.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.minzoom<=1&&h.projection.name==="globe"&&(W.push(new i.aQ(1,0,1,0,0)),W.push(new i.aQ(1,0,1,1,0)),W.push(new i.aQ(1,0,1,0,1)),W.push(new i.aQ(1,0,1,1,1)))}else if(W=h.coveringTiles({tileSize:y||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:Q,roundZoom:this._source.roundZoom&&!A,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:z}),this._source.hasTile){const ge=this._source.hasTile.bind(this._source);W=W.filter(be=>ge(be))}}else W=[];if(W.length>0&&this.transform.projection.name!=="globe"&&!this.usedForTerrain&&!Yx(this._source.type)){const ge=h.coveringZoomLevel({tileSize:y||this._source.tileSize,roundZoom:this._source.roundZoom&&!A}),be=Math.min(ge,this._source.maxzoom);if(z){const Le=h.extendTileCover(W,be);for(const Ee of Le)W.push(Ee)}else if(F){const Le=h.extendTileCoverToNearPlane(W,this.transform.getFrustum(be),be);for(const Ee of Le)W.push(Ee)}else if(this.castsShadows&&D){const Le=h.extendTileCover(W,be,D,16);for(const Ee of Le)this._shadowCasterTiles[Ee.key]=!0,W.push(Ee)}}const oe=this._updateRetainedTiles(W);if(Yx(this._source.type)&&W.length!==0){const ge={},be={},Le=Object.keys(oe);for(const We of Le){const Ue=oe[We],st=this._tiles[We];if(!st||st.fadeEndTime&&st.fadeEndTime<=i.o.now())continue;const ut=this.findLoadedParent(Ue,Math.max(Ue.overscaledZ-Ml.maxOverzooming,this._source.minzoom));ut&&(this._addTile(ut.tileID),ge[ut.tileID.key]=ut.tileID),be[We]=Ue}const Ee=W[W.length-1].overscaledZ;for(const We in this._tiles){const Ue=this._tiles[We];if(oe[We]||!Ue.hasData())continue;let st=Ue.tileID;for(;st.overscaledZ>Ee;){st=st.scaledTo(st.overscaledZ-1);const ut=this._tiles[st.key];if(ut&&ut.hasData()&&be[st.key]){oe[We]=Ue.tileID;break}}}for(const We in ge)oe[We]||(this._coveredTiles[We]=!0,oe[We]=ge[We])}for(const ge in oe)this._tiles[ge].clearFadeHold();const ve=i.bv(this._tiles,oe);for(const ge of ve){const be=this._tiles[ge];be.hasSymbolBuckets&&!be.holdingForFade()?be.setHoldDuration(this.map._fadeDuration):be.hasSymbolBuckets&&!be.symbolFadeFinished()||this._removeTile(+ge)}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,oe)=>Math.min(ae,oe.overscaledZ),1/0),F=h[0].overscaledZ,z=Math.max(F-Ml.maxOverzooming,this._source.minzoom),W=Math.max(F+Ml.maxUnderzooming,this._source.minzoom),Q={};for(const ae of h){const oe=this._addTile(ae);y[ae.key]=ae,oe.hasData()||D=this._source.maxzoom){const ge=ae.children(this._source.maxzoom)[0],be=this.getTile(ge);if(be&&be.hasData()){y[ge.key]=ge;continue}}else{const ge=ae.children(this._source.maxzoom);if(y[ge[0].key]&&y[ge[1].key]&&y[ge[2].key]&&y[ge[3].key])continue}let ve=oe.wasRequested();for(let ge=ae.overscaledZ-1;ge>=z;--ge){const be=ae.scaledTo(ge);if(A[be.key]||(A[be.key]=!0,oe=this.getTile(be),!oe&&ve&&(oe=this._addTile(be)),oe&&(y[be.key]=be,ve=oe.wasRequested(),oe.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 Cd(h,F,this.transform.tileZoom,D,this._isRaster):new Zm(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",W=i.aF(F.center.lng);for(const Q in this._tiles){const ae=this._tiles[Q];if(A&&ae.clearQueryDebugViz(),ae.holdingForFade())continue;let oe;if(z){const ve=ae.tileID.canonical;if(ve.z===0){const ge=[Math.abs(i.aA(W,...Ih(ve,-1))-W),Math.abs(i.aA(W,...Ih(ve,1))-W)];oe=[0,2*ge.indexOf(Math.min(...ge))-1]}else{const ge=[Math.abs(i.aA(W,...Ih(ve,-1))-W),Math.abs(i.aA(W,...Ih(ve,0))-W),Math.abs(i.aA(W,...Ih(ve,1))-W)];oe=[ge.indexOf(Math.min(...ge))-1]}}else oe=[0];for(const ve of oe){const ge=h.containsTile(ae,F,y,ve);ge&&D.push(ge)}}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 W=1/(1<F[z.key]-F[W.key]),y}hasTransition(){if(this._source.hasTransition())return!0;if(Yx(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 Q=()=>{this._sourceLoaded&&(this._source.off("data",Q),this._preloadTiles(h,y))};return void this._source.on("data",Q)}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 Q of D){const ae=Q.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 oe of ae)A.set(oe.key,oe);this.usedForTerrain&&Q.updateElevation(!1)}const W=Array.from(A.values());i.bw(W,(Q,ae)=>{const oe=new Zm(Q,this._source.tileSize*Q.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster,this._source.worldview);this._loadTile(oe,ve=>{this._source.type==="raster-dem"&&oe.dem&&this._backfillDEM(oe),ae(ve,oe)})},y)}}function W1(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 Yx(T){return T==="raster"||T==="image"||T==="video"||T==="custom"}function Ih(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 W=1;F.type==="fill-extrusion"?W=D.visible?F.paint.get("fill-extrusion-vertical-scale"):0:F.type==="building"&&(W=D.visible?F.paint.get("building-vertical-scale"):0);let Q=z?z.getTile(y):null;if(!Q&&z)for(const ae in z._tiles){const oe=z._tiles[ae];if(y.canonical.isChildOf(oe.tileID.canonical)){Q=oe;break}}this.currentBuildingBuckets.push({bucket:Q?Q.getBucket(F):null,tileID:Q?Q.tileID:y,verticalScale:W})}h.hasAnyZOffset=!1;let A=!1;for(let D=0;D{A in h&&(y[A]=h[A])}),y}function K0(T){T=T.slice();const h=Object.create(null);for(let y=0;y0?(D-z)/W:0;return this.points[F].mult(1-Q).add(this.points[y].mult(Q))}}class Hw{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 W=[];if(h<=0&&y<=0&&this.width<=A&&this.height<=D){if(F)return!0;for(let Q=0;Q0:W}_queryCircle(h,y,A,D,F){const z=h-A,W=h+A,Q=y-A,ae=y+A;if(W<0||z>this.width||ae<0||Q>this.height)return!D&&[];const oe=[];return this._forEachCell(z,Q,W,ae,this._queryCellCircle,oe,{hitTest:D,circle:{x:h,y,radius:A},seenUids:{box:{},circle:{}}},F),D?oe.length>0:oe}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,W,Q){const ae=W.seenUids,oe=this.boxCells[F];if(oe!==null){const ge=this.bboxes;for(const be of oe)if(!ae.box[be]){ae.box[be]=!0;const Le=4*be;if(h<=ge[Le+2]&&y<=ge[Le+3]&&A>=ge[Le+0]&&D>=ge[Le+1]&&(!Q||Q(this.boxKeys[be]))){if(W.hitTest)return z.push(!0),!0;z.push({key:this.boxKeys[be],x1:ge[Le],y1:ge[Le+1],x2:ge[Le+2],y2:ge[Le+3]})}}}const ve=this.circleCells[F];if(ve!==null){const ge=this.circles;for(const be of ve)if(!ae.circle[be]){ae.circle[be]=!0;const Le=3*be;if(this._circleAndRectCollide(ge[Le],ge[Le+1],ge[Le+2],h,y,A,D)&&(!Q||Q(this.circleKeys[be]))){if(W.hitTest)return z.push(!0),!0;{const Ee=ge[Le],We=ge[Le+1],Ue=ge[Le+2];z.push({key:this.circleKeys[be],x1:Ee-Ue,y1:We-Ue,x2:Ee+Ue,y2:We+Ue})}}}}}_queryCellCircle(h,y,A,D,F,z,W,Q){const ae=W.circle,oe=W.seenUids,ve=this.boxCells[F];if(ve!==null){const be=this.bboxes;for(const Le of ve)if(!oe.box[Le]){oe.box[Le]=!0;const Ee=4*Le;if(this._circleAndRectCollide(ae.x,ae.y,ae.radius,be[Ee+0],be[Ee+1],be[Ee+2],be[Ee+3])&&(!Q||Q(this.boxKeys[Le])))return z.push(!0),!0}}const ge=this.circleCells[F];if(ge!==null){const be=this.circles;for(const Le of ge)if(!oe.circle[Le]){oe.circle[Le]=!0;const Ee=3*Le;if(this._circlesCollide(be[Ee],be[Ee+1],be[Ee+2],ae.x,ae.y,ae.radius)&&(!Q||Q(this.circleKeys[Le])))return z.push(!0),!0}}}_forEachCell(h,y,A,D,F,z,W,Q){const ae=this._convertToXCellCoord(h),oe=this._convertToYCellCoord(y),ve=this._convertToXCellCoord(A),ge=this._convertToYCellCoord(D);for(let be=ae;be<=ve;be++)for(let Le=oe;Le<=ge;Le++)if(F.call(this,h,y,A,D,this.xCellCount*Le+be,z,W,Q))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 W=D-h,Q=F-y,ae=A+z;return ae*ae>W*W+Q*Q}_circleAndRectCollide(h,y,A,D,F,z,W){const Q=(z-D)/2,ae=Math.abs(h-(D+Q));if(ae>Q+A)return!1;const oe=(W-F)/2,ve=Math.abs(y-(F+oe));if(ve>oe+A)return!1;if(ae<=Q||ve<=oe)return!0;const ge=ae-Q,be=ve-oe;return ge*ge+be*be<=A*A}}const wt={unknown:0,flipRequired:1,flipNotRequired:2},Ms=Math.tan(85*Math.PI/180);function Js(T,h,y,A,D,F,z){const W=i.bC();if(y)if(F.name==="globe"){const Q=i.bD(D,h);i.aB(W,W,Q)}else{const Q=i.bE([],z);W[0]=Q[0],W[1]=Q[1],W[4]=Q[2],W[5]=Q[3],A||i.bB(W,W,D.angle)}else i.aB(W,D.labelPlaneMatrix,T);return W}function pn(T,h,y,A,D,F,z){const W=Js(T,h,y,A,D,F,z);return F.name==="globe"&&y||(W[2]=W[6]=W[10]=W[14]=0),W}function fn(T,h,y,A,D,F,z){if(y){if(F.name==="globe"){const W=Js(T,h,y,A,D,F,z);return i.bl(W,W),i.aB(W,T,W),W}{const W=i.bz(T),Q=i.bA([]);return Q[0]=z[0],Q[1]=z[1],Q[4]=z[2],Q[5]=z[3],i.aB(W,W,Q),A||i.bB(W,W,-D.angle),W}}return D.glCoordMatrix}function oa(T,h,y,A){const D=[T,h,y,1];y?i.aC(D,D,A):Br(D,D,A);const F=D[3];return D[0]/=F,D[1]/=F,D[2]/=F,D}function qr(T,h){return Math.min(.5+T/h*.5,1.5)}function uo(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 Xx(T,h,y,A,D,F,z,W,Q,ae,oe=1){const ve=y.transform,ge=A?T.textSizeData:T.iconSizeData,be=i.bK(ge,y.transform.zoom,oe),Le=ve.projection.name==="globe",Ee=[256/y.width*2+1,256/y.height*2+1],We=A?T.text.dynamicLayoutVertexArray:T.icon.dynamicLayoutVertexArray;We.clear();let Ue=null;Le&&(Ue=A?T.text.globeExtVertexArray:T.icon.globeExtVertexArray);const st=T.lineVertexArray,ut=A?T.text.placedSymbolArray:T.icon.placedSymbolArray,it=y.transform.width/y.transform.height;let Et,jt=!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)>Ms}(y,A)?h===wt.flipRequired?{needsFlipping:!0}:null:y<0?{needsFlipping:!0}:null}function X0(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue,st,ut){const it=h/24,Et=T.lineOffsetX*it,jt=T.lineOffsetY*it,{lineStartIndex:Tt,glyphStartIndex:_t,numGlyphs:gt,segment:Ot,writingMode:Wt,flipState:Ht}=T,ss=Tt+T.lineLength,rs=gs=>{if(oe){const[is,Jt,Ps]=gs.up,rr=ae.length;i.bN(oe,rr+0,is,Jt,Ps),i.bN(oe,rr+1,is,Jt,Ps),i.bN(oe,rr+2,is,Jt,Ps),i.bN(oe,rr+3,is,Jt,Ps)}const[$s,Xt,Bt]=gs.point;i.bO(ae,$s,Xt,Bt,gs.angle)};if(gt>1){const gs=Op(it,W,Et,jt,y,ve,ge,T,Q,F,be,Ee,!1,We,Ue,st,ut);if(!gs)return{notEnoughRoom:!0};if(A&&!y){let[$s,Xt,Bt]=gs.first.point,[is,Jt,Ps]=gs.last.point;[$s,Xt]=oa($s,Xt,Bt,z),[is,Jt]=oa(is,Jt,Ps,z);const rr=Kr(Wt,Ht,(is-$s)*Le,Jt-Xt);if(T.flipState=rr&&rr.needsFlipping?wt.flipRequired:wt.flipNotRequired,rr)return rr}rs(gs.first);for(let $s=_t+1;$s<_t+gt-1;$s++){const Xt=K1(it*W.getoffsetX($s),Et,jt,y,ve,ge,Ot,Tt,ss,Q,F,be,Ee,!1,!1,We,Ue,st,ut);if(!Xt)return ae.length-=4*($s-_t),{notEnoughRoom:!0};rs(Xt)}rs(gs.last)}else{if(A&&!y){const $s=oa(ge.x,ge.y,0,D),Xt=Tt+Ot+1,Bt=new i.P(Q.getx(Xt),Q.gety(Xt)),is=oa(Bt.x,Bt.y,0,D),Jt=is[3]>0?is:Xm(ge,Bt,$s,1,D,void 0,We,Ue.canonical),Ps=Kr(Wt,Ht,(Jt[0]-$s[0])*Le,Jt[1]-$s[1]);if(T.flipState=Ps&&Ps.needsFlipping?wt.flipRequired:wt.flipNotRequired,Ps)return Ps}const gs=K1(it*W.getoffsetX(_t),Et,jt,y,ve,ge,Ot,Tt,ss,Q,F,be,Ee,!1,!1,We,Ue,st,ut);if(!gs)return{notEnoughRoom:!0};rs(gs)}return{}}function Q0(T,h,y,A,D){const{x:F,y:z,z:W}=A.projectTilePoint(T.x,T.y,h);if(!D)return oa(F,z,W,y);const[Q,ae,oe]=D.getElevation(T,D.elevation,D.elevationFeature);return oa(F+Q,z+ae,W+oe,y)}function Xm(T,h,y,A,D,F,z,W){const Q=Q0(T.sub(h)._unit()._add(T),W,D,z,F);return i.av(Q,y,Q),i.aw(Q,Q),i.bH(Q,y,Q,A)}function K1(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue,st){const ut=A?T-h:T+h;let it=ut>0?1:-1,Et=0;A&&(it*=-1,Et=Math.PI),it<0&&(Et+=Math.PI);let jt=W+z+(it>0?0:1)|0,Tt=D,_t=D,gt=0,Ot=0;const Wt=Math.abs(ut),Ht=[],ss=[];let rs=F,gs=rs,$s=i.bF([]);const Xt=()=>Xm(gs,rs,_t,Wt-gt+1,oe,ge,Ee,We.canonical);for(;gt+Ot<=Wt;){if(jt+=it,jt=Q)return null;if(_t=Tt,gs=rs,Ht.push(_t),be&&ss.push(gs),rs=new i.P(ae.getx(jt),ae.gety(jt)),Tt=ve[jt],!Tt){const Mr=Q0(rs,We.canonical,oe,Ee,ge);Tt=Mr[3]>0?ve[jt]=Mr:Xt()}gt+=Ot;const Vs=i.av([],Tt,_t),Pr=i.bG(_t,Tt);if(y&&Pr>0&&Ot>0&&i.bJ($s,Vs)/(Ot*Pr)0,ut),Tt=ae*jt.perspectiveRatio,_t=(A.x1*y+W.x-A.padding)*Tt+jt.point.x,gt=(A.y1*y+W.y-A.padding)*Tt+jt.point.y,Ot=(A.x2*y+W.x+A.padding)*Tt+jt.point.x,Wt=(A.y2*y+W.y+A.padding)*Tt+jt.point.y,Ht=jt.perspectiveRatio<=.55||jt.occluded;return!this.isInsideGrid(_t,gt,Ot,Wt)||!Q&&this.grid.hitTest(_t,gt,Ot,Wt,ve)||Ht?{box:[],offscreen:!1,occluded:jt.occluded}:{box:[_t,gt,Ot,Wt],offscreen:this.isOffscreen(_t,gt,Ot,Wt),occluded:!1}}placeCollisionCircles(h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We){const Ue=[],st=this.transform.elevation,ut=h.getProjection(),it=h.elevationType==="road",Et=!!st||it,jt=i.bV.getAtTileOffsetFunc(We,this.transform.center.lat,this.transform.worldSize,ut),Tt=new i.P(A.tileAnchorX,A.tileAnchorY),_t=new i.P(A.tileAnchorX,A.tileAnchorY);let{x:gt,y:Ot,z:Wt}=ut.projectTilePoint(_t.x,_t.y,We.canonical),Ht=null;if(Et){const Pr=it?h.getElevationFeatureForText(D):null;Ht={getElevation:jt,elevation:st,elevationFeature:Pr};const[Mr,ur,br]=jt(Tt,st,Pr);gt+=Mr,Ot+=ur,Wt+=br}const ss=ut.name==="globe",rs=this.projectAndGetPerspectiveRatio(Q,gt,Ot,Wt,We,ss||!!st||this.transform.pitch>0,ut),{perspectiveRatio:gs}=rs,$s=(ge?W/gs:W*gs)/i.bY,Xt=oa(gt,Ot,Wt,ae),Bt=A.lineOffsetX*$s,is=A.lineOffsetY*$s,Jt=i.an(h.layers[0].layout.get("text-max-angle")),Ps=Math.cos(Jt),rr=rs.signedDistanceFromCamera>0?Op($s,z,Bt,is,it&&A.flipState===1,Xt,_t,A,F,ae,{},Et&&!ge?Ht:null,ge&&Et,ut,We,ge,Ps):null;let gr=!1,er=!1,Vs=!0;if(rr&&!rs.occluded){const Pr=.5*Le*gs+Ee,Mr=new i.P(-100,-100),ur=new i.P(this.screenRightBoundary,this.screenBottomBoundary),br=new vy,{first:Gr,last:Tn}=rr,va=Gr.path.length;let ei=[];for(let jn=va-1;jn>=1;jn--)ei.push(Gr.path[jn]);for(let jn=1;jn(Et&&!ss&&(ki=jt(vijn[3]<=0)&&(ei=[]));let Ka=[];if(ei.length>0){let jn=1/0,ci=-1/0,ki=1/0,vi=-1/0;for(const Ga of ei)jn=Math.min(jn,Ga[0]),ki=Math.min(ki,Ga[1]),ci=Math.max(ci,Ga[0]),vi=Math.max(vi,Ga[1]);ci>=Mr.x&&jn<=ur.x&&vi>=Mr.y&&ki<=ur.y&&(Ka=[ei.map(Ga=>new i.P(Ga[0],Ga[1]))],(jnur.x||kiur.y)&&(Ka=i.bW(Ka,Mr.x,Mr.y,ur.x,ur.y)))}for(const jn of Ka){br.reset(jn,.25*Pr);let ci=0;ci=br.length<=.5*Pr?1:Math.ceil(br.paddedLength/Dr)+1;for(let ki=0;ki0?(i.aC(Q,Q,h),this.fogState&&F&&W.name!=="globe"&&(ae=function(ge,be,Le,Ee,We,Ue){const st=Ue.calculateFogTileMatrix(We),ut=[be,Le,Ee];return i.af(ut,ut,st),yr(ge,i.ag(ut),Ue.pitch,Ue._fov)}(this.fogState,y,A,D,F.toUnwrapped(),this.transform)>.9)):Br(Q,Q,h);const oe=Q[3];return{point:new i.P((Q[0]/oe+1)/2*this.transform.width+Ia,(-Q[1]/oe+1)/2*this.transform.height+Ia),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(W)/oe*.5,1.5),signedDistanceFromCamera:oe,occluded:z&&Q[2]>oe||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 $d(T,h,y,A,D){const{horizontalAlign:F,verticalAlign:z}=i.c1(T),W=-(F-.5)*h,Q=-(z-.5)*y,ae=i.c2(T,A);return new i.P(W+ae[0]*D,Q+ae[1]*D)}function bl(T,h,y,A,D){const F=new i.P(T,h);return y&&F._rotate(A?D:-D),F}class bme{constructor(h,y,A,D,F,z){this.transform=h.clone(),this.projection=h.projection.name,this.collisionIndex=new Ni(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 Gw(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),W=A.latestFeatureIndex;if(!z||!W||y.fqid!==z.layerIds[0])return;const Q=z.layers[0].layout,ae=z.layers[0].paint,oe=A.collisionBoxArray,ve=Math.pow(2,this.transform.zoom-A.tileID.overscaledZ),ge=A.tileSize/i.al,be=A.tileID.toUnwrapped();this.transform.setProjection(z.projection);const Le=(Ee=A.tileID,We=z.getProjection(),Ue=this.transform,We.name===this.projection?Ue.calculateProjMatrix(Ee.toUnwrapped()):Vw(Ue,We,Ee));var Ee,We,Ue;const st=Q.get("text-pitch-alignment")==="map",ut=Q.get("text-rotation-alignment")==="map";y.compileFilter(y.options);const it=y.dynamicFilter(),Et=y.dynamicFilterNeedsFeature(),jt=this.transform.calculatePixelsToTileUnitsMatrix(A),Tt=pn(Le,A.tileID.canonical,st,ut,this.transform,z.getProjection(),jt);let _t=null;const gt=z.getProjection().createInversionMatrix(this.transform,A.tileID.canonical);if(st){const Bt=fn(Le,A.tileID.canonical,st,ut,this.transform,z.getProjection(),jt);_t=i.aB([],this.transform.labelPlaneMatrix,Bt)}let Ot=null;it&&A.latestFeatureIndex&&(Ot={unwrappedTileID:be,dynamicFilter:it,dynamicFilterNeedsFeature:Et}),this.retainedQueryData[z.bucketInstanceId]=new Ww(z.bucketInstanceId,W,z.sourceLayerIndex,z.index,A.tileID);const[Wt,Ht]=z.layers[0].layout.get("text-size-scale-range"),ss=i.aA(F,Wt,Ht),[rs,gs]=Q.get("icon-size-scale-range"),$s=i.aA(F,rs,gs),Xt={bucket:z,layout:Q,paint:ae,posMatrix:Le,invMatrix:gt,mercatorCenter:[i.aF(this.transform.center.lng),i.aJ(this.transform.center.lat)],textLabelPlaneMatrix:Tt,labelToScreenMatrix:_t,clippingData:Ot,scale:ve,textPixelRatio:ge,holdingForFade:A.holdingForFade(),collisionBoxArray:oe,partiallyEvaluatedTextSize:i.bK(z.textSizeData,this.transform.zoom,ss),partiallyEvaluatedIconSize:i.bK(z.iconSizeData,this.transform.zoom,$s),collisionGroup:this.collisionGroups.get(z.sourceID),latestFeatureIndex:A.latestFeatureIndex};if(D)for(const Bt of z.sortKeyRanges){const{sortKey:is,symbolInstanceStart:Jt,symbolInstanceEnd:Ps}=Bt;h.push({sortKey:is,symbolInstanceStart:Jt,symbolInstanceEnd:Ps,parameters:Xt})}else h.push({symbolInstanceStart:0,symbolInstanceEnd:z.symbolInstances.length,parameters:Xt})}attemptAnchorPlacement(h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue,st,ut,it,Et){const{textOffset0:jt,textOffset1:Tt,crossTileID:_t}=Ee,gt=[jt,Tt],Ot=$d(h,z,W,gt,Q),Wt=this.collisionIndex.placeCollisionBox(Ue,Q,y,A,D,F,bl(Ot.x,Ot.y,ae,oe,this.transform.angle),Le,ve,ge,be.predicate);if(ut){const Ht=Ue.getSymbolInstanceIconSize(Et,this.transform.zoom,Ee.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(Ue,Ht,ut,A,D,F,bl(Ot.x,Ot.y,ae,oe,this.transform.angle),Le,ve,ge,be.predicate).box.length===0)return}if(Wt.box.length>0){let Ht;return this.prevPlacement&&this.prevPlacement.variableOffsets[_t]&&this.prevPlacement.placements[_t]&&this.prevPlacement.placements[_t].text&&(Ht=this.prevPlacement.variableOffsets[_t].anchor),this.variableOffsets[_t]={textOffset:gt,width:z,height:W,anchor:h,textScale:Q,prevAnchor:Ht},this.markUsedJustification(Ue,h,Ee,st),Ue.allowVerticalPlacement&&(this.markUsedOrientation(Ue,st,Ee),this.placedOrientations[_t]=st),{shift:Ot,placedGlyphBoxes:Wt}}}placeLayerBucketPart(h,y,A,D,F=1){const{bucket:z,layout:W,paint:Q,posMatrix:ae,textLabelPlaneMatrix:oe,labelToScreenMatrix:ve,clippingData:ge,textPixelRatio:be,mercatorCenter:Le,invMatrix:Ee,holdingForFade:We,collisionBoxArray:Ue,partiallyEvaluatedTextSize:st,partiallyEvaluatedIconSize:ut,collisionGroup:it,latestFeatureIndex:Et}=h.parameters,jt=W.get("text-optional"),Tt=W.get("icon-optional"),_t=W.get("text-allow-overlap"),gt=W.get("icon-allow-overlap"),Ot=W.get("text-rotation-alignment")==="map",Wt=W.get("icon-rotation-alignment")==="map",Ht=W.get("text-pitch-alignment")==="map",ss=Q.get("symbol-z-offset"),rs=W.get("symbol-elevation-reference")==="sea",gs=W.get("symbol-placement"),[$s,Xt]=W.get("text-size-scale-range"),[Bt,is]=W.get("icon-size-scale-range"),Jt=i.aA(F,$s,Xt),Ps=i.aA(F,Bt,is),rr=W.get("text-variable-anchor"),gr=Ot&&gs!=="point",er=Wt&&gs!=="point",Vs=rr&&z.hasTextData(),Pr=z.hasIconTextFit()&&Vs&&z.hasIconData();this.transform.setProjection(z.projection);const Mr=Vs||gr,ur=er||Pr;let br=_t&&(gt||!z.hasIconData()||Tt),Gr=gt&&(_t||!z.hasTextData()||jt);const Tn=!ss.isConstant();!z.collisionArrays&&Ue&&z.deserializeCollisionBoxes(Ue),A&&D&&z.updateCollisionDebugBuffers(this.transform.zoom,Ue,Jt,Ps);const va=(Dr,Ka,jn)=>{const{crossTileID:ci,numVerticalGlyphVertices:ki}=Dr;let vi=null;if(ge&&ge.dynamicFilterNeedsFeature||Tn){const Po=this.retainedQueryData[z.bucketInstanceId];vi=Et.loadFeature({featureIndex:Dr.featureIndex,bucketIndex:Po.bucketIndex,sourceLayerIndex:Po.sourceLayerIndex,layoutVertexArrayOffset:0});const Qo=vi.properties?vi.properties.worldview:null;if(z.localizable&&z.worldview&&typeof Qo=="string")if(Qo==="all")vi.properties.$localized=!0;else{if(!Qo.split(",").includes(z.worldview))return;vi.properties.$localized=!0,vi.properties.worldview=z.worldview}}if(ge&&!(0,ge.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:z.worldview},vi,this.retainedQueryData[z.bucketInstanceId].tileID.canonical,new i.P(Dr.tileAnchorX,Dr.tileAnchorY),this.transform.calculateDistanceTileData(ge.unwrappedTileID)))return this.placements[ci]=new mi(!1,!1,!1,!0),void y.add(ci);const Ga=ss.evaluate(vi,{});if(y.has(ci))return;if(We)return void(this.placements[ci]=new mi(!1,!1,!1));let Vn=!1,ni=!1,ko=!0,ro=!1,di=!1,Ra=null,Hn={box:null,offscreen:null,occluded:null},Xi={box:null},Vo=null,_o=null,Di=null,zu=0,Md=0,$l=0;jn.textFeatureIndex?zu=jn.textFeatureIndex:Dr.useRuntimeCollisionCircles&&(zu=Dr.featureIndex),jn.verticalTextFeatureIndex&&(Md=jn.verticalTextFeatureIndex);const Ud=z.elevationFeatures?z.elevationFeatures[Dr.elevationFeatureIndex]:void 0,Vd=Po=>{Po.tileID=this.retainedQueryData[z.bucketInstanceId].tileID;const Qo=this.transform.elevation;Po.elevation=rs?Ga:Ga+i.bV.getAtTileOffset(Po.tileID,new i.P(Po.tileAnchorX,Po.tileAnchorY),Qo,Ud),Po.elevation+=Dr.zOffset},ad=jn.textBox;if(ad){Vd(ad);const Po=Oi=>{let ul=i.bL.horizontal;if(z.allowVerticalPlacement&&!Oi&&this.prevPlacement){const So=this.prevPlacement.placedOrientations[ci];So&&(this.placedOrientations[ci]=So,ul=So,this.markUsedOrientation(z,ul,Dr))}return ul},Qo=(Oi,ul)=>{if(z.allowVerticalPlacement&&ki>0&&jn.verticalTextBox){for(const So of z.writingModes)if(So===i.bL.vertical?(Hn=ul(),Xi=Hn):Hn=Oi(),Hn&&Hn.box&&Hn.box.length)break}else Hn=Oi()};if(rr){let Oi=rr;if(this.prevPlacement&&this.prevPlacement.variableOffsets[ci]){const wo=this.prevPlacement.variableOffsets[ci];Oi.indexOf(wo.anchor)>0&&(Oi=Oi.filter(ap=>ap!==wo.anchor),Oi.unshift(wo.anchor))}const ul=(wo,ap,_2)=>{const Up=z.getSymbolInstanceTextSize(st,Dr,this.transform.zoom,Ka),w2=(wo.x2-wo.x1)*Up+2*wo.padding,yb=(wo.y2-wo.y1)*Up+2*wo.padding,Gf=Dr.hasIconTextFit&&!gt?ap:null;Gf&&Vd(Gf);let ug={box:[],offscreen:!1,occluded:!1};const vb=_t?2*Oi.length:Oi.length;for(let Dy=0;Dy=Oi.length,Dr,Ka,z,_2,Gf,st,ut);if(hg&&(ug=hg.placedGlyphBoxes,ug&&ug.box&&ug.box.length)){Vn=!0,Ra=hg.shift;break}}return ug};Qo(()=>ul(ad,jn.iconBox,i.bL.horizontal),()=>{const wo=jn.verticalTextBox;return wo&&Vd(wo),z.allowVerticalPlacement&&!(Hn&&Hn.box&&Hn.box.length)&&ki>0&&wo?ul(wo,jn.verticalIconBox,i.bL.vertical):{box:null,offscreen:null,occluded:null}}),Hn&&(Vn=Hn.box,ko=Hn.offscreen,ro=Hn.occluded);const So=Po(!(!Hn||!Hn.box));if(!Vn&&this.prevPlacement){const wo=this.prevPlacement.variableOffsets[ci];wo&&(this.variableOffsets[ci]=wo,this.markUsedJustification(z,wo.anchor,Dr,So))}}else{const Oi=(ul,So)=>{const wo=z.getSymbolInstanceTextSize(st,Dr,this.transform.zoom,Ka),ap=this.collisionIndex.placeCollisionBox(z,wo,ul,Le,Ee,Mr,new i.P(0,0),_t,be,ae,it.predicate);return ap&&ap.box&&ap.box.length&&(this.markUsedOrientation(z,So,Dr),this.placedOrientations[ci]=So),ap};Qo(()=>Oi(ad,i.bL.horizontal),()=>{const ul=jn.verticalTextBox;return z.allowVerticalPlacement&&ki>0&&ul?(Vd(ul),Oi(ul,i.bL.vertical)):{box:null,offscreen:null,occluded:null}}),Po(!!(Hn&&Hn.box&&Hn.box.length))}}if(Vo=Hn,Vn=Vo&&Vo.box&&Vo.box.length>0,ko=Vo&&Vo.offscreen,ro=Vo&&Vo.occluded,Dr.useRuntimeCollisionCircles){const Po=Dr.centerJustifiedTextSymbolIndex>=0?Dr.centerJustifiedTextSymbolIndex:Dr.verticalPlacedTextSymbolIndex,Qo=z.text.placedSymbolArray.get(Po),Oi=i.bM(z.textSizeData,st,Qo),ul=W.get("text-padding");_o=this.collisionIndex.placeCollisionCircles(z,_t,Qo,Po,z.lineVertexArray,z.glyphOffsetArray,Oi,ae,oe,ve,A,Ht,it.predicate,Dr.collisionCircleDiameter*Oi/i.bY,ul,this.retainedQueryData[z.bucketInstanceId].tileID),Vn=_t||_o.circles.length>0&&!_o.collisionDetected,ko=ko&&_o.offscreen,ro=_o.occluded}if(jn.iconFeatureIndex&&($l=jn.iconFeatureIndex),jn.iconBox){const Po=Qo=>{Vd(Qo);const Oi=Dr.hasIconTextFit&&Ra?bl(Ra.x,Ra.y,Ot,Ht,this.transform.angle):new i.P(0,0),ul=z.getSymbolInstanceIconSize(ut,this.transform.zoom,Dr.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(z,ul,Qo,Le,Ee,ur,Oi,gt,be,ae,it.predicate)};Xi&&Xi.box&&Xi.box.length&&jn.verticalIconBox?(Di=Po(jn.verticalIconBox),ni=Di.box.length>0):(Di=Po(jn.iconBox),ni=Di.box.length>0),ko=ko&&Di.offscreen,di=Di.occluded}const um=jt||Dr.numHorizontalGlyphVertices===0&&ki===0,np=Tt||Dr.numIconVertices===0;if(um||np?np?um||(ni=ni&&Vn):Vn=ni&&Vn:ni=Vn=ni&&Vn,Vn&&Vo&&Vo.box&&this.collisionIndex.insertCollisionBox(Vo.box,W.get("text-ignore-placement"),z.bucketInstanceId,Xi&&Xi.box&&Md?Md:zu,it.ID),ni&&Di&&this.collisionIndex.insertCollisionBox(Di.box,W.get("icon-ignore-placement"),z.bucketInstanceId,$l,it.ID),_o&&(Vn&&this.collisionIndex.insertCollisionCircles(_o.circles,W.get("text-ignore-placement"),z.bucketInstanceId,zu,it.ID),A)){const Po=z.bucketInstanceId;let Qo=this.collisionCircleArrays[Po];Qo===void 0&&(Qo=this.collisionCircleArrays[Po]=new MC);for(let Oi=0;Oi<_o.circles.length;Oi+=4)Qo.circles.push(_o.circles[Oi+0]),Qo.circles.push(_o.circles[Oi+1]),Qo.circles.push(_o.circles[Oi+2]),Qo.circles.push(_o.collisionDetected?1:0)}const uh=z.projection.name!=="globe";br=br&&(uh||!ro),Gr=Gr&&(uh||!di),this.placements[ci]=new mi(Vn||br,ni||Gr,ko||z.justReloaded),y.add(ci)},ei=this.retainedQueryData[z.bucketInstanceId].tileID;if(z.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(z,ei),z.elevationType==="road"&&z.updateRoadElevation(ei.canonical),z.updateZOffset(),z.sortFeaturesByY){const Dr=z.getSortedSymbolIndexes(this.transform.angle);for(let Ka=Dr.length-1;Ka>=0;--Ka){const jn=Dr[Ka];va(z.symbolInstances.get(jn),jn,z.collisionArrays[jn])}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 Dr=z.getSortedIndexesByZOffset();for(let Ka=0;Ka=0&&(h.text.placedSymbolArray.get(F).crossTileID=ve>=0&&F!==ve?0:ae),z>=0&&(h.text.placedSymbolArray.get(z).crossTileID=ve>=0&&z!==ve?0:ae),W>=0&&(h.text.placedSymbolArray.get(W).crossTileID=ve>=0&&W!==ve?0:ae),Q>=0&&(h.text.placedSymbolArray.get(Q).crossTileID=ve>=0&&Q!==ve?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:W,rightJustifiedTextSymbolIndex:Q,verticalPlacedTextSymbolIndex:ae}=A,oe=h.text.placedSymbolArray;z>=0&&(oe.get(z).placedOrientation=D),W>=0&&(oe.get(W).placedOrientation=D),Q>=0&&(oe.get(Q).placedOrientation=D),ae>=0&&(oe.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:{},W=y?y.placedOrientations:{};for(const Q in this.placements){const ae=this.placements[Q],oe=F[Q];oe?(this.opacities[Q]=new Ff(oe,D,ae.text,ae.icon,null,ae.clipped),A=A||ae.text!==oe.text.placed||ae.icon!==oe.icon.placed):(this.opacities[Q]=new Ff(null,D,ae.text,ae.icon,ae.skipFade,ae.clipped),A=A||ae.text||ae.icon)}for(const Q in F){const ae=F[Q];if(!this.opacities[Q]){const oe=new Ff(ae,D,!1,!1);oe.isHidden()||(this.opacities[Q]=oe,A=A||ae.text.placed||ae.icon.placed)}}for(const Q in z)this.variableOffsets[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.variableOffsets[Q]=z[Q]);for(const Q in W)this.placedOrientations[Q]||!this.opacities[Q]||this.opacities[Q].isHidden()||(this.placedOrientations[Q]=W[Q]);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 W=z.getBucket(h);W&&z.latestFeatureIndex&&h.fqid===W.layerIds[0]&&(this.updateBucketOpacities(W,F,z,z.collisionBoxArray,A,D,z.tileID,h.scope),W.elevationType==="offset"&&this.buildingIndex&&this.buildingIndex.updateZOffset(W,z.tileID),W.elevationType==="road"&&W.updateRoadElevation(z.tileID.canonical),W.updateZOffset())}}updateBucketOpacities(h,y,A,D,F,z,W,Q){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,oe=h.layers[0].paint,ve=!!h.layers[0].dynamicFilter(),ge=new Ff(null,0,!1,!1,!0),be=ae.get("text-allow-overlap"),Le=ae.get("icon-allow-overlap"),Ee=ae.get("text-variable-anchor"),We=ae.get("text-rotation-alignment")==="map",Ue=ae.get("text-pitch-alignment")==="map",st=oe.get("symbol-z-offset"),ut=ae.get("symbol-elevation-reference")==="sea",it=!st.isConstant(),Et=new Ff(null,0,be&&(Le||!h.hasIconData()||ae.get("icon-optional")),Le&&(be||!h.hasTextData()||ae.get("text-optional")),!0);!h.collisionArrays&&D&&(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData())&&h.deserializeCollisionBoxes(D);const jt=(_t,gt,Ot)=>{for(let Wt=0;Wt0||Wt>0,rr=ss>0,gr=this.placedOrientations[Ht],er=gr===i.bL.vertical,Vs=gr===i.bL.horizontal||gr===i.bL.horizontalOnly;!Ps&&!rr||Jt.isHidden()||Tt++;let Pr=!1;if((Ps||rr)&&z)for(const Mr of h.activeReplacements){if(i.bZ(Mr,F,i.b_.Symbol,Q)||Mr.min.x>rs||rs>Mr.max.x||Mr.min.y>gs||gs>Mr.max.y)continue;const ur=i.b$(rs,gs,W.canonical,Mr.footprintTileId.canonical);if(Pr=i.c0(ur,Mr.footprint),Pr)break}if(Ps){const Mr=Pr?J0:Du(Jt.text);jt(h.text,Ot,er?J0:Mr),jt(h.text,Wt,Vs?J0:Mr);const ur=Jt.text.isHidden(),{leftJustifiedTextSymbolIndex:br,centerJustifiedTextSymbolIndex:Gr,rightJustifiedTextSymbolIndex:Tn,verticalPlacedTextSymbolIndex:va}=gt,ei=h.text.placedSymbolArray,Dr=ur||er?1:0;br>=0&&(ei.get(br).hidden=Dr),Gr>=0&&(ei.get(Gr).hidden=Dr),Tn>=0&&(ei.get(Tn).hidden=Dr),va>=0&&(ei.get(va).hidden=ur||Vs?1:0);const Ka=this.variableOffsets[Ht];Ka&&this.markUsedJustification(h,Ka.anchor,gt,gr);const jn=this.placedOrientations[Ht];jn&&(this.markUsedJustification(h,"left",gt,jn),this.markUsedOrientation(h,jn,gt))}if(rr){const Mr=Pr?J0:Du(Jt.icon),{placedIconSymbolIndex:ur,verticalPlacedIconSymbolIndex:br}=gt,Gr=h.icon.placedSymbolArray,Tn=Jt.icon.isHidden()?1:0;ur>=0&&(jt(h.icon,ss,er?J0:Mr),Gr.get(ur).hidden=Tn),br>=0&&(jt(h.icon,gt.numVerticalIconVertices,Vs?J0:Mr),Gr.get(br).hidden=Tn)}if(h.hasIconCollisionBoxData()||h.hasTextCollisionBoxData()){const Mr=h.collisionArrays[_t];if(Mr){let ur=new i.P(0,0),br=!0;if(Mr.textBox||Mr.verticalTextBox){if(Ee){const Tn=this.variableOffsets[Ht];Tn?(ur=$d(Tn.anchor,Tn.width,Tn.height,Tn.textOffset,Tn.textScale),We&&ur._rotate(Ue?this.transform.angle:-this.transform.angle)):br=!1}ve&&(br=!Jt.clipped),Mr.textBox&&by(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||er,Bt,ut,ur.x,ur.y),Mr.verticalTextBox&&by(h.textCollisionBox.collisionVertexArray,Jt.text.placed,!br||Vs,Bt,ut,ur.x,ur.y)}const Gr=br&&!!(!Vs&&Mr.verticalIconBox);Mr.iconBox&&by(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,Gr,Bt,ut,gt.hasIconTextFit?ur.x:0,gt.hasIconTextFit?ur.y:0),Mr.verticalIconBox&&by(h.iconCollisionBox.collisionVertexArray,Jt.icon.placed,!Gr,Bt,ut,gt.hasIconTextFit?ur.x:0,gt.hasIconTextFit?ur.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 _t=this.collisionCircleArrays[h.bucketInstanceId];h.placementInvProjMatrix=_t.invProjMatrix,h.placementViewportMatrix=_t.viewportMatrix,h.collisionCircleArray=_t.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 by(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 FE=Math.pow(2,25),Kw=Math.pow(2,24),TC=Math.pow(2,17),zE=Math.pow(2,16),AC=Math.pow(2,9),Lu=Math.pow(2,8),Qx=Math.pow(2,1);function Du(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*FE+h*Kw+y*TC+h*zE+y*AC+h*Lu+y*Qx+h}const J0=0;class Z1{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 W=this._bucketParts;for(;this._currentTileIndexQ.sortKey-ae.sortKey));this._currentPartIndex{const Q=i.o.now()-z;return!this._forceFullPlacement&&Q>2};for(;this._currentPlacementIndex>=0;){const Q=y[h[this._currentPlacementIndex]],ae=this.placement.collisionIndex.transform.zoom;if(Q.type==="symbol"&&Q.visibility!=="none"&&(!Q.minzoom||Q.minzoom<=ae)&&(!Q.maxzoom||Q.maxzoom>ae)){const oe=Q,ve=oe.layout.get("symbol-z-elevate"),ge=oe.layout.get("symbol-sort-key").constantOr(1)!==void 0,be=oe.layout.get("symbol-z-order"),Le=be==="viewport-y"||be==="auto"&&!(be!=="viewport-y"&&ge),Ee=oe.layout.get("text-allow-overlap")||oe.layout.get("icon-allow-overlap")||oe.layout.get("text-ignore-placement")||oe.layout.get("icon-ignore-placement"),We=Le&&Ee,Ue=this._inProgressLayer=this._inProgressLayer||new Z1(oe),st=i.B(Q.source,Q.scope);if(Ue.continuePlacement(ve||We?D[st]:A[st],this.placement,this._showCollisionBoxes,Q,W,F))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(h){return this.placement.commit(h),this.placement}}const Qm=512/i.al/2;class Jx{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-Ue);for(const We of Ee){const Ue=this.crossTileIDs[We];if(this.keys[We]===oe&&!A.has(Ue)){A.add(Ue),ae.crossTileID=Ue;break}}}}}class ic{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class BE{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 W=D[z];W.tileID=W.tileID.unwrapTo(W.tileID.wrap+y),F[W.tileID.key]=W}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 W in z){const Q=z[W];Q.tileID.isChildOf(h)&&Q.findMatches(y.symbolInstances,h,D)}else{const W=z[h.scaledTo(Number(F)).key];W&&W.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 zf=771;class $n{constructor(h,y,A,D){this.blendFunction=h,this.blendColor=y.toNonPremultipliedRenderColor(null),this.mask=A,this.blendEquation=D}}$n.Replace=[1,0,1,0],$n.disabled=new $n($n.Replace,i.ao.transparent,[!1,!1,!1,!1]),$n.unblended=new $n($n.Replace,i.ao.transparent,[!0,!0,!0,!0]),$n.alphaBlended=new $n([1,zf,1,zf],i.ao.transparent,[!0,!0,!0,!0]),$n.alphaBlendedNonPremultiplied=new $n([770,zf,770,zf],i.ao.transparent,[!0,!0,!0,!0]),$n.multiply=new $n([774,0,774,0],i.ao.transparent,[!0,!0,!0,!0]),$n.additive=new $n([1,1,1,1],i.ao.transparent,[!0,!0,!0,!0]);class Rr{constructor(h,y,A){this.func=h,this.mask=y,this.range=A}}Rr.ReadOnly=!1,Rr.ReadWrite=!0,Rr.disabled=new Rr(519,Rr.ReadOnly,[0,1]);const EC=7680;class xn{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}}xn.disabled=new xn({func:519,mask:0},0,0,EC,EC,EC);const Y1=1029,PC=2305;class dn{constructor(h,y,A){this.enable=h,this.mode=y,this.frontFace=A}}function Bf(T,h){const y=i.ca(T,3);i.cc(T,h),i.cg(T,3,y)}function $E(T,h){const y=i.c7([]);return i.c8(y,y,-h),i.c9(y,y,-T),y}function IC(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 $E(Math.atan2(Math.sqrt(T[0]*T[0]+T[1]*T[1]),-T[2]),F)}dn.disabled=new dn(!1,Y1,PC),dn.backCCW=new dn(!0,Y1,PC),dn.backCW=new dn(!0,Y1,2304),dn.frontCW=new dn(!0,1028,2304),dn.frontCCW=new dn(!0,1028,PC);class Ou{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),W=[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=IC(W,y)}setPitchBearing(h,y){this.orientation=$E(i.an(h),i.an(-y))}}class LC{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&&Bf(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=$E(h,y),Bf(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 W=new Float64Array(16);return i.ce(W,h,y,A,D,F,z),W}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 LC([...this.position],[...this.orientation])}}const Vc={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class DC{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 DC(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 qE{constructor(h,y,A,D,F,z,W){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(W),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 DC,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new LC,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 qE(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(ge,ve,be,Le,Ee);Q.has(We)||(F.push(new i.aQ(ve,ge,be,Le,Ee)),Q.add(We))};for(let ve=0;vege.canonical.z)continue;const be=ge.canonical,Le=ge.overscaledZ,Ee=ge.wrap,We=1<0,ut=be.y+10,Et=ge.wrap-(st?0:1),jt=ge.wrap+(Ue?0:1),Tt=st?be.x-1:We-1,_t=Ue?be.x+1:0;if(z)A[0]<0?(ae(Le,jt,be.z,_t,be.y),A[1]<0&&ut&&(ae(Le,Ee,be.z,be.x,be.y+1),ae(Le,jt,be.z,_t,be.y+1)),A[1]>0&&it&&(ae(Le,Ee,be.z,be.x,be.y-1),ae(Le,jt,be.z,_t,be.y-1))):A[0]>0?(ae(Le,Et,be.z,Tt,be.y),A[1]<0&&ut&&(ae(Le,Ee,be.z,be.x,be.y+1),ae(Le,Et,be.z,Tt,be.y+1)),A[1]>0&&it&&(ae(Le,Ee,be.z,be.x,be.y-1),ae(Le,Et,be.z,Tt,be.y-1))):A[1]<0&&ut?ae(Le,Ee,be.z,be.x,be.y+1):it&&ae(Le,Ee,be.z,be.x,be.y-1);else{const gt=ge.visibleQuadrants;1>&&(ae(Le,Et,be.z,Tt,be.y),it&&(ae(Le,Ee,be.z,be.x,be.y-1),ae(Le,Et,be.z,Tt,be.y-1))),2>&&(ae(Le,jt,be.z,_t,be.y),it&&(ae(Le,Ee,be.z,be.x,be.y-1),ae(Le,jt,be.z,_t,be.y-1))),4>&&(ae(Le,Et,be.z,Tt,be.y),ut&&(ae(Le,Ee,be.z,be.x,be.y+1),ae(Le,Et,be.z,Tt,be.y+1))),8>&&(ae(Le,jt,be.z,_t,be.y),ut&&(ae(Le,Ee,be.z,be.x,be.y+1),ae(Le,jt,be.z,_t,be.y+1)))}}const oe=[];for(const ve of F)F.some(ge=>ve.isChildOf(ge))||oe.push(ve);if(F=oe.filter(ve=>!h.some(ge=>!!(ve.overscaledZ{const Ue=We.canonical.x+.5-be[0],st=We.canonical.y+.5-be[1];return Ue*Ue+st*st{const Tt=i.cY(ut,st,it,Et,jt);F.has(Tt)||(D.push(new i.aQ(st,ut,it,Et,jt)),F.add(Tt))},W=h.reduce((st,ut)=>Math.max(st,ut.overscaledZ),A),Q=1<{const it=Math.floor(st[0]),Et=Math.floor(st[1]),jt=(st[0]-it)*i.al,Tt=(st[1]-Et)*i.al,_t=Math.floor(ut[0]),gt=Math.floor(ut[1]),Ot=(ut[0]-_t)*i.al,Wt=(ut[1]-gt)*i.al;for(let Ht=-1;Ht<=1;Ht++){const ss=it+Ht;if(!(ss<0||ss>=Q)){oe.x=jt-Ht*i.al,ve.x=Ot-(ss-_t)*i.al;for(let rs=-1;rs<=1;rs++){const gs=Et+rs;oe.y=Tt-rs*i.al,ve.y=Wt-(gs-gt)*i.al,i.cZ(oe,ve,ae)&&z(W,0,A,ss,gs)}}}},be=y.points,Le=be[i.cv],Ee=be[i.cw],We=this._projectToGround(Le,be[i.cx]),Ue=this._projectToGround(Ee,be[i.cy]);return ge(Le,We),ge(Ee,Ue),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 W=this.locationCoordinate(this.center),Q=this.center.lat,ae=1<{const Jt=new i.ae(Bt.x+25e-6,Bt.y,Bt.z),Ps=new i.ae(Bt.x,Bt.y+25e-6,Bt.z),rr=Bt.toLngLat(),gr=Jt.toLngLat(),er=Ps.toLngLat(),Vs=this.locationCoordinate(rr),Pr=this.locationCoordinate(gr),Mr=this.locationCoordinate(er),ur=Math.hypot(Pr.x-Vs.x,Pr.y-Vs.y),br=Math.hypot(Mr.x-Vs.x,Mr.y-Vs.y);return Math.sqrt(ur*br)*Tt/25e-6},gt=Bt=>{const is=Et,Jt=jt;return{aabb:i.cF(this,ae,0,0,0,Bt,Jt,is,this.projection),zoom:0,x:0,y:0,minZ:Jt,maxZ:is,wrap:Bt,fullyVisible:!1}},Ot=[];let Wt=[];const Ht=y,ss=h.reparseOverscaled?A:y,rs=(We-this._centerAltitude)*Ee,gs=Bt=>{if(!this._elevation||!Bt.tileID||!z)return;const is=this._elevation.getMinMaxForTile(Bt.tileID),Jt=Bt.aabb;is?(Jt.min[2]=is.min,Jt.max[2]=is.max,Jt.center[2]=(Jt.min[2]+Jt.max[2])/2):(Bt.shouldSplit=Xt(Bt),Bt.shouldSplit||(Jt.min[2]=Jt.max[2]=Jt.center[2]=this._centerAltitude))},$s=(Bt,is)=>{if(.707*is{if(Bt.zoom=.9)return!0}else if(F&&(Ps=Bt.aabb.distanceZ(Ue)*Ee),this.projection.isReprojectedInTileSpace&&A<=5){const br=Math.pow(2,Bt.zoom),Gr=_t(new i.ae((Bt.x+.5)/br,(Bt.y+.5)/br));rr=Gr>.85?1:Gr}if(!z&&!ve){const br=Math.sqrt(is*is+Jt*Jt+Ps*Ps);let Gr=(1<0;){const Bt=Ot.pop(),is=Bt.x,Jt=Bt.y;let Ps=Bt.fullyVisible;const rr=()=>this.projection.name==="globe"&&(Bt.y===0||Bt.y===(1<>1),Pr={aabb:z?Bt.aabb.quadrant(gr):i.cF(this,ae,Bt.zoom+1,er,Vs,Bt.wrap,Bt.minZ,Bt.maxZ,this.projection),zoom:Bt.zoom+1,x:er,y:Vs,wrap:Bt.wrap,fullyVisible:Ps,tileID:void 0,shouldSplit:void 0,minZ:Bt.minZ,maxZ:Bt.maxZ};F&&!ve&&(Pr.tileID=new i.aQ(Bt.zoom+1===Ht?ss:Bt.zoom+1,Bt.wrap,Bt.zoom+1,er,Vs),gs(Pr)),Ot.push(Pr)}else{const gr=Bt.zoom===Ht?ss:Bt.zoom;if(h.minzoom&&h.minzoom>gr)continue;let er=0;if(!Ps){let ur=st?Bt.aabb.intersectsPrecise(be):Bt.aabb.intersectsPreciseFlat(be);if(ur===0&&rr()){const br=new i.cD(Bt.zoom,is,Jt);ur=i.cE(this,ae,br,!0).intersectsPrecise(be)}if(ur===0)continue;if(h.calculateQuadrantVisibility)if(be.containsPoint(Bt.aabb.center))er=15;else for(let br=0;br<4;br++)Bt.aabb.quadrant(br).intersects(be)!==0&&(er|=1<{const Ps=[0,0,0,1],rr=[i.al,i.al,0,1],gr=this.calculateFogTileMatrix(Jt.tileID.toUnwrapped());i.aC(Ps,Ps,gr),i.aC(rr,rr,gr);const er=i.cG([],Ps,rr),Vs=i.cH([],Ps,rr),Pr=i.c$(er,Vs);if(Pr===0)return!0;let Mr=!1;const ur=this._elevation;if(ur&&Pr>Bt&&is!==0){const br=this.calculateProjMatrix(Jt.tileID.toUnwrapped());let Gr;h.isTerrainDEM||(Gr=ur.getMinMaxForTile(Jt.tileID)),Gr||(Gr={min:jt,max:Et});const Tn=i.cI(this.rotation),va=[Tn[0]*i.al,Tn[1]*i.al,Gr.max];i.af(va,va,br),Mr=(1-va[1])*this.height*.5Bt.distanceSq-is.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 W=this.worldSize;A=(y.x-F.x)/W,D=(y.y-F.y)/W}else{const W=this.pointCoordinate(y),Q=this.pointCoordinate(F);A=W.x-Q.x,D=W.y-Q.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 W=D[2],Q=F[2];return{p0:D,p1:F,t:W===Q?0:(A-W)/(Q-W)}}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,W=h.clone();for(let Q=0;Q<10&&F-D>z;Q++){W.y=i.ak(D,F,.66);const ae=this.projection.pointCoordinate3D(this,W.x,W.y);ae?(F=W.y,A=ae):D=W.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)),W=this.pointLocation3D(new i.P(D,A)),Q=this.pointLocation3D(new i.P(y,A));let ae=Math.min(F.lng,z.lng,W.lng,Q.lng),oe=Math.max(F.lng,z.lng,W.lng,Q.lng),ve=Math.min(F.lat,z.lat,W.lat,Q.lat),ge=Math.max(F.lat,z.lat,W.lat,Q.lat);const be=Math.pow(2,-this.zoom)/16*270,Le=this.projection.name==="globe"?1:4,Ee=(We,Ue,st,ut,it)=>{const Et=(We+st)/2,jt=(Ue+ut)/2,Tt=new i.P(Et,jt),{lng:_t,lat:gt}=this.pointLocation3D(Tt),Ot=Math.max(0,ae-_t,ve-gt,_t-oe,gt-ge);ae=Math.min(ae,_t),oe=Math.max(oe,_t),ve=Math.min(ve,gt),ge=Math.max(ge,gt),(itbe)&&(Ee(We,Ue,Et,jt,it+1),Ee(Et,jt,st,ut,it+1))};if(Ee(y,h,D,h,1),Ee(D,h,D,A,1),Ee(D,A,y,A,1),Ee(y,A,y,h,1),this.projection.name==="globe"){const[We,Ue]=i.cM(this);We?(ge=90,oe=180,ae=-180):Ue&&(ve=-90,oe=180,ae=-180)}return new i.aI(new i.aT(ae,ve),new i.aT(oe,ge))}_getBoundsRectangular(h,y){const{top:A,left:D}=this._edgeInsets,F=this.height-this._edgeInsets.bottom,z=this.width-this._edgeInsets.right,W=new i.P(D,A),Q=new i.P(z,A),ae=new i.P(z,F),oe=new i.P(D,F);let ve=this.pointCoordinate(W,h),ge=this.pointCoordinate(Q,h);const be=this.pointCoordinate(ae,y),Le=this.pointCoordinate(oe,y),Ee=(We,Ue)=>(Ue.y-We.y)/(Ue.x-We.x);return ve.y>1&&ge.y>=0?ve=new i.ae((1-Le.y)/Ee(Le,ve)+Le.x,1):ve.y<0&&ge.y<=1&&(ve=new i.ae(-Le.y/Ee(Le,ve)+Le.x,0)),ge.y>1&&ve.y>=0?ge=new i.ae((1-be.y)/Ee(be,ge)+be.x,1):ge.y<0&&ve.y<=1&&(ge=new i.ae(-be.y/Ee(be,ge)+be.x,0)),new i.aI().extend(this.coordinateLocation(ve)).extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(Le)).extend(this.coordinateLocation(be))}_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.maxLngve&&(W=ve-ae),ve-oebe&&(z=be-Q),be-ge{for(let Xt=0;Xt<16;Xt++)ss[Xt]=i.ak(rs[Xt],gs[Xt],$s)})(W,W,Q,i.d0(this.pitch>=zp?1:this.pitch/zp))}else W=Q;const ae=i.cP([],Q,z);let oe=i.cP([],W,z);if(this.projection.isReprojectedInTileSpace){const gt=this.locationCoordinate(this.center),Ot=i.bA([]);i.br(Ot,Ot,[gt.x*this.worldSize,gt.y*this.worldSize,0]),i.aB(Ot,Ot,i.cQ(this)),i.br(Ot,Ot,[-gt.x*this.worldSize,-gt.y*this.worldSize,0]),i.aB(oe,oe,Ot),i.aB(ae,ae,Ot),this.inverseAdjustmentMatrix=i.cR(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=i.cS([],oe,[this.worldSize,this.worldSize,this.worldSize/F,1]),this.projMatrix=oe,this.invProjMatrix=i.bl(new Float64Array(16),this.projMatrix),y){const gt=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);gt[8]=2*-h.x/this.width,gt[9]=2*h.y/this.height,this.expandedFarZProjMatrix=i.cP([],gt,z)}else this.expandedFarZProjMatrix=this.projMatrix;const ve=i.bl([],W);this.frustumCorners=i.cT.fromInvProjectionMatrix(ve,this.horizonLineFromTop(),this.height),this.cameraFrustum=i.cB.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!y);const ge=new Float32Array(16);i.bA(ge),i.cS(ge,ge,[1,-1,1]),i.cU(ge,ge,this._pitch),i.bB(ge,ge,this.angle);const be=i.cd(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=i.bz(be);const Le=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;be[8]=2*-h.x/this.width,be[9]=2*(h.y+Le)/this.height,this.skyboxMatrix=i.aB(ge,be,ge);const Ee=this.point,We=Ee.x,Ue=Ee.y,st=this.width%2/2,ut=this.height%2/2,it=Math.cos(this.angle),Et=Math.sin(this.angle),jt=We-Math.round(We)+it*st+Et*ut,Tt=Ue-Math.round(Ue)+it*ut+Et*st,_t=new Float64Array(oe);if(i.br(_t,_t,[jt>.5?jt-1:jt,Tt>.5?Tt-1:Tt,0]),this.alignedProjMatrix=_t,oe=i.bC(),i.cS(oe,oe,[this.width/2,-this.height/2,1]),i.br(oe,oe,[1,-1,0]),this.labelPlaneMatrix=oe,oe=i.bC(),i.cS(oe,oe,[1,-1,1]),i.br(oe,oe,[-1,-1,0]),i.cS(oe,oe,[2/this.width,2/this.height,1]),this.glCoordMatrix=oe,this.pixelMatrix=i.aB(new Float64Array(16),this.labelPlaneMatrix,ae),this._calcFogMatrices(),this._distanceTileDataCache={},oe=i.bl(new Float64Array(16),this.pixelMatrix),!oe)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=oe,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.cV(this);const gt=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.af(gt,gt,z),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=oe;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)),W=Math.max((h[2]-F)/Math.cos(A),z),Q=this._zoomFromMercatorZ(W);i.bH(h,h,y,W),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(Q,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),W=this.tileSize*Math.pow(2,z),Q=this.getCameraToCenterDistance(this.projection,z,W),ae=this.scaleZoom(Q/(Math.max(0,h)*this.tileSize)),oe=Math.abs(z-ae);oeae||ge.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 W=z[3]=Math.max(z[3],1e-6);return z[0]/=W,z[1]/=W,z[2]/=W,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 _y=(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,W=((1-(Q=D))*y.cameraToCenterDistance+Q*(y._farZ+z))*A;var Q;return{shouldRenderCutoff:D<1,uniformValues:{u_cutoff_params:[y._nearZ,y._farZ,(W-y._nearZ)/F,(W-z-y._nearZ)/F]}}},Jm=2048;class Zw{constructor(h,y){this.aabb=h,this.lastCascade=y}}class _me{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 Zw(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 W=this.receivers[z];if(!W||!D.intersectsAabb(W.aabb))continue;W.aabb.min=D.closestPoint(W.aabb.min),W.aabb.max=D.closestPoint(W.aabb.max);const Q=W.aabb.getCorners();for(let ae=0;ae1||ge[1]<-1||ge[1]>1){oe=!1;break}}if(W.lastCascade=ae,F=Math.max(F,ae),oe)break}}return F+1}}class X1{constructor(h){this.painter=h,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new _me,this._depthMode=new Rr(h.context.gl.LEQUAL,Rr.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((Le,Ee)=>{const We=A.style._mergedLayers[Ee];return Le+(We.hasShadowPass()&&!We.isHidden(h.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled))return;const F=A.context,z=Jm,W=Jm;if(this._cascades.length===0||Jm!==this._cascades[0].texture.size[0]){this._cascades=[];for(let Le=0;Le<2;++Le){const Ee=A._shadowMapDebug,We=F.gl,Ue=F.createFramebuffer(z,W,Ee?1:0,"texture"),st=new i.T(F,{width:z,height:W,data:null},We.DEPTH_COMPONENT16);if(Ue.depthAttachment.set(st.texture),Ee){const ut=new i.T(F,{width:z,height:W,data:null},We.RGBA8);Ue.colorAttachment0.set(ut.texture)}this._cascades.push({framebuffer:Ue,texture:st,matrix:[],far:0,boundingSphereRadius:0,frustum:new i.cB,scale:0})}}this.shadowDirection=Xw(y);let Q=0;if(h.elevation){const Le=h.elevation,Ee=[1e4,-1e4];Le.visibleDemTiles.filter(We=>We.dem).forEach(We=>{const Ue=We.dem.tree;Ee[0]=Math.min(Ee[0],Ue.minimums[0]),Ee[1]=Math.max(Ee[1],Ue.maximums[0])}),Ee[0]!==1e4&&(Q=(Ee[1]-Ee[0])*Le.exaggeration())}const ae=1.5*h.cameraToCenterDistance,oe=3*ae,ve=new Float64Array(16);for(let Le=0;Le=0)return{};const F=function(Q,ae,oe){const ve=oe/(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 W={};return W.vertices=F,W.planes=[Yw(F[1],F[0],F[4]),Yw(F[2],F[1],F[5]),Yw(F[3],F[2],F[6]),Yw(F[0],F[3],F[7])],W}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 Yw(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 Xw(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 eg(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"),W=[z.x,z.y,z.z],Q=y.properties.get("color-use-theme")==="none",ae=y.properties.get("color"),oe=y.properties.get("intensity"),ve=Math.max(i.bJ([0,0,1],W),0),ge=[0,0,0];i.c5(ge,ae.toPremultipliedRenderColor(Q?null:T.getLut(h.scope)).toArray01Linear().slice(0,3),oe);const be=[0,0,0];return i.c5(be,D.toPremultipliedRenderColor(A?null:T.getLut(y.scope)).toArray01Linear().slice(0,3),ve*F),i.db([ge[0]>0?ge[0]/(ge[0]+be[0]):0,ge[1]>0?ge[1]/(ge[1]+be[1]):0,ge[2]>0?ge[2]/(ge[2]+be[2]):0])}function wy(T,h,y,A,D,F){const z=T.zoom,W=T.scale,Q=T.worldSize,ae=1/Q,oe=T.aspect,ve=Math.sqrt(1+oe*oe)*Math.tan(.5*T.fovX),ge=ve*ve,be=A-y,Le=A+y;let Ee,We;ge>be/Le?(Ee=A,We=A*ve):(Ee=.5*Le*(1+ge),We=.5*Math.sqrt(be*be+2*(A*A+y*y)*ge+Le*Le*ge*ge));const Ue=T.projection.pixelsPerMeter(T.center.lat,Q),st=T._camera.getCameraToWorldMercator(),ut=[0,0,-Ee*ae];i.af(ut,ut,st);let it=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 Ps=T._camera.getWorldToCamera(T.worldSize,T.projection.zAxisUnit==="meters"?Ue: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 gr=new Float64Array(16);i.cP(gr,rr,Ps);const er=new Float64Array(16);i.bl(er,gr);const Vs=i.cB.fromInvProjectionMatrix(er,Q,z,!0);for(const Pr of Vs.points){const Mr=((jt=Pr)[0]/=W,jt[1]/=W,jt[2]=i.cf(jt[2],T._center.lat),jt);it=Math.max(it,i.c6(i.da([],ut,Mr)))}}var jt;it*=D/(D-1);const Tt=Math.acos(h[2]),_t=Math.atan2(-h[0],-h[1]),gt=new LC;gt.position=ut,gt.setPitchBearing(Tt,_t);const Ot=gt.getWorldToCamera(Q,Ue),Wt=it*Q,Ht=Math.min(T._mercatorZfromZoom(17)*Q*-2,-2*Wt),ss=gt.getCameraToClipOrthographic(-Wt,Wt,-Wt,Wt,Ht,(Wt+F*Ue)/h[2]),rs=new Float64Array(16);i.aB(rs,ss,Ot);const gs=i.d5(Math.floor(1e6*ut[0])/1e6*Q,Math.floor(1e6*ut[1])/1e6*Q,0),$s=.5*D,Xt=[0,0,0];i.af(Xt,gs,rs),i.c5(Xt,Xt,$s);const Bt=[Math.floor(Xt[0]),Math.floor(Xt[1]),Math.floor(Xt[2])],is=[0,0,0];i.av(is,Xt,Bt),i.c5(is,is,-1/$s);const Jt=new Float64Array(16);return i.bA(Jt),i.br(Jt,Jt,is),i.aB(rs,Jt,rs),[rs,Wt]}class wme 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 W of D){const Q=h[W];this.hasURLBeenRequested(Q)&&!A.forceReload||(this.modelByURL[Q]={modelId:W,scope:y},F.push(this.loadModel(W,Q)),z.push(W)),this.models[y][W]||(this.models[y][W]={model:null,numReferences:1})}this.numModelsLoading[y]=(this.numModelsLoading[y]||0)+z.length,Promise.allSettled(F).then(W=>{for(let Q=0;Q{this.fire(new i.y(new Error(`Could not load models: ${W.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 UE=i.a6.colorTheme,jme=new i.a9({data:new i.aa(UE.data)});function NR(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,W=A*h;return[z,W,z+D*h,W+F*h]}function kR(T){if(T)return T.map(([h,y])=>[h*i.o.devicePixelRatio,y*i.o.devicePixelRatio])}class VE{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 kd))return h;const D=y.map(z=>this.sourceCache.getTile(z)),F=A.getImages(D,Array.from(this.pendingRequests));for(const[z,W]of F)h.set(i.I.from({name:z,iconsetId:this.id}),W),this.pendingRequests.delete(z);for(const z of this.pendingRequests)this.missingRequests.add(z);return this.pendingRequests.clear(),h}}const jy=(T,h)=>Ye(T,h&&h.filter(y=>y.identifier!=="source.canvas")),SR=i.aH(Pa,["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"]),CR=i.aH(Pa,["setCenter","setZoom","setBearing","setPitch"]),OC=new Set(["background","sky","slot","custom"]),Ny={version:8,layers:[],sources:{}},Qw={duration:300,delay:0};class ep 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({},Qw),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 Se,this._hasDataDrivenEmissive=!1,this.dispatcher=y.dispatcher?y.dispatcher:new i.D(i.dh(),this),y.imageManager?this.imageManager=y.imageManager:(this.imageManager=new Ge(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 wme(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=ep.registerForPluginStateChange(D=>{A.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:D.pluginStatus,pluginURL:D.pluginURL},(F,z)=>{if(i.dl(F),z&&z.every(W=>W))for(const W in A._sourceCaches){const Q=A._sourceCaches[W],ae=Q.getSource().type;ae!=="vector"&&ae!=="geojson"||Q.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 W=this._layers[z];W.source===F.id&&this._validateLayer(W)}})}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(W){z(W,!1)}};if(typeof h=="string"){const F=this.map._requestManager.normalizeStyleURL(h),z=this.map._requestManager.transformRequest(F,i.R.Style);i.m(z,(W,Q)=>{W?this.fire(new i.y(W)):Q&&D(Q,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,W)=>{if(this._request=null,z)this.fire(new i.y(z));else if(W)return this.importsCache.set(h,W),this._load(W,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(Ny,!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),W=new Promise(oe=>{z.once("style.import.load",oe),z.once("error",oe)}).then(()=>this.mergeAll());if(D.push(W),this.resolvedImports.has(F.url)){z.loadEmpty();continue}const Q=F.data||this.importsCache.get(F.url);Q?(z.loadJSON(Q,{validate:y}),this._isInternalStyle(Q)&&(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 oe=this.fragments.findIndex(({id:ve})=>ve===A);this.fragments=this.fragments.slice(0,oe).concat(ae).concat(this.fragments.slice(oe))}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 ep(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({},Ny,{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&&jy(this,Zr(h)))return;this._loaded=!0,this.stylesheet=i.dp(h);const A=()=>{for(const Q in h.sources)this.addSource(Q,h.sources[Q],{validate:!1,isInitialLoad:!0});if(h.iconsets)for(const Q in h.iconsets)this.addIconset(Q,h.iconsets[Q]);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=K0(this.stylesheet.layers);if(this._order=F.map(Q=>Q.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 Q=this.stylesheet.lights[0];this.light=new Rt(Q.properties,Q.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new Rt(this.stylesheet.light)),this._layers={};for(const Q of F){const ae=i.du(Q,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 oe=this.getOwnLayerSourceCache(ae),ve=!!this.directionalLight&&this.directionalLight.shadowsEnabled();oe&&ae.canCastShadows()&&ve&&(oe.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 W=this.isRootStyle();h.imports?this._loadImports(h.imports,y).then(()=>{this._reloadImports(),this.fire(new i.z(W?"style.load":"style.import.load"))}).catch(Q=>{this.fire(new i.y(new Error("Failed to load imports",Q))),this.fire(new i.z(W?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new i.z(W?"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,W,Q,ae,oe;const ve={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(ge=>{if(ge.stylesheet){if(ge.light!=null&&(h=ge.light),ge.stylesheet.lights)for(const be of ge.stylesheet.lights)be.type==="ambient"&&ge.ambientLight!=null&&(y=ge.ambientLight),be.type==="directional"&&ge.directionalLight!=null&&(A=ge.directionalLight);D=this._prioritizeTerrain(D,ge.terrain,ge.stylesheet.terrain),ge.stylesheet.fog&&ge.fog!=null&&(F=ge.fog),ge.stylesheet.snow&&ge.snow!=null&&(z=ge.snow),ge.stylesheet.rain&&ge.rain!=null&&(W=ge.rain),ge.stylesheet.camera!=null&&(oe=ge.stylesheet.camera),ge.stylesheet.projection!=null&&(Q=ge.stylesheet.projection),ge.stylesheet.transition!=null&&(ae=ge.stylesheet.transition),ve[ge.scope]=ge._styleColorTheme}}),this.light=h,this.ambientLight=y,this.directionalLight=A,this.fog=F,this.snow=z,this.rain=W,this._styleColorThemeForScope=ve,D===null?delete this.terrain:this.terrain=D,this.camera=oe||{"camera-projection":"perspective"},this.projection=Q||{name:"mercator"},this.transition=Object.assign({},Qw,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 W of z._order){const Q=z._layers[W];if(Q.type==="slot"){const ae=i.dq(W);if(h[ae])continue;h[ae]=[]}Q.slot&&h[Q.slot]?h[Q.slot].push(Q):y.push(Q)}}),this._mergedOrder=[];let D=-1;const F=(z=[])=>{for(const W of z)if(W.type==="slot"){const Q=i.dq(W.id);h[Q]&&F(h[Q]),this._mergedSlots.push(Q)}else{const Q=i.B(W.id,W.scope);this._mergedOrder.push(Q),A[Q]=W,W.is3D(!!this.terrain)&&(this._has3DLayers=!0,D=this._mergedOrder.length-1),W.type==="circle"&&(this._hasCircleLayers=!0),W.type==="symbol"&&(this._hasSymbolLayers=!0),W.type==="clip"&&(this._clipLayerPresent=!0)}};if(F(y),this._has3DLayers){const z={};for(let W=0;Wz[W]-z[Q])}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 Q of Object.keys(UE))z[Q]===void 0&&(z[Q]=UE[Q].default);const W=new i.a8(jme,y,new Map(D));return W.setTransitionOrValue(z,D),W.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 W=i.I.from("mapbox-reserved-lut"),Q=new Image;Q.src=z,Q.onerror=()=>{this._styleColorTheme.lutLoading=!1,D(new Error("Failed to load image data"))},Q.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==y)return void A();this._styleColorTheme.lutLoading=!1;const{width:ae,height:oe,data:ve}=i.o.getImageData(Q);if(oe>32)return void D(new Error("The height of the image must be less than or equal to 32 pixels."));if(ae!==oe*oe)return void D(new Error("The width of the image must be equal to the height squared."));this.getImage(W)&&this.removeImage(W),this.addImage(W,{data:new i.q({width:ae,height:oe},ve),pixelRatio:1,sdf:!1,usvg:!1,version:0});const ge=this.imageManager.getImage(W,this.scope);ge?(this._styleColorTheme.lut={image:ge.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,W;const Q=i.o.devicePixelRatio>1?"@2x":"";let ae=i.m(A.transformRequest(A.normalizeSpriteURL(y,Q,".json"),i.R.SpriteJSON),(ge,be)=>{ae=null,W||(W=ge,F=be,ve())}),oe=i.n(A.transformRequest(A.normalizeSpriteURL(y,Q,".png"),i.R.SpriteImage),(ge,be)=>{oe=null,W||(W=ge,z=be,ve())});function ve(){if(W)D(W);else if(F&&z){const ge=i.o.getImageData(z),be={};for(const Le in F){const{width:Ee,height:We,x:Ue,y:st,sdf:ut,pixelRatio:it,stretchX:Et,stretchY:jt,content:Tt}=F[Le],_t=new i.q({width:Ee,height:We});i.q.copy(ge,_t,{x:Ue,y:st},{x:0,y:0},{width:Ee,height:We},null),be[Le]={data:_t,pixelRatio:it!==void 0?it:1,sdf:ut!==void 0&&ut,stretchX:Et,stretchY:jt,content:Tt,usvg:!1,version:0}}D(null,be)}}return{cancel(){ae&&(ae.cancel(),ae=null),oe&&(oe.cancel(),oe=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 VE(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 W=new Map;for(const Q in z)W.set(i.I.from(Q),z[Q]);this.addImages(W)}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 W={},Q=i.dg(new i.bt(z));for(const ae of Q.icons){const oe={version:1,pixelRatio:i.o.devicePixelRatio,content:NR(ae),stretchX:ae.metadata?kR(ae.metadata.stretch_x_areas):void 0,stretchY:ae.metadata?kR(ae.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:ae};W[ae.name]=oe}D(null,W)}))}_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 W=h.getDefaultProgramParams(z,y.zoom,this._styleColorTheme.lut);W&&(A.style=this,this.fog&&(A._fogVisible=!0,W.overrideFog=!0,A.getOrCreateProgram(z,W)),A._fogVisible=!1,W.overrideFog=!1,A.getOrCreateProgram(z,W),(this.stylesheet.terrain||this.stylesheet.projection&&this.stylesheet.projection.name==="globe")&&(W.overrideRtt=!0,A.getOrCreateProgram(z,W)))}}}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 W=this._changes.getLayerUpdatesByScope();for(const Q in W){const{updatedIds:ae,removedIds:oe}=W[Q];(ae||oe)&&(this._updateWorkerLayers(Q,ae,oe),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 W in this._mergedSourceCaches){const Q=this._mergedSourceCaches[W];F[W]=Q.used,Q.used=!1,Q.tileCoverLift=0}for(const W of this._mergedOrder){const Q=this._mergedLayers[W];if(Q.visibility!=="none"&&Q.recalculate(h,this._availableImages),!Q.isHidden(h.zoom)){const ae=this.getLayerSourceCache(Q);ae&&(ae.used=!0,ae.tileCoverLift=Math.max(ae.tileCoverLift,Q.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(Q,h)}):this.precompilePrograms(Q,h))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&D&&this.mergeLayers();const z=this.imageManager.getPendingImageProviders();for(const W of z)W.sourceCache.used=!0;for(const W in F){const Q=this._mergedSourceCaches[W];F[W]!==Q.used&&Q.getSource().fire(new i.z("data",{sourceDataType:"visibility",dataType:"source",sourceId:Q.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(),jy(this,Zr(h)))return!1;(h=i.dp(h)).layers=K0(h.layers);const A=function(z,W){if(!z)return[{command:Pa.setStyle,args:[W]}];let Q=[];try{if(!i.by(z.version,W.version))return[{command:Pa.setStyle,args:[W]}];if(i.by(z.center,W.center)||Q.push({command:Pa.setCenter,args:[W.center]}),i.by(z.zoom,W.zoom)||Q.push({command:Pa.setZoom,args:[W.zoom]}),i.by(z.bearing,W.bearing)||Q.push({command:Pa.setBearing,args:[W.bearing]}),i.by(z.pitch,W.pitch)||Q.push({command:Pa.setPitch,args:[W.pitch]}),i.by(z.sprite,W.sprite)||Q.push({command:Pa.setSprite,args:[W.sprite]}),i.by(z.glyphs,W.glyphs)||Q.push({command:Pa.setGlyphs,args:[W.glyphs]}),i.by(z.imports,W.imports)||function(be=[],Le=[],Ee){Le=Le||[];const We=(be=be||[]).map(Z0),Ue=Le.map(Z0),st=be.reduce(Y0,{}),ut=Le.reduce(Y0,{}),it=We.slice();let Et,jt,Tt,_t;for(Et=0,jt=0;Et{be.source&&ae[be.source]?Q.push({command:Pa.removeLayer,args:[be.id]}):ve.push(be)});let ge=z.terrain;ge&&ae[ge.source]&&(Q.push({command:Pa.setTerrain,args:[void 0]}),ge=void 0),Q=Q.concat(oe),i.by(ge,W.terrain)||Q.push({command:Pa.setTerrain,args:[W.terrain]}),function(be,Le,Ee){Le=Le||[];const We=(be=be||[]).map(Z0),Ue=Le.map(Z0),st=be.reduce(Y0,{}),ut=Le.reduce(Y0,{}),it=We.slice(),Et=Object.create(null);let jt,Tt,_t,gt,Ot,Wt,Ht;for(jt=0,Tt=0;jt!(z.command in CR));if(A.length===0)return!1;const D=A.filter(z=>!(z.command in SR));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(je,`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(yi,`sources.${h}`,y,null,A))return;this.map&&this.map._collectResourceTiming&&(y.collectResourceTiming=!0);const D=Fl(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 W=(z?"symbol:":"other:")+D.id,Q=i.B(W,this.scope),ae=this._sourceCaches[W]=new Ml(Q,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(ir,"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 Ea(F,al||(al=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 Ea(F,Ja||(Ja=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=ge=>.2126*(ge[0]<=.03928?ge[0]/12.92:Math.pow((ge[0]+.055)/1.055,2.4))+.7152*(ge[1]<=.03928?ge[1]/12.92:Math.pow((ge[1]+.055)/1.055,2.4))+.0722*(ge[2]<=.03928?ge[2]/12.92:Math.pow((ge[2]+.055)/1.055,2.4)),D=h.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),F=h.properties.get("intensity"),z=h.properties.get("direction"),W=1-i.d4(z.x,z.y,z.z)[2]/90,Q=A(D)*F*W,ae=y.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),oe=y.properties.get("intensity"),ve=A(ae)*oe;return Number(((Q+ve)/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 Q=this.getOwnLayer(z.layer);if(!Q){i.w(`Layer is undefined for selector: ${z.layer}`);continue}const ae=A(Q.source,Q.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 W;if(z.properties)for(const Q in z.properties){const ae=i.U(z.properties[Q]);ae.result==="success"&&(W=W||{},W[Q]=ae.value)}F.push({layerId:z.layer,namespace:z.featureNamespace,properties:W,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 W=A.getOwnLayer(z.layer);W&&F.push(W)}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 jy(this,z.value);const W=z.value.expression,Q=i.B(y,D.scope),ae=D.options.get(Q);if(!ae)return;let oe;const{minValue:ve,maxValue:ge,stepValue:be,type:Le,values:Ee}=F[y],We=i.U(F[y].default);We.result==="success"&&(oe=We.value.expression),oe?(this.options.set(Q,Object.assign({},ae,{value:W,default:oe,minValue:ve,maxValue:ge,stepValue:be,type:Le,values:Ee})),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),W=y.options.get(z),Q=W?W.value||W.default:null;D[F]=Q?Q.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 ge=i.U(h[A]);ge.result==="success"&&(F=ge.value.expression)}const{minValue:W,maxValue:Q,stepValue:ae,type:oe,values:ve}=y[A];if(D){const ge=i.B(A,this.scope);this.options.set(ge,{default:D,value:F,minValue:W,maxValue:Q,stepValue:ae,type:oe,values:ve})}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(jy(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(Aa,`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 W=this._order.length;if(y){const ve=this._order.indexOf(y);if(ve===-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?W=ve:i.w(`Layer with id "${y}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(W,0,D),this._layerOrderChanged=!0,this._layers[D]=F;const Q=this.getOwnLayerSourceCache(F),ae=!!this.directionalLight&&this.directionalLight.shadowsEnabled();Q&&F.canCastShadows()&&ae&&(Q.castsShadows=!0);const oe=this._changes.getRemovedLayer(F);if(oe&&F.source&&Q&&F.type!=="custom"){this._changes.discardLayerRemoval(F);const ve=i.B(F.source,F.scope);oe.type!==F.type?this._changes.updateSourceCache(ve,"clear"):(this._changes.updateSourceCache(ve,"reload"),Q.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(Pi,`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)&&jy(F,$t.call(Zr,{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)&&jy(F,Oo.call(Zr,{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:Q,importId:ae}=h.target,oe=this.getFragmentStyle(ae),ve=oe.getFeaturesetLayers(Q);for(const{source:ge,sourceLayer:be}of ve)oe.setFeatureState({id:h.id,source:ge,sourceLayer:be},y)}else if("layerId"in h.target){const{layerId:Q}=h.target,ae=this.getLayer(Q);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 W=this.getOwnSourceCaches(A);for(const Q of W)Q.setFeatureState(D,h.id,y)}removeFeatureState(h,y){if(this._checkLoaded(),"target"in h){if("featuresetId"in h.target){const{featuresetId:Q,importId:ae}=h.target,oe=this.getFragmentStyle(ae),ve=oe.getFeaturesetLayers(Q);for(const{source:ge,sourceLayer:be}of ve)oe.removeFeatureState({id:h.id,source:ge,sourceLayer:be},y)}else if("layerId"in h.target){const{layerId:Q}=h.target,ae=this.getLayer(Q);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 W=this.getOwnSourceCaches(A);for(const Q of W)Q.removeFeatureState(z,h.id,y)}getFeatureState(h){if(this._checkLoaded(),"target"in h){let F;if("featuresetId"in h.target){const{featuresetId:z,importId:W}=h.target,Q=this.getFragmentStyle(W),ae=Q.getFeaturesetLayers(z);for(const{source:oe,sourceLayer:ve}of ae){const ge=Q.getFeatureState({id:h.id,source:oe,sourceLayer:ve});if(ge&&!F)F=ge;else if(!i.by(F,ge))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,W=this.getLayer(z);F=this.getFeatureState({id:h.id,source:W.source,sourceLayer:W.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=W=>this._mergedLayers[W].is3D(!!this.terrain),A=this.order,D={},F=[];for(let W=A.length-1;W>=0;W--){const Q=A[W];if(y(Q)){D[Q]=W;for(const ae of h){const oe=ae[Q];if(oe)for(const ve of oe)F.push(ve)}}}F.sort((W,Q)=>Q.intersectionZ-W.intersectionZ);const z=[];for(let W=A.length-1;W>=0;W--){const Q=A[W];if(y(Q))for(let ae=F.length-1;ae>=0;ae--){const oe=F[ae].feature;if(oe.layer&&D[oe.layer.id]{if(OC.has(oe.type))return;const ve=this.getOwnLayerSourceCache(oe),ge=F[ve.id]=F[ve.id]||{sourceCache:ve,layers:{},has3DLayers:!1};oe.is3D(!!this.terrain)&&(ge.has3DLayers=!0),ge.layers[oe.fqid]=ge.layers[oe.fqid]||{styleLayer:oe,targets:[]},ge.layers[oe.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 oe of y.layers){const ve=this._layers[oe];if(!ve)return this.fire(new i.y(new Error(`The layer '${oe}' does not exist in the map's style and cannot be queried for features.`))),[];z(ve)}}else for(const oe in this._layers)z(this._layers[oe]);const W=this._queryRenderedFeatures(h,F,A),Q=this._flattenAndSortRenderedFeatures(W),ae=[];for(const oe of Q)i.dw(oe.layer.id)===this.scope&&ae.push(oe);return ae}queryRenderedFeatureset(h,y,A){let D;y&&!Array.isArray(y)&&y.filter&&(this._validate(Pi,"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 oe=this.getFeaturesetDescriptors();for(const ve of oe)z.push({targetId:F,filter:D,target:ve});for(const{style:ve}of this.fragments){const ge=ve.getFeaturesetDescriptors();for(const be of ge)z.push({targetId:F,filter:D,target:be})}}const W=this.queryRenderedTargets(h,z,A),Q=[],ae=new Set;for(const oe of W)for(const ve of oe.variants[F])gy(ve,oe,ae)||Q.push(new i.dx(oe,ve));return Q}queryRenderedTargets(h,y,A){const D={},F=(W,Q,ae,oe)=>{const ve=D[Q.id]=D[Q.id]||{sourceCache:Q,layers:{},has3DLayers:!1};if(ve.layers[W.fqid]=ve.layers[W.fqid]||{styleLayer:W,targets:[]},W.is3D(!!this.terrain)&&(ve.has3DLayers=!0),!oe)return ae.uniqueFeatureID=!1,void ve.layers[W.fqid].targets.push(ae);ve.layers[W.fqid].targets.push(Object.assign({},ae,{namespace:oe.namespace,properties:oe.properties,uniqueFeatureID:oe.uniqueFeatureID}))};for(const W of y)if("featuresetId"in W.target){const{featuresetId:Q,importId:ae}=W.target,oe=this.getFragmentStyle(ae);if(!oe||!oe._featuresetSelectors)continue;const ve=oe._featuresetSelectors[Q];if(!ve){this.fire(new i.y(new Error(`The featureset '${Q}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const ge of ve){const be=oe.getOwnLayer(ge.layerId);be&&!OC.has(be.type)&&F(be,oe.getOwnLayerSourceCache(be),W,ge)}}else if("layerId"in W.target){const{layerId:Q}=W.target,ae=this.getLayer(Q);if(!ae||OC.has(ae.type))continue;F(ae,this.getLayerSourceCache(ae),W)}const z=this._queryRenderedFeatures(h,D,A);return this._flattenAndSortRenderedFeatures(z)}_queryRenderedFeatures(h,y,A){const D=[],F=!!this.map._showQueryGeometry,z=lo.createFromScreenPoints(h,A);for(const W in y){const Q=U1(z,y[W],this._availableImages,A,F);Object.keys(Q).length&&D.push(Q)}if(this.placement)for(const W in y){if(!y[W].sourceCache._onlySymbols)continue;const Q=V1(z.screenGeometry,y[W],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(Q).length&&D.push(Q)}return D}querySourceFeatures(h,y){const A=y&&y.filter;A&&this._validate(Pi,"querySourceFeatures.filter",A,null,y);let D=[];const F=this.getOwnSourceCaches(h);for(const z of F)D=D.concat(H1(z,y));return D}addSourceType(h,y,A){return ep.getSourceType(h)?A(new Error(`A source type called "${h}" already exists.`)):(ep.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 W in h)if(!i.by(h[W],D[W])){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 W="terrain-dem-src";this.addSource(W,A.source),A=i.dp(A),A=Object.assign(A,{source:W})}const F=Object.assign({},A),z={};if(this.terrain&&D){F.source=this.terrain.get().source;const W=this.terrain?this.getFragmentStyle(this.terrain.scope):null;W&&(z.style=W.serialize())}if(this._validate(Bn,"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 W of Object.keys(i.a6.terrain))!A.hasOwnProperty(W)&&i.a6.terrain[W].default&&(A[W]=i.a6.terrain[W].default);for(const W in h)if(!i.by(h[W],z[W])){F.set(h,this.options),this.stylesheet.terrain=h;const Q=this._getTransitionParameters({duration:0});F.updateTransitions(Q),this.fire(new i.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(h){const y=this.fog=new Mn(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 dl(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 oo(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 Vt(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 jy(this,h.call(Zr,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=Xw(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],W=D.has(z._source.id);A.has(z._source.id)&&(z._source.reparseOverscaled=!1),z.update(h,void 0,void 0,y,W)}}_generateCollisionBoxes(){for(const h in this._sourceCaches){const y=this._sourceCaches[h];y.resume(),y.reload()}}_updatePlacement(h,y,A,D,F,z,W=!1){let Q=!1,ae=!1;const oe={},ve={};for(const Ee of this._mergedOrder){const We=this._mergedLayers[Ee];if(We.type!=="symbol")continue;const Ue=i.B(We.source,We.scope);let st=oe[Ue];if(!st){const it=this.getLayerSourceCache(We);if(!it)continue;const Et=it.getRenderableIds(!0).map(jt=>it.getTileByID(jt));ve[Ue]=Et.slice(),st=oe[Ue]=Et.sort((jt,Tt)=>Tt.tileID.overscaledZ-jt.tileID.overscaledZ||(jt.tileID.isLessThan(Tt.tileID)?-1:1))}const ut=this.crossTileSymbolIndex.addLayer(We,st,y.center.lng,y.projection);Q=Q||ut}this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),W=W||this._layerOrderChanged,this._layerOrderChanged&&this.fire(new i.z("neworder"));const ge=!!(this.placement&&!y.equals(this.placement.transform)),be=!!(this.placement&&(this.placement.lastReplacementSourceUpdateTime!==0&&!z||this.placement.lastReplacementSourceUpdateTime!==z.updateTime)),Le=(ge||be||Q||this.placement&&this.placement.isStale())&&D===0;if((W||!this.pauseablePlacement||Le||D!==0&&this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.o.now(),y.zoom))&&(this.pauseablePlacement=new kc(y,this._mergedOrder,W||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,oe,ve,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.o.now()),ae=!0),Q&&this.pauseablePlacement.placement.setStale()),ae||Q){this._buildingIndex.onNewFrame(y.zoom);for(let Ee=0;EeF===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],W=this.fragments[D];return A=A.filter(({id:Q})=>Q!==h),this.fragments=this.fragments.filter(({id:Q})=>Q!==h),this.stylesheet.imports=A.slice(0,F).concat(z).concat(A.slice(F)),this.fragments=this.fragments.slice(0,F).concat(W).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 W=z.style.stylesheet&&z.style.stylesheet.schema;return z.config=y,z.style.updateConfig(y,W),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 W=y.images.map(Q=>i.I.toString(Q));z.setDependencies(y.tileID.key,y.type,W)}},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)}}ep.getSourceType=function(T){return Gm[T]},ep.setSourceType=function(T,h){Gm[T]=h},ep.registerForPluginStateChange=i.dA;class MR 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,W,Q){let ae=null,oe=Number.MAX_SAFE_INTEGER;if(Q<16)return null;for(const[ve,ge]of Object.entries(F)){const be=ge.center;if(be){const Le=z.distanceTo(i.aT.convert(be));Le({id:z,name:A.floors[z].name,zIndex:A.floors[z].zIndex})).sort((z,W)=>W.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 Q1=` #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`,J1=` #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;}`,HE=` #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`,RC="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;}",om=` #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`,FC=`#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`,WE=`#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`,zC=`#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;}`,BC=`#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`,GE=`#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 Jw=/#include\s+"([^"]+)"/g,$f=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,KE=/\b[A-Za-z_][A-Za-z0-9_]*\b/g,ev=new Set(["ifdef","ifndef","elif","if","defined"]),tv=new Set;Sy(Q1,tv),Sy(HE,tv),Sy(J1,tv);const ky={"_prelude_fog.vertex.glsl":FC,"_prelude_terrain.vertex.glsl":om,"_prelude_shadow.vertex.glsl":BC,"_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":GE,"_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":WE,"_prelude_raster_particle.glsl":zC},$C={};Oa("",om),Oa(tr,FC),Oa(GE,BC),Oa(WE,""),Oa(zC,"");const TR=Oa(J1,HE),qC=Q1,Nme=[` #if defined(GL_EXT_blend_func_extended) && defined(DUAL_SOURCE_BLENDING) #extension GL_EXT_blend_func_extended : require #endif`,"precision mediump float;",qC,TR.fragmentSource].join(` `),AR=["precision highp float;",qC,TR.vertexSource].join(` `);var ZE={background:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`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:Oa(`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:Oa(`#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:Oa("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:Oa(`#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:Oa(`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:Oa("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:Oa("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:Oa("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:Oa(`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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`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:Oa(`#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:Oa(`#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:Oa(`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:Oa(`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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`#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:Oa("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:Oa("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:Oa(`#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:Oa(`#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:Oa(`#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:Oa("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:Oa(`#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 }`,RC),skyboxGradient:Oa(`#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 }`,RC),skyboxCapture:Oa(` 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:Oa(`#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:Oa(`#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:Oa(`#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:Oa(`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:Oa(`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:Oa("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:Oa("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:Oa("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:Oa("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 Sy(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(KE);if(D)for(const F of D)ev.has(F)||h.add(F)}}function Oa(T,h){const y=new Set,A=[],D=[];T=T.replace(Jw,(z,W)=>(D.push(W),"")),h=h.replace(Jw,(z,W)=>(A.push(W),""));let F=new Set(tv);Sy(T,F),Sy(h,F);for(const z of[...A,...D])$C[z]||($C[z]=new Set,Sy(ky[z],$C[z])),F=new Set([...F,...$C[z]]);return{fragmentSource:T=T.replace($f,(z,W,Q,ae,oe)=>(y.add(oe),W==="define"?` #ifndef HAS_UNIFORM_u_${oe} in ${Q} ${ae} ${oe}; #else uniform ${Q} ${ae} u_${oe}; #endif `:W==="initialize"?` #ifdef HAS_UNIFORM_u_${oe} ${Q} ${ae} ${oe} = u_${oe}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${ae} ${oe}; #endif `:W==="initialize-attribute"?"":void 0)),vertexSource:h=h.replace($f,(z,W,Q,ae,oe)=>{const ve=`MATERIAL_ATTRIBUTE_OFFSET_${oe}`,ge=ae==="float"?"vec2":ae,be=`GET_ATTRIBUTE_${ge}(a_${oe}, materialInfo, ${ve})`,Le=oe.match(/color/)?"color":ge;return W==="define-attribute-vertex-shader-only"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${ae} a_${oe}; #endif `:y.has(oe)?W==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ve}) in ${Q} ${ge} a_${oe}; #endif out ${Q} ${ae} ${oe}; #else uniform ${Q} ${ae} u_${oe}; #endif `:W==="initialize"?Le==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} ${oe} = a_${oe}; #else ${Q} ${ae} ${oe} = u_${oe}; #endif `:` #if !defined(HAS_UNIFORM_u_${oe}) #ifdef ${ve} ${oe} = unpack_mix_${Le}(${be}, u_${oe}_t); #else ${oe} = unpack_mix_${Le}(a_${oe}, u_${oe}_t); #endif #else ${Q} ${ae} ${oe} = u_${oe}; #endif `:W==="define-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} in ${Q} ${ae} a_${oe}; out ${Q} ${ae} ${oe}; #endif `:W==="initialize-attribute"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${oe} = a_${oe}; #endif `:void 0:W==="define"?` #ifndef HAS_UNIFORM_u_${oe} uniform lowp float u_${oe}_t; #if !defined(${ve}) in ${Q} ${ge} a_${oe}; #endif #else uniform ${Q} ${ae} u_${oe}; #endif `:W==="define-instanced"?Le==="mat4"?` #ifdef INSTANCED_ARRAYS in vec4 a_${oe}0; in vec4 a_${oe}1; in vec4 a_${oe}2; in vec4 a_${oe}3; #else uniform ${Q} ${ae} u_${oe}; #endif `:` #ifdef INSTANCED_ARRAYS in ${Q} ${ge} a_${oe}; #else uniform ${Q} ${ae} u_${oe}; #endif `:W==="initialize-attribute-custom"?` #ifdef HAS_ATTRIBUTE_a_${oe} ${Q} ${ae} ${oe} = a_${oe}; #endif `:Le==="vec4"?` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ve} ${Q} ${ae} ${oe} = ${be}; #else ${Q} ${ae} ${oe} = a_${oe}; #endif #else ${Q} ${ae} ${oe} = u_${oe}; #endif `:` #ifndef HAS_UNIFORM_u_${oe} #ifdef ${ve} ${Q} ${ae} ${oe} = unpack_mix_${Le}(${be}, u_${oe}_t); #else ${Q} ${ae} ${oe} = unpack_mix_${Le}(a_${oe}, u_${oe}_t); #endif #else ${Q} ${ae} ${oe} = u_${oe}; #endif `}),usedDefines:F,vertexIncludes:A,fragmentIncludes:D}}class kme{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,W,Q){this.context=h;let ae=this.boundPaintVertexBuffers.length!==D.length;for(let ve=0;!ae&&ve{const Et=ut.paint.get("hillshade-shadow-color"),jt=ut.paint.get("hillshade-shadow-color-use-theme").constantOr("default")==="none",Tt=ut.paint.get("hillshade-highlight-color"),_t=ut.paint.get("hillshade-highlight-color-use-theme").constantOr("default")==="none",gt=ut.paint.get("hillshade-accent-color"),Ot=ut.paint.get("hillshade-accent-color-use-theme").constantOr("default")==="none",Wt=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-=Ue.transform.angle;else if(Ue.style&&Ue.style.enable3dLights()&&Ue.style.directionalLight){const rs=Ue.style.directionalLight.properties.get("direction"),gs=i.d4(rs.x,rs.y,rs.z);Ht=i.an(gs[1])}const ss=!Ue.options.moving;return{u_matrix:it||Ue.transform.calculateProjMatrix(st.tileID.toUnwrapped(),ss),u_image:0,u_latrange:Sme(0,st.tileID),u_light:[ut.paint.get("hillshade-exaggeration"),Ht],u_shadow:Et.toPremultipliedRenderColor(jt?null:ut.lut),u_highlight:Tt.toPremultipliedRenderColor(_t?null:ut.lut),u_emissive_strength:Wt,u_accent:gt.toPremultipliedRenderColor(Ot?null:ut.lut)}})(T,y,A,T.terrain?h.projMatrix:null);T.uploadCommonUniforms(W,ge,h.toUnwrapped());const{tileBoundsBuffer:Le,tileBoundsIndexBuffer:Ee,tileBoundsSegments:We}=T.getTileBoundsBuffers(y);ge.draw(T,Q.TRIANGLES,D,F,z,dn.disabled,be,A.id,Le,Ee,We)}function YE(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 Mme(T,h,y){const A=T.context,D=A.gl;if(!h.dem)return;const F=h.dem;if(A.activeTexture.set(D.TEXTURE1),YE(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 W=h.hillshadeFBO;if(!W){const ge=new i.T(A,{width:z,height:z,data:null},D.RGBA8);ge.bind(D.LINEAR,D.CLAMP_TO_EDGE),W=h.hillshadeFBO=A.createFramebuffer(z,z,1,"renderbuffer"),W.colorAttachment0.set(ge.texture)}A.bindFramebuffer.set(W.framebuffer),A.viewport.set([0,0,z,z]);const{tileBoundsBuffer:Q,tileBoundsIndexBuffer:ae,tileBoundsSegments:oe}=T.getMercatorTileBoundsBuffers(),ve=[];T.linearFloatFilteringSupported()&&ve.push("TERRAIN_DEM_FLOAT_FORMAT"),T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&ve.push("USE_MRT1"),T.getOrCreateProgram("hillshadePrepare",{defines:ve}).draw(T,D.TRIANGLES,Rr.disabled,xn.disabled,$n.unblended,dn.disabled,((ge,be)=>{const Le=be.stride,Ee=i.bC();return i.ce(Ee,0,i.al,-i.al,0,0,1),i.br(Ee,Ee,[0,-i.al,0]),{u_matrix:Ee,u_image:1,u_dimension:[Le,Le],u_zoom:ge.overscaledZ}})(h.tileID,F),y.id,Q,ae,oe),h.needsHillshadePrepare=!1}class ho{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 Tme extends ho{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 ER extends ho{getDefault(){return 1}set(h){(h!==this.current||this.dirty)&&(this.gl.clearDepth(h),this.current=h,this.dirty=!1)}}class XE extends ho{getDefault(){return 0}set(h){(h!==this.current||this.dirty)&&(this.gl.clearStencil(h),this.current=h,this.dirty=!1)}}class UC extends ho{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 QE extends ho{getDefault(){return!0}set(h){(h!==this.current||this.dirty)&&(this.gl.depthMask(h),this.current=h,this.dirty=!1)}}class sv extends ho{getDefault(){return 255}set(h){(h!==this.current||this.dirty)&&(this.gl.stencilMask(h),this.current=h,this.dirty=!1)}}class eb extends ho{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 e2 extends ho{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 tb extends ho{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 PR extends ho{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 JE extends ho{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 IR extends ho{getDefault(){return this.gl.LESS}set(h){(h!==this.current||this.dirty)&&(this.gl.depthFunc(h),this.current=h,this.dirty=!1)}}class sb extends ho{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 VC extends ho{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 HC extends ho{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 e6 extends ho{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 WC extends ho{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 t2 extends ho{getDefault(){return this.gl.BACK}set(h){(h!==this.current||this.dirty)&&(this.gl.cullFace(h),this.current=h,this.dirty=!1)}}class LR extends ho{getDefault(){return this.gl.CCW}set(h){(h!==this.current||this.dirty)&&(this.gl.frontFace(h),this.current=h,this.dirty=!1)}}let DR=class extends ho{getDefault(){return null}set(T){(T!==this.current||this.dirty)&&(this.gl.useProgram(T),this.current=T,this.dirty=!1)}};class OR extends ho{getDefault(){return this.gl.TEXTURE0}set(h){(h!==this.current||this.dirty)&&(this.gl.activeTexture(h),this.current=h,this.dirty=!1)}}class rb extends ho{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 RR extends ho{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 Ame extends ho{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 Eme extends ho{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 Pme extends ho{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 t6 extends ho{getDefault(){return null}set(h){const y=this.gl;y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,h),this.current=h,this.dirty=!1}}class s6 extends ho{getDefault(){return null}set(h){this.gl&&(h!==this.current||this.dirty)&&(this.gl.bindVertexArray(h),this.current=h,this.dirty=!1)}}class r6 extends ho{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 n6 extends ho{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 FR extends ho{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 GC extends ho{constructor(h,y){super(h),this.context=h,this.parent=y}getDefault(){return null}}class KC extends GC{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 nb extends GC{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 s2 extends GC{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 zR extends nb{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const lm=(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}),ZC=(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,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:W,u_frustum_br:Q,u_frustum_bl:ae,u_globe_pos:oe,u_globe_radius:ve,u_viewport:ge,u_grid_matrix:We?Float32Array.from(We):new Float32Array(9),u_skirt_height:be,u_far_z_cutoff:Le,u_emissive_texture_available:Ee});function r2(T,h){return T!=null&&h!=null&&!(!T.hasData()||!h.hasData())&&T.demTexture!=null&&h.demTexture!=null&&T.tileID.key!==h.tileID.key}const tg=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()}},YC={0:null,1:"TERRAIN_VERTEX_MORPHING"};function XC(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 a6(T,h){const y=1<({u_matrix:T});function a2(T,h,y,A,D){if(D>0){const F=i.o.now(),z=(F-T.timeAdded)/D,W=h?(F-h.timeAdded)/D:-1,Q=y.getSource(),ae=A.coveringZoomLevel({tileSize:Q.tileSize,roundZoom:Q.roundZoom}),oe=!h||Math.abs(h.tileID.overscaledZ-ae)>Math.abs(T.tileID.overscaledZ-ae),ve=oe&&T.refreshedUponExpiration?1:i.aA(oe?z:1-W,0,1);return h?{opacity:1,mix:1-ve,isFading:z<1}:{opacity:ve,mix:0,isFading:z<1}}return{opacity:1,mix:0,isFading:!1}}class QC extends Ml{constructor(h){const y=Fl("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 i6 extends Ml{constructor(h){const y=Fl("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 W=new Zm(z,this._source.tileSize*z.overscaleFactor(),h.tileZoom,void 0,void 0,this._source.worldview);W.state="loaded",this._tiles[z.key]=W}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 o6 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 l6 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(Q){const ae=new i.bd,oe=new i.b0,ve=131;ae.reserve(17161),oe.reserve(33800);const ge=i.al/128,be=i.al+ge/2,Le=be+ge;for(let We=-ge;Webe||We<0||We>be?24575:0,ut=i.aA(Math.round(Ue),0,i.al),it=i.aA(Math.round(We),0,i.al);ae.emplaceBack(ut+st,it)}const Ee=(We,Ue)=>{const st=Ue*ve+We;oe.emplaceBack(st+1,st,st+ve),oe.emplaceBack(st+ve,st+ve+1,st+1)};for(let We=1;We<129;We++)for(let Ue=1;Ue<129;Ue++)Ee(Ue,We);return[0,129].forEach(We=>{for(let Ue=0;Ue<130;Ue++)Ee(Ue,We),Ee(We,Ue)}),[ae,oe,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 i6(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 W=z.gl;this._overlapStencilMode=new xn({func:W.GEQUAL,mask:255},0,255,W.KEEP,W.KEEP,W.REPLACE),this._previousZoom=h.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=y,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new QC(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 W=h.terrain&&h.terrain.scope,Q=D.get("source"),ae=F?this._mockSourceCache:h.getSourceCache(Q,W);if(!ae)return void i.w(`Couldn't find terrain source "${Q}".`);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 oe=()=>{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 ve=this.getScaledDemTileSize();this.sourceCache.update(y,ve,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,oe(),this._initializing=!0),oe(),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 W=F-this._previousZoom;const Q=this._previousUpdateTimestamp;let ae=F;this._evaluationZoom!=null&&(ae=this._evaluationZoom,Math.abs(F-ae)>.5&&(W=.5*(F-ae+W)),W*D<0&&(ae+=W)),this._evaluationZoom=ae;const oe=z.getExaggeration(ae),ve=oe===z.getExaggeration(Math.max(0,ae-.1));if(ve&&Math.abs(oe-this._exaggeration)<.01)return oe;let ge=Math.min(.1,.00375*(this._updateTimestamp-Q));return(ve||oe<.1||Math.abs(W)<1e-4)&&(ge=Math.min(.2,4*ge)),i.ak(this._exaggeration,oe,ge)}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(Q=>{const ae=y.getTileByID(Q).tileID;return ae.projMatrix=A.calculateProjMatrix(ae.toUnwrapped()),ae});(function(Q,ae){const oe=ae.transform.pointCoordinate(ae.transform.getCameraPoint()),ve=new i.P(oe.x,oe.y);Q.sort((ge,be)=>{if(be.overscaledZ-ge.overscaledZ)return be.overscaledZ-ge.overscaledZ;const Le=new i.P(ge.canonical.x+(1<{this.proxyToSource[Q.key]={}}),this.terrainTileForTile={};const z=this._style._mergedSourceCaches;for(const Q in z){const ae=z[Q];if(!ae.used||(ae!==this.sourceCache&&this.resetTileLookupCache(ae.id),this._setupProxiedCoordsForOrtho(ae,h[Q],F),ae.usedForTerrain))continue;const oe=h[Q];ae.getSource().reparseOverscaled&&this._assignTerrainTiles(oe)}this.proxiedCoords[y.id]=D.map(Q=>new o6(Q,Q.key,this.orthoMatrix)),this._assignTerrainTiles(D),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(F),this.renderingToTexture=!1;const W={};this._visibleDemTiles=[];for(const Q of this.proxyCoords){const ae=this.terrainTileForTile[Q.key];if(!ae)continue;const oe=ae.tileID.key;oe in W||(this._visibleDemTiles.push(ae),W[oe]=oe)}}_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),YE(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),W=D||"";return A[`u_dem_tl${W}`]=[F.x*z%1,F.y*z%1],A[`u_dem_scale${W}`]=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 W=null,Q=null,ae=1;if(A&&A.morphing&&this._useVertexMorphing){const be=A.morphing.srcDemTile,Le=A.morphing.dstDemTile;ae=A.morphing.phase,be&&Le&&(this._prepareDemTileUniforms(h,be,z,"_prev")&&(Q=be),this._prepareDemTileUniforms(h,Le,z)&&(W=Le))}const oe=be=>be&&be.demTexture&&this.painter.linearFloatFilteringSupported()?F.LINEAR:F.NEAREST;let ve=null;var ge;if(this.enabled?Q&&W?(ve=W.demTexture,D.activeTexture.set(F.TEXTURE4),Q.demTexture.bind(oe(Q),F.CLAMP_TO_EDGE),z.u_dem_lerp=ae):(W=this.terrainTileForTile[h.tileID.key],ve=this._prepareDemTileUniforms(h,W,z)?W.demTexture:this.emptyDEMTexture):ve=this.emptyDEMTexture,D.activeTexture.set(F.TEXTURE2),ve&&(z.u_dem_size=(ge=ve).size[0]===1?1:ge.size[0]-2,ve.bind(oe(W),F.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(A&&A.useDepthForOcclusion,y,z),A&&A.useMeterToDem&&W){const be=(1<{if(Ue===rs)return;const gs=[YC[rs],"PROJECTION_GLOBE_VIEW"];ut&&gs.push("CUSTOM_ANTIALIASING");const $s=ae.isTileAffectedByFog(ss);We=ae.getOrCreateProgram("globeRaster",{defines:gs,overrideFog:$s}),Ue=rs},Et=ae.colorModeForRenderPass(),jt=new Rr(Ee.LEQUAL,Rr.ReadWrite,ae.depthRangeFor3D);tg.update(be);const Tt=i.dF(st),_t=[i.aF(st.center.lng),i.aJ(st.center.lat)],gt=ae.globeSharedBuffers,Ot=[st.width*i.o.devicePixelRatio,st.height*i.o.devicePixelRatio],Wt=Float32Array.from(st.globeMatrix),Ht={useDenormalizedUpVectorScale:!0};{const ss=ae.transform,rs=XC(ss.zoom,oe.exaggeration(),oe.sourceCache._source.tileSize);Ue=-1;const gs=Ee.TRIANGLES;for(const $s of ge){const Xt=ve.getTile($s),Bt=xn.disabled,is=oe.prevTerrainTileForTile[$s.key],Jt=oe.terrainTileForTile[$s.key];r2(is,Jt)&&tg.newMorphing($s.key,is,Jt,be,250),ab(ae,Xt.emissiveTexture),Le.activeTexture.set(Ee.TEXTURE0),Xt.texture&&Xt.texture.bind(Ee.LINEAR,Ee.CLAMP_TO_EDGE);const Ps=tg.getMorphValuesForProxy($s.key),rr=Ps?1:0;Ps&&Object.assign(Ht,{morphing:{srcDemTile:Ps.from,dstDemTile:Ps.to,phase:i.dD(Ps.phase)}});const gr=i.dG($s.canonical),er=i.dH(gr.getCenter().lat),Vs=i.dI($s.canonical,gr,er,ss.worldSize/ss._pixelsPerMercatorPixel),Pr=i.bk(i.dJ($s.canonical)),Mr=ae.emissiveMode==="mrt-fallback"?1:0,ur=ZC(ss.expandedFarZProjMatrix,Wt,Tt,Pr,i.aj(ss.zoom),_t,ss.frustumCorners.TL,ss.frustumCorners.TR,ss.frustumCorners.BR,ss.frustumCorners.BL,ss.globeCenterInViewSpace,ss.globeRadius,Ot,rs,ss._farZ,Mr,Vs);if(it($s,rr),We&&(oe.setupElevationDraw(Xt,We,Ht),ae.uploadCommonUniforms(Le,We,$s.toUnwrapped()),gt)){const[br,Gr,Tn]=gt.getGridBuffers(er,rs!==0);We.draw(ae,gs,jt,Bt,Et,dn.backCCW,ur,"globe_raster",br,Gr,Tn)}}}if(gt&&(ae.renderDefaultNorthPole||ae.renderDefaultSouthPole)){const ss=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];ut&&ss.push("CUSTOM_ANTIALIASING"),We=ae.getOrCreateProgram("globeRaster",{defines:ss});for(const rs of ge){const{x:gs,y:$s,z:Xt}=rs.canonical,Bt=$s===0,is=$s===(1<br.draw(ae,Ee.TRIANGLES,jt,xn.disabled,Et,dn.disabled,ZC(st.expandedFarZProjMatrix,Vs,Vs,Pr,0,_t,st.frustumCorners.TL,st.frustumCorners.TR,st.frustumCorners.BR,st.frustumCorners.BL,st.globeCenterInViewSpace,st.globeRadius,Ot,0,st._farZ,Mr),"globe_pole_raster",Gr,rr,gr);oe.setupElevationDraw(er,We,Ht),ae.uploadCommonUniforms(Le,We,rs.toUnwrapped()),Bt&&ae.renderDefaultNorthPole&&ur(We,Jt),is&&ae.renderDefaultSouthPole&&(Vs=i.cS(i.bC(),Vs,[1,-1,1]),ur(We,Ps))}}}})(D,F,z,W,Q);else{const ae=D.context,oe=ae.gl;let ve,ge;const be=D.shadowRenderer,Le=_y(D,D.longestCutoffRange),Ee=Et=>{if(ge===Et)return;const jt=[];jt.push(YC[Et]),Le.shouldRenderCutoff&&jt.push("RENDER_CUTOFF"),be&&(jt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),be.useNormalOffset&&jt.push("NORMAL_OFFSET")),ve=D.getOrCreateProgram("terrainRaster",{defines:jt}),ge=Et},We=D.colorModeForRenderPass(),Ue=new Rr(oe.LEQUAL,Rr.ReadWrite,D.depthRangeFor3D);tg.update(Q);const st=D.transform,ut=XC(st.zoom,F.exaggeration(),F.sourceCache._source.tileSize);let it=[0,0,0];if(be){const Et=D.style.directionalLight,jt=D.style.ambientLight;Et&&jt&&(it=eg(D.style,Et,jt))}{ge=-1;const Et=oe.TRIANGLES,[jt,Tt]=[F.gridIndexBuffer,F.gridSegments];for(const _t of W){const gt=z.getTile(_t),Ot=xn.disabled,Wt=F.prevTerrainTileForTile[_t.key],Ht=F.terrainTileForTile[_t.key];r2(Wt,Ht)&&tg.newMorphing(_t.key,Wt,Ht,Q,250),ab(D,gt.emissiveTexture),ae.activeTexture.set(oe.TEXTURE0),gt.texture&>.texture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const ss=tg.getMorphValuesForProxy(_t.key),rs=ss?1:0;let gs;ss&&(gs={morphing:{srcDemTile:ss.from,dstDemTile:ss.to,phase:i.dD(ss.phase)}});const $s=D.emissiveMode==="mrt-fallback"?1:0,Xt=lm(_t.projMatrix,a6(_t.canonical,st.renderWorldCopies)?ut/10:ut,it,$s);if(Ee(rs),!ve)continue;F.setupElevationDraw(gt,ve,gs);const Bt=_t.toUnwrapped();be&&be.setupShadows(Bt,ve),D.uploadCommonUniforms(ae,ve,Bt,null,Le),ve.draw(D,Et,Ue,Ot,We,dn.backCCW,Xt,"terrain_raster",F.gridBuffer,jt,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(),W=y.style.order,Q=[];this._updateFBOs(y.emissiveMode==="mrt-fallback");let ae=0;for(const oe of F){const ve=D.getTileByID(oe.proxyTileKey),ge=D.proxyCachedFBO[oe.key]?D.proxyCachedFBO[oe.key][h]:void 0,be=ge!==void 0?D.renderCache[ge]:this.pool[ae++],Le=ge!==void 0;if(ve.texture=be.tex,ve.emissiveTexture=be.emissiveTex,Le&&!be.dirty){Q.push(ve.tileID);continue}A.bindFramebuffer.set(be.fb.framebuffer);const Ee=A.gl;let We;Ee.drawBuffers(y.emissiveMode==="mrt-fallback"?[Ee.COLOR_ATTACHMENT0,Ee.COLOR_ATTACHMENT1]:[Ee.COLOR_ATTACHMENT0]),this.renderedToTile=!1,be.dirty&&(A.clear({color:i.ao.transparent,stencil:0}),be.dirty=!1);for(let Ue=z.start;Ue<=z.end;++Ue){const st=y.style._mergedLayers[W[Ue]];if(st.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(st),it=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!it)continue;const Et=it;A.viewport.set([0,0,be.fb.width,be.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(be,it,st,ut),We=ut?ut.id:null),y.renderLayer(y,ut,st,Et)}if(Ee.drawBuffers([Ee.COLOR_ATTACHMENT0]),this._drapedRenderBatches.length===0)for(const Ue of this._pendingGroundEffectLayers){const st=y.style._mergedLayers[W[Ue]];if(st.isHidden(y.transform.zoom))continue;const ut=y.style.getLayerSourceCache(st),it=ut?this.proxyToSource[oe.key][ut.id]:[oe];if(!it)continue;const Et=it;A.viewport.set([0,0,be.fb.width,be.fb.height]),We!==(ut?ut.id:null)&&(this._setupStencil(be,it,st,ut),We=ut?ut.id:null),y.renderLayer(y,ut,st,Et)}this.renderedToTile?(be.dirty=!0,Q.push(ve.tileID)):Le||--ae,ae===5&&(ae=0,this.renderToBackBuffer(Q))}return this.renderToBackBuffer(Q),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,W=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 zR(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 W=new i.T(D,{width:z[0],height:z[1],data:null},F.R8);W.bind(F.LINEAR,F.CLAMP_TO_EDGE),h.emissiveTex=W,A.createColorAttachment(D,1),A.colorAttachment1.set(W.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 Df){h=!0;break}if(!h)return;const y={};for(let A=0;AQ>W.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 W=0;W=0;z--){const W=A[z];if(y.getTileByID(W.key),y.proxyCachedFBO[W.key]!==void 0){const Q=h[W.key],ae=this.proxyToSource[W.key];let oe=0;for(const ve in ae){const ge=ae[ve],be=Q[ve];if(!be||be.length!==ge.length||ge.some((Le,Ee)=>Le!==be[Ee]||D[ve]&&D[ve].hasOwnProperty(Le.key))){oe=-1;break}++oe}for(const ve in y.proxyCachedFBO[W.key])y.renderCache[y.proxyCachedFBO[W.key][ve]].dirty=oe<0||oe!==Object.values(Q).length}}const F=[...this._drapedRenderBatches];F.sort((z,W)=>W.end-W.start-(z.end-z.start));for(const z of F)for(const W of A){if(y.proxyCachedFBO[W.key])continue;let Q=y.renderCachePool.pop();Q===void 0&&y.renderCache.length<50&&(Q=y.renderCache.length,y.renderCache.push(this._createFBO())),Q!==void 0&&(y.proxyCachedFBO[W.key]={},y.proxyCachedFBO[W.key][z.start]=Q,y.renderCache[Q].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 W;if(A.isTileClipped())W=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);W=1,this._overlapStencilMode.test={func:z.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+W>255&&(F.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=W,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):xn.disabled}_renderTileClippingMasks(h,y){const A=this.painter,D=this.painter.context,F=D.gl;A._tileClippingMaskIDs={},D.setColorMode($n.disabled),D.setDepthMode(Rr.disabled);const z=A.getOrCreateProgram("clippingMask");for(const W of h){const Q=A._tileClippingMaskIDs[W.key]=--y;z.draw(A,F.TRIANGLES,Rr.disabled,new xn({func:F.ALWAYS,mask:0},Q,255,F.KEEP,F.KEEP,F.REPLACE),$n.disabled,dn.disabled,n2(W.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],W=i.da([],A.slice(0,3),z);i.aw(W,W);const Q=this.raycast(z,W,this._exaggeration);return Q!==null&&Q?(i.bH(z,z,W,Q),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 Q=0;Qoe.overscaledZ-ae.overscaledZ)}_setupProxiedCoordsForImageSource(h,y,A){if(!h.getSource().loaded())return;const D=this.proxiedCoords[h.id]=[],F=this.proxyCoords,z=h.getSource(),W=z.tileID;if(!W)return;const Q=new i.P(W.x,W.y)._div(1<(ve.min.x=Math.min(ve.min.x,ge.x-Q.x),ve.min.y=Math.min(ve.min.y,ge.y-Q.y),ve.max.x=Math.max(ve.max.x,ge.x-Q.x),ve.max.y=Math.max(ve.max.y,ge.y-Q.y),ve),{min:new i.P(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.P(-Number.MAX_VALUE,-Number.MAX_VALUE)}),oe=(ve,ge)=>{const be=ve.wrap+ve.canonical.x/(1<We+ae.max.x||Le+EeUe+ae.max.y};for(let ve=0;vez.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,W,Q;D=i.bC();const ae=y.tileID.wrap-h.wrap<0?(z=i.al>>F,W=z*((y.tileID.canonical.x<=ve){const ge=h.canonical.z-ve;y.getSource().reparseOverscaled?(W=Math.max(h.canonical.z+2,y.transform.tileZoom),z=new i.aQ(W,h.wrap,ve,h.canonical.x>>ge,h.canonical.y>>ge)):ge!==0&&(W=ve,z=new i.aQ(W,h.wrap,ve,h.canonical.x>>ge,h.canonical.y>>ge))}z.key!==h.key&&(ae.push(z.key),A=y.getTile(z))}const oe=ve=>{ae.forEach(ge=>{D[ge]=ve}),ae.length=0};for(W-=1;W>=Q&&(!A||!A.hasData());W--){A&&oe(A.tileID.key);const ve=z.calculateScaledKey(W);if(A=y.getTileByID(ve),A&&A.hasData())break;const ge=D[ve];if(ge===null)break;ge===void 0?ae.push(ve):A=y.getTileByID(ge)}return oe(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 ib(T,h,y){const A=function(W,Q,ae){const oe=i.bJ(Q,W),ve=i.bJ(ae,[.2126,.7152,.0722]),ge=(Le,Ee,We)=>(1-We)*Le+We*Ee,be=ge(1-.3*Math.min(ve,1),1,Math.min(oe+1,1));return ge(.92,1,Math.asin(i.aA(Q[2],-1,1))/Math.PI+.5)*be}(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 Ime=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Lme=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","building","buildingBloom","elevatedStructures","model","symbol"];class BR{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 W=h.gl;this.program=W.createProgram(),this.configuration=D,this.name=y,this.fixedDefines=[...z];const Q=`#version 300 es ${(D?D.defines():[]).concat(z.map(Ee=>`#define ${Ee}`)).join(` `)}`,ae=[Q,Nme];for(const Ee of A.fragmentIncludes)ae.push(ky[Ee]);ae.push(A.fragmentSource);const oe=ae.join(` `),ve=[Q,AR];for(const Ee of A.vertexIncludes)ve.push(ky[Ee]);this.forceManualRenderingForInstanceIDShaders=h.forceManualRenderingForInstanceIDShaders&&A.vertexSource.includes("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&ve.push("uniform int u_instanceID;"),ve.push(A.vertexSource);let ge=ve.join(` `);this.forceManualRenderingForInstanceIDShaders&&(ge=ge.replaceAll("gl_InstanceID","u_instanceID"));const be=W.createShader(W.FRAGMENT_SHADER);if(W.isContextLost())return void(this.failedToCreate=!0);W.shaderSource(be,oe),W.compileShader(be),W.attachShader(this.program,be);const Le=W.createShader(W.VERTEX_SHADER);W.isContextLost()?this.failedToCreate=!0:(W.shaderSource(Le,ge),W.compileShader(Le),W.attachShader(this.program,Le),this.attributes={},W.linkProgram(this.program),W.deleteShader(Le),W.deleteShader(be),this.fixedUniforms=F(h),this.fixedUniformsEntries=Object.entries(this.fixedUniforms),this.binderUniforms=D?D.getUniforms(h):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(Ee=>({u_instanceID:new i.ch(Ee)}))(h)),(z.includes("TERRAIN")||y.includes("symbol")||y.includes("circle"))&&(this.terrainUniforms=(Ee=>({u_dem:new i.ch(Ee),u_dem_prev:new i.ch(Ee),u_dem_tl:new i.ck(Ee),u_dem_scale:new i.cj(Ee),u_dem_tl_prev:new i.ck(Ee),u_dem_scale_prev:new i.cj(Ee),u_dem_size:new i.cj(Ee),u_dem_lerp:new i.cj(Ee),u_exaggeration:new i.cj(Ee),u_depth:new i.ch(Ee),u_depth_size_inv:new i.ck(Ee),u_depth_range_unpack:new i.ck(Ee),u_occluder_half_size:new i.cj(Ee),u_occlusion_depth_offset:new i.cj(Ee),u_meter_to_dem:new i.cj(Ee),u_label_plane_matrix_inv:new i.cl(Ee)}))(h)),z.includes("GLOBE")&&(this.globeUniforms=(Ee=>({u_tile_tl_up:new i.ci(Ee),u_tile_tr_up:new i.ci(Ee),u_tile_br_up:new i.ci(Ee),u_tile_bl_up:new i.ci(Ee),u_tile_up_scale:new i.cj(Ee)}))(h)),z.includes("FOG")&&(this.fogUniforms=(Ee=>({u_fog_matrix:new i.cl(Ee),u_fog_range:new i.ck(Ee),u_fog_color:new i.d3(Ee),u_fog_horizon_blend:new i.cj(Ee),u_fog_vertical_limit:new i.ck(Ee),u_fog_temporal_offset:new i.cj(Ee),u_frustum_tl:new i.ci(Ee),u_frustum_tr:new i.ci(Ee),u_frustum_br:new i.ci(Ee),u_frustum_bl:new i.ci(Ee),u_globe_pos:new i.ci(Ee),u_globe_radius:new i.cj(Ee),u_globe_transition:new i.cj(Ee),u_is_globe:new i.ch(Ee),u_viewport:new i.ck(Ee)}))(h)),z.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(Ee=>({u_cutoff_params:new i.d3(Ee)}))(h)),z.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(Ee=>({u_lighting_ambient_color:new i.ci(Ee),u_lighting_directional_dir:new i.ci(Ee),u_lighting_directional_color:new i.ci(Ee),u_ground_radiance:new i.ci(Ee)}))(h)),z.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(Ee=>({u_light_matrix_0:new i.cl(Ee),u_light_matrix_1:new i.cl(Ee),u_fade_range:new i.ck(Ee),u_shadow_normal_offset:new i.ci(Ee),u_shadow_intensity:new i.cj(Ee),u_shadow_texel_size:new i.cj(Ee),u_shadow_map_resolution:new i.cj(Ee),u_shadow_direction:new i.ci(Ee),u_shadow_bias:new i.ci(Ee),u_shadowmap_0:new i.ch(Ee),u_shadowmap_1:new i.ch(Ee)}))(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,W,Q,ae,oe){const ve=h.options.wireframe;if(ve.terrain===!1&&ve.layers2D===!1&&ve.layers3D===!1)return;const ge=h.context;if(!(!(!ve.terrain||this.name!=="terrainRaster"&&this.name!=="globeRaster")||!(!ve.layers2D||h._terrain&&h._terrain.renderingToTexture||!Ime.includes(this.name))||!(!ve.layers3D||!Lme.includes(this.name))))return;const be=ge.gl,Le=h.wireframeDebugCache.getLinesFromTrianglesBuffer(h.frameCounter,F,ge);if(!Le)return;const Ee=[...this.fixedDefines,"DEBUG_WIREFRAME"],We=h.getOrCreateProgram(this.name,{config:this.configuration,defines:Ee});ge.program.set(We.program);const Ue=(it,Et,jt)=>{if(Et[it]&&jt[it])for(const Tt in Et[it])jt[it][Tt]&&jt[it][Tt].set(jt.program,Tt,Et[it][Tt].current)};ae&&ae.setUniforms(We.program,ge,We.binderUniforms,W,{zoom:Q}),Ue("fixedUniforms",this,We),Ue("terrainUniforms",this,We),Ue("globeUniforms",this,We),Ue("fogUniforms",this,We),Ue("lightsUniforms",this,We),Ue("shadowUniforms",this,We),Le.bind(),ge.setColorMode(new $n([be.ONE,be.ONE_MINUS_SRC_ALPHA,be.ZERO,be.ONE],i.ao.transparent,[!0,!0,!0,!1])),ge.setDepthMode(new Rr(y.func===be.LESS?be.LEQUAL:y.func,Rr.ReadOnly,y.range)),ge.setStencilMode(xn.disabled);const st=3*z.primitiveLength*2,ut=3*z.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const it=oe||1;for(let Et=0;Et1?be.drawElementsInstanced(be.LINES,st,be.UNSIGNED_SHORT,ut,oe):be.drawElements(be.LINES,st,be.UNSIGNED_SHORT,ut);F.bind(),ge.program.set(this.program),ge.setDepthMode(y),ge.setStencilMode(A),ge.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,W,Q,ae,oe,ve,ge,be,Le,Ee,We){const Ue=h.context,st=Ue.gl;if(this.failedToCreate)return;Ue.program.set(this.program),Ue.setDepthMode(A),Ue.setStencilMode(D),Ue.setColorMode(F),Ue.setCullFace(z);for(const[_t,gt]of this.fixedUniformsEntries)gt.set(this.program,_t,W[_t]);Le&&Le.setUniforms(this.program,Ue,this.binderUniforms,ge,{zoom:be});const ut={[st.POINTS]:1,[st.LINES]:2,[st.TRIANGLES]:3,[st.LINE_STRIP]:1}[y];this.checkUniforms(Q,"RENDER_SHADOWS",this.shadowUniforms);const it=Ee||[],Et=Le?Le.getPaintVertexBuffers():[],jt=y===st.TRIANGLES&&oe,Tt=We&&We>0?1:void 0;for(const _t of ve.get()){const gt=_t.vaos||(_t.vaos={});if((gt[Q]||(gt[Q]=new kme)).bind(Ue,this,ae,Et,oe,_t.vertexOffset,it,Tt),this.forceManualRenderingForInstanceIDShaders){const Ot=We||1;for(let Wt=0;Wt1?st.drawElementsInstanced(y,_t.primitiveLength*ut,st.UNSIGNED_SHORT,_t.primitiveOffset*ut*2,We):oe?st.drawElements(y,_t.primitiveLength*ut,st.UNSIGNED_SHORT,_t.primitiveOffset*ut*2):st.drawArrays(y,_t.vertexOffset,_t.vertexLength);jt&&this._drawDebugWireframe(h,A,D,F,oe,_t,ge,be,Le,We)}}}function $R(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 JC={terrain:0,flat:1},Dme=i.bC(),e3=(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue)=>{const st=h.style.light,ut=st.properties.get("position"),it=[ut.x,ut.y,ut.z],Et=i.dO();st.properties.get("anchor")==="viewport"&&(i.dP(Et,-h.transform.angle),i.dQ(it,it,Et));const jt=st.properties.get("color").toPremultipliedRenderColor(null),Tt=h.transform,_t={u_matrix:T,u_lightpos:it,u_lightintensity:st.properties.get("intensity"),u_lightcolor:[jt.r,jt.g,jt.b],u_vertical_gradient:+y,u_opacity:A,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Dme,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:JC[ae],u_base_type:JC[oe],u_ao:D,u_edge_radius:F,u_width_scale:z,u_flood_light_color:Le,u_vertical_scale:Ee,u_flood_light_intensity:We,u_ground_shadow_factor:Ue};return Tt.projection.name==="globe"&&(_t.u_tile_id=[W.canonical.x,W.canonical.y,1<({u_matrix:T,u_edge_radius:h,u_width_scale:y,u_vertical_scale:A,u_height_type:JC[D],u_base_type:JC[F]}),qR=(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue)=>{const st=e3(T,h,y,A,D,F,z,W,ae,oe,ve,ge,be,Le,Ee,We,1,[0,0,0]),ut={u_height_factor:-Math.pow(2,W.overscaledZ)/Q.tileSize/8};return Object.assign(st,$R(h,Q,Ue),ut)},ob=(T,h,y,A,D,F,z,W,Q,ae,oe)=>({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:W,u_attenuation:Q,u_edge_radius:ae,u_fb:0,u_fb_size:oe,u_dynamic_offset:1}),d6=(T,h,y)=>({u_matrix:T,u_emissive_strength:h,u_ground_shadow_factor:y}),u6=(T,h,y,A,D,F=0)=>Object.assign(d6(T,h,D),$R(y,A,F)),UR=(T,h,y,A)=>({u_matrix:T,u_world:y,u_emissive_strength:h,u_ground_shadow_factor:A}),h6=(T,h,y,A,D,F,z=0)=>Object.assign(u6(T,h,y,A,F,z),{u_world:D}),Cy=(T,h)=>({u_matrix:T,u_ground_shadow_factor:h}),rv=(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}),t3=(T,h,y,A,D,F,z,W,Q)=>({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:W,u_flood_light_intensity:Q}),VR=T=>({u_matrix:T}),My=T=>({u_matrix:T}),m6=(T,h,y,A,D,F,z,W)=>{const Q=i.al/F.tileSize;return{u_matrix:T,u_inv_rot_matrix:h,u_camera_to_center_distance:y.getCameraToCenterDistance(W),u_extrude_scale:[y.pixelsToGLUnits[0]/Q,y.pixelsToGLUnits[1]/Q],u_zoom_transition:A,u_tile_id:z,u_merc_center:D}},i2=(T,h,y=1)=>({u_matrix:T,u_color:h,u_overlay:0,u_overlay_scale:y}),HR=i.bC(),WR=(T,h,y,A,D,F,z)=>{const W=T.transform,Q=W.projection.name==="globe",ae=Q?i.dR(W.zoom,h.canonical)*W._pixelsPerMercatorPixel:i.ay(y,1,F),oe={u_matrix:h.projMatrix,u_extrude_scale:ae,u_intensity:z,u_inv_rot_matrix:HR,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(Q){oe.u_inv_rot_matrix=A,oe.u_merc_center=D,oe.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:oe.mix,u_opacity:oe.opacity*ve.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:ve.paint.get("raster-brightness-min"),u_brightness_high:ve.paint.get("raster-brightness-max"),u_saturation_factor:i.dT(ve.paint.get("raster-saturation")),u_contrast_factor:i.dS(ve.paint.get("raster-contrast")),u_spin_weights:KR(ve.paint.get("raster-hue-rotate")),u_perspective_transform:ge,u_raster_elevation:be,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:Q,u_colorization_mix:s3(i.dU,Ee,Ue),u_colorization_offset:r3(i.dU,We,Ue),u_color_ramp:Le,u_texture_offset:[ut/(st+2*ut),st/(st+2*ut)],u_texture_res:[st+2*ut,st+2*ut],u_emissive_strength:it});function KR(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 qf=.05,Ome=(T,h,y,A,D,F,z,W,Q,ae,oe,ve)=>({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:oe.mix,u_opacity:oe.opacity,u_image0:0,u_image1:1,u_raster_elevation:ve,u_zoom_transition:z,u_merc_center:W,u_cutoff_params:Q}),Rme=(T,h,y,A,D,F,z,W,Q,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:W,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[qf,qf]}),ZR=(T,h,y,A,D,F,z,W,Q,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:W,u_data_scale:[255*Q[0],255*Q[1]],u_data_offset:ae,u_particle_pos_scale:1.1,u_particle_pos_offset:[qf,qf]}),YR=i.bC(),n3=(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue,st,ut,it,Et,jt,Tt)=>{const _t=D.transform,gt={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:_t.getCameraToCenterDistance(st),u_rotate_symbol:+y,u_aspect_ratio:_t.width/_t.height,u_fade_change:D.options.fadeDuration?D.symbolFadeChange:1,u_matrix:F,u_label_plane_matrix:z,u_coord_matrix:W,u_is_text:+ae,u_elevation_from_sea:Q?1:0,u_pitch_with_map:+A,u_texsize:oe,u_texsize_icon:ve,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:YR,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:YR,u_up_vector:[0,-1,0],u_color_adj_mat:Et,u_icon_transition:jt||0,u_gamma_scale:A?D.transform.getCameraToCenterDistance(st)*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:it,u_lutTexture:Vc.LUT};return st.name==="globe"&&(gt.u_tile_id=[be.canonical.x,be.canonical.y,1<({u_matrix:T,u_emissive_strength:h,u_opacity:y,u_color:A}),Ty=(T,h,y,A,D,F,z,W,Q)=>Object.assign(function(ae,oe,ve,ge,be,Le){const{width:Ee,height:We}=ge.imageManager.getPixelSize(oe),Ue=Math.pow(2,Le.tileID.overscaledZ),st=Le.tileSize*Math.pow(2,ge.transform.tileZoom)/Ue,ut=st*(Le.tileID.canonical.x+Le.tileID.wrap*Ue),it=st*Le.tileID.canonical.y;return{u_image:0,u_pattern_tl:ve.tl,u_pattern_br:ve.br,u_texsize:[Ee,We],u_pattern_size:ve.displaySize,u_pattern_units_to_pixels:be?[ge.transform.width,-1*ge.transform.height]:[1/i.ay(Le,1,ge.transform.tileZoom),1/i.ay(Le,1,ge.transform.tileZoom)],u_pixel_coord_upper:[ut>>16,it>>16],u_pixel_coord_lower:[65535&ut,65535&it]}}(0,F,z,A,W,Q),{u_matrix:T,u_emissive_strength:h,u_opacity:y}),lb=new Float32Array(i.bA([])),nv=(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be=[0,0,0],Le,Ee,We)=>{const Ue=D.style.light,st=Ue.properties.get("position"),ut=[-st.x,-st.y,st.z],it=i.dO();Ue.properties.get("anchor")==="viewport"&&(i.dP(it,-D.transform.angle),i.dQ(ut,ut,it));const Et=oe.alphaMode==="MASK",jt=Ue.properties.get("color").toNonPremultipliedRenderColor(null),Tt=ge.paint.get("model-ambient-occlusion-intensity"),_t=ge.paint.get("model-color").constantOr(i.ao.white).toNonPremultipliedRenderColor(null);return _t.a=ge.paint.get("model-color-mix-intensity").constantOr(0),We&&(_t.r=We[0],_t.g=We[1],_t.b=We[2],_t.a=We[3]),Ee&&(_t.r=Ee.color.r,_t.g=Ee.color.g,_t.b=Ee.color.b,_t.a=Ee.colorMix,ve=Ee.emissionStrength,F*=Ee.opacity),{u_matrix:T,u_lighting_matrix:h,u_normal_matrix:y,u_node_matrix:A||lb,u_lightpos:ut,u_lightintensity:Ue.properties.get("intensity"),u_lightcolor:[jt.r,jt.g,jt.b],u_camera_pos:be,u_opacity:F,u_baseTextureIsAlpha:0,u_alphaMask:+Et,u_alphaCutoff:oe.alphaCutoff,u_baseColorFactor:z.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:W.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:Q,u_roughnessFactor:ae,u_baseColorTexture:Vc.BaseColor,u_metallicRoughnessTexture:Vc.MetallicRoughness,u_normalTexture:Vc.Normal,u_occlusionTexture:Vc.Occlusion,u_emissionTexture:Vc.Emission,u_lutTexture:Vc.LUT,u_color_mix:_t.toArray01(),u_aoIntensity:Tt,u_emissive_strength:ve,u_occlusionTextureTransform:Le||[0,0,0,0]}},p6=(T,h=lb,y=lb)=>({u_matrix:T,u_instance:h,u_node_matrix:y}),a3={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 f6={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class XR{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 W=h.gl;this.buffer=W.createBuffer(),h.bindVertexBuffer.set(this.buffer),W.bufferData(W.ARRAY_BUFFER,y.arrayBuffer,this.dynamicDraw?W.DYNAMIC_DRAW:W.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 QR{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 KC(h,z,0)),D>1&&(this.colorAttachment1=new KC(h,z,1)),F&&(this.depthAttachmentType=F,this.depthAttachment=F==="renderbuffer"?new nb(h,z):new s2(h,z))}createColorAttachment(h,y){y===0?this.colorAttachment0=new KC(h,this.framebuffer,0):y===1&&(this.colorAttachment1=new KC(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 cb{constructor(h,y){this.gl=h,this.clearColor=new Tme(this),this.clearDepth=new ER(this),this.clearStencil=new XE(this),this.colorMask=new UC(this),this.depthMask=new QE(this),this.stencilMask=new sv(this),this.stencilFunc=new eb(this),this.stencilOp=new e2(this),this.stencilTest=new tb(this),this.depthRange=new PR(this),this.depthTest=new JE(this),this.depthFunc=new IR(this),this.blend=new sb(this),this.blendFunc=new VC(this),this.blendColor=new HC(this),this.blendEquation=new e6(this),this.cullFace=new WC(this),this.cullFaceSide=new t2(this),this.frontFace=new LR(this),this.program=new DR(this),this.activeTexture=new OR(this),this.viewport=new rb(this),this.bindFramebuffer=new RR(this),this.bindRenderbuffer=new Ame(this),this.bindTexture=new Eme(this),this.bindVertexBuffer=new Pme(this),this.bindElementBuffer=new t6(this),this.bindVertexArrayOES=new s6(this),this.pixelStoreUnpack=new r6(this),this.pixelStoreUnpackPremultiplyAlpha=new n6(this),this.pixelStoreUnpackFlipY=new FR(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 XR(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 QR(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,$n.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 av;function Sr(T,h,y,A,D,F,z){const W=T.context,Q=W.gl,ae=T.transform,oe=[i.aF(ae.center.lng),i.aJ(ae.center.lat)],ve=y.layout.get("symbol-placement"),ge=y.layout.get("text-variable-anchor"),be=y.layout.get("icon-rotation-alignment")==="map",Le=y.layout.get("text-rotation-alignment")==="map",Ee=ve!=="point",We=[];let Ue=0,st=0;for(let gt=0;gt0){const ur=i.bC(),br=er;i.cP(ur,Ht.placementInvProjMatrix,ae.glCoordMatrix),i.cP(ur,ur,Ht.placementViewportMatrix),We.push({circleArray:Pr,circleOffset:st,transform:br,invTransform:ur,projection:Ht.getProjection()}),Ue+=Pr.length/4,st=Ue}if(!Vs)continue;T.terrain&&T.terrain.setupElevationDraw(Wt,gr);const Mr=Ps?[Ot.canonical.x,Ot.canonical.y,1<=0&&(be[ut.associatedIconIndex]={x:Ht,y:ss,z:rs,angle:is})}else Rp(jt,ve)}if(ae){ge.clear();const st=T.icon.placedSymbolArray;for(let ut=0;ut{let Ra=[0,0,0];if(di){const Hn=T.style.directionalLight,Xi=T.style.ambientLight;Hn&&Xi&&(Ra=eg(T.style,Hn,Xi))}return Ra},Ka=di=>{gt.depthOcclusionForSymbolsAndCircles&&(y.hasOcclusionOpacityProperties||T.terrain)&&(di.push("DEPTH_D24"),di.push("DEPTH_OCCLUSION"))},jn=di=>{y.lut&&!jt&&(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+Vc.LUT),y.lut.texture&&y.lut.texture.bind(Tt.gl.LINEAR,Tt.gl.CLAMP_TO_EDGE),di.push("APPLY_LUT_ON_GPU"))},ci=()=>{const di=Ot&&y.layout.get("symbol-placement")!=="point",Ra=[];Ka(Ra),jn(Ra);const Hn=di||Tn,Xi=Vs.elevationType==="road",Vo=T.shadowRenderer,_o=Xi&&Ht&&!!Vo&&Vo.enabled,Di=Dr(_o),zu=Xi&&Ht&&!T.terrain?Xt:$s,Md=y.paint.get("icon-image-cross-fade");T.terrainRenderModeElevated()&&Ht&&Ra.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(Ra.push("PROJECTION_GLOBE_VIEW"),Hn&&Ra.push("PROJECTED_POS_ON_VIEWPORT")),Md>0&&Vs.hasAnySecondaryIcon&&Ra.push("ICON_TRANSITION"),!Vs.icon.zOffsetVertexBuffer||Xi&&T.terrain||Ra.push("Z_OFFSET"),Ue===0&&st===0&&ut===0&&it===1||Ra.push("COLOR_ADJUSTMENT"),Vs.sdfIcons&&Ra.push("RENDER_SDF"),_o&&Ra.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&Ht&&!T.terrain&&Vs.icon.orientationVertexBuffer&&Ra.push("ELEVATED_ROADS");const $l=Vs.icon.programConfigurations.get(y.id),Ud=T.getOrCreateProgram("symbol",{config:$l,defines:Ra}),Vd=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ad=Vs.iconSizeData,um=i.bK(ad,gt.zoom),np=Ht||!gt.isOrthographic,uh=Js(ur,er.tileID.canonical,Ht,Ot,gt,Vs.getProjection(),br),Po=fn(ur,er.tileID.canonical,Ht,Ot,gt,Vs.getProjection(),br),Qo=T.translatePosMatrix(Po,er,W,ae,!0),Oi=T.translatePosMatrix(ur,er,W,ae),ul=Hn?l2:uh,So=Ot&&!Ht&&!di;let wo=rr;!Jt&&!gt.mercatorFromTransition||Ot||(wo=sg(gt));const ap=Pr?wo:rr,_2=y.getColorAdjustmentMatrix(Ue,st,ut,it),Up=n3(ad.kind,um,So,Ht,T,Oi,ul,Qo,Et,!1,Vd,[0,0],0,gr,Mr,Bt,va,ap,Vs.getProjection(),Di,ei,_2,Md,null),w2=er.imageAtlasTexture?er.imageAtlasTexture:null,yb=y.layout.get("icon-size").constantOr(0)!==1||Vs.iconsNeedLinear,Gf=Vs.sdfIcons||T.options.rotating||T.options.zooming||yb||np?_t.LINEAR:_t.NEAREST,ug=Vs.sdfIcons&&y.paint.get("icon-halo-width").constantOr(1)!==0,vb=T.terrain&&Ht&&di?i.bl(i.bC(),uh):l2;if(di&&Vs.icon){const Dy=i.bV.getAtTileOffsetFunc(gr,gt.center.lat,gt.worldSize,Vs.getProjection()),hg=pn(ur,er.tileID.canonical,Ht,Ot,gt,Vs.getProjection(),br),Vp=y.layout.get("icon-size-scale-range"),mg=i.aA(T.scaleFactor,Vp[0],Vp[1]);Xx(Vs,ur,T,!1,hg,Po,Ht,Ee,Dy,gr,mg)}return{program:Ud,buffers:Vs.icon,uniformValues:Up,atlasTexture:w2,atlasTextureIcon:null,atlasInterpolation:Gf,atlasInterpolationIcon:null,isSDF:Vs.sdfIcons,hasHalo:ug,depthMode:zu,tile:er,renderWithShadows:_o,labelPlaneMatrixInv:vb}},ki=()=>{const di=Wt&&y.layout.get("symbol-placement")!=="point",Ra=[],Hn=di||is||Tn,Xi=Vs.elevationType==="road",Vo=T.shadowRenderer,_o=Xi&&ss&&!!Vo&&Vo.enabled,Di=Dr(_o),zu=Xi&&ss&&!T.terrain?Xt:$s;T.terrainRenderModeElevated()&&ss&&Ra.push("PITCH_WITH_MAP_TERRAIN"),Pr&&(Ra.push("PROJECTION_GLOBE_VIEW"),Hn&&Ra.push("PROJECTED_POS_ON_VIEWPORT")),!Vs.text.zOffsetVertexBuffer||Xi&&T.terrain||Ra.push("Z_OFFSET"),Vs.iconsInText&&Ra.push("RENDER_TEXT_AND_SYMBOL"),Ra.push("RENDER_SDF"),_o&&Ra.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Xi&&ss&&!T.terrain&&Vs.text.orientationVertexBuffer&&Ra.push("ELEVATED_ROADS"),Ka(Ra);const Md=Vs.text.programConfigurations.get(y.id),$l=T.getOrCreateProgram("symbol",{config:Md,defines:Ra});let Ud,Vd=[0,0],ad=null;const um=Vs.textSizeData;Vs.iconsInText&&(Vd=er.imageAtlasTexture?er.imageAtlasTexture.size:[0,0],ad=er.imageAtlasTexture?er.imageAtlasTexture:null,Ud=ss||!gt.isOrthographic||T.options.rotating||T.options.zooming||um.kind==="composite"||um.kind==="camera"?_t.LINEAR:_t.NEAREST);const np=er.glyphAtlasTexture?er.glyphAtlasTexture.size:[0,0],uh=y.layout.get("text-size-scale-range"),Po=i.aA(T.scaleFactor,uh[0],uh[1]),Qo=i.bK(um,gt.zoom,Po),Oi=Js(ur,er.tileID.canonical,ss,Wt,gt,Vs.getProjection(),br),ul=fn(ur,er.tileID.canonical,ss,Wt,gt,Vs.getProjection(),br),So=T.translatePosMatrix(ul,er,Q,oe,!0),wo=T.translatePosMatrix(ur,er,Q,oe),ap=Hn?l2:Oi,_2=Wt&&!ss&&!di;let Up=rr;!Jt&&!gt.mercatorFromTransition||Wt||(Up=sg(gt));const w2=n3(um.kind,Qo,_2,ss,T,wo,ap,So,Et,!0,np,Vd,0,gr,Mr,Bt,va,Pr?Up:rr,Vs.getProjection(),Di,ei,null,null,Po),yb=er.glyphAtlasTexture?er.glyphAtlasTexture:null,Gf=_t.LINEAR,ug=y.paint.get("text-halo-width").constantOr(1)!==0,vb=T.terrain&&ss&&di?i.bl(i.bC(),Oi):l2;if(di&&Vs.text){const Dy=i.bV.getAtTileOffsetFunc(gr,gt.center.lat,gt.worldSize,Vs.getProjection()),hg=pn(ur,er.tileID.canonical,ss,Wt,gt,Vs.getProjection(),br);Xx(Vs,ur,T,!0,hg,ul,ss,We,Dy,gr,Po)}return{program:$l,buffers:Vs.text,uniformValues:w2,atlasTexture:yb,atlasTextureIcon:ad,atlasInterpolation:Gf,atlasInterpolationIcon:Ud,isSDF:!0,hasHalo:ug,depthMode:zu,tile:er,renderWithShadows:_o,labelPlaneMatrixInv:vb}},vi=Vs.icon.segments.get().length,Ga=Vs.text.segments.get().length,Vn=vi&&!z.onlyText?ci():null,ni=Ga&&!z.onlyIcons?ki():null,ko=y.paint.get("icon-opacity").constantOr(1),ro=y.paint.get("text-opacity").constantOr(1);if(rs&&Vs.canOverlap){gs=!0;const di=ko&&!z.onlyText?Vs.icon.segments.get():[],Ra=ro&&!z.onlyIcons?Vs.text.segments.get():[];for(const Hn of di)Ps.push({segments:new i.bg([Hn]),sortKey:Hn.sortKey,state:Vn});for(const Hn of Ra)Ps.push({segments:new i.bg([Hn]),sortKey:Hn.sortKey,state:ni})}else z.onlyText||Ps.push({segments:ko?Vs.icon.segments:new i.bg([]),sortKey:0,state:Vn}),z.onlyIcons||Ps.push({segments:ro?Vs.text.segments:new i.bg([]),sortKey:0,state:ni})}gs&&Ps.sort((gr,er)=>gr.sortKey-er.sortKey);for(const gr of Ps){const er=gr.state;if(er)if(T.terrain?T.terrain.setupElevationDraw(er.tile,er.program,{useDepthForOcclusion:gt.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:er.labelPlaneMatrixInv}):T.setupDepthForOcclusion(gt.depthOcclusionForSymbolsAndCircles,er.program),Tt.activeTexture.set(_t.TEXTURE0),er.atlasTexture&&er.atlasTexture.bind(er.atlasInterpolation,_t.CLAMP_TO_EDGE,!0),er.atlasTextureIcon&&(Tt.activeTexture.set(_t.TEXTURE1),er.atlasTextureIcon&&er.atlasTextureIcon.bind(er.atlasInterpolationIcon,_t.CLAMP_TO_EDGE,!0)),er.renderWithShadows&&T.shadowRenderer.setupShadows(er.tile.tileID.toUnwrapped(),er.program,"vector-tile"),T.uploadCommonLightUniforms(T.context,er.program),er.hasHalo){const Vs=er.uniformValues;Vs.u_is_halo=1,x6(er.buffers,gr.segments,y,T,er.program,er.depthMode,D,F,Vs,2),Vs.u_is_halo=0}else{if(er.isSDF){const Vs=er.uniformValues;er.hasHalo&&(Vs.u_is_halo=1,x6(er.buffers,gr.segments,y,T,er.program,er.depthMode,D,F,Vs,1)),Vs.u_is_halo=0}x6(er.buffers,gr.segments,y,T,er.program,er.depthMode,D,F,er.uniformValues,1)}}}function x6(T,h,y,A,D,F,z,W,Q,ae){const oe=[T.dynamicLayoutVertexBuffer,T.opacityVertexBuffer,T.iconTransitioningVertexBuffer,T.globeExtVertexBuffer,T.zOffsetVertexBuffer,T.orientationVertexBuffer];D.draw(A,A.context.gl.TRIANGLES,F,z,W,dn.disabled,Q,y.id,T.layoutVertexBuffer,T.indexBuffer,h,y.paint,A.transform.zoom,T.programConfigurations.get(y.id),oe,ae)}function JR(T,h){const y=1<=zp?1:be.pitch/zp))),2*Le}(T.transform),ae=T.transform.getFreeCameraOptions().position,oe="elevatedStructuresDepthReconstruct",ve=T.getOrCreateProgram(oe,{defines:["DEPTH_RECONSTRUCTION"]}),ge=T.getOrCreateProgram(oe);for(const be of A){const Le=h.getTile(be),Ee=Le.getBucket(y);if(!Ee)continue;const We=Ee.elevatedStructures;if(!We)continue;const Ue=Ee.elevationBufferData.heightRange,st=JR(be.toUnwrapped(),ae),ut=T.translatePosMatrix(be.projMatrix,Le,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor"));let it,Et,jt,Tt;if(D==="initialize"){if(!Ue||Ue.min>=1||We.depthSegments.segments[0].primitiveLength===0)continue;it=rv(ut,st,Q,1,0),Et=z,jt=We.depthSegments,Tt=ve}else if(D==="reset"){if(!Ue||Ue.min>=0||We.maskSegments.segments[0].primitiveLength===0)continue;it=rv(ut,st,0,0,1),Et=W,jt=We.maskSegments,Tt=ve}else if(D==="geometry"){if(We.depthSegments.segments[0].primitiveLength===0)continue;it=rv(ut,st,Q,1,0),Et=z,jt=We.depthSegments,Tt=ge}Tt.draw(T,F.TRIANGLES,Et,xn.disabled,$n.disabled,dn.disabled,it,y.id,We.vertexBuffer,We.indexBuffer,jt,y.paint,T.transform.zoom)}}function o3(T,h,y,A){const{painter:D,sourceCache:F,layer:z,coords:W,colorMode:Q,elevationType:ae,terrainEnabled:oe,pass:ve}=T,ge=D.context.gl,be=z.paint.get("fill-pattern"),Le=z.paint.get("fill-pattern-cross-fade"),Ee=be.constantOr(null);let We=ae;ae!=="road"||h&&!oe||(We="none");const Ue=We==="road",st=T.painter.shadowRenderer,ut=Ue&&!!st&&st.enabled,it=new Rr(D.context.gl.LEQUAL,Rr.ReadOnly,D.depthRangeFor3D);let Et=[0,0,0];if(ut){const gt=D.style.directionalLight,Ot=D.style.ambientLight;gt&&Ot&&(Et=eg(D.style,gt,Ot))}const jt=be&&be.constantOr(1),Tt=D.terrain&&D.terrain.renderingToTexture,_t=(gt,Ot)=>{let Wt,Ht,ss,rs,gs;Ot?(Wt=jt&&!z.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",ss=ge.LINES):(Wt=jt?"fillPattern":"fill",ss=ge.TRIANGLES);for(const $s of W){const Xt=F.getTile($s);if(jt&&!Xt.patternsLoaded())continue;const Bt=Xt.getBucket(z);if(!Bt)continue;const is=h?Bt.elevationBufferData:Bt.bufferData;if(is.isEmpty())continue;D.prepareDrawTile();const Jt=is.programConfigurations.get(z.id),Ps=D.isTileAffectedByFog($s),rr=[],gr=[];Ue&&(rr.push("ELEVATED_ROADS"),gr.push(is.elevatedLayoutVertexBuffer)),ut&&rr.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),Tt&&y&&rr.push("USE_MRT1"),jt&&(D.context.activeTexture.set(ge.TEXTURE0),Xt.imageAtlasTexture&&Xt.imageAtlasTexture.bind(ge.LINEAR,ge.CLAMP_TO_EDGE),Jt.updatePaintBuffers());let er=!1;if(Ee&&Xt.imageAtlas){const br=Xt.imageAtlas,Gr=i.e3.from(Ee),Tn=Gr.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),va=Gr.getSecondary(),ei=br.patternPositions.get(Tn),Dr=va?br.patternPositions.get(va.scaleSelf(i.o.devicePixelRatio).toString()):null;er=!!ei&&!!Dr,ei&&Jt.setConstantPatternPositions(ei,Dr)}Le>0&&(er||Jt.getPatternTransitionVertexBuffer("fill-pattern"))&&rr.push("FILL_PATTERN_TRANSITION");const Vs=D.getOrCreateProgram(Wt,{config:Jt,overrideFog:Ps,defines:rr}),Pr=D.translatePosMatrix($s.projMatrix,Xt,z.paint.get("fill-translate"),z.paint.get("fill-translate-anchor"));ut&&st.setupShadows(Xt.tileID.toUnwrapped(),Vs,"vector-tile");const Mr=z.paint.get("fill-emissive-strength");if(Ot){rs=is.lineIndexBuffer,gs=is.lineSegments;const br=D.terrain&&D.terrain.renderingToTexture?D.terrain.drapeBufferSize:[ge.drawingBufferWidth,ge.drawingBufferHeight];Ht=Wt==="fillOutlinePattern"&&jt?h6(Pr,Mr,D,Xt,br,Et,Le):UR(Pr,Mr,br,Et)}else rs=is.indexBuffer,gs=is.triangleSegments,Ht=jt?u6(Pr,Mr,D,Xt,Et,Le):d6(Pr,Mr,Et);D.uploadCommonUniforms(D.context,Vs,$s.toUnwrapped());let ur=gt;(ae==="road"&&!oe||ae==="offset")&&(ur=it),Vs.draw(D,ss,ur,A||D.stencilModeForClipping($s),Q,dn.disabled,Ht,z.id,is.layoutVertexBuffer,rs,gs,z.paint,D.transform.zoom,Jt,gr)}};D.renderPass===ve&&_t(D.depthModeForSublayer(1,D.renderPass==="opaque"?Rr.ReadWrite:Rr.ReadOnly),!1),We==="none"&&D.renderPass==="translucent"&&z.paint.get("fill-antialias")&&_t(D.depthModeForSublayer(z.getPaintProperty("fill-outline-color")?2:0,Rr.ReadOnly),!0)}function l3(T,h,y,A,D,F,z,W){y.resetLayerRenderingStats(T);const Q=T.context,ae=Q.gl,oe=T.transform,ve=y.paint.get("fill-extrusion-pattern"),ge=y.paint.get("fill-extrusion-pattern-cross-fade"),be=ve.constantOr(null),Le=ve.constantOr(1),Ee=y.paint.get("fill-extrusion-opacity"),We=T.style.enable3dLights(),Ue=y.paint.get(We&&!Le?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),st=[y.paint.get("fill-extrusion-ambient-occlusion-intensity"),Ue],ut=y.layout.get("fill-extrusion-edge-radius"),it=ut>0&&!y.paint.get("fill-extrusion-rounded-roof"),Et=it?0:ut,jt=oe.projection.name==="globe"?i.eb():0,Tt=oe.projection.name==="globe",_t=Tt?i.aj(oe.zoom):0,gt=[i.aF(oe.center.lng),i.aJ(oe.center.lat)],Ot=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",Wt=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"),ss=y.paint.get("fill-extrusion-vertical-scale"),rs=y.paint.get("fill-extrusion-line-width").constantOr(1)!==0,gs=y.paint.get("fill-extrusion-height-alignment"),$s=y.paint.get("fill-extrusion-base-alignment"),Xt=_y(T,y.paint.get("fill-extrusion-cutoff-fade-range")),Bt=[];let is;Tt&&Bt.push("PROJECTION_GLOBE_VIEW"),st[0]>0&&Bt.push("FAUX_AO"),it&&Bt.push("ZERO_ROOF_RADIUS"),W&&Bt.push("HAS_CENTROID"),Ht>0&&Bt.push("FLOOD_LIGHT"),Xt.shouldRenderCutoff&&Bt.push("RENDER_CUTOFF"),rs&&Bt.push("RENDER_WALL_MODE");const Jt=T.renderPass==="shadow",Ps=T.shadowRenderer,rr=Jt&&!!Ps,gr=Jt?dn.disabled:dn.backCCW;T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0);let er=[0,0,0];if(Ps){const Mr=T.style.directionalLight,ur=T.style.ambientLight;Mr&&ur&&(er=eg(T.style,Mr,ur)),Jt||(Bt.push("RENDER_SHADOWS","DEPTH_TEXTURE"),Ps.useNormalOffset&&Bt.push("NORMAL_OFFSET")),is=Bt.concat(["SHADOWS_SINGLE_CASCADE"])}const Vs=rr?"fillExtrusionDepth":Le?"fillExtrusionPattern":"fillExtrusion",Pr=y.getLayerRenderingStats();for(const Mr of A){const ur=h.getTile(Mr),br=ur.getBucket(y);if(!br||br.projection.name!==oe.projection.name)continue;let Gr=!1;Ps&&(Gr=Ps.getMaxCascadeForTile(Mr.toUnwrapped())===0);const Tn=T.isTileAffectedByFog(Mr),va=br.programConfigurations.get(y.id);let ei=!1;if(be&&ur.imageAtlas){const Ga=ur.imageAtlas,Vn=i.e3.from(be),ni=Vn.getPrimary().scaleSelf(i.o.devicePixelRatio).toString(),ko=Vn.getSecondary(),ro=Ga.patternPositions.get(ni),di=ko?Ga.patternPositions.get(ko.scaleSelf(i.o.devicePixelRatio).toString()):null;ei=!!ro&&!!di,ro&&va.setConstantPatternPositions(ro,di)}ge>0&&(ei||va.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&Bt.push("FILL_EXTRUSION_PATTERN_TRANSITION");const Dr=T.getOrCreateProgram(Vs,{config:va,defines:Gr?is:Bt,overrideFog:Tn});if(T.terrain&&T.terrain.setupElevationDraw(ur,Dr,{useMeterToDem:!0}),!br.centroidVertexBuffer){const Ga=Dr.getAttributeLocation(ae,"a_centroid_pos");Ga!==-1&&ae.vertexAttrib2f(Ga,0,0)}!Jt&&Ps&&Ps.setupShadows(ur.tileID.toUnwrapped(),Dr,"vector-tile"),Le&&(T.context.activeTexture.set(ae.TEXTURE0),ur.imageAtlasTexture&&ur.imageAtlasTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),va.updatePaintBuffers());const Ka=y.paint.get("fill-extrusion-vertical-gradient"),jn=1/br.tileToMeter;let ci;if(Jt&&Ps){if(ng(ur.tileID,br.maxHeight,T))continue;const Ga=Ps.calculateShadowPassMatrixFromTile(ur.tileID.toUnwrapped());ci=c6(Ga,Et,jn,ss,gs,$s)}else{const Ga=T.translatePosMatrix(Mr.expandedProjMatrix,ur,y.paint.get("fill-extrusion-translate"),y.paint.get("fill-extrusion-translate-anchor")),Vn=oe.projection.createInversionMatrix(oe,Mr.canonical);ci=Le?qR(Ga,T,Ka,Ee,st,Et,jn,Mr,ur,jt,gs,$s,_t,gt,Vn,Wt,ss,ge):e3(Ga,T,Ka,Ee,st,Et,jn,Mr,jt,gs,$s,_t,gt,Vn,Wt,ss,Ht,er)}T.uploadCommonUniforms(Q,Dr,Mr.toUnwrapped(),null,Xt);let ki=br.segments;if(oe.projection.name==="mercator"&&!Jt&&(ki=br.getVisibleSegments(ur.tileID,T.terrain,T.transform.getFrustum(0)),!ki.get().length))continue;if(Pr)if(Jt)for(const Ga of ki.get())Pr.numRenderedVerticesInShadowPass+=Ga.primitiveLength;else for(const Ga of ki.get())Pr.numRenderedVerticesInTransparentPass+=Ga.primitiveLength;const vi=[];(T.terrain||W)&&vi.push(br.centroidVertexBuffer),Tt&&vi.push(br.layoutVertexExtBuffer),rs&&vi.push(br.wallVertexBuffer),Dr.draw(T,Q.gl.TRIANGLES,D,F,z,gr,ci,y.id,br.layoutVertexBuffer,br.indexBuffer,ki,y.paint,T.transform.zoom,va,vi)}T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!1)}class g6{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function rg(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge,be,Le,Ee,We,Ue,st,ut){const it=h.context,Et=it.gl,jt=h.transform,Tt=h.transform.zoom,_t=[],gt=T.translate,Ot=T.translateAnchor,Wt=T.edgeRadius,Ht=_y(h,T.cutoffFadeRange);oe==="clear"?(_t.push("CLEAR_SUBPASS"),ut&&(_t.push("CLEAR_FROM_TEXTURE"),it.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE))):oe==="sdf"?_t.push("SDF_SUBPASS"):oe==="emissive"&&(_t.push("USE_MRT1"),it.activeTexture.set(Et.TEXTURE0),ut.bind(Et.LINEAR,Et.CLAMP_TO_EDGE)),Ue&&_t.push("HAS_CENTROID"),Ht.shouldRenderCutoff&&_t.push("RENDER_CUTOFF");const ss=(rs,gs,$s,Xt,Bt)=>{let is=_t;gs.groundRadiusBuffer!=null&&(is=_t.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const Jt=gs.programConfigurations.get(A.id),Ps=h.isTileAffectedByFog(rs),rr=h.getOrCreateProgram("fillExtrusionGroundEffect",{config:Jt,defines:is,overrideFog:Ps}),gr=ob(h,Xt,ve,ae,Bt,[ge,be*Bt],Le,Ee,We,Tt>=17?0:Wt*Bt,ut?ut.size[0]:0),er=[];Ue&&er.push(gs.hiddenByLandmarkVertexBuffer),gs.groundRadiusBuffer!=null&&er.push(gs.groundRadiusBuffer),h.uploadCommonUniforms(it,rr,rs.toUnwrapped(),null,Ht),rr.draw(h,it.gl.TRIANGLES,F,z,W,Q,gr,A.id,gs.vertexBuffer,gs.indexBuffer,$s,A.paint,Tt,Jt,er)};for(const rs of D){const gs=y.getTile(rs),$s=gs.getBucket(A);if(!$s||$s.projection.name!==jt.projection.name||!$s.groundEffect||$s.groundEffect&&!$s.groundEffect.hasData())continue;const Xt=$s.groundEffect,Bt=1/$s.tileToMeter;{const is=h.translatePosMatrix(rs.projMatrix,gs,gt,Ot),Jt=Xt.getDefaultSegment();ss(rs,Xt,Jt,is,Bt)}if(st)for(let is=0;is<4;is++){const Jt=i.e9[is](rs),Ps=y.getTile(Jt);if(!Ps)continue;const rr=Ps.getBucket(A);if(!rr||rr.projection.name!==jt.projection.name||!rr.groundEffect||rr.groundEffect&&!rr.groundEffect.hasData())continue;const gr=rr.groundEffect;let er,Vs;is===0?(er=[-i.al,0,0],Vs=1):is===1?(er=[i.al,0,0],Vs=0):is===2?(er=[0,-i.al,0],Vs=3):(er=[0,i.al,0],Vs=2);const Pr=gr.regionSegments[Vs];if(!Pr)continue;const Mr=new Float32Array(16);i.br(Mr,rs.projMatrix,er),ss(rs,gr,Pr,h.translatePosMatrix(Mr,gs,gt,Ot),Bt)}}}function Fme(T,h,y,A,D,F,z){A.centroidVertexArray.length===0&&A.createCentroidsBuffer();const W=F?F.findDEMTileFor(y):null;if(!(W&&W.dem||z))return;F&&W&&W.dem&&A.selfDEMTileTimestamp!==W.dem._timestamp&&(A.borderDoneWithNeighborZ=[-1,-1,-1,-1],A.selfDEMTileTimestamp=W.dem._timestamp);const Q=Ue=>new i.P(Math.ceil((Ue+i.ed)*i.ee),0),ae=Ue=>{const st=h.getSource().minzoom,ut=Et=>{const jt=h.getTileByID(Et);if(jt&&jt.hasData())return jt.getBucket(D)},it=[0,-1,1];for(const Et of it){if(Ue.overscaledZ+Et(oe[0]=Math.min(Ue.min.y,st.min.y),oe[1]=Math.max(Ue.max.y,st.max.y),oe[2]=i.al-st.min.x>Ue.max.x?st.min.x-i.al:Ue.max.x,oe),ge=(Ue,st)=>(oe[0]=Math.min(Ue.min.x,st.min.x),oe[1]=Math.max(Ue.max.x,st.max.x),oe[2]=i.al-st.min.y>Ue.max.y?st.min.y-i.al:Ue.max.y,oe),be=[(Ue,st)=>ve(Ue,st),(Ue,st)=>ve(st,Ue),(Ue,st)=>ge(Ue,st),(Ue,st)=>ge(st,Ue)],Le=(Ue,st,ut,it,Et,jt,Tt)=>{if(!F)return 0;const _t=[[jt?ut:Ue,jt?Ue:ut,0],[jt?ut:st,jt?st:ut,0]],gt=Tt<0?i.al+Tt:Tt,Ot=[jt?gt:(Ue+st)/2,jt?(Ue+st)/2:gt,0];return ut===0&&Tt<0||ut!==0&&Tt>0?F.getForTilePoints(Et,[Ot],!0,it):_t.push(Ot),F.getForTilePoints(y,_t,!0,W),Math.max(_t[0][2],_t[1][2],Ot[2])/F.exaggeration()};for(let Ue=0;Ue<4;Ue++){const st=A.borderFeatureIndices[Ue];if(st.length===0)continue;const ut=i.e9[Ue](y),it=ae(ut);if(!(it&&it instanceof i.ea))continue;const Et=F?F.findDEMTileFor(ut):null;if(!(Et&&Et.dem||z)||(F&&Et&&Et.dem&&A.borderDEMTileTimestamp[Ue]!==Et.dem._timestamp&&(A.borderDoneWithNeighborZ[Ue]=-1,A.borderDEMTileTimestamp[Ue]=Et.dem._timestamp),A.borderDoneWithNeighborZ[Ue]===it.canonical.z))continue;it.centroidVertexArray.length===0&&it.createCentroidsBuffer();const jt=(Ue<2?1:5)-Ue,Tt=it.borderDoneWithNeighborZ[jt]!==A.canonical.z,_t=it.borderFeatureIndices[jt];let gt=0;if(A.canonical.z!==it.canonical.z){for(const Ot of st)A.showCentroid(A.featuresOnBorder[Ot]);if(Tt)for(const Ot of _t)it.showCentroid(it.featuresOnBorder[Ot]);A.borderDoneWithNeighborZ[Ue]=it.canonical.z,it.borderDoneWithNeighborZ[jt]=A.canonical.z}for(const Ot of st){const Wt=A.featuresOnBorder[Ot],Ht=A.centroidData[Wt.centroidDataIndex],ss=Wt.borders[Ue];let rs;for(;gt<_t.length;){rs=it.featuresOnBorder[_t[gt]];const gs=rs.borders[jt];if(gs[1]>ss[0]+3||gs[0]>ss[0]-3)break;it.showCentroid(rs),gt++}if(rs&><_t.length){const gs=gt;let $s=0;for(;!(rs.borders[jt][0]>ss[1]-3)&&($s++,++gt!==_t.length);)rs=it.featuresOnBorder[_t[gt]];rs=it.featuresOnBorder[_t[gs]];let Xt=!1;if($s>=1){const Jt=rs.borders[jt];Math.abs(ss[0]-Jt[0])<3&&Math.abs(ss[1]-Jt[1])<3&&($s=1,Xt=!0,gt=gs+1)}else if($s===0){A.showCentroid(Wt);continue}const Bt=it.centroidData[rs.centroidDataIndex];z&&Xt&&(((Ee=Ht).flags|(We=Bt).flags)&i.ec?(Ee.flags|=i.ec,We.flags|=i.ec):(Ee.flags&=~i.ec,We.flags&=~i.ec));const is=Wt.intersectsCount()>1||rs.intersectsCount()>1;if($s>1)gt=gs,Ht.centroidXY=Bt.centroidXY=new i.P(0,0);else if(Et&&Et.dem&&!is){const Jt=be[Ue](Ht,Bt),Ps=Ue%2?i.al-1:0,rr=Le(Jt[0],Math.min(i.al-1,Jt[1]),Ps,Et,ut,Ue<2,Jt[2]);Ht.centroidXY=Bt.centroidXY=Q(rr)}else is?Ht.centroidXY=Bt.centroidXY=new i.P(0,0):(Ht.centroidXY=A.encodeBorderCentroid(Wt),Bt.centroidXY=it.encodeBorderCentroid(rs));A.writeCentroidToBuffer(Ht),it.writeCentroidToBuffer(Bt)}else A.showCentroid(Wt)}A.borderDoneWithNeighborZ[Ue]=it.canonical.z,it.borderDoneWithNeighborZ[jt]=A.canonical.z}var Ee,We;(A.needsCentroidUpdate||!A.centroidVertexBuffer&&A.centroidVertexArray.length!==0)&&A.uploadCentroid(T)}const Lh=[1,0,0],y6=[0,1,0],Ru=[0,0,1];function ng(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 W=h;if(A.elevation){const Ee=A.elevation.getMinMaxForTile(T);Ee&&(W+=Ee.max)}const Q=[...D.shadowDirection];Q[2]=-Q[2];const ae=D.computeSimplifiedTileShadowVolume(F,W,z,Q);if(!ae)return!1;const oe=[Lh,y6,Ru,Q,[Q[0],0,Q[2]],[0,Q[1],Q[2]]],ve=A.projection.name==="globe",ge=A.scaleZoom(z),be=i.cB.fromInvProjectionMatrix(A.invProjMatrix,A.worldSize,ge,!ve),Le=D.getCurrentCascadeFrustum();return be.intersectsPrecise(ae.vertices,ae.planes,oe)===0||Le.intersectsPrecise(ae.vertices,ae.planes,oe)===0}function d2(T){const{painter:h,source:y,layer:A,coords:D}=T;let F=T.defines;const z=h.context,W=h.renderPass==="shadow",Q=h.renderPass==="light-beam",ae=h.shadowRenderer,oe=i.ef(h.transform.center.lat,h.transform.zoom),ve=_y(h,A.paint.get("building-cutoff-fade-range"));ve.shouldRenderCutoff&&(F=F.concat("RENDER_CUTOFF")),T.floodLightIntensity>0&&(F=F.concat("FLOOD_LIGHT"));for(const ge of D){const be=y.getTile(ge),Le=be.getBucket(A);if(!Le)continue;ae&&ae.getMaxCascadeForTile(ge.toUnwrapped())===0&&(F=F.concat("SHADOWS_SINGLE_CASCADE"));const Ee=Le.programConfigurations.get(A.id);let We,Ue,st,ut=h.translatePosMatrix(ge.expandedProjMatrix,be,[0,0],"map");if(ut=i.cS(i.bC(),ut,[1,1,T.verticalScale]),W&&ae){if(ng(be.tileID,Le.maxHeight*oe,h))continue;let Et=ae.calculateShadowPassMatrixFromTile(be.tileID.toUnwrapped());Et=i.cS(i.bC(),Et,[1,1,T.verticalScale]),st=My(Et),We=Ue=h.getOrCreateProgram("buildingDepth",{config:Ee,defines:F,overrideFog:!1})}else if(Q)We=Ue=h.getOrCreateProgram("buildingBloom",{config:Ee,defines:F,overrideFog:!1}),st=VR(ut);else{const Et=h.transform.calculatePosMatrix(ge.toUnwrapped(),h.transform.worldSize);i.cS(Et,Et,[1,1,T.verticalScale]);const jt=i.bC();i.cS(jt,Et,[1,-1,1/oe]),i.bl(jt,jt),i.eg(jt,jt);const Tt=h.transform.getFreeCameraOptions().position,_t=1<{if(Q){const Tt=Et.entranceBloom;jt.draw(h,z.gl.TRIANGLES,T.depthMode,xn.disabled,T.blendMode,dn.disabled,st,A.id,Tt.layoutVertexBuffer,Tt.indexBuffer,Tt.segmentsBucket,A.paint,h.transform.zoom,Ee,[Tt.layoutAttenuationBuffer,Tt.layoutColorBuffer])}else{const Tt=Et.segmentsBucket;let _t=[Et.layoutNormalBuffer,Et.layoutCentroidBuffer,Et.layoutColorBuffer,Et.layoutFloodLightDataBuffer];Et.layoutFacadePaintBuffer&&(_t=_t.concat([Et.layoutFacadeDataBuffer,Et.layoutFacadeVerticalRangeBuffer,Et.layoutFacadePaintBuffer])),jt.draw(h,z.gl.TRIANGLES,T.depthMode,xn.disabled,T.blendMode,W?dn.disabled:dn.backCW,st,A.id,Et.layoutVertexBuffer,Et.indexBuffer,Tt,A.paint,h.transform.zoom,Ee,_t)}};h.uploadCommonUniforms(z,Ue,ge.toUnwrapped(),null,ve),Le.buildingWithoutFacade&&it(Le.buildingWithoutFacade,Ue),Le.buildingWithFacade&&(We!==Ue&&h.uploadCommonUniforms(z,We,ge.toUnwrapped(),null,ve),it(Le.buildingWithFacade,We))}}function c3(T,h,y,A,D,F,z,W,Q,ae,oe,ve,ge){const be=T.context.gl,Le=T.depthModeForSublayer(1,Rr.ReadOnly,be.LEQUAL,!0),Ee=.1*(1-(We=oe))+3*We;var We;const Ue=T._showOverdrawInspector,st=ve,ut=new g6;Ue||rg(ut,T,h,y,A,Le,new xn({func:be.ALWAYS,mask:255},255,255,be.KEEP,be.KEEP,be.REPLACE),new $n([be.ONE,be.ONE,be.ONE,be.ONE],i.ao.transparent,[!1,!1,!1,!0],be.MIN),dn.disabled,D,"sdf",F,z,W,Q,ae,Ee,st,!1);{const it=Ue?xn.disabled:new xn({func:be.EQUAL,mask:255},255,255,be.KEEP,be.DECR,be.DECR),Et=Ue?T.colorModeForRenderPass():new $n([be.ONE_MINUS_DST_ALPHA,be.DST_ALPHA,be.ONE,be.ONE],i.ao.transparent,[!0,!0,!0,!0]);rg(ut,T,h,y,A,Le,it,Et,dn.disabled,D,"color",F,z,W,Q,ae,Ee,st,!1)}}function d3(T){return[T[0]*i.eh,T[1]*i.eh,T[2]*i.eh,0]}function u2(T,h,y,A,D,F,z,W,Q){const ae=A.getSource(),oe=y.globeSharedBuffers;if(!oe)return;let ve,ge,be;if(h&&(ve=A.getTile(h)),ae instanceof i.aU?(ge=ae.texture,be=i.dK(0,0,y.transform)):ve&&h&&(ge=ve.texture,be=i.dK(h.canonical.z,h.canonical.x,y.transform)),!ge||!be)return;T||(be=i.cS(i.bC(),be,[1,-1,1]));const Le=y.context,Ee=Le.gl,We=D.paint.get("raster-resampling")==="nearest"?Ee.NEAREST:Ee.LINEAR,Ue=y.colorModeForDrapableLayerRenderPass(F),st=z.defines;st.push("GLOBE_POLES");const ut=new Rr(Ee.LEQUAL,Rr.ReadWrite,y.depthRangeFor3D),it=Float32Array.from(y.transform.expandedFarZProjMatrix),Et=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0))));y.terrain&&y.terrain.prepareDrawTile(),Le.activeTexture.set(Ee.TEXTURE0),ge.bind(We,Ee.CLAMP_TO_EDGE),Le.activeTexture.set(Ee.TEXTURE1),ge.bind(We,Ee.CLAMP_TO_EDGE),"useMipmap"in ge&&Le.extTextureFilterAnisotropic&&y.transform.pitch>20&&Ee.texParameterf(Ee.TEXTURE_2D,Le.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Le.extTextureFilterAnisotropicMax);const[jt,Tt,_t,gt]=h?oe.getPoleBuffers(h.canonical.z,!1):oe.getPoleBuffers(0,!0),Ot=D.paint.get("raster-elevation");let Wt;T?(Wt=jt,y.renderDefaultNorthPole=Ot!==0):(Wt=Tt,y.renderDefaultSouthPole=Ot!==0);const Ht=d3(z.mix),ss=((gs,$s,Xt,Bt,is,Jt,Ps,rr,gr,er,Vs,Pr,Mr)=>GR(gs,$s,Xt,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,er,Vs,Pr,1,0,Mr))(it,Et,be,i.aj(y.transform.zoom),0,D,0,Ot,0,Ht,z.offset,z.range,F),rs=y.getOrCreateProgram("raster",{defines:st});y.uploadCommonUniforms(Le,rs,null),rs.draw(y,Ee.TRIANGLES,ut,Q,Ue,W,ss,D.id,Wt,_t,gt)}function eF(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 ag(T,h,y,A){if(T)return h instanceof kd&&T instanceof Cd?h.getTextureDescriptor(T,y,!0):{texture:T.texture,mix:d3(A.mix),offset:A.offset,buffer:0,tileSize:1}}var Ki=i.ei([{name:"a_index",type:"Int16",components:1}]);class u3{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,Q),ss=i.el(Ht);ge=i.aB(new Float32Array(16),Q.globeMatrix,ss),i.aB(ge,Q.projMatrix,ge)}const be=i.bC();be[12]+=2*D/(i.o.devicePixelRatio*Q.width),be[13]+=2*F/(i.o.devicePixelRatio*Q.height),i.aB(ge,be,ge);const Le=T.getOrCreateProgram("debug",{defines:ve}),Ee=h.getTileByID(y.key);T.terrain&&T.terrain.setupElevationDraw(Ee,Le);const We=Rr.disabled,Ue=xn.disabled,st=T.colorModeForRenderPass(),ut="$debug";W.activeTexture.set(ae.TEXTURE0),T.emptyTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),oe?Ee._makeGlobeTileDebugBuffers(T.context,Q):Ee._makeDebugTileBoundsBuffers(T.context,Q.projection);const it=Ee._tileDebugBuffer||T.debugBuffer,Et=Ee._tileDebugIndexBuffer||T.debugIndexBuffer,jt=Ee._tileDebugSegments||T.debugSegments;if(Le.draw(T,ae.LINE_STRIP,We,Ue,st,dn.disabled,i2(ge,A.toPremultipliedRenderColor(null)),ut,it,Et,jt,null,null,null,[Ee._globeTileDebugBorderBuffer]),z){const Ht=Ee.latestRawTileData,ss=Math.floor((Ht&&Ht.byteLength||0)/1024);let rs=y.canonical.toString();y.overscaledZ!==y.canonical.z&&(rs+=` => ${y.overscaledZ}`),rs+=` ${Ee.state}`,rs+=` ${ss}kb`,function(gs,$s){gs.initDebugOverlayCanvas();const Xt=gs.debugOverlayCanvas,Bt=gs.context.gl,is=gs.debugOverlayCanvas.getContext("2d");is.clearRect(0,0,Xt.width,Xt.height),is.shadowColor="white",is.shadowBlur=2,is.lineWidth=1.5,is.strokeStyle="white",is.textBaseline="top",is.font="bold 36px Open Sans, sans-serif",is.fillText($s,5,5),is.strokeText($s,5,5),gs.debugOverlayTexture.update(Xt),gs.debugOverlayTexture.bind(Bt.LINEAR,Bt.CLAMP_TO_EDGE)}(T,rs)}const Tt=h.getTile(y).tileSize,_t=512/Math.min(Tt,512)*(y.overscaledZ/Q.zoom)*.5,gt=Ee._tileDebugTextBuffer||T.debugBuffer,Ot=Ee._tileDebugTextIndexBuffer||T.quadTriangleIndexBuffer,Wt=Ee._tileDebugTextSegments||T.debugSegments;Le.draw(T,ae.TRIANGLES,We,Ue,$n.alphaBlended,dn.disabled,i2(ge,i.ao.transparent.toPremultipliedRenderColor(null),_t),ut,gt,Ot,Wt,null,null,null,[Ee._globeTileDebugTextBuffer])}function lv(T,h,y,A){Kt(T,0,h+y/2,T.transform.width,y,A)}function Eo(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,W=z.gl;W.enable(W.SCISSOR_TEST),W.scissor(h*i.o.devicePixelRatio,y*i.o.devicePixelRatio,A*i.o.devicePixelRatio,D*i.o.devicePixelRatio),z.clear({color:F}),W.disable(W.SCISSOR_TEST)}const aF=i.ei([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:h3}=aF;function Uf(T,h,y,A){T.emplaceBack(h,y,A)}class m3{constructor(h){this.vertexArray=new i.em,this.indices=new i.b0,Uf(this.vertexArray,-1,-1,1),Uf(this.vertexArray,1,-1,1),Uf(this.vertexArray,-1,1,1),Uf(this.vertexArray,1,1,1),Uf(this.vertexArray,-1,-1,-1),Uf(this.vertexArray,1,-1,-1),Uf(this.vertexArray,-1,1,-1),Uf(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,h3),this.indexBuffer=h.createIndexBuffer(this.indices),this.segment=i.bg.simpleSegment(0,0,36,12)}}function cv(T,h,y,A,D,F){const z=T.context.gl,W=h.paint.get("sky-atmosphere-color"),Q=h.paint.get("sky-atmosphere-halo-color"),ae=h.paint.get("sky-atmosphere-sun-intensity"),oe=((ve,ge,be,Le,Ee)=>({u_matrix_3f:ve,u_sun_direction:ge,u_sun_intensity:be,u_color_tint_r:[Le.r,Le.g,Le.b,Le.a],u_color_tint_m:[Ee.r,Ee.g,Ee.b,Ee.a],u_luminance:5e-5}))(i.eo(i.dO(),A),D,ae,W.toPremultipliedRenderColor(null),Q.toPremultipliedRenderColor(null));z.framebufferTexture2D(z.FRAMEBUFFER,z.COLOR_ATTACHMENT0,z.TEXTURE_CUBE_MAP_POSITIVE_X+F,h.skyboxTexture,0),y.draw(T,z.TRIANGLES,Rr.disabled,xn.disabled,$n.unblended,dn.frontCW,oe,"skyboxCapture",h.skyboxGeometry.vertexBuffer,h.skyboxGeometry.indexBuffer,h.skyboxGeometry.segment)}const iF=i.ei([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class db{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,iF.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 zme=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 Bme{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class oF{constructor(h){this.colorModeAlphaBlendedWriteRGB=new $n([1,zf,1,zf],i.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new $n([1,0,1,0],i.ao.transparent,[!1,!1,!1,!0]),this.params=new Bme,this.updateNeeded=!0}update(h){const y=h.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new db(y);const A=this.params.sizeRange,D=this.params.intensityRange,F=function(oe){const ve=i.eq(30),ge=[];for(let be=0;be{const _t=F.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];Tt&&_t.push("ALPHA_PASS");const gt=h.getOrCreateProgram("globeAtmosphere",{defines:_t}),Ot=((Ht,ss,rs,gs,$s,Xt,Bt,is,Jt,Ps,rr,gr)=>({u_frustum_tl:Ht,u_frustum_tr:ss,u_frustum_br:rs,u_frustum_bl:gs,u_horizon:$s,u_transition:Xt,u_fadeout_range:Bt,u_atmosphere_fog_color:is.toArray01(),u_high_color:Jt.toArray01(),u_space_color:Ps.toArray01(),u_temporal_offset:rr,u_horizon_angle:gr}))(F.frustumCorners.TL,F.frustumCorners.TR,F.frustumCorners.BR,F.frustumCorners.BL,F.frustumCorners.horizon,W,We,oe,ge,Le,st,Et);h.uploadCommonUniforms(A,gt);const Wt=this.atmosphereBuffer;Wt&>.draw(h,D.TRIANGLES,z,xn.disabled,Tt?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,dn.backCW,Ot,Tt?"atmosphere_glow_alpha":"atmosphere_glow",Wt.vertexBuffer,Wt.indexBuffer,Wt.segments)};jt(!1),jt(!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,W=h.getOrCreateProgram("stars"),Q=i.c7([]);i.c9(Q,Q,-z._pitch),i.c8(Q,Q,-z.angle),i.c9(Q,Q,i.an(z._center.lat)),i.et(Q,Q,-i.an(z._center.lng));const ae=i.cc(new Float32Array(16),Q),oe=i.aB([],z.starsProjMatrix,ae),ve=i.eo([],ae),ge=i.eu([],ve),be=[0,1,0];i.dQ(be,be,ge),i.c5(be,be,this.params.sizeMultiplier);const Le=[1,0,0];i.dQ(Le,Le,ge),i.c5(Le,Le,this.params.sizeMultiplier);const Ee=(We=be,Ue=Le,st=A,{u_matrix:Float32Array.from(oe),u_up:We,u_right:Ue,u_intensity_multiplier:st});var We,Ue,st;h.uploadCommonUniforms(D,W),this.starsVx&&this.starsIdx&&W.draw(h,F.TRIANGLES,Rr.disabled,xn.disabled,this.colorModeAlphaBlendedWriteRGB,dn.disabled,Ee,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class p3{constructor(){this.visibleTiles=[]}updateBorders(h,y){const A=[],D=[],F=h._getRenderableCoordinates(!1,!0);for(const Q of F){const ae=h.getTile(Q);if(!ae.hasData())continue;const oe=ae.getBucket(y);oe&&(oe.isEmpty()||(A.push(Q.key),D.push({bucket:oe,tileID:Q.canonical})))}let z=A.length!==this.visibleTiles.length;if(!z){A.sort();for(let Q=0;QQ.tileID.z-ae.tileID.z||Q.tileID.x-ae.tileID.x||Q.tileID.y-ae.tileID.y);for(const Q of D){const ae=new Array,oe=new Array,ve=Q.bucket;for(const ge of ve.featuresOnBorder)W.has(ge.featureId)?oe.push(ge.footprintIndex):(W.add(ge.featureId),ae.push(ge.footprintIndex));ve.updateFootprintHiddenFlags(ae,i.ev,!1),ve.updateFootprintHiddenFlags(oe,i.ev,!0)}}}function f3(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 x3(T,h,y,A,D){const F=y.material,z=A.context,{baseColorTexture:W,metallicRoughnessTexture:Q}=F.pbrMetallicRoughness,{normalTexture:ae,occlusionTexture:oe,emissionTexture:ve}=F;function ge(Le,Ee,We){if(Le&&(T.push(Ee),z.activeTexture.set(z.gl.TEXTURE0+We),Le.gfxTexture)){const{minFilter:Ue,magFilter:st,wrapS:ut,wrapT:it}=Le.sampler;Le.gfxTexture.bindExtraParam(Ue,st,ut,it)}}ge(W,"HAS_TEXTURE_u_baseColorTexture",Vc.BaseColor),ge(Q,"HAS_TEXTURE_u_metallicRoughnessTexture",Vc.MetallicRoughness),ge(ae,"HAS_TEXTURE_u_normalTexture",Vc.Normal),ge(oe,"HAS_TEXTURE_u_occlusionTexture",Vc.Occlusion),ge(ve,"HAS_TEXTURE_u_emissionTexture",Vc.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+Vc.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 be=A.shadowRenderer;be&&(T.push("RENDER_SHADOWS","DEPTH_TEXTURE"),be.useNormalOffset&&T.push("NORMAL_OFFSET"))}function g3(T,h,y,A,D,F){const z=T.modelOpacity,W=h.context,Q=new Rr(h.context.gl.LEQUAL,T.isLightMesh?Rr.ReadOnly:Rr.ReadWrite,h.depthRangeFor3D),ae=h.transform,oe=T.mesh,ve=oe.material,ge=ve.pbrMetallicRoughness,be=h.style.fog;let Le;Le=h.transform.projection.zAxisUnit==="pixels"?[...T.nodeModelMatrix]:i.aB([],A.zScaleMatrix,T.nodeModelMatrix),i.aB(Le,A.negCameraPosMatrix,Le);const Ee=i.bl([],Le);i.eg(Ee,Ee);const We=y.paint.get("model-color-use-theme").constantOr("default")==="none",Ue=y.paint.get("model-emissive-strength").constantOr(0),st=nv(new Float32Array(T.worldViewProjection),new Float32Array(Le),new Float32Array(Ee),null,h,z,ge.baseColorFactor,ve.emissiveFactor,ge.metallicFactor,ge.roughnessFactor,ve,Ue,y,void 0,void 0,T.materialOverride,T.modelColor),ut={defines:[]},it=[],Et=h.shadowRenderer;Et&&(Et.useNormalOffset=!1),x3(ut.defines,it,oe,h,We?null:y.lut);let jt=null;if(be){const gt=f3(T.nodeModelMatrix,h.transform);if(jt=new Float32Array(gt),ae.projection.name!=="globe"){const Ot=oe.aabb.min,Wt=oe.aabb.max,[Ht,ss]=be.getOpacityForBounds(gt,Ot[0],Ot[1],Wt[0],Wt[1]);ut.overrideFog=Ht>=ys||ss>=ys}}const Tt=_y(h,y.paint.get("model-cutoff-fade-range"));Tt.shouldRenderCutoff&&ut.defines.push("RENDER_CUTOFF");const _t=h.getOrCreateProgram("model",ut);h.uploadCommonUniforms(W,_t,null,jt,Tt),h.renderPass!=="shadow"&&Et&&Et.setupShadowsFromMatrix(T.nodeModelMatrix,_t),_t.draw(h,W.gl.TRIANGLES,Q,D,F,oe.material.doubleSided?dn.disabled:dn.backCCW,st,y.id,oe.vertexBuffer,oe.indexBuffer,oe.segments,y.paint,h.transform.zoom,void 0,it)}function h2(T,h){return T.style._importedAsBasemap?"basemap":h.scope}function dv(T,h,y,A,D,F,z,W,Q,ae){const oe=T.transform,ve=!!h.isGeometryBloom&&h.isGeometryBloom;if(ve&&T.renderPass==="shadow")return;const ge=oe.projection.name==="globe"?i.eD(y,oe):[...y];i.aB(ge,ge,h.globalMatrix);const be=i.aB([],A,ge);if(h.meshes)for(const Le of h.meshes){const Ee=W.get(Le.material.name);if(Ee&&Ee.opacity<=0)continue;if(Le.material.alphaMode!=="BLEND"){z.push({mesh:Le,depth:0,modelIndex:D,worldViewProjection:be,nodeModelMatrix:ge,isLightMesh:ve,materialOverride:Ee,modelOpacity:Q,modelColor:ae});continue}const We=i.af([],Le.centroid,be);!oe.isOrthographic&&We[2]<=0||F.push({mesh:Le,depth:We[2],modelIndex:D,worldViewProjection:be,nodeModelMatrix:ge,isLightMesh:ve,materialOverride:Ee,modelOpacity:Q,modelColor:ae})}if(h.children)for(const Le of h.children)dv(T,Le,y,A,D,F,z,W,Q,ae)}function $p(T,h,y,A){const D=y.shadowRenderer;if(!D)return;const F=D.getShadowPassDepthMode(),z=D.getShadowPassColorMode(),W=D.calculateShadowPassMatrixFromMatrix(h),Q=p6(W);y.getOrCreateProgram("modelDepth",{defines:y._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(y,y.context.gl.TRIANGLES,F,xn.disabled,z,dn.disabled,Q,A.id,T.vertexBuffer,T.indexBuffer,T.segments,A.paint,y.transform.zoom,void 0,void 0)}function lF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const Q={type:"Unknown",id:h,properties:W},ae={orientation:T.paint.get("model-rotation").evaluate(Q,y)};F.set(z,ae)}}function cF(T,h,y,A,D,F){for(const z of D){const W=Object.assign({},A);W.part=z;const Q={type:"Unknown",id:h,properties:W},ae={color:T.paint.get("model-color").evaluate(Q,y),colorMix:T.paint.get("model-color-mix-intensity").evaluate(Q,y),opacity:T.paint.get("model-opacity").evaluate(Q,y),emissionStrength:T.paint.get("model-emissive-strength").evaluate(Q,y)};F.set(z,ae)}}function dF(T,h,y,A,D){let F=!1;for(const W of A)W.modelOpacity!==1&&(g3(W,T,h,D[W.modelIndex],xn.disabled,$n.disabled),F=!0);for(const W of A)g3(W,T,h,D[W.modelIndex],W.modelOpacity!==1?T.stencilModeFor3D():xn.disabled,T.colorModeForRenderPass());F&&T.resetStencilClippingMasks();const z=$n.additive;for(const W of y)g3(W,T,h,D[W.modelIndex],xn.disabled,W.isLightMesh?z:T.colorModeForRenderPass())}function uF(T,h,y){const A=h.updateZoomBasedPaintProperties(),D=function(F,z,W){let Q,ae,oe,ve=F.terrain?F.terrain.exaggeration():0;if(F.terrain&&ve>0){const ge=F.terrain,be=ge.findDEMTileFor(W);be&&be.dem?Q=i.eF.create(ge,W,be):ve=0}if(ve===0&&(z.terrainElevationMin=0,z.terrainElevationMax=0),ve===z.validForExaggeration&&(ve===0||Q&&Q._demTile&&Q._demTile.tileID===z.validForDEMTile.id&&Q._dem._timestamp===z.validForDEMTile.timestamp))return!1;for(const ge in z.instancesPerModel){const be=z.instancesPerModel[ge];for(let Le=0;Leae&&(ae=be.max)}const oe=i.aA(A.x,F,z)-A.x,ve=i.aA(A.y,W,Q)-A.y,ge=i.cf(ae,h.center.lat)-A.z;return h._zoomFromMercatorZ(Math.sqrt(oe*oe+ve*ve+ge*ge))}function hF(T,h,y,A,D,F,z){const W=T.context,Q=T.renderPass==="shadow",ae=T.shadowRenderer,oe=Q&&ae?ae.getShadowPassDepthMode():new Rr(W.gl.LEQUAL,Rr.ReadWrite,T.depthRangeFor3D),ve=T.isTileAffectedByFog(F),ge=T.transform.projection.name==="globe";if(y.meshes)for(const be of y.meshes){const Le=ge?[]:["MODEL_POSITION_ON_GPU"],Ee=[];let We,Ue,st;const ut=!ge&&A.instancedDataArray.length>20;ut&&Le.push("INSTANCED_ARRAYS");const it=_y(T,h.paint.get("model-cutoff-fade-range"));if(it.shouldRenderCutoff&&Le.push("RENDER_CUTOFF"),Q&&ae)We=T.getOrCreateProgram("modelDepth",{defines:Le}),Ue=p6(z.shadowTileMatrix,z.shadowTileMatrix,Float32Array.from(y.globalMatrix)),st=ae.getShadowPassColorMode();else{x3(Le,Ee,be,T,h.paint.get("model-color-use-theme").constantOr("default")==="none"?null:h.lut),We=T.getOrCreateProgram("model",{defines:Le,overrideFog:ve});const jt=be.material,Tt=jt.pbrMetallicRoughness,_t=h.paint.get("model-opacity").constantOr(1),gt=h.paint.get("model-emissive-strength").constantOr(0);Ue=nv(F.expandedProjMatrix,Float32Array.from(y.globalMatrix),new Float32Array(16),null,T,_t,Tt.baseColorFactor,jt.emissiveFactor,Tt.metallicFactor,Tt.roughnessFactor,jt,gt,h,D),ae&&(z.shadowUniformsInitialized?We.setShadowUniformValues(W,ae.getShadowUniformValues()):(ae.setupShadows(F.toUnwrapped(),We,"model-tile"),z.shadowUniformsInitialized=!0)),st=it.shouldRenderCutoff||_t<1||jt.alphaMode!=="OPAQUE"?$n.alphaBlended:$n.unblended}T.uploadCommonUniforms(W,We,F.toUnwrapped(),null,it);const Et=be.material.doubleSided?dn.disabled:dn.backCCW;if(ut)Ee.push(A.instancedDataBuffer),We.draw(T,W.gl.TRIANGLES,oe,xn.disabled,st,Et,Ue,h.id,be.vertexBuffer,be.indexBuffer,be.segments,h.paint,T.transform.zoom,void 0,Ee,A.instancedDataArray.length);else{const jt=Q?"u_instance":"u_normal_matrix";for(let Tt=0;TtQ[1]?z:Q,F[0]=y.max[0],z=i.aC(i.eG(),F,D),W=z[1]Q[1]?z:Q,F[1]=y.min[1],z=i.aC(i.eG(),F,D),W=z[1]Q[1]?z:Q;const ae=i.aA(A[0],0,1),oe=100*h.pixelsPerMeter*i.aA(A[1],0,1),ve=i.aA(A[2],0,1),ge=i.eH(i.eG(),W,Q,ae),be=Math.tan(.5*h.fovX),Le=-ge[2]*be;if(oe===0)return ge[1]<-Math.abs(Le)?ve:1;const Ee=(-Math.abs(Le)-ge[1])/oe,We=(st,ut,it)=>(1-it)*st+it*ut,Ue=i.aA(We(1,ve,Ee),ve,1);return We(1,Ue,i.aA((h.pitch-20)/20,0,1))}class mF{}class Ey{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(h,y,A){{const ve=this._storage.get(y.id);if(ve)return ve.lastUsedFrameIdx=h,ve.buf}const D=A.gl,F=D.getBufferParameter(D.ELEMENT_ARRAY_BUFFER,D.BUFFER_SIZE),z=new ArrayBuffer(F),W=new Int16Array(z);D.getBufferSubData(D.ELEMENT_ARRAY_BUFFER,0,new Int16Array(z));const Q=new i.eJ;for(let ve=0;ve30&&(A.buf.destroy(),this._storage.delete(y))}destroy(){for(const[h,y]of this._storage)y.buf.destroy(),this._storage.delete(h)}}class ub{constructor(){this.occluderSize=30,this.depthOffset=-1e-4}}const hb=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 ig{constructor(h){this.revealStart=11,this.revealRange=2}}const b6=i.ei([{type:"Float32",name:"a_pos_2f",components:2}]);class _6{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,W=new i.b0;z.emplaceBack(-1,-1),z.emplaceBack(1,-1),z.emplaceBack(1,1),z.emplaceBack(-1,1),W.emplaceBack(0,1,2),W.emplaceBack(0,2,3),this.vignetteVx=h.context.createVertexBuffer(z,b6.members),this.vignetteIdx=h.context.createIndexBuffer(W)}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,Rr.disabled,xn.disabled,$n.alphaBlended,dn.disabled,z,"vignette",this.vignetteVx,this.vignetteIdx,D)}var F}}class w6{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),W=i.an(F.lat),Q=h.pixelsPerMeter/y,ae=z*i.eM,oe=i.eM*Math.log(Math.tan(Math.PI/4+W/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 ve=-this._offsetYPrev+oe,ge=-this._elevationPrev+D;this._accumulatedOffsetX+=(-this._offsetXPrev+ae)*Q,this._accumulatedOffsetY+=ve*Q,this._accumulatedElevation+=ge*Q,this._offsetXPrev=ae,this._offsetYPrev=oe,this._elevationPrev=D}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function y3(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 cm(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=cm(this.particlesCount),D=new i.eN,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let Q=0;QA)return;const D=ch(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 W=structuredClone(this._vignetteParams);W.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,W.strength=1,W.color=structuredClone(h.style.rain.state.vignetteColor));const Q=this.updateOnRender(h,F.timeFactor),ae=h.context,oe=ae.gl,ve=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},oe.RGBA8)),F.distortionStrength>0&&(ae.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE),oe.copyTexSubImage2D(oe.TEXTURE_2D,0,0,0,0,0,h.width,h.height));const ge=h.getOrCreateProgram("rainParticle");h.uploadCommonUniforms(ae,ge),ae.activeTexture.set(oe.TEXTURE0),this.screenTexture.bind(oe.LINEAR,oe.CLAMP_TO_EDGE);const be=[F.color.r,F.color.g,F.color.b,F.color.a],Le=(Ee,We)=>{const Ue=y3(this._movement.getPosition(),Ee),st=F.dropletSizeX,ut=F.dropletSizeX*F.dropletSizeYScale,it=h.width/2,Et=h.height/2,jt=ch(0,F.screenThinning.start,0,1,F.screenThinning.intensity),Tt=ch(.001,F.screenThinning.range,0,1,F.screenThinning.intensity),_t=ch(0,F.screenThinning.particleOffset,0,1,F.screenThinning.intensity),gt=(Ot={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:Ue,velocityConeAperture:F.velocityConeAperture,velocity:F.velocity,boxSize:Ee,rainDropletSize:[st,ut],distortionStrength:F.distortionStrength,rainDirection:z,color:be,screenSize:[ve.width,ve.height],thinningCenterPos:[it,Et],thinningShape:[jt,Tt,Math.pow(10,F.screenThinning.fadePower)],thinningAffectedRatio:F.screenThinning.affectedRatio,thinningParticleOffset:_t,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 Wt=Math.round(F.intensity*this.particlesCount),Ht=i.bg.simpleSegment(0,0,4*Wt,2*Wt);ge.draw(h,oe.TRIANGLES,Rr.disabled,xn.disabled,$n.alphaBlended,dn.disabled,gt,"rain_particles",this.particlesVx,this.particlesIdx,Ht)};F.distortionStrength>0&&Le(F.boxSize,!0),Le(F.boxSize,!1),this._vignette.draw(h,W)}}const j6=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 N6 extends uv{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 ig("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=cm(this.particlesCount),D=new i.eO,F=new i.b0;let z=0;const W=i.eq(1323123451230);for(let Q=0;Qz)return;const W=ch(0,1,F.revealStart,F.revealStart+F.revealRange,z);D.strength*=W,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 Q=this.updateOnRender(h,y.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const ae=h.context,oe=ae.gl,ve=h.transform,ge=h.getOrCreateProgram("snowParticle");h.uploadCommonUniforms(ae,ge),((be,Le,Ee)=>{const We=y3(this._movement.getPosition(),be),Ue=ve.width/2,st=ve.height/2,ut=ch(0,Ee.screenThinning.start,0,1,Ee.screenThinning.intensity),it=ch(.001,Ee.screenThinning.range,0,1,Ee.screenThinning.intensity),Et=ch(0,Ee.screenThinning.particleOffset,0,1,Ee.screenThinning.intensity),jt=(Tt={modelview:Q.modelviewMatrix,projection:Q.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:We,velocityConeAperture:Ee.velocityConeAperture,velocity:Ee.velocity,horizontalOscillationRadius:Ee.horizontalOscillationRadius,horizontalOscillationRate:Ee.horizontalOscillationRate,boxSize:be,billboardSize:1*Ee.billboardSize,simpleShapeParameters:[Ee.shapeFadeStart,Ee.shapeFadePower],screenSize:[ve.width,ve.height],thinningCenterPos:[Ue,st],thinningShape:[ut,it,Math.pow(10,Ee.screenThinning.fadePower)],thinningAffectedRatio:Ee.screenThinning.affectedRatio,thinningParticleOffset:Et,color:[Ee.color.r,Ee.color.g,Ee.color.b,Ee.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 _t=Math.round(Ee.intensity*this.particlesCount),gt=i.bg.simpleSegment(0,0,4*_t,2*_t);this.particlesVx&&this.particlesIdx&&ge.draw(h,oe.TRIANGLES,Rr.disabled,xn.disabled,$n.alphaBlended,dn.disabled,jt,"snow_particles",this.particlesVx,this.particlesIdx,gt)})(y.boxSize,0,y),this._vignette.draw(h,D)}}const Py={symbol:function(T,h,y,A,D){if(T.renderPass!=="translucent")return;const F=xn.disabled,z=T.colorModeForRenderPass(),W=y.layout.get("text-variable-anchor"),Q=y.layout.get("text-size-scale-range"),ae=i.aA(T.scaleFactor,Q[0],Q[1]);W&&function(ge,be,Le,Ee,We,Ue,st,ut){const it=be.transform,Et=We==="map",jt=Ue==="map";for(const Tt of ge){const _t=Ee.getTile(Tt),gt=_t.getBucket(Le);if(!gt||!gt.text||!gt.text.segments.get().length)continue;const Ot=i.bK(gt.textSizeData,it.zoom,ut),Wt=Ym(Tt,gt.getProjection(),it),Ht=it.calculatePixelsToTileUnitsMatrix(_t),ss=Js(Wt,_t.tileID.canonical,jt,Et,it,gt.getProjection(),Ht),rs=gt.hasIconTextFit()&>.hasIconData();Ot&&Jr(gt,Et,jt,st,it,ss,Tt,Math.pow(2,it.zoom-_t.tileID.overscaledZ),Ot,rs)}}(A,T,y,h,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),D,ae);const oe=y.paint.get("icon-opacity").constantOr(1)!==0,ve=y.paint.get("text-opacity").constantOr(1)!==0;y.layout.get("symbol-sort-key").constantOr(1)!==void 0&&(oe||ve)?c2(T,h,y,A,F,z):(oe&&c2(T,h,y,A,F,z,{onlyIcons:!0}),ve&&c2(T,h,y,A,F,z,{onlyText:!0})),h.map.showCollisionBoxes&&(Sr(T,h,y,A,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),!0),Sr(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"),W=y.layout.get("circle-sort-key").constantOr(1)!==void 0,Q=y.paint.get("circle-emissive-strength");if(D.constantOr(1)===0&&(F.constantOr(1)===0||z.constantOr(1)===0))return;const ae=T.context,oe=ae.gl,ve=T.transform,ge=!(!T.terrain||!T.terrain.enabled),be=y.layout.get("circle-elevation-reference"),Le=T.depthModeForSublayer(0,Rr.ReadOnly),Ee=new Rr(T.context.gl.LEQUAL,Rr.ReadOnly,T.depthRangeFor3D),We=be==="none"||ge?Le:Ee,Ue=xn.disabled,st=T.colorModeForDrapableLayerRenderPass(Q),ut=ve.projection.name==="globe",it=[i.aF(ve.center.lng),i.aJ(ve.center.lat)],Et=[];for(let Tt=0;TtTt.sortKey-_t.sortKey);const jt={useDepthForOcclusion:ve.depthOcclusionForSymbolsAndCircles};for(const Tt of Et){const{programConfiguration:_t,program:gt,layoutVertexBuffer:Ot,dynamicBuffers:Wt,indexBuffer:Ht,uniformValues:ss,tile:rs}=Tt.state,gs=Tt.segments;T.terrain&&T.terrain.setupElevationDraw(rs,gt,jt),T.uploadCommonUniforms(ae,gt,rs.tileID.toUnwrapped()),gt.draw(T,oe.TRIANGLES,We,Ue,st,dn.disabled,ss,y.id,Ot,Ht,gs,y.paint,ve.zoom,_t,Wt)}},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=xn.disabled,W=new $n([F.ONE,F.ONE,F.ONE,F.ONE],i.ao.transparent,[!0,!0,!0,!0]);(function(be,Le,Ee,We){const Ue=be.gl,st=Le.width*We,ut=Le.height*We;be.activeTexture.set(Ue.TEXTURE1),be.viewport.set([0,0,st,ut]);let it=Ee.heatmapFbo;if(!it||it&&(it.width!==st||it.height!==ut)){it&&it.destroy();const Et=Ue.createTexture();Ue.bindTexture(Ue.TEXTURE_2D,Et),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_WRAP_S,Ue.CLAMP_TO_EDGE),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_WRAP_T,Ue.CLAMP_TO_EDGE),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_MIN_FILTER,Ue.LINEAR),Ue.texParameteri(Ue.TEXTURE_2D,Ue.TEXTURE_MAG_FILTER,Ue.LINEAR),it=Ee.heatmapFbo=be.createFramebuffer(st,ut,1,null),function(jt,Tt,_t,gt,Ot,Wt){const Ht=jt.gl;Ht.texImage2D(Ht.TEXTURE_2D,0,jt.extRenderToTextureHalfFloat?Ht.RGBA16F:Ht.RGBA,Ot,Wt,0,Ht.RGBA,jt.extRenderToTextureHalfFloat?Ht.HALF_FLOAT:Ht.UNSIGNED_BYTE,null),gt.colorAttachment0.set(_t)}(be,0,Et,it,st,ut)}else Ue.bindTexture(Ue.TEXTURE_2D,it.colorAttachment0.get()),be.bindFramebuffer.set(it.framebuffer)})(D,T,y,T.transform.projection.name==="globe"?.5:.25),D.clear({color:i.ao.transparent});const Q=T.transform,ae=Q.projection.name==="globe",oe=ae?["PROJECTION_GLOBE_VIEW"]:[],ve=ae?dn.frontCCW:dn.disabled,ge=[i.aF(Q.center.lng),i.aJ(Q.center.lat)];for(let be=0;be({u_image:0,u_color_ramp:1,u_opacity:ve.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(),W=y.paint.get("line-emissive-strength").constantOr(0),Q=y.paint.get("line-occlusion-opacity"),ae=y.layout.get("line-elevation-reference"),oe=y.layout.get("line-width-unit")==="meters",ve=ae==="sea",ge=!(!T.terrain||!T.terrain.enabled),be=T.context,Le=be.gl;if(y.hasElevatedBuckets&&T.transform.projection.name==="globe")return;const Ee=y.layout.get("line-cross-slope"),We=Ee!==void 0,Ue=Ee<1,st=T.colorModeForDrapableLayerRenderPass(z?W:null),ut=T.terrain&&T.terrain.renderingToTexture,it=ut?1:i.o.devicePixelRatio,Et=y.paint.get("line-dasharray"),jt=Et.constantOr(1),Tt=y.layout.get("line-cap"),_t=Et.constantOr(null),gt=Tt.constantOr(null),Ot=y.paint.get("line-pattern"),Wt=Ot.constantOr(1),Ht=y.paint.get("line-pattern-cross-fade"),ss=Ot.constantOr(null),rs=y.paint.get("line-opacity").constantOr(1);let gs=!Wt&&rs!==1||T.depthOcclusion&&Q>0&&Q<1;const $s=y.paint.get("line-gradient"),Xt=Wt?"linePattern":"line",Bt=i.e2(y);let is;if(ut&&T.terrain&&T.terrain.clipOrMaskOverlapStencilType()&&(gs=!1),Q!==0&&T.depthOcclusion){const gr=y.paint._values["line-opacity"];gr&&gr.value&&gr.value.kind==="constant"?is=gr.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=(gr,er,Vs,Pr,Mr,ur)=>{for(const br of gr){const Gr=h.getTile(br);if(Wt&&!Gr.patternsLoaded())continue;const Tn=Gr.getBucket(y);if(!Tn||Tn.elevationType!=="none"&&!Mr||Tn.elevationType==="none"&&Mr)continue;T.prepareDrawTile();const va=[...er],ei=T.shadowRenderer,Dr=Tn.elevationType==="road"&&!!ei&&ei.enabled;let Ka=[0,0,0];if(Dr){const Hn=T.style.directionalLight,Xi=T.style.ambientLight;Hn&&Xi&&(Ka=eg(T.style,Hn,Xi)),va.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const jn=Tn.programConfigurations.get(y.id);let ci=!1;if(ss&&Gr.imageAtlas){const Hn=i.e3.from(ss),Xi=Hn.getPrimary().scaleSelf(it).toString(),Vo=Gr.imageAtlas.patternPositions.get(Xi),_o=Hn.getSecondary(),Di=_o?Gr.imageAtlas.patternPositions.get(_o.scaleSelf(it).toString()):null;ci=!!Vo&&!!Di,Vo&&jn.setConstantPatternPositions(Vo,Di)}Ht>0&&(ci||jn.getPatternTransitionVertexBuffer("line-pattern"))&&va.push("LINE_PATTERN_TRANSITION");const ki=T.isTileAffectedByFog(br),vi=T.getOrCreateProgram(Xt,{config:jn,defines:va,overrideFog:ki});if(!Wt&&_t&>&&Gr.lineAtlas){const Hn=Gr.lineAtlas.getDash(_t,gt);Hn&&jn.setConstantPatternPositions(Hn)}Dr&&ei.setupShadows(Gr.tileID.toUnwrapped(),vi,"vector-tile");let[Ga,Vn]=y.paint.get("line-trim-offset");(gt==="round"||gt==="square")&&Ga!==Vn&&(Ga===0&&(Ga-=1),Vn===1&&(Vn+=1));const ni=ut?br.projMatrix:null,ko=oe?1/Tn.tileToMeter/i.ay(Gr,1,T.transform.zoom):1,ro=oe?1/Tn.tileToMeter/i.ay(Gr,1,Math.floor(T.transform.zoom)):1,di=Wt?i.e4(T,Gr,y,ni,it,ko,ro,[Ga,Vn],Ka,Ht):i.e5(T,Gr,y,ni,Tn.lineClipsArray.length,it,ko,ro,[Ga,Vn],Ka);if($s){const Hn=Tn.gradients[y.id];let Xi=Hn.texture;if(y.gradientVersion!==Hn.version){let Vo=256;if(y.stepInterpolant){const _o=h.getSource().maxzoom,Di=br.canonical.z===_o?Math.ceil(1<{is!=null&&(is.value=rs*Q),vi.draw(T,Le.TRIANGLES,Vs,Hn,st,dn.disabled,di,y.id,Tn.layoutVertexBuffer,Tn.indexBuffer,Tn.segments,y.paint,T.transform.zoom,jn,[Tn.layoutVertexBuffer2,Tn.patternVertexBuffer,Tn.zOffsetVertexBuffer]),is!=null&&(is.value=rs)};if(gs&&!Mr){const Hn=T.stencilModeForClipping(br).ref;Hn===0&&ut&&be.clear({stencil:0});const Xi={func:Le.EQUAL,mask:255};di.u_alpha_discard_threshold=.8,Ra(new xn(Xi,Hn,255,Le.KEEP,Le.KEEP,Le.INVERT)),di.u_alpha_discard_threshold=0,Ra(new xn(Xi,Hn,255,Le.KEEP,Le.KEEP,Le.KEEP))}else di.u_alpha_discard_threshold=gs&&Mr&&ur?.8:0,Ra(Mr?Pr:T.stencilModeForClipping(br))}};let Ps=T.depthModeForSublayer(0,Rr.ReadOnly);const rr=new Rr(T.depthOcclusion?Le.GREATER:Le.LEQUAL,Rr.ReadOnly,T.depthRangeFor3D);if(y.hasNonElevatedBuckets){const gr=!ut&&T.terrain;Q!==0&&gr?i.w(`Occlusion opacity for layer ${y.id} is supported on terrain only if the layer has line-z-offset enabled.`):gr?i.w(`Cannot render non-elevated lines in immediate mode when terrain is enabled. Layer: ${y.id}.`):Jt(A,Bt,Ps,xn.disabled,!1,!0)}if(y.hasElevatedBuckets){ae==="hd-road-markup"?ge||(Ps=rr,Bt.push("ELEVATED_ROADS")):(Bt.push("ELEVATED"),Ps=rr,We&&Bt.push(Ue?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),ve&&Bt.push("ELEVATION_REFERENCE_SEA"));const gr=gs?T.stencilModeFor3D():xn.disabled;T.forceTerrainMode=!0,Jt(A,Bt,Ps,gr,!0,!0),gs&&Jt(A,Bt,Ps,gr,!0,!1),T.forceTerrainMode=!1}gs&&(T.resetStencilClippingMasks(),ut&&be.clear({stencil:0})),Q===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"),W=T.colorModeForDrapableLayerRenderPass(z),Q=y.paint.get("fill-pattern"),ae=T.opaquePassEnabledForLayer()&&!Q.constantOr(1)&&D.constantOr(i.ao.transparent).a===1&&F.constantOr(0)===1?"opaque":"translucent";let oe="none";y.layout.get("fill-elevation-reference")!=="none"?oe="road":y.paint.get("fill-z-offset").constantOr(1)!==0&&(oe="offset");const ve=!(!T.terrain||!T.terrain.enabled),ge={painter:T,sourceCache:h,layer:y,coords:A,colorMode:W,elevationType:oe,terrainEnabled:ve,pass:ae};if(T.renderPass==="shadow")return void(T.shadowRenderer&&oe==="road"&&!ve&&function(Le){const{painter:Ee,sourceCache:We,layer:Ue,coords:st}=Le,ut=Ee.context.gl,it=Le.painter.shadowRenderer;for(const Et of st){const jt=We.getTile(Et),Tt=jt.getBucket(Ue);if(!Tt)continue;const _t=Tt.elevatedStructures;if(!_t||!_t.shadowCasterSegments||_t.shadowCasterSegments.segments[0].primitiveLength===0)continue;Ee.prepareDrawTile();const gt=Tt.bufferData.programConfigurations.get(Ue.id),Ot=Ee.isTileAffectedByFog(Et),Wt=Ee.getOrCreateProgram("elevatedStructuresDepth",{config:gt,overrideFog:Ot}),Ht=it.calculateShadowPassMatrixFromTile(jt.tileID.toUnwrapped());Ee.uploadCommonUniforms(Ee.context,Wt,Et.toUnwrapped());const ss={u_matrix:Ht,u_depth_bias:0};Wt.draw(Ee,ut.TRIANGLES,it.getShadowPassDepthMode(),xn.disabled,it.getShadowPassColorMode(),dn.disabled,ss,Ue.id,_t.vertexBuffer,_t.indexBuffer,_t.shadowCasterSegments,Ue.paint,Ee.transform.zoom,gt)}}(ge));const be=T.emissiveMode==="mrt-fallback";if(oe!=="offset"){if(o3(ge,!1,be),oe==="road"){const Le=!ve&&T.renderPass==="translucent";Le&&i3(T,h,y,A,"geometry"),o3(ge,!0,be,xn.disabled),Le&&function(Ee){const{painter:We,sourceCache:Ue,layer:st,coords:ut,colorMode:it}=Ee,Et=We.context.gl,jt=Ee.painter.shadowRenderer,Tt=!!jt&&jt.enabled,_t=new Rr(We.context.gl.LEQUAL,Rr.ReadOnly,We.depthRangeFor3D);let gt=[0,0,0];if(Tt){const Wt=We.style.directionalLight,Ht=We.style.ambientLight;Wt&&Ht&&(gt=eg(We.style,Wt,Ht))}const Ot=Wt=>{for(const Ht of ut){const ss=Ue.getTile(Ht),rs=ss.getBucket(st);if(!rs)continue;const gs=rs.elevatedStructures;if(!gs)continue;let $s,Xt;if(Wt?($s=gs.renderableBridgeSegments,Xt=gs.bridgeProgramConfigurations.get(st.id)):($s=gs.renderableTunnelSegments,Xt=gs.tunnelProgramConfigurations.get(st.id)),!$s||$s.segments[0].primitiveLength===0)continue;Xt.updatePaintBuffers(),We.prepareDrawTile();const Bt=We.isTileAffectedByFog(Ht),is=[];Tt&&is.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const Jt=We.getOrCreateProgram("elevatedStructures",{config:Xt,overrideFog:Bt,defines:is}),Ps=We.translatePosMatrix(Ht.projMatrix,ss,st.paint.get("fill-translate"),st.paint.get("fill-translate-anchor"));Tt&&jt.setupShadows(ss.tileID.toUnwrapped(),Jt,"vector-tile");const rr=Cy(Ps,gt);We.uploadCommonUniforms(We.context,Jt,Ht.toUnwrapped()),Jt.draw(We,Et.TRIANGLES,_t,xn.disabled,it,dn.backCCW,rr,st.id,gs.vertexBuffer,gs.indexBuffer,$s,st.paint,We.transform.zoom,Xt,[gs.vertexBufferNormal])}};Ot(!0),Ot(!1)}(ge)}}else o3(ge,!1,be,T.stencilModeFor3D())},"fill-extrusion":function(T,h,y,A){const D=y.paint.get("fill-extrusion-opacity"),F=T.context,z=F.gl,W=T.terrain,Q=W&&W.renderingToTexture;if(D===0)return;const ae=T.emissiveMode==="mrt-fallback",oe=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),ve=T.style.order.indexOf(y.fqid);if(oe&&function(ge,be,Le,Ee,We){for(const Ue of Ee){const st=be.getTile(Ue).getBucket(Le);st&&(st.updateReplacement(Ue,ge.replacementSource,We),st.uploadCentroid(ge.context))}}(T,h,y,A,ve),W||oe)for(const ge of A){const be=h.getTile(ge).getBucket(y);be&&Fme(T.context,h,ge,be,y,W,oe)}if(T.renderPass==="shadow"&&T.shadowRenderer){const ge=T.shadowRenderer;if(W&&D<.65&&y._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof i.ad)return;const be=ge.getShadowPassDepthMode(),Le=ge.getShadowPassColorMode();l3(T,h,y,A,be,xn.disabled,Le,oe)}else if(T.renderPass==="translucent"){const ge=!y.paint.get("fill-extrusion-pattern").constantOr(1),be=y.paint.get("fill-extrusion-color").constantOr(i.ao.white);if(!Q&&be.a!==0){const Le=new Rr(T.context.gl.LEQUAL,Rr.ReadWrite,T.depthRangeFor3D);D===1&&ge?l3(T,h,y,A,Le,xn.disabled,$n.unblended,oe):(l3(T,h,y,A,Le,xn.disabled,$n.disabled,oe),l3(T,h,y,A,Le,T.stencilModeFor3D(),T.colorModeForRenderPass(),oe),T.resetStencilClippingMasks())}if(T.style.enable3dLights()&&ge&&(!W&&T.transform.projection.name!=="globe"||Q)){const Le=y.paint.get("fill-extrusion-opacity"),Ee=y.paint.get("fill-extrusion-ambient-occlusion-intensity"),We=y.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),Ue=y.paint.get("fill-extrusion-flood-light-intensity"),st=y.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default")==="none",ut=y.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(st?null:y.lut).toArray01().slice(0,3),it=Ee>0&&We>0,Et=Ue>0,jt=(gt,Ot,Wt)=>(1-Wt)*gt+Wt*Ot,Tt=new g6;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 _t=gt=>{const Ot=T.depthModeForSublayer(1,Rr.ReadOnly,z.LEQUAL,!0),Wt=y.paint.get(gt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),Ht=jt(.1,3,Wt),ss=T._showOverdrawInspector;if(!ss){const rs=new xn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),gs=new $n([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);rg(Tt,T,h,y,A,Ot,rs,gs,dn.disabled,gt,"sdf",Le,Ee,We,Ue,ut,Ht,oe,!1)}{const rs=ss?xn.disabled:new xn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),gs=ss?T.colorModeForRenderPass():new $n([z.ONE_MINUS_DST_ALPHA,z.DST_ALPHA,z.ONE,z.ONE],i.ao.transparent,[!0,!0,!0,!0]);rg(Tt,T,h,y,A,Ot,rs,gs,dn.disabled,gt,"color",Le,Ee,We,Ue,ut,Ht,oe,!1)}};if(Q){const gt=()=>{const Wt=W.drapeBufferSize[0],Ht=W.drapeBufferSize[1];let ss=W.framebufferCopyTexture;return ss&&(!ss||ss.size[0]===Wt&&ss.size[1]===Ht)||(ss&&ss.destroy(),ss=W.framebufferCopyTexture=new i.T(F,new i.q({width:Wt,height:Ht}),z.RGBA8)),ss.bind(z.LINEAR,z.CLAMP_TO_EDGE),z.copyTexSubImage2D(z.TEXTURE_2D,0,0,0,0,0,Wt,Ht),ss},Ot=(Wt,Ht,ss)=>{const rs=T.depthModeForSublayer(1,Rr.ReadOnly,z.LEQUAL,!1),gs=y.paint.get(Wt?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),$s=jt(.1,3,gs);{const Xt=new $n([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0]);rg(Tt,T,h,y,A,rs,xn.disabled,Xt,dn.disabled,Wt,"clear",Le,Ee,We,Ue,ut,$s,oe,Ht)}{const Xt=new xn({func:z.ALWAYS,mask:255},255,255,z.KEEP,z.KEEP,z.REPLACE),Bt=new $n([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!1,!1,!1,!0],z.MIN);rg(Tt,T,h,y,A,rs,Xt,Bt,dn.disabled,Wt,"sdf",Le,Ee,We,Ue,ut,$s,oe,Ht)}ae&&!Wt&&(ss=gt());{const Xt=Wt?z.ZERO:z.ONE_MINUS_DST_ALPHA,Bt=new xn({func:z.EQUAL,mask:255},255,255,z.KEEP,z.DECR,z.DECR),is=new $n([Xt,z.DST_ALPHA,z.ONE_MINUS_DST_ALPHA,z.ZERO],i.ao.transparent,[!0,!0,!0,!0]);rg(Tt,T,h,y,A,rs,Bt,is,dn.disabled,Wt,"color",Le,Ee,We,Ue,ut,$s,oe,Ht)}if(!ae||Wt){const Xt=new $n([z.ONE,z.ONE,z.ONE,Wt?z.ZERO:z.ONE],i.ao.transparent,[!1,!1,!1,!0],Wt?z.FUNC_ADD:z.MAX);rg(Tt,T,h,y,A,rs,xn.disabled,Xt,dn.disabled,Wt,"clear",Le,Ee,We,Ue,ut,$s,oe,Ht,ss)}else{z.drawBuffers([z.NONE,z.COLOR_ATTACHMENT1]);const Xt=new xn({func:z.EQUAL,mask:255},254,255,z.KEEP,z.DECR,z.DECR),Bt=new $n([z.ONE,z.ONE,z.ONE,z.ONE],i.ao.transparent,[!0,!1,!1,!1],z.MAX);rg(Tt,T,h,y,A,rs,Xt,Bt,dn.disabled,Wt,"emissive",Le,Ee,We,Ue,ut,$s,oe,Ht,ss),z.drawBuffers([z.COLOR_ATTACHMENT0])}};if(it||Et){let Wt;T.prepareDrawTile(),ae&&!it||(Wt=gt()),it&&Ot(!0,!1,Wt),Et&&Ot(!1,!0,Wt)}}else it&&_t(!0),Et&&_t(!1),(it||Et)&&T.resetStencilClippingMasks()}}},building:function(T,h,y,A){T.currentLayer0&&F>0,ae=!0;const oe=y.paint.get("building-vertical-scale");if(oe<=0)return;T.shadowRenderer||(ae=!1);const ve=T.conflationActive&&T.style.isLayerClipped(y,h.getSource()),ge=T.style.order.indexOf(y.fqid);if(function(be,Le,Ee,We,Ue,st){for(const ut of st){const it=Le.getTile(ut).getBucket(Ee);it&&(Ue&&it.updateReplacement(ut,be.replacementSource,We),it.uploadUpdatedIndexBuffer(be.context))}}(T,h,y,ge,ve,A),function(be,Le,Ee,We){for(const Ue of We){const st=Le.getTile(Ue).getBucket(Ee);st&&st.needsEvaluation()&&st.uploadUpdatedColorBuffer(be.context)}}(T,h,y,A),y.resetLayerRenderingStats(T),T.shadowRenderer&&(T.shadowRenderer.useNormalOffset=!0),T.renderPass==="shadow"&&T.shadowRenderer){const be=T.shadowRenderer,Le=[],Ee=be.getShadowPassDepthMode();d2({painter:T,source:h,layer:y,coords:A,defines:Le,blendMode:be.getShadowPassColorMode(),depthMode:Ee,opacity:W,verticalScale:oe,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if(T.renderPass==="translucent"){let be=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];ae&&(be=be.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),T.shadowRenderer&&T.shadowRenderer.useNormalOffset&&(be=be.concat("NORMAL_OFFSET"));const Le=y.paint.get("building-facade-emissive-chance"),Ee=y.paint.get("building-ambient-occlusion-intensity"),We=y.paint.get("building-flood-light-intensity"),Ue=y.paint.get("building-flood-light-color-use-theme").constantOr("default")==="none",st=y.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(Ue?null:y.lut).toArray01().slice(0,3),ut=y.paint.get("building-flood-light-ground-attenuation"),it=We>0,Et=new Rr(T.context.gl.LEQUAL,Rr.ReadWrite,T.depthRangeFor3D);W<1&&d2({painter:T,source:h,layer:y,coords:A,defines:be,blendMode:$n.disabled,depthMode:Et,opacity:W,verticalScale:oe,facadeEmissiveChance:Le,facadeAOIntensity:Ee,floodLightIntensity:We,floodLightColor:st,depthOnly:!0});const jt=T.colorModeForRenderPass();d2({painter:T,source:h,layer:y,coords:A,defines:be,blendMode:jt,depthMode:Et,opacity:W,verticalScale:oe,facadeEmissiveChance:Le,facadeAOIntensity:Ee,floodLightIntensity:We,floodLightColor:st}),Q&&c3(T,h,y,A,!0,W,D,F,We,st,z,ve),it&&c3(T,h,y,A,!1,W,D,F,We,st,ut,ve)}else if(T.renderPass==="light-beam"){const be=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],Le=new Rr(T.context.gl.LEQUAL,Rr.ReadOnly,T.depthRangeFor3D);d2({painter:T,source:h,layer:y,coords:A,defines:be,blendMode:$n.alphaBlended,depthMode:Le,opacity:W,verticalScale:oe,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,W]=T.renderPass!=="translucent"||F?[{},A]:T.stencilConfigForOverlap(A);for(const Q of W){const ae=h.getTile(Q);if(ae.needsHillshadePrepare&&T.renderPass==="offscreen")Mme(T,ae,y);else if(T.renderPass==="translucent"){const oe=T.depthModeForSublayer(0,Rr.ReadOnly),ve=y.paint.get("hillshade-emissive-strength"),ge=T.colorModeForDrapableLayerRenderPass(ve),be=F&&T.terrain?T.terrain.stencilModeForRTTOverlap(Q):z[Q.overscaledZ];Cme(T,Q,ae,y,oe,be,ge)}}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",W=y.paint.get("raster-elevation")!==0,Q=W&&z;if(T.renderElevatedRasterBackface&&!Q)return;const ae=T.context,oe=ae.gl,ve=h.getSource(),ge=function(jt,Tt,_t,gt,Ot){const Wt=Tt.paint.get("raster-color"),Ht=jt.type==="raster-array",ss=[],rs=Tt.paint.get("raster-resampling"),gs=Tt.paint.get("raster-color-mix");let $s=Tt.paint.get("raster-color-range");const Xt=[gs[0],gs[1],gs[2],0],Bt=gs[3];let is=rs==="nearest"?gt.NEAREST:gt.LINEAR;if(Ht&&(ss.push("RASTER_ARRAY"),Wt||ss.push("RASTER_COLOR"),rs==="linear"&&ss.push("RASTER_ARRAY_LINEAR"),is=gt.NEAREST,!$s&&jt.rasterLayers)){const Jt=jt.rasterLayers.find(({id:Ps})=>Ps===Tt.sourceLayer);Jt&&Jt.fields&&Jt.fields.range&&($s=Jt.fields.range)}if($s=$s||[0,1],Wt){ss.push("RASTER_COLOR"),_t.activeTexture.set(gt.TEXTURE2),Tt.updateColorRamp($s);let Jt=Tt.colorRampTexture;Jt||(Jt=Tt.colorRampTexture=new i.T(_t,Tt.colorRamp,gt.RGBA8)),Jt.bind(gt.LINEAR,gt.CLAMP_TO_EDGE)}return Ot&&ss.push("USE_MRT1"),{mix:Xt,range:$s,offset:Bt,defines:ss,resampling:is}}(ve,y,ae,oe,T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback");if(ve instanceof i.aU&&!A.length&&!z)return;const be=y.paint.get("raster-emissive-strength"),Le=T.colorModeForDrapableLayerRenderPass(be),Ee=T.terrain&&T.terrain.renderingToTexture,We=!T.options.moving,Ue=y.paint.get("raster-resampling")==="nearest"?oe.NEAREST:oe.LINEAR;if(ve instanceof i.aU&&!A.length&&(ve.onNorthPole||ve.onSouthPole)){const jt=W?T.stencilModeFor3D():xn.disabled;return void u2(!!ve.onNorthPole,null,T,h,y,be,ge,dn.disabled,jt)}if(!A.length)return;const[st,ut]=ve instanceof i.aU||Ee?[{},A]:T.stencilConfigForOverlap(A),it=ut[ut.length-1].overscaledZ;Q&&ge.defines.push("PROJECTION_GLOBE_VIEW"),W&&ge.defines.push("RENDER_CUTOFF");const Et=(jt,Tt,_t)=>{for(const gt of jt){const Ot=gt.toUnwrapped(),Wt=h.getTile(gt);if(Ee&&(!Wt||!Wt.hasData()))continue;ae.activeTexture.set(oe.TEXTURE0);const Ht=ag(Wt,ve,y,ge);if(!Ht||!Ht.texture)continue;const{texture:ss,mix:rs,offset:gs,tileSize:$s,buffer:Xt}=Ht;let Bt,is;Ee?(Bt=Rr.disabled,is=gt.projMatrix):W?(Bt=new Rr(oe.LEQUAL,Rr.ReadWrite,T.depthRangeFor3D),is=z?Float32Array.from(T.transform.expandedFarZProjMatrix):T.transform.calculateProjMatrix(Ot,We)):(Bt=T.depthModeForSublayer(gt.overscaledZ-it,y.paint.get("raster-opacity")===1?Rr.ReadWrite:Rr.ReadOnly,oe.LESS),is=T.transform.calculateProjMatrix(Ot,We));const Jt=T.terrain&&Ee?T.terrain.stencilModeForRTTOverlap(gt):st[gt.overscaledZ],Ps=F?0:y.paint.get("raster-fade-duration");Wt.registerFadeDuration(Ps);const rr=h.findLoadedParent(gt,0),gr=a2(Wt,rr,h,T.transform,Ps);let er,Vs;!gr.isFading&&Wt.refreshedUponExpiration&&(Wt.refreshedUponExpiration=!1),T.terrain&&T.terrain.prepareDrawTile(),ae.activeTexture.set(oe.TEXTURE0),ss.bind(Ue,oe.CLAMP_TO_EDGE),ae.activeTexture.set(oe.TEXTURE1),rr?(rr.texture&&rr.texture.bind(Ue,oe.CLAMP_TO_EDGE),er=Math.pow(2,rr.tileID.overscaledZ-Wt.tileID.overscaledZ),Vs=[Wt.tileID.canonical.x*er%1,Wt.tileID.canonical.y*er%1]):ss.bind(Ue,oe.CLAMP_TO_EDGE),"useMipmap"in ss&&ae.extTextureFilterAnisotropic&&T.transform.pitch>20&&oe.texParameterf(oe.TEXTURE_2D,ae.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,ae.extTextureFilterAnisotropicMax);const Pr=T.transform;let Mr;const ur=W?eF(Pr):[0,0,0,0];let br,Gr,Tn,va,ei,Dr=0;if(Q&&ve instanceof i.aU&&ve.coordinates.length>3)br=Float32Array.from(i.bk(i.dJ(new i.cD(0,0,0)))),Gr=Float32Array.from(Pr.globeMatrix),Tn=Float32Array.from(i.dF(Pr)),va=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Mr=ve.elevatedGlobePerspectiveTransform,ei=ve.elevatedGlobeGridMatrix||new Float32Array(9);else if(Q){const ki=i.dG(gt.canonical);Dr=i.dH(ki.getCenter().lat),br=Float32Array.from(i.bk(i.dJ(gt.canonical))),Gr=Float32Array.from(Pr.globeMatrix),Tn=Float32Array.from(i.dF(Pr)),va=[i.aF(Pr.center.lng),i.aJ(Pr.center.lat)],Mr=[0,0],ei=Float32Array.from(i.dI(gt.canonical,ki,Dr,Pr.worldSize/Pr._pixelsPerMercatorPixel))}else Mr=ve instanceof i.aU?ve.perspectiveTransform:[0,0],br=new Float32Array(16),Gr=new Float32Array(9),Tn=new Float32Array(16),va=[0,0],ei=new Float32Array(9);const Ka=GR(is,br,Gr,Tn,ei,Vs||[0,0],i.aj(T.transform.zoom),va,ur,er||1,gr,y,Mr,W?y.paint.get("raster-elevation"):0,2,rs,gs,ge.range,$s,Xt,be),jn=T.isTileAffectedByFog(gt),ci=T.getOrCreateProgram("raster",{defines:ge.defines,overrideFog:jn});if(T.uploadCommonUniforms(ae,ci,Ot),ve instanceof i.aU){const ki=ve.elevatedGlobeVertexBuffer,vi=ve.elevatedGlobeIndexBuffer;if(Ee||!z)ve.boundsBuffer&&ve.boundsSegments&&ci.draw(T,oe.TRIANGLES,Bt,xn.disabled,Le,dn.disabled,Ka,y.id,ve.boundsBuffer,T.quadTriangleIndexBuffer,ve.boundsSegments);else if(ki&&vi){const Ga=Pr.zoom<=i.c_?ve.elevatedGlobeSegments:ve.getSegmentsForLongitude(Pr.center.lng);Ga&&ci.draw(T,oe.TRIANGLES,Bt,xn.disabled,Le,Tt,Ka,y.id,ki,vi,Ga)}}else if(Q){Bt=new Rr(oe.LEQUAL,Rr.ReadOnly,T.depthRangeFor3D);const ki=T.globeSharedBuffers;if(ki){const[vi,Ga,Vn]=ki.getGridBuffers(Dr,!1);ci.draw(T,oe.TRIANGLES,Bt,_t||Jt,T.colorModeForRenderPass(),Tt,Ka,y.id,vi,Ga,Vn)}}else{const{tileBoundsBuffer:ki,tileBoundsIndexBuffer:vi,tileBoundsSegments:Ga}=T.getTileBoundsBuffers(Wt);ci.draw(T,oe.TRIANGLES,Bt,Jt,Le,dn.disabled,Ka,y.id,ki,vi,Ga)}}if(!(ve instanceof i.aU)&&Q)for(const gt of jt){const Ot=gt.canonical.y===(1<>>16,2654435769),((gt=Math.imul(gt^gt>>>16,2654435769))>>>0)/4294967296},_t=1/1.1;for(let gt=0;gti.e9[Jt](ss));Xt.push(ss);const Bt=ss.canonical.x,is=ss.canonical.y;for(const Jt of Xt){const Ps=it.getTile(Ot?Jt.wrapped():Jt);if(!Ps)continue;const rr=Ps.rasterParticleState;if(!rr)continue;const gr=Jt.canonical.x+(1<Tt.tileID)),be&&(ae.activeTexture.set(oe.TEXTURE0),T.imageManager.bind(T.context,y.scope));const jt=[];if(T.terrain&&T.terrain.renderingToTexture&&T.emissiveMode==="mrt-fallback"&&jt.push("USE_MRT1"),Q){const Tt=T.getOrCreateProgram(ut,{overrideFog:!1,overrideRtt:!0,defines:jt}),_t=new Float32Array(i.bA([])),gt=new i.aQ(0,0,0,0,0),Ot=be?Ty(_t,W,z,T,0,y.scope,Le,Q,{tileID:gt,tileSize:ge}):o2(_t,W,z,D.toPremultipliedRenderColor(F?null:y.lut));Tt.draw(T,oe.TRIANGLES,Ue,We,st,dn.disabled,Ot,y.id,T.viewportBuffer,T.quadTriangleIndexBuffer,T.viewportSegments)}else for(const Tt of Et){const _t=T.isTileAffectedByFog(Tt),gt=T.getOrCreateProgram(ut,{overrideFog:_t,defines:jt}),Ot=Tt.toUnwrapped(),Wt=A?Tt.projMatrix:T.transform.calculateProjMatrix(Ot);T.prepareDrawTile();const Ht=h?h.getTile(Tt):it?it[Tt.key]:new Zm(Tt,ge,ve.zoom,T),ss=be?Ty(Wt,W,z,T,0,y.scope,Le,Q,{tileID:Tt,tileSize:ge}):o2(Wt,W,z,D.toPremultipliedRenderColor(F?null:y.lut));T.uploadCommonUniforms(ae,gt,Ot);const{tileBoundsBuffer:rs,tileBoundsIndexBuffer:gs,tileBoundsSegments:$s}=T.getTileBoundsBuffers(Ht);gt.draw(T,oe.TRIANGLES,Ue,We,st,dn.disabled,ss,y.id,rs,gs,$s)}},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"),W=new Rr(F.gl.LEQUAL,Rr.ReadOnly,[0,1]),Q=T.frameCounter/1e3%1;z==="atmosphere"?T.renderPass==="offscreen"?y.needsSkyboxCapture(T)&&(function(ae,oe,ve,ge){const be=ae.context,Le=be.gl;let Ee=oe.skyboxFbo;if(!Ee){Ee=oe.skyboxFbo=be.createFramebuffer(32,32,1,null),oe.skyboxGeometry=new m3(be),oe.skyboxTexture=be.gl.createTexture(),Le.bindTexture(Le.TEXTURE_CUBE_MAP,oe.skyboxTexture),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_WRAP_S,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_WRAP_T,Le.CLAMP_TO_EDGE),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_MIN_FILTER,Le.LINEAR),Le.texParameteri(Le.TEXTURE_CUBE_MAP,Le.TEXTURE_MAG_FILTER,Le.LINEAR);for(let ut=0;ut<6;++ut)Le.texImage2D(Le.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,Le.RGBA,32,32,0,Le.RGBA,Le.UNSIGNED_BYTE,null)}be.bindFramebuffer.set(Ee.framebuffer),be.viewport.set([0,0,32,32]);const We=oe.getCenter(ae,!0),Ue=ae.getOrCreateProgram("skyboxCapture"),st=new Float64Array(16);i.bA(st),i.en(st,st,.5*-Math.PI),cv(ae,oe,Ue,st,We,0),i.bA(st),i.en(st,st,.5*Math.PI),cv(ae,oe,Ue,st,We,1),i.bA(st),i.cU(st,st,.5*-Math.PI),cv(ae,oe,Ue,st,We,2),i.bA(st),i.cU(st,st,.5*Math.PI),cv(ae,oe,Ue,st,We,3),i.bA(st),cv(ae,oe,Ue,st,We,4),i.bA(st),i.en(st,st,Math.PI),cv(ae,oe,Ue,st,We,5),be.viewport.set([0,0,ae.width,ae.height])}(T,y),y.markSkyboxValid(T)):T.renderPass==="sky"&&function(ae,oe,ve,ge,be){const Le=ae.context,Ee=Le.gl,We=ae.transform,Ue=ae.getOrCreateProgram("skybox");Le.activeTexture.set(Ee.TEXTURE0),Ee.bindTexture(Ee.TEXTURE_CUBE_MAP,oe.skyboxTexture);const st=((ut,it,Et,jt,Tt)=>({u_matrix:ut,u_sun_direction:it,u_cubemap:0,u_opacity:jt,u_temporal_offset:Tt}))(We.skyboxMatrix,oe.getCenter(ae,!1),0,ge,be);ae.uploadCommonUniforms(Le,Ue),Ue.draw(ae,Ee.TRIANGLES,ve,xn.disabled,ae.colorModeForRenderPass(),dn.backCW,st,"skybox",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(T,y,W,D,Q):z==="gradient"&&T.renderPass==="sky"&&function(ae,oe,ve,ge,be){const Le=ae.context,Ee=Le.gl,We=ae.transform,Ue=ae.getOrCreateProgram("skyboxGradient");oe.skyboxGeometry||(oe.skyboxGeometry=new m3(Le)),Le.activeTexture.set(Ee.TEXTURE0);let st=oe.colorRampTexture;st||(st=oe.colorRampTexture=new i.T(Le,oe.colorRamp,Ee.RGBA8)),st.bind(Ee.LINEAR,Ee.CLAMP_TO_EDGE);const ut=((it,Et,jt,Tt,_t)=>({u_matrix:it,u_color_ramp:0,u_center_direction:Et,u_radius:i.an(jt),u_opacity:Tt,u_temporal_offset:_t}))(We.skyboxMatrix,oe.getCenter(ae,!1),oe.paint.get("sky-gradient-radius"),ge,be);ae.uploadCommonUniforms(Le,Ue),Ue.draw(ae,Ee.TRIANGLES,ve,xn.disabled,ae.colorModeForRenderPass(),dn.backCW,ut,"skyboxGradient",oe.skyboxGeometry.vertexBuffer,oe.skyboxGeometry.indexBuffer,oe.skyboxGeometry.segment)}(T,y,W,D,Q)},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 W=T.transform.pointMerc;z.call(F,D.gl,T.transform.customLayerMatrix(),T.transform.getProjection(),T.transform.globeToMercatorMatrix(),i.aj(T.transform.zoom),[W.x,W.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 W=F.renderToTile;if(W){const Q=A[0].canonical,ae={x:Q.x+A[0].wrap*(F.wrapTileId?0:1<{ae&&(ae.useNormalOffset=!0,oe||(ae.enabled=!0))},ge=h.getSource();if(T.renderPass==="light-beam"&&ge.type!=="batched-model")return;if(ge.type==="vector"||ge.type==="geojson")return function(it,Et,jt,Tt,_t){const gt=it.transform,Ot=gt.projection.name==="globe",Wt=gt.getFreeCameraOptions().position;if(!it.modelManager)return;const Ht=it.modelManager;jt.modelManager=Ht;const ss=it.shadowRenderer;if(!jt._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const rs=jt._unevaluatedLayout._values["model-id"],gs=Object.assign({},jt.layout.get("model-id").parameters),$s=it.style.order.indexOf(jt.fqid),Xt=jt.paint.get("model-opacity").constantOr(1);for(const Bt of Tt){const is=Et.getTile(Bt).getBucket(jt);if(!is||is.projection.name!==gt.projection.name)continue;const Jt=is.getModelUris();if(Jt&&!is.modelsRequested&&(Ht.addModelsFromBucket(Jt,_t),is.modelsRequested=!0),Ot)gs.zoom=Bt.overscaledZ;else{const ur=Fu(Bt,gt);gs.zoom=ur}const Ps=rs.possiblyEvaluate(gs);if(uF(it,is,Bt),Vf.shadowUniformsInitialized=!1,Vf.useSingleShadowCascade=!!ss&&ss.getMaxCascadeForTile(Bt.toUnwrapped())===0,it.renderPass==="shadow"&&ss){if(it.currentShadowCascade===1&&is.isInsideFirstShadowMapFrustum)continue;const ur=gt.calculatePosMatrix(Bt.toUnwrapped(),gt.worldSize);if(Vf.tileMatrix.set(ur),Vf.shadowTileMatrix=Float32Array.from(ss.calculateShadowPassMatrixFromMatrix(ur)),Vf.aabb.min=[0,0,0],Vf.aabb.max[0]=Vf.aabb.max[1]=i.al,Vf.aabb.max[2]=0,$me(is,Vf,it,jt.scope))continue}const rr=1<0&&it.style.isLayerClipped(jt,Et.getSource())&&is.updateReplacement(Bt,it.replacementSource,$s,jt.scope)&&(is.uploaded=!1,is.upload(it.context));let er=0;const Vs=new Array,Pr=new Array,Mr=new Array;for(let ur in is.instancesPerModel){const br=is.instancesPerModel[ur];br.features.length>0&&!Ot&&(ur=Ps.evaluate(br.features[0].feature,{}));const Gr=Ht.getModel(ur,_t);if(Gr||Ht.hasURLBeenRequested(ur)||is.modelUris.includes(ur)||(is.modelUris.push(ur),is.modelsRequested=!1),Gr&&Gr.uploaded)if(Ot){const Tn=i.c5([],[Wt.x,Wt.y,Wt.z],it.transform.worldSize);i.ew(Tn,Tn);for(let va=0;va0&&Ka.elevationUpdate(ur.terrain,va,Dr,Gr.source),Ka.needsReEvaluation(ur,ei,Gr)&&Ka.evaluate(Gr))}})(it,Et,jt,Tt),function(){let ur,br,Gr;Vs?(ur=Tt.length-1,br=-1,Gr=-1):(ur=0,br=Tt.length,Gr=1);const Tn=new Float64Array(16),va=i.cA(),ei=new i.P(0,0);for(let Dr=ur;Dr!==br;Dr+=Gr){const Ka=Tt[Dr],jn=Et.getTile(Ka).getBucket(jt);if(!jn||!jn.uploaded)continue;let ci=!1;Wt&&(ci=Wt.getMaxCascadeForTile(Ka.toUnwrapped())===0);const ki=gt.calculatePosMatrix(Ka.toUnwrapped(),gt.worldSize),vi=jn.modelTraits;!rr&&Vs&&(i.bl(Tn,ki),i.af(va,ss,Tn),ei.x=va[0],ei.y=va[1]);const Ga=[];jn.setFilter(jt.filter);for(const Vn of jn.getNodesInfo()){if(Vn.hiddenByReplacement||!Vn.node.meshes)continue;const ni=Vn.node;let ko=0;it.terrain&&ni.elevation&&(ko=ni.elevation*it.terrain.exaggeration());const ro=(()=>{const Ud=Vn.aabb;return Ps.min=[...Ud.min],Ps.max=[...Ud.max],Ps.min[2]+=ko,Ps.max[2]+=ko,i.af(Ps.min,Ps.min,ki),i.af(Ps.max,Ps.max,ki),Ps})(),di=Vn.evaluatedScale;if(di[0]<=1&&di[1]<=1&&di[2]<=1&&ro.intersects(gr)===0)continue;if(!rr&&Vs){const Ud=.16666666666666666;Vn.cameraCollisionOpacity=ss[0]>ro.min[0]&&ss[0]ro.min[1]&&ss[1]!Vs||Vn.opacity===1&&ni.opacity===1?Vn.depthni.depth?-1:1);for(const Vn of Ga){const ni=Vn.nodeInfo,ko=ni.node;let ro=i.aB([],Xt,Vn.tileModelMatrix);i.aB(ro,gs,ro);const di=i.bl([],ro);i.eg(di,di),i.cS(di,di,m2),ro=i.aB(ro,ro,ko.globalMatrix);const Ra=it.renderPass==="light-beam",Hn=jt.paint.get("model-color-use-theme").constantOr("default")==="none",Xi=vi&i.eI.HasMapboxMeshFeatures,Vo=Xi?0:ni.evaluatedRMEA[0][2];for(let _o=0;_o=ys||wo>=ys}}const ad=Di.material;let um;ad.occlusionTexture&&ad.occlusionTexture.offsetScale&&(um=ad.occlusionTexture.offsetScale,$l.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const np=it.getOrCreateProgram("model",$l);!rr&&Wt&&Wt.setupShadowsFromMatrix(Vn.tileModelMatrix,np,Wt.useNormalOffset),it.uploadCommonUniforms(_t,np,null,Vd);const uh=ad.pbrMetallicRoughness;uh.metallicFactor=.9,uh.roughnessFactor=.5;const Po=nv(new Float32Array(Md),new Float32Array(ro),new Float32Array(di),new Float32Array(ko.globalMatrix),it,Vn.opacity,uh.baseColorFactor,ad.emissiveFactor,uh.metallicFactor,uh.roughnessFactor,ad,Vo,jt,[0,0,0],um);!zu&&(ni.hasTranslucentParts||Vn.opacity<1)&&np.draw(it,_t.gl.TRIANGLES,is,xn.disabled,$n.disabled,dn.backCCW,Po,jt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,jt.paint,it.transform.zoom,void 0,Ud),np.draw(it,_t.gl.TRIANGLES,zu?Jt:is,xn.disabled,zu||Vn.opacity<1||ni.hasTranslucentParts?$n.alphaBlended:$n.unblended,dn.backCCW,Po,jt.id,Di.vertexBuffer,Di.indexBuffer,Di.segments,jt.paint,it.transform.zoom,void 0,Ud)}}}}()}(T,h,y,A),void ve();if(ge.type!=="model")return;const be=ge.getModels(),Le=[],Ee=T.transform.getFreeCameraOptions().position,We=i.c5([],[Ee.x,Ee.y,Ee.z],T.transform.worldSize);i.ew(We,We);const Ue=[],st=[];let ut=0;for(const it of be){const Et=h.getFeatureState("",it.id),jt={type:"Unknown",id:it.id,properties:it.featureProperties},Tt=y.paint.get("model-rotation").evaluate(jt,Et),_t=y.paint.get("model-scale").evaluate(jt,Et),gt=y.paint.get("model-translation").evaluate(jt,Et),Ot=y.paint.get("model-opacity").evaluate(jt,Et);lF(y,it.id,Et,it.featureProperties,it.nodeOverrideNames,it.nodeOverrides),cF(y,it.id,Et,it.featureProperties,it.materialOverrideNames,it.materialOverrides),it.nodeOverrides.size>0&&it.computeBoundsAndApplyParent(),it.computeModelMatrix(T,Tt,_t,gt,W,z,!1);const Wt=i.bA([]),Ht=i.ef(it.position.lat,T.transform.zoom),ss=i.bq([],[1,1,1/Ht]);i.br(Wt,Wt,We),Le.push({zScaleMatrix:ss,negCameraPosMatrix:Wt});for(const rs of it.nodes)dv(T,rs,it.matrix,T.transform.expandedFarZProjMatrix,ut,Ue,st,it.materialOverrides,Ot);ut++}if(Ue.sort((it,Et)=>Et.depth-it.depth),T.renderPass!=="shadow")dF(T,y,Ue,st,Le),ve();else{for(const it of st)$p(it.mesh,it.nodeModelMatrix,T,y);for(const it of Ue)$p(it.mesh,it.nodeModelMatrix,T,y);ve()}}},b3={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,h2(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 kd&&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(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)},"raster-particle":function(T,h,y){const A=h.getSource();if(!(A instanceof kd&&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(W=>h.getTileByID(W));for(const W of z)W.updateNeeded(T.id,F)&&A.prepareTile(W,D,T.id,F)}},dm={fill:i3},_3={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 Rr(D.LEQUAL,Rr.ReadOnly,T.depthRangeFor3D),z=new xn({func:D.ALWAYS,mask:255},255,255,D.KEEP,D.KEEP,D.REPLACE),W=T.transform.getFreeCameraOptions().position,Q=T.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const ae of A){const oe=h.getTile(ae),ve=oe.getBucket(y);if(!ve)continue;const ge=ve.elevatedStructures;if(!ge||ge.depthSegments.segments[0].primitiveLength===0)continue;const be=JR(ae.toUnwrapped(),W),Le=T.translatePosMatrix(ae.projMatrix,oe,y.paint.get("fill-translate"),y.paint.get("fill-translate-anchor")),Ee=rv(Le,be,0,1,0);Q.draw(T,D.TRIANGLES,F,z,$n.disabled,dn.disabled,Ee,y.id,ge.vertexBuffer,ge.indexBuffer,ge.depthSegments,y.paint,T.transform.zoom)}}};class w3{constructor(h,y,A,D,F){this.context=new cb(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 Q of z)this._debugParams.enabledLayers[Q]=!0;for(const Q of z);this.occlusionParams=new ub,this.setup(),this.numSublayers=Ml.maxUnderzooming+Ml.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 X1(this),this._wireframeDebugCache=new Ey,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const W=new i.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new i.T(this.context,W,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 l6(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 l6(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 W=new i.be;for(const ae of[0,1,3,2,0])W.emplaceBack(ae);this.debugIndexBuffer=h.createIndexBuffer(W),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 Q=this.context.gl;this.stencilClearMode=new xn({func:Q.ALWAYS,mask:0},0,255,Q.ZERO,Q.ZERO,Q.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,Rr.disabled,this.stencilClearMode,$n.disabled,dn.disabled,n2(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 W=!1;for(const Q of A)if(this._tileClippingMaskIDs[Q.key]===void 0){W=!0;break}if(!W)return}this.currentStencilSource=y.id;const D=this.context,F=D.gl;this.nextStencilID+A.length>256&&this.clearStencil(),D.setColorMode($n.disabled),D.setDepthMode(Rr.disabled);const z=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const W of A){const Q=y.getTile(W),ae=this._tileClippingMaskIDs[W.key]=this.nextStencilID++,{tileBoundsBuffer:oe,tileBoundsIndexBuffer:ve,tileBoundsSegments:ge}=this.getTileBoundsBuffers(Q);z.draw(this,F.TRIANGLES,Rr.disabled,new xn({func:F.ALWAYS,mask:0},ae,255,F.KEEP,F.KEEP,F.REPLACE),$n.disabled,dn.disabled,n2(W.projMatrix),"$clipping",oe,ve,ge)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const h=this.nextStencilID++,y=this.context.gl;return new xn({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 xn({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,W)=>W.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 W=0;Wthis._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(Xt=>{const Bt=D[Xt];return!(Bt.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[Bt.type]});let W=z(),Q=!1,ae=!1,oe=null,ve=0,ge=!1;for(const Xt of W){const Bt=D[Xt];Bt.visibility!=="none"&&(Bt.type==="circle"?Q=!0:Bt.type==="building"?(oe=Bt,++ve):Bt.type==="symbol"&&(Bt.hasOcclusionOpacityProperties?ae=!0:Q=!0))}this.updateEmissiveMode();let be=W.map(Xt=>D[Xt]);const Le=this.style._mergedSourceCaches;this.imageManager=h.imageManager,this.modelManager=h.modelManager,this.symbolFadeChange=h.placement.symbolFadeChange(i.o.now()),this.imageManager.beginFrame();for(const Xt in Le){const Bt=Le[Xt];Bt.used&&(Bt.prepare(this.context),Bt.getSource().usedInConflation&&++ve)}let Ee=!1;for(const Xt of be)Xt.isHidden(this.transform.zoom)||(Xt.type==="clip"&&(Ee=!0),this.prepareLayer(Xt));const We={},Ue={},st={},ut={},it={};for(const Xt in Le){const Bt=Le[Xt];We[Xt]=Bt.getVisibleCoordinates(),Ue[Xt]=We[Xt].slice().reverse(),st[Xt]=Bt.getVisibleCoordinates(!0).reverse(),ut[Xt]=Bt.getShadowCasterCoordinates(),it[Xt]=Bt.sortCoordinatesByDistance(We[Xt])}const Et=Xt=>{const Bt=this.style.getLayerSourceCache(Xt);return Bt&&Bt.used?Bt.getSource():null};if(ve||Ee||this._clippingActiveLastFrame){const Xt=[],Bt=[];let is=0;for(const Jt of be)this.isSourceForClippingOrConflation(Jt,Et(Jt))&&(Xt.push(Jt),Bt.push(is)),is++;if(Xt&&(Ee||Xt.length>1)||this._clippingActiveLastFrame){Ee=!1;const Jt=[];for(let Ps=0;Ps0){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=Xt),this._lastOcclusionLayer=Xt)}const jt=this.style&&this.style.fog;jt?(this._fogVisible=jt.getOpacity(this.transform.pitch)!==0,this._fogVisible&&this.transform.projection.name!=="globe"&&(this._fogVisible=jt.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(st),this.opaquePassCutoff=0,W=z(),be=W.map(Xt=>D[Xt]));const Tt=this._shadowRenderer;if(Tt){Tt.updateShadowParameters(this.transform,this.style.directionalLight);for(const Xt in Le)for(const Bt of We[Xt]){let is={min:0,max:0};this.terrain&&(is=this.terrain.getMinMaxForTile(Bt)||is),Tt.addShadowReceiver(Bt.toUnwrapped(),is.min,is.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 oF(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const _t=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),gt=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(_t&&!this._snow&&(this._snow=new N6(this)),!_t&&this._snow&&(this._snow.destroy(),delete this._snow),gt&&!this._rain&&(this._rain=new v3(this)),!gt&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),oe){this.buildingTileBorderManager||(this.buildingTileBorderManager=new p3);const Xt=this.style.getLayerSourceCache(oe);this.buildingTileBorderManager.updateBorders(Xt,oe)}if(!nt.has(this.context.gl))return;this.renderPass="offscreen";for(const Xt of be){const Bt=h.getLayerSourceCache(Xt);if(!Xt.hasOffscreenPass()||Xt.isHidden(this.transform.zoom))continue;const is=Bt?Ue[Bt.id]:void 0;(Xt.type==="custom"||Xt.type==="raster"||Xt.type==="raster-particle"||Xt.isSky()||is&&is.length)&&this.renderLayer(this,Bt,Xt,is)}this.depthRangeFor3D=[0,1-(be.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(),Wt=(()=>{if(y.showOverdrawInspector)return i.ao.black;const Xt=this.style.fog;if(Xt&&this.transform.projection.supportsFog){const Bt=this.style.getLut(Xt.scope);if(!Ot){const is=Xt.properties.get("color-use-theme")==="none",Jt=Xt.properties.get("color").toNonPremultipliedRenderColor(is?null:Bt).toArray01();return new i.ao(...Jt)}if(Ot){const is=Xt.properties.get("space-color-use-theme")==="none",Jt=Xt.properties.get("space-color").toNonPremultipliedRenderColor(is?null:Bt).toArray01();return new i.ao(...Jt)}}return i.ao.transparent})();if(this.context.clear({color:Wt,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=W.length-1;this.currentLayer>=0;this.currentLayer--){const Xt=be[this.currentLayer],Bt=h.getLayerSourceCache(Xt);if(Xt.isSky())continue;const is=Bt?(Xt.is3D(F)?it:Ue)[Bt.id]:void 0;this._renderTileClippingMasks(Xt,Bt,is),this.renderLayer(this,Bt,Xt,is)}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&&Xt.hasShadowPass()&&--ss==0){{this.clearStencil(),this.resetStencilClippingMasks();const is=this.currentLayer;for(this.currentLayer=0;this.currentLayer=this._lastOcclusionLayer&&this.layersWithOcclusionOpacity.length>0){const is=this.currentLayer;this.depthOcclusion=!0;for(const Jt of this.layersWithOcclusionOpacity){this.currentLayer=Jt;const Ps=be[this.currentLayer],rr=h.getLayerSourceCache(Ps),gr=rr?Ue[rr.id]:void 0;this.terrain||this._renderTileClippingMasks(Ps,rr,rr?We[rr.id]:void 0),this.renderLayer(this,rr,Ps,gr)}this.depthOcclusion=!1,this.currentLayer=is,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 Xt=null;be.forEach(Bt=>{const is=h.getLayerSourceCache(Bt);is&&!Bt.isHidden(this.transform.zoom)&&is.getVisibleCoordinates().length&&(!Xt||Xt.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=BR.cacheKey(ZE[h],h,F,D);return this.cache[z]||(this.cache[z]=new BR(this.context,h,ZE[h],D,a3[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,W,Q)=>{const ae=z.properties.get("direction"),oe=z.properties.get("color-use-theme")==="none",ve=z.properties.get("color").toNonPremultipliedRenderColor(oe?null:Q.getLut(z.scope)).toArray01(),ge=z.properties.get("intensity"),be=W.properties.get("color-use-theme")==="none",Le=W.properties.get("color").toNonPremultipliedRenderColor(be?null:Q.getLut(W.scope)).toArray01(),Ee=W.properties.get("intensity"),We=[ae.x,ae.y,ae.z],Ue=i.dN(Le,Ee),st=i.dN(ve,ge);return{u_lighting_ambient_color:Ue,u_lighting_directional_dir:We,u_lighting_directional_color:st,u_ground_radiance:ib(We,st,Ue)}})(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 W=z.getOpacity(this.transform.pitch),Q=((ae,oe,ve,ge,be,Le,Ee,We,Ue,st,ut,it)=>{const Et=ae.transform,jt=oe.properties.get("color-use-theme")==="none",Tt=oe.properties.get("color").toNonPremultipliedRenderColor(jt?null:ae.style.getLut(oe.scope)).toArray01();Tt[3]=ge;const _t=ae.frameCounter/1e3%1,[gt,Ot]=oe.properties.get("vertical-range");return{u_fog_matrix:ve?Et.calculateFogTileMatrix(ve):it||ae.identityMat,u_fog_range:oe.getFovAdjustedRange(Et._fov),u_fog_color:Tt,u_fog_horizon_blend:oe.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(gt,Ot),Ot],u_fog_temporal_offset:_t,u_frustum_tl:be,u_frustum_tr:Le,u_frustum_br:Ee,u_frustum_bl:We,u_globe_pos:Ue,u_globe_radius:st,u_viewport:ut,u_globe_transition:i.aj(Et.zoom),u_is_globe:+(Et.projection.name==="globe")}})(this,z,A,W,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,Q)}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 Zm(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 W;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/((W=this.depthRangeFor3D)[1]-W[0]),-1-2*W[0]/(W[1]-W[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 j3(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 k6{constructor(h){this._hashName=h&&encodeURIComponent(h),i.aY(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=j3(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=zl(h);if(this._hashName){const A=this._hashName;let D=!1;const F=location.hash.slice(1).split("&").map(z=>{const W=z.split("=")[0];return W===A?(D=!0,`${W}=${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 zl(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,W=Math.round(y.lat*F)/F,Q=T.getBearing(),ae=T.getPitch();let oe=h?`/${z}/${W}/${A}`:`${A}/${W}/${z}`;return(Q||ae)&&(oe+="/"+Math.round(10*Q)/10),ae&&(oe+=`/${Math.round(ae)}`),oe}const mb={linearity:.3,easing:i.eT(0,0,.3,1)},S6=Object.assign({deceleration:2500,maxSpeed:1400},mb),C6=Object.assign({deceleration:20,maxSpeed:1400},mb),hv=Object.assign({deceleration:1e3,maxSpeed:360},mb),M6=Object.assign({deceleration:1e3,maxSpeed:90},mb);class T6{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=Hf(y.pan.mag(),A,Object.assign({},S6,h||{}));D.offset=y.pan.mult(F.amount/y.pan.mag()),D.center=this._map.transform.center,pb(D,F)}if(y.zoom){const F=Hf(y.zoom,A,C6);D.zoom=this._map.transform.zoom+F.amount,pb(D,F)}if(y.bearing){const F=Hf(y.bearing,A,hv);D.bearing=this._map.transform.bearing+i.aA(F.amount,-179,179),pb(D,F)}if(y.pitch){const F=Hf(y.pitch,A,M6);D.pitch=this._map.transform.pitch+F.amount,pb(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 pb(T,h){(!T.duration||T.durationy.unproject(Q)),W=F.reduce((Q,ae,oe,ve)=>Q.add(ae.div(ve.length)),new i.P(0,0));super(h,{points:F,point:W,lngLats:z,lngLat:y.unproject(W),originalEvent:A}),this._defaultPrevented=!1}}class A6 extends i.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(h,y){super("wheel",{originalEvent:y}),this._defaultPrevented=!1}}class N3{constructor(h,y){this._map=h,this._clickTolerance=y.clickTolerance}reset(){this._mousedownPos=void 0}wheel(h){return this._firePreventable(new A6(this._map,h))}mousedown(h,y){return this._mousedownPos=y,this._firePreventable(new dh(h.type,this._map,h))}mouseup(h){this._map.fire(new dh(h.type,this._map,h))}preclick(h){const y=new MouseEvent("preclick",h);this._map.fire(new dh(y.type,this._map,y))}click(h,y){this._mousedownPos&&this._mousedownPos.dist(y)>=this._clickTolerance||(this.preclick(h),this._map.fire(new dh(h.type,this._map,h)))}dblclick(h){return this._firePreventable(new dh(h.type,this._map,h))}mouseover(h){this._map.fire(new dh(h.type,this._map,h))}mouseout(h){this._map.fire(new dh(h.type,this._map,h))}touchstart(h){return this._firePreventable(new Iy(h.type,this._map,h))}touchmove(h){this._map.fire(new Iy(h.type,this._map,h))}touchend(h){this._map.fire(new Iy(h.type,this._map,h))}touchcancel(h){this._map.fire(new Iy(h.type,this._map,h))}_firePreventable(h){if(this._map.fire(h),h.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class E6{constructor(h){this._map=h}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(h){this._map.fire(new dh(h.type,this._map,h))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new dh("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(h){this._delayContextMenu?this._contextMenuEvent=h:this._map.fire(new dh(h.type,this._map,h)),this._map.listens("contextmenu")&&h.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class k3{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&&(I(),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,${Q}px)`,this._box.style.width=W-z+"px",this._box.style.height=ae-Q+"px")})}mouseupWindow(h,y){if(!this._active)return;const A=this._startPos,D=y;if(A&&h.button===0){if(this.reset(),q(),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),L(),delete this._startPos,delete this._lastPos}_fireEvent(h,y){return this._map.fire(new i.z(h,{originalEvent:y}))}}function S3(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=S3(A,y)))}touchmove(h,y,A){if(this.aborted||!this.centroid)return;const D=S3(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 C3{constructor(h){this.singleTap=new pF(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 fF{constructor(){this._zoomIn=new C3({numTouches:1,numTaps:2}),this._zoomOut=new C3({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 xF={0:1,2:2},P6={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class M3{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=xF[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=S3(A,y),F=new i.P(0,0),z=new i.P(0,0);let W=0;for(const ae in D){const oe=D[ae],ve=this._touches[ae];ve&&(F._add(oe),z._add(oe.sub(ve)),W++,D[ae]=oe)}if(this._touches=D,W{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class T3{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,W=p2(A,y,F),Q=p2(A,y,z);if(!W||!Q)return;const ae=this._aroundCenter?null:W.add(Q).div(2);return this._move([W,Q],ae,h)}touchend(h,y,A){if(!this._firstTwoTouches)return;const[D,F]=this._firstTwoTouches,z=p2(A,y,D),W=p2(A,y,F);z&&W||(this._active&&q(),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 p2(T,h,y){for(let A=0;AMath.abs(T.x)}class Ume extends T3{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,A3(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 A3(h)&&A3(y)&&z}}const Vme={panStep:100,bearingStep:15,pitchStep:10};class Hme{constructor(){const h=Vme;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:W=>{const Q=W.getZoom();W.easeTo({duration:300,easeId:"keyboardHandler",easing:f2,zoom:y?Math.round(Q)+y*(h.shiftKey?2:1):Q,bearing:W.getBearing()+A*this._bearingStep,pitch:W.getPitch()+D*this._pitchStep,offset:[-F*this._panStep,-z*this._panStep],center:W.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 f2(T){return T*(2-T)}const D6=4.000244140625,O6=1/450;class E3{constructor(h,y){this._map=h,this._el=h.getCanvasContainer(),this._handler=y,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=O6,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%D6==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)>D6?this._wheelZoomRate:this._defaultZoomRate;let oe=2/(1+Math.exp(-Math.abs(this._delta*ae)));this._delta<0&&oe!==0&&(oe=1/oe);const ve=y(),ge=Math.pow(2,ve),be=typeof this._targetZoom=="number"?h.zoomScale(this._targetZoom):ge;this._targetZoom=Math.min(h.maxZoom,Math.max(h.minZoom,h.scaleZoom(be*oe))),this._type==="wheel"&&(this._startZoom=ve,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,W=!1;if(this._type==="wheel"&&D&&F){const ae=Math.min((i.o.now()-this._lastWheelEventTime)/200,1),oe=F(ae);z=i.ak(D,A,oe),ae<1?this._frameId||(this._frameId=!0):W=!0}else z=A,W=!0;this._active=!0,W&&(this._active=!1,this._finishTimeout=window.setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200));let Q=z-y();return Q*this._lastDelta<0&&(Q=0),{noInertia:!0,needsRenderFrame:!W,zoomDelta:Q,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,W=Math.sqrt(.0729-z*z);y=i.eT(z,W,.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=j("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 og{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 P3{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 Bl{constructor(){this._tap=new C3({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 Wf{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 x2{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 I3{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 g2=T=>T.zoom||T.drag||T.pitch||T.rotate;class Wme extends i.z{}class y2{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 L3(T){return T.panDelta&&T.panDelta.mag()||T.zoomDelta||T.bearingDelta||T.pitchDelta}class Gme{constructor(h,y){this._map=h,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new T6(h),this._bearingSnap=y.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new y2,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 W=D===document?this.handleWindowEvent:this.handleEvent;D.addEventListener(F,W,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 N3(y,h));const D=y.boxZoom=new k3(y,h);this._add("boxZoom",D);const F=new fF,z=new P3;y.doubleClickZoom=new og(z,F),this._add("tapZoom",F),this._add("clickZoom",z);const W=new Bl;this._add("tapDragZoom",W);const Q=y.touchPitch=new Ume(y);this._add("touchPitch",Q);const ae=new I6(h),oe=new L6(h);y.dragRotate=new x2(h,ae,oe),this._add("mouseRotate",ae,["mousePitch"]),this._add("mousePitch",oe,["mouseRotate"]);const ve=new gF(h),ge=new yF(y,h);y.dragPan=new Wf(A,ve,ge),this._add("mousePan",ve),this._add("touchPan",ge,["touchZoom","touchRotate"]);const be=new bo,Le=new qme;y.touchZoomRotate=new I3(A,Le,be,W),this._add("touchRotate",be,["touchPan","touchZoom"]),this._add("touchZoom",Le,["touchPan","touchRotate"]),this._add("blockableMapEvent",new E6(y));const Ee=y.scrollZoom=new E3(y,this);this._add("scrollZoom",Ee,["mousePan"]);const We=y.keyboard=new Hme;this._add("keyboard",We);for(const Ue of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])h.interactive&&h[Ue]&&y[Ue].enable(h[Ue])}_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!!g2(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={},W={},Q=h.touches?this._getMapTouches(h.touches):void 0,ae=Q?B(this._el,Q):A?void 0:U(this._el,h);for(const{handlerName:ge,handler:be,allowed:Le}of this._handlers){if(!be.isEnabled())continue;let Ee;this._blockedByActive(W,Le,ge)?be.reset():be[y||h.type]&&(Ee=be[y||h.type](h,ae,Q),this.mergeHandlerResult(F,z,Ee,ge,D),Ee&&Ee.needsRenderFrame&&this._triggerRenderFrame()),(Ee||be.isActive())&&(W[ge]=be)}const oe={};for(const ge in this._previousActiveHandlers)W[ge]||(oe[ge]=D);this._previousActiveHandlers=W,(Object.keys(oe).length||L3(F))&&(this._changes.push([F,z,oe]),this._triggerRenderFrame()),(Object.keys(W).length||L3(F))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ve}=F;ve&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ve(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=st=>[st.x,st.y,st.z];if((st=>{const ut=this._eventsInProgress.drag;return ut&&!this._handlersById[ut.handlerName].isActive()})()&&!L3(h)){const st=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"),st!==F.zoom&&this._map._update(!0)}if(F._isCameraConstrained&&D._stop(!0),!L3(h))return void this._fireEvents(y,A,!0);let{panDelta:W,zoomDelta:Q,bearingDelta:ae,pitchDelta:oe,around:ve,aroundCoord:ge,pinchAround:be}=h;F._isCameraConstrained&&(Q>0&&(Q=0),F._isCameraConstrained=!1),be!==void 0&&(ve=be),(Q||(st=>y[st]&&!this._eventsInProgress[st])("drag"))&&ve&&(this._dragOrigin=z(F.pointCoordinate3D(ve)),this._originalZoom=F.zoom,this._trackingEllipsoid.setup(F._camera.position,this._dragOrigin)),F.cameraElevationReference="sea",D._stop(!0),ve=ve||D.transform.centerPoint,ae&&(F.bearing+=ae),oe&&(F.pitch+=oe),F._updateCameraState();const Le=[0,0,0];if(W)if(F.projection.name==="mercator"){const st=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ve).dir),ut=this._trackingEllipsoid.projectRay(F.screenPointToMercatorRay(ve.sub(W)).dir);Le[0]=ut[0]-st[0],Le[1]=ut[1]-st[1]}else{const st=F.pointCoordinate(ve);if(F.projection.name==="globe"){W=W.rotate(-F.angle);const ut=F._pixelsPerMercatorPixel/F.worldSize;Le[0]=-W.x*i.eW(i.a$(st.y))*ut,Le[1]=-W.y*i.eW(F.center.lat)*ut}else{const ut=F.pointCoordinate(ve.sub(W));st&&ut&&(Le[0]=ut.x-st.x,Le[1]=ut.y-st.y)}}const Ee=F.zoom,We=[0,0,0];if(Q){const st=z(ge||F.pointCoordinate3D(ve)),ut={dir:i.aw([],i.av([],st,F._camera.position))};if(ut.dir[2]<0){const it=F.zoomDeltaToMovement(st,Q);i.c5(We,ut.dir,it)}}const Ue=i.d8(Le,Le,We);F._translateCameraConstrained(Ue),Q&&Math.abs(F.zoom-Ee)>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=g2(this._eventsInProgress),F=g2(h),z={};for(const oe in h){const{originalEvent:ve}=h[oe];this._eventsInProgress[oe]||(z[`${oe}start`]=ve),this._eventsInProgress[oe]=h[oe]}!D&&F&&this._fireEvent("movestart",F.originalEvent);for(const oe in z)this._fireEvent(oe,z[oe]);F&&this._fireEvent("move",F.originalEvent);for(const oe in h){const{originalEvent:ve}=h[oe];this._fireEvent(oe,ve)}const W={};let Q;for(const oe in this._eventsInProgress){const{handlerName:ve,originalEvent:ge}=this._eventsInProgress[oe];this._handlersById[ve].isActive()||(delete this._eventsInProgress[oe],Q=y[ve]||ge,W[`${oe}end`]=Q)}for(const oe in W)this._fireEvent(oe,W[oe]);const ae=g2(this._eventsInProgress);if(A&&(D||F)&&!ae){this._updatingCamera=!0;const oe=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),ve=ge=>ge!==0&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Wme("renderFrame",{timeStamp:h})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const D3="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class R6 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 W=h.clone(),Q=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ae=i.aT.convert(y),oe=i.aT.convert(A),ve=.5*(ae.lat+oe.lat),ge=.5*(ae.lng+oe.lng),be=i.eZ(ve,ge),Le=i.aw([],be),Ee=i.aw([],i.bI([],Le,[0,1,0])),We=i.bI([],Ee,Le),Ue=[Ee[0],Ee[1],Ee[2],0,We[0],We[1],We[2],0,Le[0],Le[1],Le[2],0,0,0,0,1],st=[be,i.eZ(ae.lat,ae.lng),i.eZ(oe.lat,ae.lng),i.eZ(oe.lat,oe.lng),i.eZ(ae.lat,oe.lng),i.eZ(ve,ae.lng),i.eZ(ve,oe.lng),i.eZ(ae.lat,ge),i.eZ(oe.lat,ge)];let ut=i.d9.fromPoints(st.map(Jt=>[i.bJ(Ee,Jt),i.bJ(We,Jt),i.bJ(Le,Jt)]));const it=i.af([],ut.center,Ue);i.e_(it)===0&&i.e$(it,0,0,1),i.aw(it,it),i.c5(it,it,i.aD),W.center=i.f0(it);const Et=W.getWorldToCameraMatrix(),jt=i.bl(new Float64Array(16),Et);ut=i.d9.applyTransform(ut,i.aB([],Et,Ue));const Tt=this._extendAABB(ut,W,Q,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");ut=Tt,i.af(it,it,Et);const _t=.5*(ut.max[2]-ut.min[2]),gt=this._minimumAABBFrustumDistance(W,ut),Ot=i.c5([],[0,0,1],_t),Wt=i.d8(Ot,it,Ot),Ht=gt+(W.pitch===0?0:i.bG(it,Wt)),ss=W.globeCenterInViewSpace,rs=i.av([],it,[ss[0],ss[1],ss[2]]);i.aw(rs,rs),i.c5(rs,rs,Ht);const gs=i.d8([],it,rs);i.af(gs,gs,jt);const $s=i.eM/i.aD,Xt=i.ag(gs),Bt=i.cf(Math.max(Xt*$s-i.eM,Number.EPSILON),0),is=Math.min(W.zoomFromMercatorZAdjusted(Bt),Q.maxZoom);return is>.5*(i.c_+i.cL)?(W.setProjection({name:"mercator"}),W.zoom=is,this._cameraForBounds(W,y,A,D,F,z)):{center:W.center,zoom:is,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)),W=z,Q=F,ae=F,oe=z,ve=y.width-(Q+ae),ge=y.height-(W+oe),be=i.av([],h.max,h.min),Le=Math.min(ve/be[0],ge/be[1]),Ee=Math.min(y.scaleZoom(y.scale*Le),A.maxZoom);if(isNaN(Ee))return null;const We=y.scale/y.zoomScale(Ee),Ue=new i.d9([h.min[0]-Q*We,h.min[1]-oe*We,h.min[2]],[h.max[0]+ae*We,h.max[1]+W*We,h.max[2]]),st=(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 Ue.center[0]-=st.x*We,Ue.center[1]+=st.y*We,Ue}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 W=h.clone(),Q=this._extendCameraOptions(z);W.bearing=D,W.pitch=F;const ae=i.aT.convert(y),oe=i.aT.convert(A),ve=new i.aT(ae.lng,oe.lat),ge=new i.aT(oe.lng,ae.lat),be=W.project(ae),Le=W.project(oe),Ee=this.queryTerrainElevation(ae),We=this.queryTerrainElevation(oe),Ue=this.queryTerrainElevation(ve),st=this.queryTerrainElevation(ge),ut=[[be.x,be.y,Math.min(Ee||0,We||0,Ue||0,st||0)],[Le.x,Le.y,Math.max(Ee||0,We||0,Ue||0,st||0)]];let it=i.d9.fromPoints(ut);const Et=W.getWorldToCameraMatrix(),jt=i.bl(new Float64Array(16),Et);it=i.d9.applyTransform(it,Et);const Tt=this._extendAABB(it,W,Q,D);if(!Tt)return void i.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");it=Tt;const _t=.5*i.av([],it.max,it.min)[2],gt=this._minimumAABBFrustumDistance(W,it),Ot=[0,0,1,0];i.aC(Ot,Ot,Et),i.f1(Ot,Ot);const Wt=i.c5([],Ot,gt+_t),Ht=i.d8([],it.center,Wt);i.af(it.center,it.center,jt),i.af(Ht,Ht,jt);const ss=W.unproject(new i.P(it.center[0],it.center[1])),rs=i.f2(W.projection,ss),gs=Math.pow(2,rs),$s=Math.min(W._zoomFromMercatorZ(Ht[2]*W.pixelsPerMeter*gs/W.worldSize),Q.maxZoom);return W.mercatorFromTransition&&$s<.5*(i.c_+i.cL)?(W.setProjection({name:"globe"}),W.zoom=$s,this._cameraForBounds(W,y,A,D,F,z)):{center:ss,zoom:$s,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),W=i.P.convert(y),Q=new i.P(Math.min(z.x,W.x),Math.min(z.y,W.y)),ae=new i.P(Math.max(z.x,W.x),Math.max(z.y,W.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(z,W))return this;const oe=this.transform.pointLocation3D(Q),ve=this.transform.pointLocation3D(ae),ge=this.transform.pointLocation3D(new i.P(Q.x,ae.y)),be=this.transform.pointLocation3D(new i.P(ae.x,Q.y)),Le=[Math.min(oe.lng,ve.lng,ge.lng,be.lng),Math.min(oe.lat,ve.lat,ge.lat,be.lat)],Ee=[Math.max(oe.lng,ve.lng,ge.lng,be.lng),Math.max(oe.lat,ve.lat,ge.lat,be.lat)],We=D&&D.pitch?D.pitch:this.getPitch(),Ue=this._cameraForBounds(this.transform,Le,Ee,A,We,D);return this._fitInternal(Ue,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 W=typeof h.padding=="number"?this._extendPadding(h.padding):h.padding;if(h.padding!=null&&!A.isPaddingEqual(W))if(h.retainPadding===!1){const Q=A.clone();Q.padding=W,A.setLocationAtPoint(A.center,Q.centerPoint)}else A.padding=W;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(D3),this.transform.getFreeCameraOptions()}setFreeCameraOptions(h,y){const A=this.transform;if(!A.projection.supportsFreeCamera)return i.w(D3),this;this.stop();const D=A.zoom,F=A.pitch,z=A.bearing;A.setFreeCameraOptions(h);const W=D!==A.zoom,Q=F!==A.pitch,ae=z!==A.bearing;return this.fire(new i.z("movestart",y)).fire(new i.z("move",y)),W&&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)),Q&&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(),W=this.getPadding(),Q="zoom"in h?+h.zoom:D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ve=this._extendPadding(h.padding),ge=i.P.convert(h.offset);let be,Le,Ee;if(A.projection.name==="globe"){const Ot=i.ae.fromLngLat(A.center),Wt=ge.rotate(-A.angle);Ot.x+=Wt.x/A.worldSize,Ot.y+=Wt.y/A.worldSize;const Ht=Ot.toLngLat(),ss=i.aT.convert(h.center||Ht);this._normalizeCenter(ss),be=A.centerPoint.add(Wt),Le=new i.P(Ot.x,Ot.y).mult(A.worldSize),Ee=new i.P(i.aF(ss.lng),i.aJ(ss.lat)).mult(A.worldSize).sub(Le)}else{be=A.centerPoint.add(ge);const Ot=A.pointLocation(be),Wt=i.aT.convert(h.center||Ot);this._normalizeCenter(Wt),Le=A.project(Ot),Ee=A.project(Wt).sub(Le)}const We=A.zoomScale(Q-D);let Ue,st;h.around&&(Ue=i.aT.convert(h.around),st=A.locationPoint(Ue));const ut=this._zooming||Q!==D,it=this._rotating||F!==ae,Et=this._pitching||oe!==z,jt=!A.isPaddingEqual(ve),Tt=h.retainPadding===!1?A.clone():A,_t=Ot=>Wt=>{if(ut&&(Ot.zoom=i.ak(D,Q,Wt)),it&&(Ot.bearing=i.ak(F,ae,Wt)),Et&&(Ot.pitch=i.ak(z,oe,Wt)),jt&&(Tt.interpolatePadding(W,ve,Wt),be=Tt.centerPoint.add(ge)),Ue)Ot.setLocationAtPoint(Ue,st);else{const Ht=Ot.zoomScale(Ot.zoom-D),ss=Q>D?Math.min(2,We):Math.max(.5,We),rs=Math.pow(ss,1-Wt),gs=Ot.unproject(Le.add(Ee.mult(Wt*rs)).mult(Ht));Ot.setLocationAtPoint(Ot.renderWorldCopies?gs.wrap():gs,be)}return h.preloadOnly||this._fireMoveEvents(y),Ot};if(h.preloadOnly){const Ot=this._emulate(_t,h.duration,A);return this._preloadTiles(Ot),this}const gt={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=ut,this._rotating=it,this._pitching=Et,this._padding=jt,this._easeId=h.easeId,this._prepareEase(y,h.noMoveStart,gt),this._ease(_t(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(),W=this.getPadding(),Q="zoom"in h?i.aA(+h.zoom,A.minZoom,A.maxZoom):D,ae="bearing"in h?this._normalizeBearing(h.bearing,F):F,oe="pitch"in h?+h.pitch:z,ve=this._extendPadding(h.padding),ge=A.zoomScale(Q-D),be=i.P.convert(h.offset);let Le=A.centerPoint.add(be);const Ee=A.pointLocation(Le),We=i.aT.convert(h.center||Ee);this._normalizeCenter(We);const Ue=A.project(Ee),st=A.project(We).sub(Ue);let ut=h.curve;const it=Math.max(A.width,A.height),Et=it/ge,jt=st.mag();if("minZoom"in h){const Jt=i.aA(Math.min(h.minZoom,D,Q),A.minZoom,A.maxZoom),Ps=it/A.zoomScale(Jt-D);ut=Math.sqrt(Ps/jt*2)}const Tt=ut*ut;function _t(Jt){const Ps=(Et*Et-it*it+(Jt?-1:1)*Tt*Tt*jt*jt)/(2*(Jt?Et:it)*Tt*jt);return Math.log(Math.sqrt(Ps*Ps+1)-Ps)}function gt(Jt){return(Math.exp(Jt)-Math.exp(-Jt))/2}function Ot(Jt){return(Math.exp(Jt)+Math.exp(-Jt))/2}const Wt=_t(0);let Ht=function(Jt){return Ot(Wt)/Ot(Wt+ut*Jt)},ss=function(Jt){return it*((Ot(Wt)*(gt(Ps=Wt+ut*Jt)/Ot(Ps))-gt(Wt))/Tt)/jt;var Ps},rs=(_t(1)-Wt)/ut;if(Math.abs(jt)<1e-6||!isFinite(rs)){if(Math.abs(it-Et)<1e-6)return this.easeTo(h,y);const Jt=Eth.maxDuration&&(h.duration=0);const gs=F!==ae,$s=oe!==z,Xt=!A.isPaddingEqual(ve),Bt=h.retainPadding===!1?A.clone():A,is=Jt=>Ps=>{const rr=Ps*rs,gr=1/Ht(rr);Jt.zoom=Ps===1?Q:D+Jt.scaleZoom(gr),gs&&(Jt.bearing=i.ak(F,ae,Ps)),$s&&(Jt.pitch=i.ak(z,oe,Ps)),Xt&&(Bt.interpolatePadding(W,ve,Ps),Le=Bt.centerPoint.add(be));const er=Ps===1?We:Jt.unproject(Ue.add(st.mult(ss(rr))).mult(gr));return Jt.setLocationAtPoint(Jt.renderWorldCopies?er.wrap():er,Le),Jt._updateCameraOnTerrain(),h.preloadOnly||this._fireMoveEvents(y),Jt};if(h.preloadOnly){const Jt=this._emulate(is,h.duration,A);return this._preloadTiles(Jt),this}return this._zooming=!0,this._rotating=gs,this._pitching=$s,this._padding=Xt,this._prepareEase(y,!1),this._ease(is(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 W=0;W<=D;W++){const Q=z(W/D);F.push(Q.clone())}return F}_preloadTiles(h,y){}}class v2{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=j("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=j("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=j("span","mapboxgl-ctrl-icon",this._compactButton);return D.setAttribute("aria-hidden","true"),D.setAttribute("title",A),this._innerContainer=j("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(W=>{const Q=W.textContent||"";if(W.tagName!=="A")return void W.replaceWith(z.createTextNode(Q));const ae=W.getAttribute("href");if(!ae||!/^(https?:|mailto:)/i.test(ae))return void W.replaceWith(z.createTextNode(Q));const oe=z.createElement("a");oe.href=ae,oe.textContent=Q,oe.rel="noopener nofollow";const ve=W.getAttribute("class");ve&&(oe.className=ve),W.replaceWith(oe)}),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 b2{constructor(){i.aY(["_updateLogo","_updateCompact"],this)}onAdd(h){this._map=h,this._container=j("div","mapboxgl-ctrl");const y=j("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 fb{constructor(){i.aY(["_onIndoorUpdate"],this)}onAdd(h){return this._map=h,this._container=j("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",y=>this._onIndoorUpdate(y)),this._container}_createButton(h,y){const A=j("button",h,this._container);return A.type="button",A.addEventListener("click",y),A}_createSeparator(){return j("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)});j("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 dg={"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 Ly extends i.z{constructor(h,y,A,D){const{point:F,lngLat:z,originalEvent:W,target:Q}=h;super(h.type,{point:F,lngLat:z,originalEvent:W,target:Q}),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 W=new Set;for(const Q of y){for(const[ae,oe]of D){if(!oe.target)continue;const ve=Q.variants?Q.variants[ae]:null;if(ve){for(const ge of ve){if(gy(ge,Q,W,ae))continue;const be=new i.dx(Q,ge),Le=Kx(ge,Q,ae);F&&be.id!==void 0&&(be.state=this.map.getFeatureState(be));const Ee=A?this.prevHoveredFeatures.get(Le):null,We=new Ly(h,ae,oe,be),Ue=Ee?Ee.stop:oe.handler(We);if(A&&this.hoveredFeatures.set(Le,{feature:Q,stop:Ue}),Ue!==!1){z=!0;break}}if(z)break}}if(z)break}if(!z)for(const[Q,ae]of D){const{handler:oe,target:ve}=ae;if(!ve&&oe(new Ly(h,Q,ae,null))!==!1)break}}}function Kme(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 Zme={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"},Yme={showCompass:!0,showZoom:!0,visualizePitch:!1};class Xme{constructor(h,y,A=!1){this._clickTolerance=10,this.element=y,this.mouseRotate=new I6({clickTolerance:h.dragRotate._mouseRotate._clickTolerance}),this.map=h,A&&(this.mousePitch=new L6({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),I()}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),W=z&&z.pitchDelta;W&&A.setPitch(A.getPitch()+W)}}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(){L(),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 qd={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%)"},tp={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class O3 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:W=0,rotation:Q=tp.rotation,rotationAlignment:ae=tp.rotationAlignment,pitchAlignment:oe=tp.pitchAlignment,occludedOpacity:ve=tp.occludedOpacity,altitude:ge=tp.altitude}=h||{};this._anchor=A,this._color=D,this._scale=F,this._draggable=z,this._clickTolerance=W,this._rotation=Q,this._rotationAlignment=ae,this._pitchAlignment=oe,this._occludedOpacity=ve,this._altitude=ge,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",Ee=>{Ee.preventDefault()}),this._element.addEventListener("mousedown",Ee=>{Ee.preventDefault()});const be=this._element.classList;for(const Ee in qd)be.remove(`mapboxgl-marker-anchor-${Ee}`);be.add(`mapboxgl-marker-anchor-${this._anchor}`);const Le=h&&h.className?h.className.trim().split(/\s+/):[];be.add(...Le),this._popup=null}_createDefaultMarker(){const h=j("div"),y=w("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=w("radialGradient",{id:"shadowGradient"},w("defs",{},y));w("stop",{offset:"10%","stop-opacity":.4},A),w("stop",{offset:"100%","stop-opacity":.05},A),w("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},y)}return w("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),w("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),w("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||tp.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) ${qd[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 Q=y.getPitch();return Q?`rotateX(${Q}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 W=D/z;return`rotateX(${-F.y*W}deg) rotateY(${F.x*W}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 W=h.sub(z),Q=i.cX(Math.atan2(W.y,W.x));A=(Q>90?Q-270:Q+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=F6(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 qE(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 lg,this._domRenderTaskQueue=new lg,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.b2(),this._locale=Object.assign({},dg,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 cg(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=T.scaleFactor,this._requestManager=new X(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 Gme(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 k6(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 v2({customAttribution:T.customAttribution})),this._logoControl=new b2,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(W=>this.getLayer(W));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 W=A(z.point);W.length?D||(D=!0,y.call(this,new dh(T,this,z.originalEvent,{features:W}))):D=!1},mouseout:()=>{D=!1}}}}if(T==="mouseleave"||T==="mouseout"){let D=!1;return{listener:y,targets:h,delegates:{mousemove:W=>{A(W.point).length?D=!0:D&&(D=!1,y.call(this,new dh(T,this,W.originalEvent)))},mouseout:W=>{D&&(D=!1,y.call(this,new dh(T,this,W.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 ep(this,y).load(T),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new ep(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 W=i.I.from(T);if(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap){const{width:Q,height:ae,data:oe}=i.o.getImageData(h);this.style.addImage(W,{data:new i.q({width:Q,height:ae},oe),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:Q,height:ae}=h,oe=h;this.style.addImage(W,{data:new i.q({width:Q,height:ae},new Uint8Array(oe.data)),pixelRatio:y,stretchX:D,stretchY:F,content:z,sdf:A,usvg:!1,version:0,userImage:oe}),oe.onAdd&&oe.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:W}=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 Q=!(h instanceof HTMLImageElement||ImageBitmap&&h instanceof ImageBitmap);let ae=!1;A.usvg?(A.data=new i.q({width:F,height:z},new Uint8Array(W)),A.usvg=!1,A.icon=void 0,ae=!0):A.data.replace(W,Q),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 fb),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 MR(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=j("div","mapboxgl-canary",T)).style.visibility="hidden",this._detectMissingCSS();const h=this._canvasContainer=j("div","mapboxgl-canvas-container",T);this._canvas=j("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=j("div","mapboxgl-control-container",T),A=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(D=>{A[D]=j("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?(et(h,!0),this.painter=new w3(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,oe=this.transform.pitch,ve=i.o.now(),ge=new i.ac(ae,{now:ve,fadeDuration:F,pitch:oe,transition:this.style.transition,worldview:this._worldview});this.style.update(ge)}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 W=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),W&&(this._placementDirty=W.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 oe=D.getQueryParameter(h,D.QUERY_RESULT)/1e6;D.deleteQuery(h),this.fire(new i.z("gpu-timing-frame",{cpuTime:ae,gpuTime:oe}))},50)}if(this.listens("gpu-timing-layer")){const ae=this.painter.collectGpuTimers();setTimeout(()=>{const oe=this.painter.queryGpuTimers(ae);this.fire(new i.z("gpu-timing-layer",{layerTimes:oe}))},50)}if(this.listens("gpu-timing-deferred-render")){const ae=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const oe=this.painter.queryGpuTimeDeferredRender(ae);this.fire(new i.z("gpu-timing-deferred-render",{gpuTime:oe}))},50)}const Q=this._sourcesDirty||this._styleDirty||this._placementDirty||z;if(Q||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 oe=this._calculateSpeedIndex();this.fire(new i.z("speedindexcompleted",{speedIndex:oe})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||Q||(this._fullyLoaded=!0,p.mark(u.fullLoad),this._performanceMetricsCollection&&ft(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(){Ve(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,T=>{if(T&&(T.message===te||T.status===401)){const h=this.painter.context.gl;et(h,!1),this._logoControl instanceof b2&&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/")))}}),Ne(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&Fe(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&Me(this._requestManager._customAccessToken)}_postAddingAppearancesToStyleEvent(){ct(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({},Yme,T),this._container=j("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})}),j("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})}),j("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=j("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 Xme(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=j("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},Qme,T),i.aY(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=j3(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(T){return this._map=T,this._container=j("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=j("button","mapboxgl-ctrl-geolocate",this._container),j("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=j("div","mapboxgl-user-location"),this._dotElement.appendChild(j("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(j("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new O3({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=j("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new O3({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:v2,ScaleControl:class{constructor(T={}){this.options=Object.assign({},xb,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 W=3.2808*z;W>5280?this._setScale(T,W/5280,"mile"):this._setScale(T,W,"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 W=F/z;return W=W>=10?10:W>=5?5:W>=3?3:W>=2?2:W>=1?1:function(Q){const ae=Math.pow(10,Math.ceil(-Math.log(Q)/Math.LN10));return Math.round(Q*ae)/ae}(W),z*W}(h),D=A/h;this._container.innerHTML=y!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:y}).format(A):`${A} ${z6[y]}`,this._container.style.width=T*D+"px"})}onAdd(T){return this._map=T,this._language=T.getLanguage(),this._container=j("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=j("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=j("button","mapboxgl-ctrl-fullscreen",this._controlContainer);j("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:fb,Popup:class extends i.E{constructor(T){super(),this.options=Object.assign(Object.create(sp),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=j("div","mapboxgl-popup-content",this._container||void 0);if(h.appendChild(T),this.options.closeButton){const y=this._closeButton=j("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(W)return"bottom-right"}return z?"left":W?"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=j("div","mapboxgl-popup",h.getContainer()),this._tip=j("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=F6(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=mv(this.options.offset),z=this._anchor=this._getAnchor(F.y),W=mv(this.options.offset,z),Q=D.add(W).round();h._requestDomTask(()=>{this._container&&z&&(this._container.style.transform=`${qd[z]} translate(${Q.x}px,${Q.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(rp);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:O3,Style:ep,LngLat:i.aT,LngLatBounds:i.aI,Point:i.P,MercatorCoordinate:i.ae,FreeCameraOptions:Ou,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})})(dWe);var mNt=dWe.exports;const xl=Ao(mNt);function vs({className:t,...s}){return e.jsx("div",{className:Pt("animate-pulse rounded-md bg-muted",t),...s})}const QEe={coming_soon:"#3B82F6",active:"#10B981",price_improvement:"#F97316",under_contract:"#8B5CF6",sold:"#6B7280"},JEe={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function pNt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function fNt({listings:t,isLoading:s}){const r=pr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),[l,i]=k.useState(""),[c,u]=k.useState(!0);return k.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)})()},[]),k.useEffect(()=>{if(!n.current||!l||a.current)return;xl.accessToken=l;const f=t.filter(_=>_.latitude!=null&&_.longitude!=null);let g=[-98.5795,39.8283],b=4;if(f.length>0){const _=f.reduce((w,N)=>w+N.longitude,0)/f.length,j=f.reduce((w,N)=>w+N.latitude,0)/f.length;g=[_,j],b=f.length===1?12:10}return a.current=new xl.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:b,center:g}),a.current.addControl(new xl.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[l]),k.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 I,L,R;const b=QEe[g.status]||"#10B981",_=((I=g.photos)==null?void 0:I.find(q=>q.is_primary))||((L=g.photos)==null?void 0:L[0]),w=window.location.hostname==="listings.relevelup.com"||window.location.hostname.startsWith("listings.")?`/${g.slug||g.id}`:`/public/listing/${g.slug||g.id}`,N=document.createElement("div");N.className="cursor-pointer",N.innerHTML=`
`;const C=new xl.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${_!=null&&_.photo_url?``:""}
${pNt(g.price)}
${g.property_address||""}
${g.city}, ${g.state}
${JEe[g.status]||g.status} ${g.bedrooms?`${g.bedrooms} bed`:""} ${g.bathrooms?`${g.bathrooms} bath`:""}
${(R=g.agent)!=null&&R.name?`
Listed by ${g.agent.name}
`:""}
Click to view details →
`),M=new xl.Marker(N).setLngLat([g.longitude,g.latitude]).setPopup(C).addTo(a.current);o.current.push(M)}),f.length>1){const g=new xl.LngLatBounds;f.forEach(b=>g.extend([b.longitude,b.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]),k.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(QEe).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:JEe[f]})]},f))}),e.jsx("div",{ref:n,className:"w-full h-[500px] rounded-lg shadow-lg border border-gray-200"})]})}function Y8(t,[s,r]){return Math.min(r,Math.max(s,t))}function AO(t){const s=k.useRef({value:t,previous:t});return k.useMemo(()=>(s.current.value!==t&&(s.current.previous=s.current.value,s.current.value=t),s.current.previous),[t])}var xNt=[" ","Enter","ArrowUp","ArrowDown"],gNt=[" ","Enter"],DS="Select",[$de,qde,yNt]=pO(DS),[KA]=nd(DS,[yNt,L0]),Ude=L0(),[vNt,Mw]=KA(DS),[bNt,_Nt]=KA(DS),hWe=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:b,form:_}=t,j=Ude(s),[w,N]=k.useState(null),[C,M]=k.useState(null),[I,L]=k.useState(!1),R=Sw(u),[q,U]=rh({prop:n,defaultProp:a??!1,onChange:o,caller:DS}),[B,V]=rh({prop:l,defaultProp:i,onChange:c,caller:DS}),Y=k.useRef(null),J=w?_||!!w.closest("form"):!0,[te,X]=k.useState(new Set),ce=Array.from(te).map(ne=>ne.props.value).join(";");return e.jsx(yO,{...j,children:e.jsxs(vNt,{required:b,scope:s,trigger:w,onTriggerChange:N,valueNode:C,onValueNodeChange:M,valueNodeHasChildren:I,onValueNodeHasChildrenChange:L,contentId:Mu(),value:B,onValueChange:V,open:q,onOpenChange:U,dir:R,triggerPointerDownPosRef:Y,disabled:g,children:[e.jsx($de.Provider,{scope:s,children:e.jsx(bNt,{scope:t.__scopeSelect,onNativeOptionAdd:k.useCallback(ne=>{X(re=>new Set(re).add(ne))},[]),onNativeOptionRemove:k.useCallback(ne=>{X(re=>{const le=new Set(re);return le.delete(ne),le})},[]),children:r})}),J?e.jsxs(OWe,{"aria-hidden":!0,required:b,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(te)]},ce):null]})})};hWe.displayName=DS;var mWe="SelectTrigger",pWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,disabled:n=!1,...a}=t,o=Ude(r),l=Mw(mWe,r),i=l.disabled||n,c=$a(s,l.onTriggerChange),u=qde(r),p=k.useRef("touch"),[f,g,b]=FWe(j=>{const w=u().filter(M=>!M.disabled),N=w.find(M=>M.value===l.value),C=zWe(w,j,N);C!==void 0&&l.onValueChange(C.value)}),_=j=>{i||(l.onOpenChange(!0),b()),j&&(l.triggerPointerDownPosRef.current={x:Math.round(j.pageX),y:Math.round(j.pageY)})};return e.jsx(BA,{asChild:!0,...o,children:e.jsx(sn.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":RWe(l.value)?"":void 0,...a,ref:c,onClick:Ir(a.onClick,j=>{j.currentTarget.focus(),p.current!=="mouse"&&_(j)}),onPointerDown:Ir(a.onPointerDown,j=>{p.current=j.pointerType;const w=j.target;w.hasPointerCapture(j.pointerId)&&w.releasePointerCapture(j.pointerId),j.button===0&&j.ctrlKey===!1&&j.pointerType==="mouse"&&(_(j),j.preventDefault())}),onKeyDown:Ir(a.onKeyDown,j=>{const w=f.current!=="";!(j.ctrlKey||j.altKey||j.metaKey)&&j.key.length===1&&g(j.key),!(w&&j.key===" ")&&xNt.includes(j.key)&&(_(),j.preventDefault())})})})});pWe.displayName=mWe;var fWe="SelectValue",xWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,children:o,placeholder:l="",...i}=t,c=Mw(fWe,r),{onValueNodeHasChildrenChange:u}=c,p=o!==void 0,f=$a(s,c.onValueNodeChange);return wd(()=>{u(p)},[u,p]),e.jsx(sn.span,{...i,ref:f,style:{pointerEvents:"none"},children:RWe(c.value)?e.jsx(e.Fragment,{children:l}):o})});xWe.displayName=fWe;var wNt="SelectIcon",gWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,children:n,...a}=t;return e.jsx(sn.span,{"aria-hidden":!0,...a,ref:s,children:n||"▼"})});gWe.displayName=wNt;var jNt="SelectPortal",yWe=t=>e.jsx(OA,{asChild:!0,...t});yWe.displayName=jNt;var OS="SelectContent",vWe=k.forwardRef((t,s)=>{const r=Mw(OS,t.__scopeSelect),[n,a]=k.useState();if(wd(()=>{a(new DocumentFragment)},[]),!r.open){const o=n;return o?gp.createPortal(e.jsx(bWe,{scope:t.__scopeSelect,children:e.jsx($de.Slot,{scope:t.__scopeSelect,children:e.jsx("div",{children:t.children})})}),o):null}return e.jsx(_We,{...t,ref:s})});vWe.displayName=OS;var Mg=10,[bWe,Tw]=KA(OS),NNt="SelectContentImpl",kNt=aw("SelectContent.RemoveScroll"),_We=k.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:b,sticky:_,hideWhenDetached:j,avoidCollisions:w,...N}=t,C=Mw(OS,r),[M,I]=k.useState(null),[L,R]=k.useState(null),q=$a(s,Fe=>I(Fe)),[U,B]=k.useState(null),[V,Y]=k.useState(null),J=qde(r),[te,X]=k.useState(!1),ce=k.useRef(!1);k.useEffect(()=>{if(M)return Ide(M)},[M]),Ade();const ne=k.useCallback(Fe=>{const[Ce,...Me]=J().map(Te=>Te.ref.current),[$e]=Me.slice(-1),ct=document.activeElement;for(const Te of Fe)if(Te===ct||(Te==null||Te.scrollIntoView({block:"nearest"}),Te===Ce&&L&&(L.scrollTop=0),Te===$e&&L&&(L.scrollTop=L.scrollHeight),Te==null||Te.focus(),document.activeElement!==ct))return},[J,L]),re=k.useCallback(()=>ne([U,M]),[ne,U,M]);k.useEffect(()=>{te&&re()},[te,re]);const{onOpenChange:le,triggerPointerDownPosRef:pe}=C;k.useEffect(()=>{if(M){let Fe={x:0,y:0};const Ce=$e=>{var ct,Te;Fe={x:Math.abs(Math.round($e.pageX)-(((ct=pe.current)==null?void 0:ct.x)??0)),y:Math.abs(Math.round($e.pageY)-(((Te=pe.current)==null?void 0:Te.y)??0))}},Me=$e=>{Fe.x<=10&&Fe.y<=10?$e.preventDefault():M.contains($e.target)||le(!1),document.removeEventListener("pointermove",Ce),pe.current=null};return pe.current!==null&&(document.addEventListener("pointermove",Ce),document.addEventListener("pointerup",Me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",Ce),document.removeEventListener("pointerup",Me,{capture:!0})}}},[M,le,pe]),k.useEffect(()=>{const Fe=()=>le(!1);return window.addEventListener("blur",Fe),window.addEventListener("resize",Fe),()=>{window.removeEventListener("blur",Fe),window.removeEventListener("resize",Fe)}},[le]);const[xe,_e]=FWe(Fe=>{const Ce=J().filter(ct=>!ct.disabled),Me=Ce.find(ct=>ct.ref.current===document.activeElement),$e=zWe(Ce,Fe,Me);$e&&setTimeout(()=>$e.ref.current.focus())}),fe=k.useCallback((Fe,Ce,Me)=>{const $e=!ce.current&&!Me;(C.value!==void 0&&C.value===Ce||$e)&&(B(Fe),$e&&(ce.current=!0))},[C.value]),we=k.useCallback(()=>M==null?void 0:M.focus(),[M]),Ie=k.useCallback((Fe,Ce,Me)=>{const $e=!ce.current&&!Me;(C.value!==void 0&&C.value===Ce||$e)&&Y(Fe)},[C.value]),Ne=n==="popper"?wve:wWe,Ae=Ne===wve?{side:i,sideOffset:c,align:u,alignOffset:p,arrowPadding:f,collisionBoundary:g,collisionPadding:b,sticky:_,hideWhenDetached:j,avoidCollisions:w}:{};return e.jsx(bWe,{scope:r,content:M,viewport:L,onViewportChange:R,itemRefCallback:fe,selectedItem:U,onItemLeave:we,itemTextRefCallback:Ie,focusSelectedItem:re,selectedItemText:V,position:n,isPositioned:te,searchRef:xe,children:e.jsx(NO,{as:kNt,allowPinchZoom:!0,children:e.jsx(wO,{asChild:!0,trapped:C.open,onMountAutoFocus:Fe=>{Fe.preventDefault()},onUnmountAutoFocus:Ir(a,Fe=>{var Ce;(Ce=C.trigger)==null||Ce.focus({preventScroll:!0}),Fe.preventDefault()}),children:e.jsx(ww,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:Fe=>Fe.preventDefault(),onDismiss:()=>C.onOpenChange(!1),children:e.jsx(Ne,{role:"listbox",id:C.contentId,"data-state":C.open?"open":"closed",dir:C.dir,onContextMenu:Fe=>Fe.preventDefault(),...N,...Ae,onPlaced:()=>X(!0),ref:q,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:Ir(N.onKeyDown,Fe=>{const Ce=Fe.ctrlKey||Fe.altKey||Fe.metaKey;if(Fe.key==="Tab"&&Fe.preventDefault(),!Ce&&Fe.key.length===1&&_e(Fe.key),["ArrowUp","ArrowDown","Home","End"].includes(Fe.key)){let $e=J().filter(ct=>!ct.disabled).map(ct=>ct.ref.current);if(["ArrowUp","End"].includes(Fe.key)&&($e=$e.slice().reverse()),["ArrowUp","ArrowDown"].includes(Fe.key)){const ct=Fe.target,Te=$e.indexOf(ct);$e=$e.slice(Te+1)}setTimeout(()=>ne($e)),Fe.preventDefault()}})})})})})})});_We.displayName=NNt;var SNt="SelectItemAlignedPosition",wWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onPlaced:n,...a}=t,o=Mw(OS,r),l=Tw(OS,r),[i,c]=k.useState(null),[u,p]=k.useState(null),f=$a(s,q=>p(q)),g=qde(r),b=k.useRef(!1),_=k.useRef(!0),{viewport:j,selectedItem:w,selectedItemText:N,focusSelectedItem:C}=l,M=k.useCallback(()=>{if(o.trigger&&o.valueNode&&i&&u&&j&&w&&N){const q=o.trigger.getBoundingClientRect(),U=u.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),V=N.getBoundingClientRect();if(o.dir!=="rtl"){const ct=V.left-U.left,Te=B.left-ct,ft=q.left-Te,me=q.width+ft,Ve=Math.max(me,U.width),nt=window.innerWidth-Mg,et=Y8(Te,[Mg,Math.max(Mg,nt-Ve)]);i.style.minWidth=me+"px",i.style.left=et+"px"}else{const ct=U.right-V.right,Te=window.innerWidth-B.right-ct,ft=window.innerWidth-q.right-Te,me=q.width+ft,Ve=Math.max(me,U.width),nt=window.innerWidth-Mg,et=Y8(Te,[Mg,Math.max(Mg,nt-Ve)]);i.style.minWidth=me+"px",i.style.right=et+"px"}const Y=g(),J=window.innerHeight-Mg*2,te=j.scrollHeight,X=window.getComputedStyle(u),ce=parseInt(X.borderTopWidth,10),ne=parseInt(X.paddingTop,10),re=parseInt(X.borderBottomWidth,10),le=parseInt(X.paddingBottom,10),pe=ce+ne+te+le+re,xe=Math.min(w.offsetHeight*5,pe),_e=window.getComputedStyle(j),fe=parseInt(_e.paddingTop,10),we=parseInt(_e.paddingBottom,10),Ie=q.top+q.height/2-Mg,Ne=J-Ie,Ae=w.offsetHeight/2,Fe=w.offsetTop+Ae,Ce=ce+ne+Fe,Me=pe-Ce;if(Ce<=Ie){const ct=Y.length>0&&w===Y[Y.length-1].ref.current;i.style.bottom="0px";const Te=u.clientHeight-j.offsetTop-j.offsetHeight,ft=Math.max(Ne,Ae+(ct?we:0)+Te+re),me=Ce+ft;i.style.height=me+"px"}else{const ct=Y.length>0&&w===Y[0].ref.current;i.style.top="0px";const ft=Math.max(Ie,ce+j.offsetTop+(ct?fe:0)+Ae)+Me;i.style.height=ft+"px",j.scrollTop=Ce-Ie+j.offsetTop}i.style.margin=`${Mg}px 0`,i.style.minHeight=xe+"px",i.style.maxHeight=J+"px",n==null||n(),requestAnimationFrame(()=>b.current=!0)}},[g,o.trigger,o.valueNode,i,u,j,w,N,o.dir,n]);wd(()=>M(),[M]);const[I,L]=k.useState();wd(()=>{u&&L(window.getComputedStyle(u).zIndex)},[u]);const R=k.useCallback(q=>{q&&_.current===!0&&(M(),C==null||C(),_.current=!1)},[M,C]);return e.jsx(MNt,{scope:r,contentWrapper:i,shouldExpandOnScrollRef:b,onScrollButtonChange:R,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:I},children:e.jsx(sn.div,{...a,ref:f,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});wWe.displayName=SNt;var CNt="SelectPopperPosition",wve=k.forwardRef((t,s)=>{const{__scopeSelect:r,align:n="start",collisionPadding:a=Mg,...o}=t,l=Ude(r);return e.jsx(vO,{...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)"}})});wve.displayName=CNt;var[MNt,ije]=KA(OS,{}),jve="SelectViewport",jWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,nonce:n,...a}=t,o=Tw(jve,r),l=ije(jve,r),i=$a(s,o.onViewportChange),c=k.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($de.Slot,{scope:r,children:e.jsx(sn.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:i,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ir(a.onScroll,u=>{const p=u.currentTarget,{contentWrapper:f,shouldExpandOnScrollRef:g}=l;if(g!=null&&g.current&&f){const b=Math.abs(c.current-p.scrollTop);if(b>0){const _=window.innerHeight-Mg*2,j=parseFloat(f.style.minHeight),w=parseFloat(f.style.height),N=Math.max(j,w);if(N<_){const C=N+b,M=Math.min(_,C),I=C-M;f.style.height=M+"px",f.style.bottom==="0px"&&(p.scrollTop=I>0?I:0,f.style.justifyContent="flex-end")}}}c.current=p.scrollTop})})})]})});jWe.displayName=jve;var NWe="SelectGroup",[TNt,ANt]=KA(NWe),ENt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Mu();return e.jsx(TNt,{scope:r,id:a,children:e.jsx(sn.div,{role:"group","aria-labelledby":a,...n,ref:s})})});ENt.displayName=NWe;var kWe="SelectLabel",SWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=ANt(kWe,r);return e.jsx(sn.div,{id:a.id,...n,ref:s})});SWe.displayName=kWe;var voe="SelectItem",[PNt,CWe]=KA(voe),MWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,value:n,disabled:a=!1,textValue:o,...l}=t,i=Mw(voe,r),c=Tw(voe,r),u=i.value===n,[p,f]=k.useState(o??""),[g,b]=k.useState(!1),_=$a(s,C=>{var M;return(M=c.itemRefCallback)==null?void 0:M.call(c,C,n,a)}),j=Mu(),w=k.useRef("touch"),N=()=>{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(PNt,{scope:r,value:n,disabled:a,textId:j,isSelected:u,onItemTextChange:k.useCallback(C=>{f(M=>M||((C==null?void 0:C.textContent)??"").trim())},[]),children:e.jsx($de.ItemSlot,{scope:r,value:n,disabled:a,textValue:p,children:e.jsx(sn.div,{role:"option","aria-labelledby":j,"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:Ir(l.onFocus,()=>b(!0)),onBlur:Ir(l.onBlur,()=>b(!1)),onClick:Ir(l.onClick,()=>{w.current!=="mouse"&&N()}),onPointerUp:Ir(l.onPointerUp,()=>{w.current==="mouse"&&N()}),onPointerDown:Ir(l.onPointerDown,C=>{w.current=C.pointerType}),onPointerMove:Ir(l.onPointerMove,C=>{var M;w.current=C.pointerType,a?(M=c.onItemLeave)==null||M.call(c):w.current==="mouse"&&C.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ir(l.onPointerLeave,C=>{var M;C.currentTarget===document.activeElement&&((M=c.onItemLeave)==null||M.call(c))}),onKeyDown:Ir(l.onKeyDown,C=>{var I;((I=c.searchRef)==null?void 0:I.current)!==""&&C.key===" "||(gNt.includes(C.key)&&N(),C.key===" "&&C.preventDefault())})})})})});MWe.displayName=voe;var vI="SelectItemText",TWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,className:n,style:a,...o}=t,l=Mw(vI,r),i=Tw(vI,r),c=CWe(vI,r),u=_Nt(vI,r),[p,f]=k.useState(null),g=$a(s,N=>f(N),c.onItemTextChange,N=>{var C;return(C=i.itemTextRefCallback)==null?void 0:C.call(i,N,c.value,c.disabled)}),b=p==null?void 0:p.textContent,_=k.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:b},c.value),[c.disabled,c.value,b]),{onNativeOptionAdd:j,onNativeOptionRemove:w}=u;return wd(()=>(j(_),()=>w(_)),[j,w,_]),e.jsxs(e.Fragment,{children:[e.jsx(sn.span,{id:c.textId,...o,ref:g}),c.isSelected&&l.valueNode&&!l.valueNodeHasChildren?gp.createPortal(o.children,l.valueNode):null]})});TWe.displayName=vI;var AWe="SelectItemIndicator",EWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return CWe(AWe,r).isSelected?e.jsx(sn.span,{"aria-hidden":!0,...n,ref:s}):null});EWe.displayName=AWe;var Nve="SelectScrollUpButton",PWe=k.forwardRef((t,s)=>{const r=Tw(Nve,t.__scopeSelect),n=ije(Nve,t.__scopeSelect),[a,o]=k.useState(!1),l=$a(s,n.onScrollButtonChange);return wd(()=>{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(LWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop-c.offsetHeight)}}):null});PWe.displayName=Nve;var kve="SelectScrollDownButton",IWe=k.forwardRef((t,s)=>{const r=Tw(kve,t.__scopeSelect),n=ije(kve,t.__scopeSelect),[a,o]=k.useState(!1),l=$a(s,n.onScrollButtonChange);return wd(()=>{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(LWe,{...t,ref:l,onAutoScroll:()=>{const{viewport:i,selectedItem:c}=r;i&&c&&(i.scrollTop=i.scrollTop+c.offsetHeight)}}):null});IWe.displayName=kve;var LWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,onAutoScroll:n,...a}=t,o=Tw("SelectScrollButton",r),l=k.useRef(null),i=qde(r),c=k.useCallback(()=>{l.current!==null&&(window.clearInterval(l.current),l.current=null)},[]);return k.useEffect(()=>()=>c(),[c]),wd(()=>{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(sn.div,{"aria-hidden":!0,...a,ref:s,style:{flexShrink:0,...a.style},onPointerDown:Ir(a.onPointerDown,()=>{l.current===null&&(l.current=window.setInterval(n,50))}),onPointerMove:Ir(a.onPointerMove,()=>{var u;(u=o.onItemLeave)==null||u.call(o),l.current===null&&(l.current=window.setInterval(n,50))}),onPointerLeave:Ir(a.onPointerLeave,()=>{c()})})}),INt="SelectSeparator",DWe=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t;return e.jsx(sn.div,{"aria-hidden":!0,...n,ref:s})});DWe.displayName=INt;var Sve="SelectArrow",LNt=k.forwardRef((t,s)=>{const{__scopeSelect:r,...n}=t,a=Ude(r),o=Mw(Sve,r),l=Tw(Sve,r);return o.open&&l.position==="popper"?e.jsx(bO,{...a,...n,ref:s}):null});LNt.displayName=Sve;var DNt="SelectBubbleInput",OWe=k.forwardRef(({__scopeSelect:t,value:s,...r},n)=>{const a=k.useRef(null),o=$a(n,a),l=AO(s);return k.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(sn.select,{...r,style:{...I$e,...r.style},ref:o,defaultValue:s})});OWe.displayName=DNt;function RWe(t){return t===""||t===void 0}function FWe(t){const s=gd(t),r=k.useRef(""),n=k.useRef(0),a=k.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=k.useCallback(()=>{r.current="",window.clearTimeout(n.current)},[]);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),[r,a,o]}function zWe(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=ONt(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 ONt(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var RNt=hWe,BWe=pWe,FNt=xWe,zNt=gWe,BNt=yWe,$We=vWe,$Nt=jWe,qWe=SWe,UWe=MWe,qNt=TWe,UNt=EWe,VWe=PWe,HWe=IWe,WWe=DWe;const Ys=RNt,Qs=FNt,Gs=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(BWe,{ref:n,className:Pt("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(zNt,{asChild:!0,children:e.jsx(To,{className:"h-4 w-4 opacity-50"})})]}));Gs.displayName=BWe.displayName;const GWe=k.forwardRef(({className:t,...s},r)=>e.jsx(VWe,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(pf,{className:"h-4 w-4"})}));GWe.displayName=VWe.displayName;const KWe=k.forwardRef(({className:t,...s},r)=>e.jsx(HWe,{ref:r,className:Pt("flex cursor-default items-center justify-center py-1",t),...s,children:e.jsx(To,{className:"h-4 w-4"})}));KWe.displayName=HWe.displayName;const Ks=k.forwardRef(({className:t,children:s,position:r="popper",...n},a)=>e.jsx(BNt,{children:e.jsxs($We,{ref:a,className:Pt("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(GWe,{}),e.jsx($Nt,{className:Pt("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:s}),e.jsx(KWe,{})]})}));Ks.displayName=$We.displayName;const VNt=k.forwardRef(({className:t,...s},r)=>e.jsx(qWe,{ref:r,className:Pt("py-1.5 pl-8 pr-2 text-sm font-semibold",t),...s}));VNt.displayName=qWe.displayName;const Mt=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(UWe,{ref:n,className:Pt("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(UNt,{children:e.jsx(fa,{className:"h-4 w-4"})})}),e.jsx(qNt,{children:s})]}));Mt.displayName=UWe.displayName;const HNt=k.forwardRef(({className:t,...s},r)=>e.jsx(WWe,{ref:r,className:Pt("-mx-1 my-1 h-px bg-muted",t),...s}));HNt.displayName=WWe.displayName;const WNt=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}}),ZWe=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}),YWe=()=>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}}),GNt=()=>Lt({mutationFn:async t=>{const{error:s}=await H.rpc("increment_listing_share_click",{p_share_token:t});if(s)throw s}}),KNt={active:"bg-emerald-500",coming_soon:"bg-blue-600",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},e6e={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},ZNt={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function XWe(){const[t,s]=k.useState(""),[r,n]=k.useState(!1),[a,o]=k.useState({status:"",propertyType:"",minPrice:"",maxPrice:""}),{data:l,isLoading:i}=WNt({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(rd,{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(Ei,{to:"/public/listings",className:"flex items-center",children:e.jsx("img",{src:cWe,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(${hNt})`},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(hn,{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(hn,{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(FM,{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(Ys,{value:a.status||"all",onValueChange:f=>o({...a,status:f==="all"?"":f}),children:[e.jsx(Gs,{className:"bg-white",children:e.jsx(Qs,{placeholder:"Any status"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"Any status"}),Object.entries(e6e).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(Ys,{value:a.propertyType||"all",onValueChange:f=>o({...a,propertyType:f==="all"?"":f}),children:[e.jsx(Gs,{className:"bg-white",children:e.jsx(Qs,{placeholder:"Any type"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"Any type"}),Object.entries(ZNt).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(Or,{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(fNt,{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 j,w,N;const g=((j=f.photos)==null?void 0:j.find(C=>C.is_primary))||((w=f.photos)==null?void 0:w[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(Ei,{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(Sn,{className:"h-12 w-12 text-gray-300"})}),e.jsx(tt,{className:`absolute top-2 left-2 ${KNt[f.status]} text-white border-0 text-xs font-medium px-2 py-0.5`,children:e6e[f.status]}),e.jsx("button",{className:"absolute top-2 right-2 p-2 rounded-full bg-white/80 hover:bg-white transition-colors",onClick:C=>C.preventDefault(),children:e.jsx(ii,{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}),((N=f.agent.brokerage)==null?void 0:N.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(Sn,{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:aje,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 Pe=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("rounded-lg border bg-card text-card-foreground shadow-sm",t),...s}));Pe.displayName="Card";const Dt=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex flex-col space-y-1.5 p-6",t),...s}));Dt.displayName="CardHeader";const zt=k.forwardRef(({className:t,...s},r)=>e.jsx("h3",{ref:r,className:Pt("text-2xl font-semibold leading-none tracking-tight",t),...s}));zt.displayName="CardTitle";const xr=k.forwardRef(({className:t,...s},r)=>e.jsx("p",{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));xr.displayName="CardDescription";const Re=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("p-6 pt-0",t),...s}));Re.displayName="CardContent";const BL=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("flex items-center p-6 pt-0",t),...s}));BL.displayName="CardFooter";var YNt="Label",QWe=k.forwardRef((t,s)=>e.jsx(sn.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())}}));QWe.displayName=YNt;var JWe=QWe;const XNt=lC("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),ye=k.forwardRef(({className:t,...s},r)=>e.jsx(JWe,{ref:r,className:Pt(XNt(),t),...s}));ye.displayName=JWe.displayName;const boe="/assets/levelup-logo-color-D3mY9gCJ.png";function QNt(){const t=nu(),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(XWe,{}):n.startsWith("public/")?null:e.jsx(JNt,{slug:n})}function JNt({slug:t}){return e.jsx(skt,{slug:t})}const ekt={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"},t6e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function skt({slug:t}){var B,V;const{data:s,isLoading:r}=ZWe(t),n=YWe(),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(null),C=Y=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Y),M=async Y=>{if(Y.preventDefault(),!(!a.trim()||!c.trim()||!s)){b(!0);try{await n.mutateAsync({listingId:s.id,agentId:s.agent_id,firstName:a.trim(),lastName:l.trim(),email:c.trim(),phone:p.trim()}),j(!0),he.success("Thanks! The agent will be in touch soon.")}catch(J){console.error("Lead submission error:",J),he.error(`Failed to submit: ${J.message||"Please try again"}`)}finally{b(!1)}}},I=(s==null?void 0:s.photos)||[],L=I.find(Y=>Y.is_primary)||I[0],R=()=>{w!==null&&N(w===0?I.length-1:w-1)},q=()=>{w!==null&&N(w===I.length-1?0:w+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:boe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Sn,{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(rd,{children:[e.jsxs("title",{children:[U," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA ${s.square_footage?s.square_footage.toLocaleString()+" sqft":""} ${t6e[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:`${C(s.price)} - ${s.bedrooms||""}BD ${s.bathrooms||""}BA in ${s.city}, ${s.state}`}),e.jsx("meta",{property:"og:type",content:"website"}),L&&e.jsx("meta",{property:"og:image",content:L.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:boe,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(ri,{className:"h-4 w-4 mr-2"}),"Back to Listings"]}),I.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:()=>N(0),children:e.jsx("img",{src:L==null?void 0:L.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:I.slice(1,5).map((Y,J)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>N(J+1),children:[e.jsx("img",{src:Y.photo_url,alt:`Photo ${J+2}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),J===3&&I.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center text-white font-semibold",children:["+",I.length-5," more"]})]},Y.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(tt,{className:`${ekt[s.status]} text-white border-0`,children:tkt[s.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:C(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(Ba,{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(Np,{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(Nh,{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(x0,{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(cn,{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(tt,{variant:"secondary",children:[e.jsx(wa,{className:"h-3 w-3 mr-1"}),t6e[s.property_type]]}),s.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",s.lot_size]}),s.has_hoa&&e.jsx(tt,{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(an,{className:"h-4 w-4 mr-2"}),"View on MLS"]})})]})]}),e.jsxs("div",{className:"space-y-6",children:[s.agent&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{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(Pe,{className:"border-primary",children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{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(dr,{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(ye,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:a,onChange:Y=>o(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:l,onChange:Y=>i(Y.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:c,onChange:Y=>u(Y.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:p,onChange:Y=>f(Y.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:w!==null,onOpenChange:()=>N(null),children:e.jsxs(fs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(bs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>N(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(Or,{className:"h-5 w-5"})}),w!==null&&I[w]&&e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:I[w].photo_url,alt:`Photo ${w+1}`,className:"w-full max-h-[80vh] object-contain"}),I.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:R,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(ll,{className:"h-6 w-6"})}),e.jsx("button",{onClick:q,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(xa,{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:[w+1," / ",I.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 Vde({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 eGe=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}),rkt=()=>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}}),nkt=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}),tGe=()=>{const t=es();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"]}),he.success("Agent card created")},onError:s=>he.error(s.message)})},sGe=()=>{const t=es();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"]}),he.success("Agent card updated")},onError:s=>he.error(s.message)})},fo=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:{}})},akt=async(t,s)=>{const{error:r}=await H.from("agent_card_leads").insert({card_id:t,...s});if(r)throw r},rGe=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 Hde({open:t,onOpenChange:s,cardId:r,type:n,agentName:a}){const[o,l]=k.useState(""),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),N=async C=>{if(C.preventDefault(),!o.trim()){he.error("Please enter your name");return}w(!0);try{await akt(r,{lead_type:n,name:o.trim(),email:i.trim()||void 0,phone:u.trim()||void 0,message:b.trim()||void 0,intent:f||void 0}),fo(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:b.trim()||void 0,intent:f||void 0}}).catch(M=>console.error("Card lead notify failed:",M)),he.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{he.error("Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md rounded-2xl",children:[e.jsxs(_s,{children:[e.jsx(bs,{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:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-name",children:"Name *"}),e.jsx(ze,{id:"lead-name",value:o,onChange:C=>l(C.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-phone",children:"Phone"}),e.jsx(ze,{id:"lead-phone",type:"tel",value:u,onChange:C=>p(C.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-email",children:"Email"}),e.jsx(ze,{id:"lead-email",type:"email",value:i,onChange:C=>c(C.target.value),placeholder:"you@example.com"})]}),n==="booking"&&e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lead-intent",children:"I'm looking to..."}),e.jsxs(Ys,{value:f,onValueChange:g,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select one"})}),e.jsxs(Ks,{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(ye,{htmlFor:"lead-message",children:n==="referral"?"Tell us about them":"Message (optional)"}),e.jsx(ze,{id:"lead-message",value:b,onChange:C=>_(C.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:j,children:j?"Sending...":"Submit"})]})]})})}const ikt=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}),okt=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}),lkt=()=>{const t=es();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]}),he.success("Block added")},onError:s=>he.error(s.message)})},ckt=()=>{const t=es();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"]}),he.success("Block updated")},onError:s=>he.error(s.message)})},dkt=()=>{const t=es();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"]}),he.success("Block removed")},onError:s=>he.error(s.message)})};function ukt(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 hkt(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 mkt={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 pkt({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=hkt(r.video_url),o=n||!!a,l=n?ukt(r.video_url):a||r.video_url;return e.jsx("div",{className:mkt[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 fkt={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 xkt({block:t,variant:s}){const n=t.config.testimonials||[],[a,o]=k.useState(0);if(n.length===0)return null;const l=fkt[s],i=n[a];return e.jsxs("div",{className:l.container,children:[e.jsxs("div",{className:l.card,children:[e.jsx(U_,{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(ll,{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(xa,{className:"h-4 w-4"})})]})]})}const gkt={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 ykt({block:t,variant:s}){const n=t.config.tags||[];if(n.length===0)return null;const a=gkt[s];return e.jsx("div",{className:a.container,children:n.map((o,l)=>e.jsx("span",{className:a.tag,children:o},l))})}const vkt={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 bkt({block:t,cardId:s,variant:r}){const a=t.config.links||[];if(a.length===0)return null;const o=vkt[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:()=>fo(s,"button_click",`custom_link_${l.label}`),className:o.link,children:[e.jsx("span",{children:l.label}),e.jsx(an,{className:`h-4 w-4 ${o.icon}`})]},i))})}const Cve={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 _kt({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 wkt={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 jkt({block:t,cardId:s,variant:r}){const a=t.config.platforms||[],o=wkt[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=Cve[l.platform.toLowerCase()];return!c||!l.url?null:e.jsx("a",{href:l.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(s,"button_click",`social_${l.platform}`),className:o.linkClass,title:c.label,children:e.jsx(_kt,{path:c.icon,color:c.color})},i)})})]})}function Wde({cardId:t,variant:s}){const{data:r}=ikt(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(pkt,{block:l,variant:s},l.id);case"testimonials":return e.jsx(xkt,{block:l,variant:s},l.id);case"specialties":return e.jsx(ykt,{block:l,variant:s},l.id);case"custom_links":return e.jsx(bkt,{block:l,cardId:t,variant:s},l.id);default:return null}}),o&&e.jsx(jkt,{block:o,cardId:t,variant:s})]})}async function Nkt(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 kkt(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 Gde(t){const{first:s,last:r}=kkt(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 Nkt(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),he.success("Contact saved!")}function Skt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,M)=>{fo(t.id,"button_click",C),M()},c=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:he.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:he.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:he.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var C,M;fo(t.id,"contact_saved"),Gde({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(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),he.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={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(_n,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(za,{src:t.avatar_url||void 0,alt:o}),e.jsx(wn,{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(Un,{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(io,{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(dr,{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(cn,{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(Vde,{card:t,variant:"standard"}),e.jsx(Wde,{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(Ci,{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:()=>{fo(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(mr,{className:"h-4 w-4 mr-3 text-primary"}),"Refer a Friend"]}),e.jsxs(K,{variant:"ghost",onClick:j,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(rc,{className:"h-4 w-4 mr-3 text-primary"}),"Connect with Me"]}),e.jsxs(K,{variant:"ghost",onClick:b,className:"w-full justify-start h-12 rounded-2xl text-slate-700 hover:bg-slate-100",children:[e.jsx(bd,{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((C,M)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${C.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:w[C.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(Hde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Ckt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,M)=>{fo(t.id,"button_click",C),M()},c=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:he.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:he.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:he.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var C,M;fo(t.id,"contact_saved"),Gde({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(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),he.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={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(_n,{className:"h-32 w-32 mx-auto mb-5 ring-2 ring-[#c9a84c]/40 shadow-2xl",children:[e.jsx(za,{src:t.avatar_url||void 0,alt:o}),e.jsx(wn,{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:Un,label:"Call",handler:c},{icon:io,label:"Text",handler:u},{icon:dr,label:"Email",handler:p}].map(({icon:C,label:M,handler:I})=>e.jsxs("button",{onClick:I,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(C,{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(cn,{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(Vde,{card:t,variant:"luxury"}),e.jsx(Wde,{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(Ci,{className:"h-4 w-4 text-[#c9a84c]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(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(mr,{className:"h-4 w-4 text-[#c9a84c]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,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(rc,{className:"h-4 w-4 text-[#c9a84c]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,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(bd,{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((C,M)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${C.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:w[C.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#4a5568]",children:"Powered by LevelUp"})})]}),e.jsx(Hde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Mkt({card:t}){var M,I,L,R;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((M=t.profile)==null?void 0:M.name)||"Agent",l=o.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2),i={accent:((I=t.bold_theme_colors)==null?void 0:I.accent)||"#ff5722",dark:((L=t.bold_theme_colors)==null?void 0:L.dark)||"#1a1a2e",button:((R=t.bold_theme_colors)==null?void 0:R.button)||"#ff5722"},c=(q,U)=>{const B=parseInt(q.replace("#",""),16),V=Math.max(0,(B>>16)-U),Y=Math.max(0,(B>>8&255)-U),J=Math.max(0,(B&255)-U);return`#${(V<<16|Y<<8|J).toString(16).padStart(6,"0")}`};c(i.accent,25),c(i.dark,-20),c(i.button,25);const u=(q,U)=>{fo(t.id,"button_click",q),U()},p=()=>u("call",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`tel:${t.profile.phone}`:he.error("Phone number not available")}),f=()=>u("text",()=>{var q;(q=t.profile)!=null&&q.phone?window.location.href=`sms:${t.profile.phone}`:he.error("Phone number not available")}),g=()=>u("email",()=>{var q;(q=t.profile)!=null&&q.email?window.location.href=`mailto:${t.profile.email}`:he.error("Email not available")}),b=()=>{t.booking_url?u("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},_=()=>{var q,U;fo(t.id,"contact_saved"),Gde({name:o,phone:(q=t.profile)==null?void 0:q.phone,email:(U=t.profile)==null?void 0:U.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},j=async()=>{if(fo(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),he.success("Link copied!")},w=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},N=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},C={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(_n,{className:"h-28 w-28 mx-auto mb-4 shadow-2xl",style:{boxShadow:`0 0 0 4px ${i.accent}`},children:[e.jsx(za,{src:t.avatar_url||void 0,alt:o}),e.jsx(wn,{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:Un,label:"Call",handler:p},{icon:io,label:"Text",handler:f},{icon:dr,label:"Email",handler:g}].map(({icon:q,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(q,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:U})]},U))}),e.jsxs("button",{onClick:b,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(cn,{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(Vde,{card:t,variant:"bold"}),e.jsx(Wde,{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(Ci,{className:"h-4 w-4",style:{color:i.accent}})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(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: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(mr,{className:"h-4 w-4",style:{color:i.accent}})," Refer a Friend"]}),e.jsxs("button",{onClick:N,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(rc,{className:"h-4 w-4",style:{color:i.accent}})," Connect with Me"]}),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(bd,{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((q,U)=>e.jsx("a",{href:q.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${q.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:C[q.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(Hde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function Tkt({card:t}){var N;const[s,r]=k.useState(!1),[n,a]=k.useState("booking"),o=((N=t.profile)==null?void 0:N.name)||"Agent",l=o.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),i=(C,M)=>{fo(t.id,"button_click",C),M()},c=()=>i("call",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`tel:${t.profile.phone}`:he.error("Phone number not available")}),u=()=>i("text",()=>{var C;(C=t.profile)!=null&&C.phone?window.location.href=`sms:${t.profile.phone}`:he.error("Phone number not available")}),p=()=>i("email",()=>{var C;(C=t.profile)!=null&&C.email?window.location.href=`mailto:${t.profile.email}`:he.error("Email not available")}),f=()=>{t.booking_url?i("book",()=>window.open(t.booking_url,"_blank")):(a("booking"),r(!0),fo(t.id,"button_click","book"))},g=()=>{var C,M;fo(t.id,"contact_saved"),Gde({name:o,phone:(C=t.profile)==null?void 0:C.phone,email:(M=t.profile)==null?void 0:M.email,brokerage:t.brokerage_name,avatarUrl:t.avatar_url,cardUrl:window.location.href})},b=async()=>{if(fo(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),he.success("Link copied!")},_=()=>{a("referral"),r(!0),fo(t.id,"button_click","refer")},j=()=>{a("connect"),r(!0),fo(t.id,"button_click","connect")},w={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(_n,{className:"h-28 w-28 mx-auto mb-4 ring-4 ring-white shadow-lg",children:[e.jsx(za,{src:t.avatar_url||void 0,alt:o}),e.jsx(wn,{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:Un,label:"Call",handler:c},{icon:io,label:"Text",handler:u},{icon:dr,label:"Email",handler:p}].map(({icon:C,label:M,handler:I})=>e.jsxs("button",{onClick:I,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(C,{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(cn,{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(Vde,{card:t,variant:"classic"}),e.jsx(Wde,{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(Ci,{className:"h-4 w-4 text-[#5a7a6f]"})," Save Contact"]}),t.show_leave_review&&t.review_source_url&&e.jsxs("button",{onClick:()=>{fo(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(mr,{className:"h-4 w-4 text-[#5a7a6f]"})," Refer a Friend"]}),e.jsxs("button",{onClick:j,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(rc,{className:"h-4 w-4 text-[#5a7a6f]"})," Connect with Me"]}),e.jsxs("button",{onClick:b,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(bd,{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((C,M)=>e.jsx("a",{href:C.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>fo(t.id,"button_click",`social_${C.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:w[C.platform.toLowerCase()]||"🔗"},M))}),e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-xs text-[#a0aec0]",children:"Powered by LevelUp"})})]}),e.jsx(Hde,{open:s,onOpenChange:r,cardId:t.id,type:n,agentName:o})]})}function oje({card:t}){switch(t.theme){case"luxury":return e.jsx(Ckt,{card:t});case"bold":return e.jsx(Mkt,{card:t});case"classic":return e.jsx(Tkt,{card:t});case"standard":default:return e.jsx(Skt,{card:t})}}function Akt(){const t=nu();k.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(Ekt,{slug:s})}function Ekt({slug:t}){return e.jsx(Pkt,{slug:t})}function Pkt({slug:t}){var o;const{data:s,isLoading:r,error:n}=eGe(t);if(k.useEffect(()=>{s!=null&&s.id&&fo(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(rd,{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(oje,{card:s})]})}function nGe({presentationId:t,ctaLabel:s,agentName:r,prefillName:n,prefillEmail:a,prefillPhone:o}){const[l,i]=k.useState(n||""),[c,u]=k.useState(a||""),[p,f]=k.useState(o||""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(!1),[C,M]=k.useState(!1),I=async L=>{if(L.preventDefault(),!l.trim()){he.error("Please enter your name");return}N(!0);try{const{error:R}=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(R)throw R;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(q=>console.error("Presentation lead notify failed:",q)),M(!0)}catch{he.error("Something went wrong. Please try again.")}finally{N(!1)}};return C?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(fa,{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:I,className:"space-y-4 max-w-md mx-auto",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-name",children:"Name *"}),e.jsx(ze,{id:"pres-lead-name",value:l,onChange:L=>i(L.target.value),placeholder:"Your name",required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-phone",children:"Phone"}),e.jsx(ze,{id:"pres-lead-phone",type:"tel",value:p,onChange:L=>f(L.target.value),placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-email",children:"Email"}),e.jsx(ze,{id:"pres-lead-email",type:"email",value:c,onChange:L=>u(L.target.value),placeholder:"you@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"pres-lead-intent",children:"I'm looking to..."}),e.jsxs(Ys,{value:g,onValueChange:b,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select one"})}),e.jsxs(Ks,{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(ye,{htmlFor:"pres-lead-message",children:"Message (optional)"}),e.jsx(ze,{id:"pres-lead-message",value:_,onChange:L=>j(L.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:w,children:w?"Sending...":s})]})}function Ikt(){const t=nu();k.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(Lkt,{shareToken:s})}function Lkt({shareToken:t}){var _;const[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,c]=k.useState(!1);k.useEffect(()=>{u()},[t]);const u=async()=>{const{data:j,error:w}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(w||!j){c(!0),a(!1);return}const{data:N}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",j.owner_user_id).single();let C;if(N!=null&&N.brokerage_id){const{data:I}=await H.from("brokerages").select("name").eq("id",N.brokerage_id).single();C=(I==null?void 0:I.name)||void 0}let M=null;if(j.contact_id){const{data:I}=await H.from("innercircle_contacts").select("first_name, last_name, email, phone").eq("id",j.contact_id).single();M=I}r({...j,owner_name:N==null?void 0:N.name,owner_email:N==null?void 0:N.email,owner_phone:N==null?void 0:N.phone,owner_avatar:N==null?void 0:N.avatar_url,owner_title:(N==null?void 0:N.title)||void 0,brokerage_name:C,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: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")}},f=j=>{const w=j.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(w)return`https://www.youtube.com/embed/${w[1]}?rel=0`;if(j.includes("iframe.mediadelivery.net/play/")){const M=j.replace("/play/","/embed/"),I=M.includes("?")?"&":"?";return`${M}${I}responsive=true`}if(j.includes("iframe.mediadelivery.net")){const M=j.includes("?")?"&":"?";return`${j}${M}responsive=true`}const N=j.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(N)return`https://www.loom.com/embed/${N[1]}`;const C=j.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return C?`https://iframe.mediadelivery.net/embed/${C[1]}/${C[2]}?responsive=true`:j};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(j=>j.is_visible!==!1),b=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:[b!=null&&b.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(b.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"})}):b!=null&&b.image_url?e.jsx("div",{className:"rounded-xl overflow-hidden shadow-lg",children:e.jsx("img",{src:b.image_url,alt:b.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:b==null?void 0:b.icon}),e.jsx("h3",{className:"text-xl font-semibold text-gray-800",children:b==null?void 0:b.title}),e.jsx("p",{className:"text-gray-500 mt-1 text-sm",children:b==null?void 0:b.description})]}),(b==null?void 0:b.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:b.text}})]}),e.jsx("div",{className:"md:col-span-2 space-y-3",children:g.map((j,w)=>e.jsx("button",{onClick:()=>l(w),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===w?"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(w+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})]})]})},w))})]}),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(an,{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(nGe,{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 Bx=()=>{const t=li();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 Dkt(){const{user:t}=Rs(),s=li(),{data:r}=Bx();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 fMs(t){const{user:s}=Rs();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 aGe(t){const{user:s}=Rs(),r=es();return k.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 Okt(){const t=es(),s=li();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"]}),vn({title:"Open house created!"})},onError:r=>{vn({title:"Error",description:r.message,variant:"destructive"})}})}function iGe(){const t=es();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 Rkt(){const t=es();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"]}),vn({title:"Open house deleted"})}})}function Fkt(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 zkt(t){const{user:s}=Rs();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 Bkt(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 $kt(){return Lt({mutationFn:async t=>{const{error:s}=await H.from("open_house_survey_responses").insert(t);if(s)throw s}})}function qkt(t){const{user:s}=Rs();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 Ukt(){const t=es();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 Vkt(){const t=es();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 Hkt(){const t=es();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 Wkt(){const t=es();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 Gkt(){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 Kde="Switch",[Kkt]=nd(Kde),[Zkt,Ykt]=Kkt(Kde),oGe=k.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,b]=k.useState(null),_=$a(s,M=>b(M)),j=k.useRef(!1),w=g?p||!!g.closest("form"):!0,[N,C]=rh({prop:a,defaultProp:o??!1,onChange:u,caller:Kde});return e.jsxs(Zkt,{scope:r,checked:N,disabled:i,children:[e.jsx(sn.button,{type:"button",role:"switch","aria-checked":N,"aria-required":l,"data-state":uGe(N),"data-disabled":i?"":void 0,disabled:i,value:c,...f,ref:_,onClick:Ir(t.onClick,M=>{C(I=>!I),w&&(j.current=M.isPropagationStopped(),j.current||M.stopPropagation())})}),w&&e.jsx(dGe,{control:g,bubbles:!j.current,name:n,value:c,checked:N,required:l,disabled:i,form:p,style:{transform:"translateX(-100%)"}})]})});oGe.displayName=Kde;var lGe="SwitchThumb",cGe=k.forwardRef((t,s)=>{const{__scopeSwitch:r,...n}=t,a=Ykt(lGe,r);return e.jsx(sn.span,{"data-state":uGe(a.checked),"data-disabled":a.disabled?"":void 0,...n,ref:s})});cGe.displayName=lGe;var Xkt="SwitchBubbleInput",dGe=k.forwardRef(({__scopeSwitch:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=$a(l,o),c=AO(r),u=gO(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.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}})});dGe.displayName=Xkt;function uGe(t){return t?"checked":"unchecked"}var hGe=oGe,Qkt=cGe;const $r=k.forwardRef(({className:t,...s},r)=>e.jsx(hGe,{className:Pt("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(Qkt,{className:Pt("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")})}));$r.displayName=hGe.displayName;function ea(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 pl(t,s){return t instanceof Date?new t.constructor(s):new Date(s)}function Tl(t,s){const r=ea(t);return isNaN(s)?pl(t,NaN):(s&&r.setDate(r.getDate()+s),r)}function zm(t,s){const r=ea(t);if(isNaN(s))return pl(t,NaN);if(!s)return r;const n=r.getDate(),a=pl(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 mGe(t,s){const r=+ea(t);return pl(t,r+s)}const lje=6048e5,Jkt=864e5,Zde=6e4,EO=36e5,e4t=1e3,Q7=43200,s6e=1440;function r6e(t,s){return mGe(t,s*EO)}let t4t={};function Aw(){return t4t}function Yh(t,s){var i,c,u,p;const r=Aw(),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=ea(t),o=a.getDay(),l=(o=a.getTime()?r+1:s.getTime()>=l.getTime()?r:r-1}function Bm(t){const s=ea(t);return s.setHours(0,0,0,0),s}function cw(t){const s=ea(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 hf(t,s){const r=Bm(t),n=Bm(s),a=+r-cw(r),o=+n-cw(n);return Math.round((a-o)/Jkt)}function s4t(t){const s=pGe(t),r=pl(t,0);return r.setFullYear(s,0,4),r.setHours(0,0,0,0),M1(r)}function eM(t,s){return mGe(t,s*Zde)}function p4(t,s){const r=s*7;return Tl(t,r)}function r4t(t,s){return zm(t,s*12)}function n4t(t){let s;return t.forEach(function(r){const n=ea(r);(s===void 0||s{const n=ea(r);(!s||s>n||isNaN(+n))&&(s=n)}),s||new Date(NaN)}function cie(t,s){const r=ea(t),n=ea(s),a=r.getTime()-n.getTime();return a<0?-1:a>0?1:a}function cje(t){return pl(t,Date.now())}function Sl(t,s){const r=Bm(t),n=Bm(s);return+r==+n}function dje(t){return t instanceof Date||typeof t=="object"&&Object.prototype.toString.call(t)==="[object Date]"}function Mve(t){if(!dje(t)&&typeof t!="number")return!1;const s=ea(t);return!isNaN(Number(s))}function LT(t,s){const r=ea(t),n=ea(s),a=r.getFullYear()-n.getFullYear(),o=r.getMonth()-n.getMonth();return a*12+o}function i4t(t,s,r){const n=Yh(t,r),a=Yh(s,r),o=+n-cw(n),l=+a-cw(a);return Math.round((o-l)/lje)}function iy(t,s){const r=ea(t),n=ea(s),a=n6e(r,n),o=Math.abs(hf(r,n));r.setDate(r.getDate()-a*o);const l=+(n6e(r,n)===-a),i=a*(o-l);return i===0?0:i}function n6e(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 fGe(t){return s=>{const n=(t?Math[t]:Math.trunc)(s);return n===0?0:n}}function xGe(t,s){return+ea(t)-+ea(s)}function o4t(t,s,r){const n=xGe(t,s)/EO;return fGe(r==null?void 0:r.roundingMethod)(n)}function l4t(t){const s=ea(t);return s.setHours(23,59,59,999),s}function lx(t){const s=ea(t),r=s.getMonth();return s.setFullYear(s.getFullYear(),r+1,0),s.setHours(23,59,59,999),s}function c4t(t){const s=ea(t);return+l4t(s)==+lx(s)}function d4t(t,s){const r=ea(t),n=ea(s),a=cie(r,n),o=Math.abs(LT(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=cie(r,n)===-a;c4t(ea(t))&&o===1&&cie(t,n)===1&&(i=!1),l=a*(o-Number(i))}return l===0?0:l}function u4t(t,s,r){const n=xGe(t,s)/1e3;return fGe(r==null?void 0:r.roundingMethod)(n)}function h4t(t,s){const r=ea(t.start),n=ea(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(ea(l)),l.setDate(l.getDate()+i),l.setHours(0,0,0,0);return a?c.reverse():c}function Lc(t){const s=ea(t);return s.setDate(1),s.setHours(0,0,0,0),s}function gGe(t){const s=ea(t),r=pl(t,0);return r.setFullYear(s.getFullYear(),0,1),r.setHours(0,0,0,0),r}function Yde(t,s){var i,c,u,p;const r=Aw(),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=ea(t),o=a.getDay(),l=(o{let n;const a=m4t[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 _xe(t){return(s={})=>{const r=s.width?String(s.width):t.defaultWidth;return t.formats[r]||t.formats[t.defaultWidth]}}const f4t={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},x4t={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},g4t={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},y4t={date:_xe({formats:f4t,defaultWidth:"full"}),time:_xe({formats:x4t,defaultWidth:"full"}),dateTime:_xe({formats:g4t,defaultWidth:"full"})},v4t={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},b4t=(t,s,r,n)=>v4t[t];function BP(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 _4t={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},w4t={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},j4t={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"]},N4t={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"]},k4t={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"}},S4t={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"}},C4t=(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"},M4t={ordinalNumber:C4t,era:BP({values:_4t,defaultWidth:"wide"}),quarter:BP({values:w4t,defaultWidth:"wide",argumentCallback:t=>t-1}),month:BP({values:j4t,defaultWidth:"wide"}),day:BP({values:N4t,defaultWidth:"wide"}),dayPeriod:BP({values:k4t,defaultWidth:"wide",formattingValues:S4t,defaultFormattingWidth:"wide"})};function $P(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)?A4t(i,f=>f.test(l)):T4t(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 T4t(t,s){for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&s(t[r]))return r}function A4t(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 P4t=/^(\d+)(th|st|nd|rd)?/i,I4t=/\d+/i,L4t={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},D4t={any:[/^b/i,/^(a|c)/i]},O4t={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},R4t={any:[/1/i,/2/i,/3/i,/4/i]},F4t={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},z4t={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]},B4t={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},$4t={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]},q4t={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},U4t={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}},V4t={ordinalNumber:E4t({matchPattern:P4t,parsePattern:I4t,valueCallback:t=>parseInt(t,10)}),era:$P({matchPatterns:L4t,defaultMatchWidth:"wide",parsePatterns:D4t,defaultParseWidth:"any"}),quarter:$P({matchPatterns:O4t,defaultMatchWidth:"wide",parsePatterns:R4t,defaultParseWidth:"any",valueCallback:t=>t+1}),month:$P({matchPatterns:F4t,defaultMatchWidth:"wide",parsePatterns:z4t,defaultParseWidth:"any"}),day:$P({matchPatterns:B4t,defaultMatchWidth:"wide",parsePatterns:$4t,defaultParseWidth:"any"}),dayPeriod:$P({matchPatterns:q4t,defaultMatchWidth:"any",parsePatterns:U4t,defaultParseWidth:"any"})},Xde={code:"en-US",formatDistance:p4t,formatLong:y4t,formatRelative:b4t,localize:M4t,match:V4t,options:{weekStartsOn:0,firstWeekContainsDate:1}};function H4t(t){const s=ea(t);return hf(s,gGe(s))+1}function uje(t){const s=ea(t),r=+M1(s)-+s4t(s);return Math.round(r/lje)+1}function hje(t,s){var p,f,g,b;const r=ea(t),n=r.getFullYear(),a=Aw(),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??((b=(g=a.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=pl(t,0);l.setFullYear(n+1,0,o),l.setHours(0,0,0,0);const i=Yh(l,s),c=pl(t,0);c.setFullYear(n,0,o),c.setHours(0,0,0,0);const u=Yh(c,s);return r.getTime()>=i.getTime()?n+1:r.getTime()>=u.getTime()?n:n-1}function W4t(t,s){var i,c,u,p;const r=Aw(),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=hje(t,s),o=pl(t,0);return o.setFullYear(a,0,n),o.setHours(0,0,0,0),Yh(o,s)}function mje(t,s){const r=ea(t),n=+Yh(r,s)-+W4t(r,s);return Math.round(n/lje)+1}function ml(t,s){const r=t<0?"-":"",n=Math.abs(t).toString().padStart(s,"0");return r+n}const Pb={y(t,s){const r=t.getFullYear(),n=r>0?r:1-r;return ml(s==="yy"?n%100:n,s.length)},M(t,s){const r=t.getMonth();return s==="M"?String(r+1):ml(r+1,2)},d(t,s){return ml(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 ml(t.getHours()%12||12,s.length)},H(t,s){return ml(t.getHours(),s.length)},m(t,s){return ml(t.getMinutes(),s.length)},s(t,s){return ml(t.getSeconds(),s.length)},S(t,s){const r=s.length,n=t.getMilliseconds(),a=Math.trunc(n*Math.pow(10,r-3));return ml(a,s.length)}},f5={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},a6e={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 Pb.y(t,s)},Y:function(t,s,r,n){const a=hje(t,n),o=a>0?a:1-a;if(s==="YY"){const l=o%100;return ml(l,2)}return s==="Yo"?r.ordinalNumber(o,{unit:"year"}):ml(o,s.length)},R:function(t,s){const r=pGe(t);return ml(r,s.length)},u:function(t,s){const r=t.getFullYear();return ml(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 ml(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 ml(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 Pb.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 ml(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=mje(t,n);return s==="wo"?r.ordinalNumber(a,{unit:"week"}):ml(a,s.length)},I:function(t,s,r){const n=uje(t);return s==="Io"?r.ordinalNumber(n,{unit:"week"}):ml(n,s.length)},d:function(t,s,r){return s==="do"?r.ordinalNumber(t.getDate(),{unit:"date"}):Pb.d(t,s)},D:function(t,s,r){const n=H4t(t);return s==="Do"?r.ordinalNumber(n,{unit:"dayOfYear"}):ml(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 ml(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 ml(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 ml(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=f5.noon:n===0?a=f5.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=f5.evening:n>=12?a=f5.afternoon:n>=4?a=f5.morning:a=f5.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 Pb.h(t,s)},H:function(t,s,r){return s==="Ho"?r.ordinalNumber(t.getHours(),{unit:"hour"}):Pb.H(t,s)},K:function(t,s,r){const n=t.getHours()%12;return s==="Ko"?r.ordinalNumber(n,{unit:"hour"}):ml(n,s.length)},k:function(t,s,r){let n=t.getHours();return n===0&&(n=24),s==="ko"?r.ordinalNumber(n,{unit:"hour"}):ml(n,s.length)},m:function(t,s,r){return s==="mo"?r.ordinalNumber(t.getMinutes(),{unit:"minute"}):Pb.m(t,s)},s:function(t,s,r){return s==="so"?r.ordinalNumber(t.getSeconds(),{unit:"second"}):Pb.s(t,s)},S:function(t,s){return Pb.S(t,s)},X:function(t,s,r){const n=t.getTimezoneOffset();if(n===0)return"Z";switch(s){case"X":return o6e(n);case"XXXX":case"XX":return e4(n);case"XXXXX":case"XXX":default:return e4(n,":")}},x:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"x":return o6e(n);case"xxxx":case"xx":return e4(n);case"xxxxx":case"xxx":default:return e4(n,":")}},O:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"O":case"OO":case"OOO":return"GMT"+i6e(n,":");case"OOOO":default:return"GMT"+e4(n,":")}},z:function(t,s,r){const n=t.getTimezoneOffset();switch(s){case"z":case"zz":case"zzz":return"GMT"+i6e(n,":");case"zzzz":default:return"GMT"+e4(n,":")}},t:function(t,s,r){const n=Math.trunc(t.getTime()/1e3);return ml(n,s.length)},T:function(t,s,r){const n=t.getTime();return ml(n,s.length)}};function i6e(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+ml(o,2)}function o6e(t,s){return t%60===0?(t>0?"-":"+")+ml(Math.abs(t)/60,2):e4(t,s)}function e4(t,s=""){const r=t>0?"-":"+",n=Math.abs(t),a=ml(Math.trunc(n/60),2),o=ml(n%60,2);return r+a+s+o}const l6e=(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"})}},vGe=(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"})}},G4t=(t,s)=>{const r=t.match(/(P+)(p+)?/)||[],n=r[1],a=r[2];if(!a)return l6e(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}}",l6e(n,s)).replace("{{time}}",vGe(a,s))},Tve={p:vGe,P:G4t},K4t=/^D+$/,Z4t=/^Y+$/,Y4t=["D","DD","YY","YYYY"];function bGe(t){return K4t.test(t)}function _Ge(t){return Z4t.test(t)}function Ave(t,s,r){const n=X4t(t,s,r);if(console.warn(n),Y4t.includes(t))throw new RangeError(n)}function X4t(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 Q4t=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,J4t=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,eSt=/^'([^]*?)'?$/,tSt=/''/g,sSt=/[a-zA-Z]/;function ps(t,s,r){var p,f,g,b,_,j,w,N;const n=Aw(),a=(r==null?void 0:r.locale)??n.locale??Xde,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??((b=(g=n.locale)==null?void 0:g.options)==null?void 0:b.firstWeekContainsDate)??1,l=(r==null?void 0:r.weekStartsOn)??((j=(_=r==null?void 0:r.locale)==null?void 0:_.options)==null?void 0:j.weekStartsOn)??n.weekStartsOn??((N=(w=n.locale)==null?void 0:w.options)==null?void 0:N.weekStartsOn)??0,i=ea(t);if(!Mve(i))throw new RangeError("Invalid time value");let c=s.match(J4t).map(C=>{const M=C[0];if(M==="p"||M==="P"){const I=Tve[M];return I(C,a.formatLong)}return C}).join("").match(Q4t).map(C=>{if(C==="''")return{isToken:!1,value:"'"};const M=C[0];if(M==="'")return{isToken:!1,value:rSt(C)};if(a6e[M])return{isToken:!0,value:C};if(M.match(sSt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+M+"`");return{isToken:!1,value:C}});a.localize.preprocessor&&(c=a.localize.preprocessor(i,c));const u={firstWeekContainsDate:o,weekStartsOn:l,locale:a};return c.map(C=>{if(!C.isToken)return C.value;const M=C.value;(!(r!=null&&r.useAdditionalWeekYearTokens)&&_Ge(M)||!(r!=null&&r.useAdditionalDayOfYearTokens)&&bGe(M))&&Ave(M,s,String(t));const I=a6e[M[0]];return I(i,M,a.localize,u)}).join("")}function rSt(t){const s=t.match(eSt);return s?s[1].replace(tSt,"'"):t}function nSt(t,s,r){const n=Aw(),a=(r==null?void 0:r.locale)??n.locale??Xde,o=2520,l=cie(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=ea(s),u=ea(t)):(c=ea(t),u=ea(s));const p=u4t(u,c),f=(cw(u)-cw(c))/1e3,g=Math.round((p-f)/60);let b;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(gn.getTime()}function FS(t,s){const r=ea(t),n=ea(s);return+r<+n}function uSt(t){return+ea(t)>Date.now()}function hSt(t,s){const r=s instanceof Date?pl(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 mSt=10;class wGe{constructor(){Nn(this,"subPriority",0)}validate(s,r){return!0}}class pSt extends wGe{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 fSt extends wGe{constructor(){super(...arguments);Nn(this,"priority",mSt);Nn(this,"subPriority",-1)}set(r,n){return n.timestampIsSet?r:pl(r,hSt(r,Date))}}class nl{run(s,r,n,a){const o=this.parse(s,r,n,a);return o?{setter:new pSt(o.value,this.validate,this.set,this.priority,this.subPriority),rest:o.rest}:null}validate(s,r,n){return!0}}class xSt extends nl{constructor(){super(...arguments);Nn(this,"priority",140);Nn(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 Id={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}/},t0={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 Ld(t,s){return t&&{value:s(t.value),rest:t.rest}}function Yc(t,s){const r=s.match(t);return r?{value:parseInt(r[0],10),rest:s.slice(r[0].length)}:null}function s0(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*EO+o*Zde+l*e4t),rest:s.slice(r[0].length)}}function jGe(t){return Yc(Id.anyDigitsSigned,t)}function jd(t,s){switch(t){case 1:return Yc(Id.singleDigit,s);case 2:return Yc(Id.twoDigits,s);case 3:return Yc(Id.threeDigits,s);case 4:return Yc(Id.fourDigits,s);default:return Yc(new RegExp("^\\d{1,"+t+"}"),s)}}function _oe(t,s){switch(t){case 1:return Yc(Id.singleDigitSigned,s);case 2:return Yc(Id.twoDigitsSigned,s);case 3:return Yc(Id.threeDigitsSigned,s);case 4:return Yc(Id.fourDigitsSigned,s);default:return Yc(new RegExp("^-?\\d{1,"+t+"}"),s)}}function pje(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 NGe(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 kGe(t){return t%400===0||t%4===0&&t%100!==0}class gSt extends nl{constructor(){super(...arguments);Nn(this,"priority",130);Nn(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 Ld(jd(4,r),o);case"yo":return Ld(a.ordinalNumber(r,{unit:"year"}),o);default:return Ld(jd(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=NGe(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 ySt extends nl{constructor(){super(...arguments);Nn(this,"priority",130);Nn(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 Ld(jd(4,r),o);case"Yo":return Ld(a.ordinalNumber(r,{unit:"year"}),o);default:return Ld(jd(n.length,r),o)}}validate(r,n){return n.isTwoDigitYear||n.year>0}set(r,n,a,o){const l=hje(r,o);if(a.isTwoDigitYear){const c=NGe(a.year,l);return r.setFullYear(c,0,o.firstWeekContainsDate),r.setHours(0,0,0,0),Yh(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),Yh(r,o)}}class vSt extends nl{constructor(){super(...arguments);Nn(this,"priority",130);Nn(this,"incompatibleTokens",["G","y","Y","u","Q","q","M","L","w","d","D","e","c","t","T"])}parse(r,n){return _oe(n==="R"?4:n.length,r)}set(r,n,a){const o=pl(r,0);return o.setFullYear(a,0,4),o.setHours(0,0,0,0),M1(o)}}class bSt extends nl{constructor(){super(...arguments);Nn(this,"priority",130);Nn(this,"incompatibleTokens",["G","y","Y","R","w","I","i","e","c","t","T"])}parse(r,n){return _oe(n==="u"?4:n.length,r)}set(r,n,a){return r.setFullYear(a,0,1),r.setHours(0,0,0,0),r}}class _St extends nl{constructor(){super(...arguments);Nn(this,"priority",120);Nn(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 jd(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 wSt extends nl{constructor(){super(...arguments);Nn(this,"priority",120);Nn(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 jd(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 jSt extends nl{constructor(){super(...arguments);Nn(this,"incompatibleTokens",["Y","R","q","Q","L","w","I","D","i","e","c","t","T"]);Nn(this,"priority",110)}parse(r,n,a){const o=l=>l-1;switch(n){case"M":return Ld(Yc(Id.month,r),o);case"MM":return Ld(jd(2,r),o);case"Mo":return Ld(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 NSt extends nl{constructor(){super(...arguments);Nn(this,"priority",110);Nn(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 Ld(Yc(Id.month,r),o);case"LL":return Ld(jd(2,r),o);case"Lo":return Ld(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 kSt(t,s,r){const n=ea(t),a=mje(n,r)-s;return n.setDate(n.getDate()-a*7),n}class SSt extends nl{constructor(){super(...arguments);Nn(this,"priority",100);Nn(this,"incompatibleTokens",["y","R","u","q","Q","M","L","I","d","D","i","t","T"])}parse(r,n,a){switch(n){case"w":return Yc(Id.week,r);case"wo":return a.ordinalNumber(r,{unit:"week"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a,o){return Yh(kSt(r,a,o),o)}}function CSt(t,s){const r=ea(t),n=uje(r)-s;return r.setDate(r.getDate()-n*7),r}class MSt extends nl{constructor(){super(...arguments);Nn(this,"priority",100);Nn(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 Yc(Id.week,r);case"Io":return a.ordinalNumber(r,{unit:"week"});default:return jd(n.length,r)}}validate(r,n){return n>=1&&n<=53}set(r,n,a){return M1(CSt(r,a))}}const TSt=[31,28,31,30,31,30,31,31,30,31,30,31],ASt=[31,29,31,30,31,30,31,31,30,31,30,31];class ESt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(this,"subPriority",1);Nn(this,"incompatibleTokens",["Y","R","q","Q","w","I","D","i","e","c","t","T"])}parse(r,n,a){switch(n){case"d":return Yc(Id.date,r);case"do":return a.ordinalNumber(r,{unit:"date"});default:return jd(n.length,r)}}validate(r,n){const a=r.getFullYear(),o=kGe(a),l=r.getMonth();return o?n>=1&&n<=ASt[l]:n>=1&&n<=TSt[l]}set(r,n,a){return r.setDate(a),r.setHours(0,0,0,0),r}}class PSt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(this,"subpriority",1);Nn(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 Yc(Id.dayOfYear,r);case"Do":return a.ordinalNumber(r,{unit:"date"});default:return jd(n.length,r)}}validate(r,n){const a=r.getFullYear();return kGe(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 fje(t,s,r){var f,g,b,_;const n=Aw(),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??((_=(b=n.locale)==null?void 0:b.options)==null?void 0:_.weekStartsOn)??0,o=ea(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 Tl(o,p)}class ISt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(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=fje(r,a,o),r.setHours(0,0,0,0),r}}class LSt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(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 Ld(jd(n.length,r),l);case"eo":return Ld(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=fje(r,a,o),r.setHours(0,0,0,0),r}}class DSt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(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 Ld(jd(n.length,r),l);case"co":return Ld(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=fje(r,a,o),r.setHours(0,0,0,0),r}}function OSt(t,s){const r=ea(t),n=oSt(r),a=s-n;return Tl(r,a)}class RSt extends nl{constructor(){super(...arguments);Nn(this,"priority",90);Nn(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 jd(n.length,r);case"io":return a.ordinalNumber(r,{unit:"day"});case"iii":return Ld(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 Ld(a.day(r,{width:"narrow",context:"formatting"}),o);case"iiiiii":return Ld(a.day(r,{width:"short",context:"formatting"})||a.day(r,{width:"narrow",context:"formatting"}),o);case"iiii":default:return Ld(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=OSt(r,a),r.setHours(0,0,0,0),r}}class FSt extends nl{constructor(){super(...arguments);Nn(this,"priority",80);Nn(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(pje(a),0,0,0),r}}class zSt extends nl{constructor(){super(...arguments);Nn(this,"priority",80);Nn(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(pje(a),0,0,0),r}}class BSt extends nl{constructor(){super(...arguments);Nn(this,"priority",80);Nn(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(pje(a),0,0,0),r}}class $St extends nl{constructor(){super(...arguments);Nn(this,"priority",70);Nn(this,"incompatibleTokens",["H","K","k","t","T"])}parse(r,n,a){switch(n){case"h":return Yc(Id.hour12h,r);case"ho":return a.ordinalNumber(r,{unit:"hour"});default:return jd(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 qSt extends nl{constructor(){super(...arguments);Nn(this,"priority",70);Nn(this,"incompatibleTokens",["a","b","h","K","k","t","T"])}parse(r,n,a){switch(n){case"H":return Yc(Id.hour23h,r);case"Ho":return a.ordinalNumber(r,{unit:"hour"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=23}set(r,n,a){return r.setHours(a,0,0,0),r}}class USt extends nl{constructor(){super(...arguments);Nn(this,"priority",70);Nn(this,"incompatibleTokens",["h","H","k","t","T"])}parse(r,n,a){switch(n){case"K":return Yc(Id.hour11h,r);case"Ko":return a.ordinalNumber(r,{unit:"hour"});default:return jd(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 VSt extends nl{constructor(){super(...arguments);Nn(this,"priority",70);Nn(this,"incompatibleTokens",["a","b","h","H","K","t","T"])}parse(r,n,a){switch(n){case"k":return Yc(Id.hour24h,r);case"ko":return a.ordinalNumber(r,{unit:"hour"});default:return jd(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 HSt extends nl{constructor(){super(...arguments);Nn(this,"priority",60);Nn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"m":return Yc(Id.minute,r);case"mo":return a.ordinalNumber(r,{unit:"minute"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setMinutes(a,0,0),r}}class WSt extends nl{constructor(){super(...arguments);Nn(this,"priority",50);Nn(this,"incompatibleTokens",["t","T"])}parse(r,n,a){switch(n){case"s":return Yc(Id.second,r);case"so":return a.ordinalNumber(r,{unit:"second"});default:return jd(n.length,r)}}validate(r,n){return n>=0&&n<=59}set(r,n,a){return r.setSeconds(a,0),r}}class GSt extends nl{constructor(){super(...arguments);Nn(this,"priority",30);Nn(this,"incompatibleTokens",["t","T"])}parse(r,n){const a=o=>Math.trunc(o*Math.pow(10,-n.length+3));return Ld(jd(n.length,r),a)}set(r,n,a){return r.setMilliseconds(a),r}}class KSt extends nl{constructor(){super(...arguments);Nn(this,"priority",10);Nn(this,"incompatibleTokens",["t","T","x"])}parse(r,n){switch(n){case"X":return s0(t0.basicOptionalMinutes,r);case"XX":return s0(t0.basic,r);case"XXXX":return s0(t0.basicOptionalSeconds,r);case"XXXXX":return s0(t0.extendedOptionalSeconds,r);case"XXX":default:return s0(t0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:pl(r,r.getTime()-cw(r)-a)}}class ZSt extends nl{constructor(){super(...arguments);Nn(this,"priority",10);Nn(this,"incompatibleTokens",["t","T","X"])}parse(r,n){switch(n){case"x":return s0(t0.basicOptionalMinutes,r);case"xx":return s0(t0.basic,r);case"xxxx":return s0(t0.basicOptionalSeconds,r);case"xxxxx":return s0(t0.extendedOptionalSeconds,r);case"xxx":default:return s0(t0.extended,r)}}set(r,n,a){return n.timestampIsSet?r:pl(r,r.getTime()-cw(r)-a)}}class YSt extends nl{constructor(){super(...arguments);Nn(this,"priority",40);Nn(this,"incompatibleTokens","*")}parse(r){return jGe(r)}set(r,n,a){return[pl(r,a*1e3),{timestampIsSet:!0}]}}class XSt extends nl{constructor(){super(...arguments);Nn(this,"priority",20);Nn(this,"incompatibleTokens","*")}parse(r){return jGe(r)}set(r,n,a){return[pl(r,a),{timestampIsSet:!0}]}}const QSt={G:new xSt,y:new gSt,Y:new ySt,R:new vSt,u:new bSt,Q:new _St,q:new wSt,M:new jSt,L:new NSt,w:new SSt,I:new MSt,d:new ESt,D:new PSt,E:new ISt,e:new LSt,c:new DSt,i:new RSt,a:new FSt,b:new zSt,B:new BSt,h:new $St,H:new qSt,K:new USt,k:new VSt,m:new HSt,s:new WSt,S:new GSt,X:new KSt,x:new ZSt,t:new YSt,T:new XSt},JSt=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,eCt=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,tCt=/^'([^]*?)'?$/,sCt=/''/g,rCt=/\S/,nCt=/[a-zA-Z]/;function xje(t,s,r,n){var j,w,N,C;const a=iSt(),o=a.locale??Xde,l=a.firstWeekContainsDate??((w=(j=a.locale)==null?void 0:j.options)==null?void 0:w.firstWeekContainsDate)??1,i=a.weekStartsOn??((C=(N=a.locale)==null?void 0:N.options)==null?void 0:C.weekStartsOn)??0;if(s==="")return t===""?ea(r):pl(r,NaN);const c={firstWeekContainsDate:l,weekStartsOn:i,locale:o},u=[new fSt],p=s.match(eCt).map(M=>{const I=M[0];if(I in Tve){const L=Tve[I];return L(M,o.formatLong)}return M}).join("").match(JSt),f=[];for(let M of p){_Ge(M)&&Ave(M,s,t),bGe(M)&&Ave(M,s,t);const I=M[0],L=QSt[I];if(L){const{incompatibleTokens:R}=L;if(Array.isArray(R)){const U=f.find(B=>R.includes(B.token)||B.token===I);if(U)throw new RangeError(`The format string mustn't contain \`${U.fullToken}\` and \`${M}\` at the same time`)}else if(L.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:I,fullToken:M});const q=L.run(t,M,o.match,c);if(!q)return pl(r,NaN);u.push(q.setter),t=q.rest}else{if(I.match(nCt))throw new RangeError("Format string contains an unescaped latin alphabet character `"+I+"`");if(M==="''"?M="'":I==="'"&&(M=aCt(M)),t.indexOf(M)===0)t=t.slice(M.length);else return pl(r,NaN)}}if(t.length>0&&rCt.test(t))return pl(r,NaN);const g=u.map(M=>M.priority).sort((M,I)=>I-M).filter((M,I,L)=>L.indexOf(M)===I).map(M=>u.filter(I=>I.priority===M).sort((I,L)=>L.subPriority-I.subPriority)).map(M=>M[0]);let b=ea(r);if(isNaN(b.getTime()))return pl(r,NaN);const _={};for(const M of g){if(!M.validate(b,c))return pl(r,NaN);const I=M.set(b,_,c);Array.isArray(I)?(b=I[0],Object.assign(_,I[1])):b=I}return pl(r,b)}function aCt(t){return t.match(tCt)[1].replace(sCt,"'")}function y0(t){return+ea(t)o-l);return r>=n&&r<=a}function die(t,s){return Tl(t,-s)}function wm(t,s){const n=hCt(t);let a;if(n.date){const c=mCt(n.date,2);a=pCt(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=fCt(n.time),isNaN(l)))return new Date(NaN);if(n.timezone){if(i=xCt(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 J7={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},cCt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,dCt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,uCt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function hCt(t){const s={},r=t.split(J7.dateTimeDelimiter);let n;if(r.length>2)return s;if(/:/.test(r[0])?n=r[0]:(s.date=r[0],n=r[1],J7.timeZoneDelimiter.test(s.date)&&(s.date=t.split(J7.timeZoneDelimiter)[0],n=t.substr(s.date.length,t.length))),n){const a=J7.timezone.exec(n);a?(s.time=n.replace(a[1],""),s.timezone=a[1]):s.time=n}return s}function mCt(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 pCt(t,s){if(s===null)return new Date(NaN);const r=t.match(cCt);if(!r)return new Date(NaN);const n=!!r[4],a=qP(r[1]),o=qP(r[2])-1,l=qP(r[3]),i=qP(r[4]),c=qP(r[5])-1;if(n)return _Ct(s,i,c)?gCt(s,i,c):new Date(NaN);{const u=new Date(0);return!vCt(s,o,l)||!bCt(s,a)?new Date(NaN):(u.setUTCFullYear(s,o,Math.max(a,l)),u)}}function qP(t){return t?parseInt(t):1}function fCt(t){const s=t.match(dCt);if(!s)return NaN;const r=wxe(s[1]),n=wxe(s[2]),a=wxe(s[3]);return wCt(r,n,a)?r*EO+n*Zde+a*1e3:NaN}function wxe(t){return t&&parseFloat(t.replace(",","."))||0}function xCt(t){if(t==="Z")return 0;const s=t.match(uCt);if(!s)return 0;const r=s[1]==="+"?-1:1,n=parseInt(s[2]),a=s[3]&&parseInt(s[3])||0;return jCt(n,a)?r*(n*EO+a*Zde):NaN}function gCt(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 yCt=[31,null,31,30,31,30,31,31,30,31,30,31];function SGe(t){return t%400===0||t%4===0&&t%100!==0}function vCt(t,s,r){return s>=0&&s<=11&&r>=1&&r<=(yCt[s]||(SGe(t)?29:28))}function bCt(t,s){return s>=1&&s<=(SGe(t)?366:365)}function _Ct(t,s,r){return s>=1&&s<=53&&r>=0&&r<=6}function wCt(t,s,r){return t===24?s===0&&r===0:r>=0&&r<60&&s>=0&&s<60&&t>=0&&t<25}function jCt(t,s){return s>=0&&s<=59}function jxe(t,s){const r=ea(t),n=r.getFullYear(),a=r.getDate(),o=pl(t,0);o.setFullYear(n,s,15),o.setHours(0,0,0,0);const l=aSt(o);return r.setMonth(s,Math.min(a,l)),r}function $L(t,s){const r=ea(t);return r.setHours(s),r}function qL(t,s){const r=ea(t);return r.setMinutes(s),r}function d6e(t,s){const r=ea(t);return isNaN(+r)?pl(t,NaN):(r.setFullYear(s),r)}function f4(t,s){return zm(t,-s)}var Go;(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})(Go||(Go={}));var u6e;(function(t){t.mergeShapes=(s,r)=>({...s,...r})})(u6e||(u6e={}));const da=Go.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Hb=t=>{switch(typeof t){case"undefined":return da.undefined;case"string":return da.string;case"number":return Number.isNaN(t)?da.nan:da.number;case"boolean":return da.boolean;case"function":return da.function;case"bigint":return da.bigint;case"symbol":return da.symbol;case"object":return Array.isArray(t)?da.array:t===null?da.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?da.promise:typeof Map<"u"&&t instanceof Map?da.map:typeof Set<"u"&&t instanceof Set?da.set:typeof Date<"u"&&t instanceof Date?da.date:da.object;default:return da.unknown}},nn=Go.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 k0 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()}}k0.create=t=>new k0(t);const Eve=(t,s)=>{let r;switch(t.code){case nn.invalid_type:t.received===da.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case nn.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Go.jsonStringifyReplacer)}`;break;case nn.unrecognized_keys:r=`Unrecognized key(s) in object: ${Go.joinValues(t.keys,", ")}`;break;case nn.invalid_union:r="Invalid input";break;case nn.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Go.joinValues(t.options)}`;break;case nn.invalid_enum_value:r=`Invalid enum value. Expected ${Go.joinValues(t.options)}, received '${t.received}'`;break;case nn.invalid_arguments:r="Invalid function arguments";break;case nn.invalid_return_type:r="Invalid function return type";break;case nn.invalid_date:r="Invalid date";break;case nn.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}"`:Go.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case nn.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 nn.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 nn.custom:r="Invalid input";break;case nn.invalid_intersection_types:r="Intersection results could not be merged";break;case nn.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case nn.not_finite:r="Number must be finite";break;default:r=s.defaultError,Go.assertNever(t)}return{message:r}};let NCt=Eve;function kCt(){return NCt}const SCt=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 Zn(t,s){const r=kCt(),n=SCt({issueData:s,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Eve?void 0:Eve].filter(a=>!!a)});t.common.issues.push(n)}class Cf{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 Cf.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"}),bI=t=>({status:"dirty",value:t}),$x=t=>({status:"valid",value:t}),h6e=t=>t.status==="aborted",m6e=t=>t.status==="dirty",DT=t=>t.status==="valid",woe=t=>typeof Promise<"u"&&t instanceof Promise;var _a;(function(t){t.errToObj=s=>typeof s=="string"?{message:s}:s||{},t.toString=s=>typeof s=="string"?s:s==null?void 0:s.message})(_a||(_a={}));class dw{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 p6e=(t,s)=>{if(DT(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 k0(t.common.issues);return this._error=r,this._error}}};function ao(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 Uo{get description(){return this._def.description}_getType(s){return Hb(s.data)}_getOrReturnCtx(s,r){return r||{common:s.parent.common,data:s.data,parsedType:Hb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}_processInputParams(s){return{status:new Cf,ctx:{common:s.parent.common,data:s.data,parsedType:Hb(s.data),schemaErrorMap:this._def.errorMap,path:s.path,parent:s.parent}}}_parseSync(s){const r=this._parse(s);if(woe(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:Hb(s)},a=this._parseSync({data:s,path:n.path,parent:n});return p6e(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:Hb(s)};if(!this["~standard"].async)try{const o=this._parseSync({data:s,path:[],parent:r});return DT(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=>DT(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:Hb(s)},a=this._parse({data:s,path:n.path,parent:n}),o=await(woe(a)?a:Promise.resolve(a));return p6e(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:nn.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 FT({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 K_.create(this,this._def)}nullable(){return zT.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return v0.create(this)}promise(){return Soe.create(this,this._def)}or(s){return Noe.create([this,s],this._def)}and(s){return koe.create(this,s,this._def)}transform(s){return new FT({...ao(this._def),schema:this,typeName:zi.ZodEffects,effect:{type:"transform",transform:s}})}default(s){const r=typeof s=="function"?s:()=>s;return new Dve({...ao(this._def),innerType:this,defaultValue:r,typeName:zi.ZodDefault})}brand(){return new ZCt({typeName:zi.ZodBranded,type:this,...ao(this._def)})}catch(s){const r=typeof s=="function"?s:()=>s;return new Ove({...ao(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 gje.create(this,s)}readonly(){return Rve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const CCt=/^c[^\s-]{8,}$/i,MCt=/^[0-9a-z]+$/,TCt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ACt=/^[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,ECt=/^[a-z0-9_-]{21}$/i,PCt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ICt=/^[-+]?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,DCt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Nxe;const OCt=/^(?:(?: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])$/,RCt=/^(?:(?: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])$/,FCt=/^(([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]))$/,zCt=/^(([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])$/,BCt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$Ct=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,CGe="((\\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])))",qCt=new RegExp(`^${CGe}$`);function MGe(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 UCt(t){return new RegExp(`^${MGe(t)}$`)}function VCt(t){let s=`${CGe}T${MGe(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 HCt(t,s){return!!((s==="v4"||!s)&&OCt.test(t)||(s==="v6"||!s)&&FCt.test(t))}function WCt(t,s){if(!PCt.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 GCt(t,s){return!!((s==="v4"||!s)&&RCt.test(t)||(s==="v6"||!s)&&zCt.test(t))}class __ extends Uo{_parse(s){if(this._def.coerce&&(s.data=String(s.data)),this._getType(s)!==da.string){const o=this._getOrReturnCtx(s);return Zn(o,{code:nn.invalid_type,expected:da.string,received:o.parsedType}),Fi}const n=new Cf;let a;for(const o of this._def.checks)if(o.kind==="min")s.data.lengtho.value&&(a=this._getOrReturnCtx(s,a),Zn(a,{code:nn.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:nn.invalid_string,..._a.errToObj(n)})}_addCheck(s){return new __({...this._def,checks:[...this._def.checks,s]})}email(s){return this._addCheck({kind:"email",..._a.errToObj(s)})}url(s){return this._addCheck({kind:"url",..._a.errToObj(s)})}emoji(s){return this._addCheck({kind:"emoji",..._a.errToObj(s)})}uuid(s){return this._addCheck({kind:"uuid",..._a.errToObj(s)})}nanoid(s){return this._addCheck({kind:"nanoid",..._a.errToObj(s)})}cuid(s){return this._addCheck({kind:"cuid",..._a.errToObj(s)})}cuid2(s){return this._addCheck({kind:"cuid2",..._a.errToObj(s)})}ulid(s){return this._addCheck({kind:"ulid",..._a.errToObj(s)})}base64(s){return this._addCheck({kind:"base64",..._a.errToObj(s)})}base64url(s){return this._addCheck({kind:"base64url",..._a.errToObj(s)})}jwt(s){return this._addCheck({kind:"jwt",..._a.errToObj(s)})}ip(s){return this._addCheck({kind:"ip",..._a.errToObj(s)})}cidr(s){return this._addCheck({kind:"cidr",..._a.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,..._a.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,..._a.errToObj(s==null?void 0:s.message)})}duration(s){return this._addCheck({kind:"duration",..._a.errToObj(s)})}regex(s,r){return this._addCheck({kind:"regex",regex:s,..._a.errToObj(r)})}includes(s,r){return this._addCheck({kind:"includes",value:s,position:r==null?void 0:r.position,..._a.errToObj(r==null?void 0:r.message)})}startsWith(s,r){return this._addCheck({kind:"startsWith",value:s,..._a.errToObj(r)})}endsWith(s,r){return this._addCheck({kind:"endsWith",value:s,..._a.errToObj(r)})}min(s,r){return this._addCheck({kind:"min",value:s,..._a.errToObj(r)})}max(s,r){return this._addCheck({kind:"max",value:s,..._a.errToObj(r)})}length(s,r){return this._addCheck({kind:"length",value:s,..._a.errToObj(r)})}nonempty(s){return this.min(1,_a.errToObj(s))}trim(){return new __({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new __({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new __({...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 __({checks:[],typeName:zi.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...ao(t)});function KCt(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 OT extends Uo{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)!==da.number){const o=this._getOrReturnCtx(s);return Zn(o,{code:nn.invalid_type,expected:da.number,received:o.parsedType}),Fi}let n;const a=new Cf;for(const o of this._def.checks)o.kind==="int"?Go.isInteger(s.data)||(n=this._getOrReturnCtx(s,n),Zn(n,{code:nn.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),Zn(n,{code:nn.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty()):o.kind==="multipleOf"?KCt(s.data,o.value)!==0&&(n=this._getOrReturnCtx(s,n),Zn(n,{code:nn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):o.kind==="finite"?Number.isFinite(s.data)||(n=this._getOrReturnCtx(s,n),Zn(n,{code:nn.not_finite,message:o.message}),a.dirty()):Go.assertNever(o);return{status:a.value,value:s.data}}gte(s,r){return this.setLimit("min",s,!0,_a.toString(r))}gt(s,r){return this.setLimit("min",s,!1,_a.toString(r))}lte(s,r){return this.setLimit("max",s,!0,_a.toString(r))}lt(s,r){return this.setLimit("max",s,!1,_a.toString(r))}setLimit(s,r,n,a){return new OT({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:_a.toString(a)}]})}_addCheck(s){return new OT({...this._def,checks:[...this._def.checks,s]})}int(s){return this._addCheck({kind:"int",message:_a.toString(s)})}positive(s){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_a.toString(s)})}negative(s){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_a.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_a.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_a.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:_a.toString(r)})}finite(s){return this._addCheck({kind:"finite",message:_a.toString(s)})}safe(s){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_a.toString(s)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_a.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"&&Go.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 OT({checks:[],typeName:zi.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...ao(t)});class X8 extends Uo{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)!==da.bigint)return this._getInvalidInput(s);let n;const a=new Cf;for(const o of this._def.checks)o.kind==="min"?(o.inclusive?s.datao.value:s.data>=o.value)&&(n=this._getOrReturnCtx(s,n),Zn(n,{code:nn.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),Zn(n,{code:nn.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):Go.assertNever(o);return{status:a.value,value:s.data}}_getInvalidInput(s){const r=this._getOrReturnCtx(s);return Zn(r,{code:nn.invalid_type,expected:da.bigint,received:r.parsedType}),Fi}gte(s,r){return this.setLimit("min",s,!0,_a.toString(r))}gt(s,r){return this.setLimit("min",s,!1,_a.toString(r))}lte(s,r){return this.setLimit("max",s,!0,_a.toString(r))}lt(s,r){return this.setLimit("max",s,!1,_a.toString(r))}setLimit(s,r,n,a){return new X8({...this._def,checks:[...this._def.checks,{kind:s,value:r,inclusive:n,message:_a.toString(a)}]})}_addCheck(s){return new X8({...this._def,checks:[...this._def.checks,s]})}positive(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_a.toString(s)})}negative(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_a.toString(s)})}nonpositive(s){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_a.toString(s)})}nonnegative(s){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_a.toString(s)})}multipleOf(s,r){return this._addCheck({kind:"multipleOf",value:s,message:_a.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 X8({checks:[],typeName:zi.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...ao(t)});class Pve extends Uo{_parse(s){if(this._def.coerce&&(s.data=!!s.data),this._getType(s)!==da.boolean){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.boolean,received:n.parsedType}),Fi}return $x(s.data)}}Pve.create=t=>new Pve({typeName:zi.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...ao(t)});class joe extends Uo{_parse(s){if(this._def.coerce&&(s.data=new Date(s.data)),this._getType(s)!==da.date){const o=this._getOrReturnCtx(s);return Zn(o,{code:nn.invalid_type,expected:da.date,received:o.parsedType}),Fi}if(Number.isNaN(s.data.getTime())){const o=this._getOrReturnCtx(s);return Zn(o,{code:nn.invalid_date}),Fi}const n=new Cf;let a;for(const o of this._def.checks)o.kind==="min"?s.data.getTime()o.value&&(a=this._getOrReturnCtx(s,a),Zn(a,{code:nn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Go.assertNever(o);return{status:n.value,value:new Date(s.data.getTime())}}_addCheck(s){return new joe({...this._def,checks:[...this._def.checks,s]})}min(s,r){return this._addCheck({kind:"min",value:s.getTime(),message:_a.toString(r)})}max(s,r){return this._addCheck({kind:"max",value:s.getTime(),message:_a.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 joe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:zi.ZodDate,...ao(t)});class f6e extends Uo{_parse(s){if(this._getType(s)!==da.symbol){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.symbol,received:n.parsedType}),Fi}return $x(s.data)}}f6e.create=t=>new f6e({typeName:zi.ZodSymbol,...ao(t)});class x6e extends Uo{_parse(s){if(this._getType(s)!==da.undefined){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.undefined,received:n.parsedType}),Fi}return $x(s.data)}}x6e.create=t=>new x6e({typeName:zi.ZodUndefined,...ao(t)});class g6e extends Uo{_parse(s){if(this._getType(s)!==da.null){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.null,received:n.parsedType}),Fi}return $x(s.data)}}g6e.create=t=>new g6e({typeName:zi.ZodNull,...ao(t)});class y6e extends Uo{constructor(){super(...arguments),this._any=!0}_parse(s){return $x(s.data)}}y6e.create=t=>new y6e({typeName:zi.ZodAny,...ao(t)});class v6e extends Uo{constructor(){super(...arguments),this._unknown=!0}_parse(s){return $x(s.data)}}v6e.create=t=>new v6e({typeName:zi.ZodUnknown,...ao(t)});class uw extends Uo{_parse(s){const r=this._getOrReturnCtx(s);return Zn(r,{code:nn.invalid_type,expected:da.never,received:r.parsedType}),Fi}}uw.create=t=>new uw({typeName:zi.ZodNever,...ao(t)});class b6e extends Uo{_parse(s){if(this._getType(s)!==da.undefined){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.void,received:n.parsedType}),Fi}return $x(s.data)}}b6e.create=t=>new b6e({typeName:zi.ZodVoid,...ao(t)});class v0 extends Uo{_parse(s){const{ctx:r,status:n}=this._processInputParams(s),a=this._def;if(r.parsedType!==da.array)return Zn(r,{code:nn.invalid_type,expected:da.array,received:r.parsedType}),Fi;if(a.exactLength!==null){const l=r.data.length>a.exactLength.value,i=r.data.lengtha.maxLength.value&&(Zn(r,{code:nn.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 dw(r,l,r.path,i)))).then(l=>Cf.mergeArray(n,l));const o=[...r.data].map((l,i)=>a.type._parseSync(new dw(r,l,r.path,i)));return Cf.mergeArray(n,o)}get element(){return this._def.type}min(s,r){return new v0({...this._def,minLength:{value:s,message:_a.toString(r)}})}max(s,r){return new v0({...this._def,maxLength:{value:s,message:_a.toString(r)}})}length(s,r){return new v0({...this._def,exactLength:{value:s,message:_a.toString(r)}})}nonempty(s){return this.min(1,s)}}v0.create=(t,s)=>new v0({type:t,minLength:null,maxLength:null,exactLength:null,typeName:zi.ZodArray,...ao(s)});function I5(t){if(t instanceof Zd){const s={};for(const r in t.shape){const n=t.shape[r];s[r]=K_.create(I5(n))}return new Zd({...t._def,shape:()=>s})}else return t instanceof v0?new v0({...t._def,type:I5(t.element)}):t instanceof K_?K_.create(I5(t.unwrap())):t instanceof zT?zT.create(I5(t.unwrap())):t instanceof zS?zS.create(t.items.map(s=>I5(s))):t}class Zd extends Uo{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=Go.objectKeys(s);return this._cached={shape:s,keys:r},this._cached}_parse(s){if(this._getType(s)!==da.object){const u=this._getOrReturnCtx(s);return Zn(u,{code:nn.invalid_type,expected:da.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 uw&&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 dw(a,f,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof uw){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&&(Zn(a,{code:nn.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 dw(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=>Cf.mergeObjectSync(n,u)):Cf.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(s){return _a.errToObj,new Zd({...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:_a.errToObj(s).message??a}:{message:a}}}:{}})}strip(){return new Zd({...this._def,unknownKeys:"strip"})}passthrough(){return new Zd({...this._def,unknownKeys:"passthrough"})}extend(s){return new Zd({...this._def,shape:()=>({...this._def.shape(),...s})})}merge(s){return new Zd({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 Zd({...this._def,catchall:s})}pick(s){const r={};for(const n of Go.objectKeys(s))s[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Zd({...this._def,shape:()=>r})}omit(s){const r={};for(const n of Go.objectKeys(this.shape))s[n]||(r[n]=this.shape[n]);return new Zd({...this._def,shape:()=>r})}deepPartial(){return I5(this)}partial(s){const r={};for(const n of Go.objectKeys(this.shape)){const a=this.shape[n];s&&!s[n]?r[n]=a:r[n]=a.optional()}return new Zd({...this._def,shape:()=>r})}required(s){const r={};for(const n of Go.objectKeys(this.shape))if(s&&!s[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof K_;)o=o._def.innerType;r[n]=o}return new Zd({...this._def,shape:()=>r})}keyof(){return TGe(Go.objectKeys(this.shape))}}Zd.create=(t,s)=>new Zd({shape:()=>t,unknownKeys:"strip",catchall:uw.create(),typeName:zi.ZodObject,...ao(s)});Zd.strictCreate=(t,s)=>new Zd({shape:()=>t,unknownKeys:"strict",catchall:uw.create(),typeName:zi.ZodObject,...ao(s)});Zd.lazycreate=(t,s)=>new Zd({shape:t,unknownKeys:"strip",catchall:uw.create(),typeName:zi.ZodObject,...ao(s)});class Noe extends Uo{_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 k0(i.ctx.common.issues));return Zn(r,{code:nn.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 k0(c));return Zn(r,{code:nn.invalid_union,unionErrors:i}),Fi}}get options(){return this._def.options}}Noe.create=(t,s)=>new Noe({options:t,typeName:zi.ZodUnion,...ao(s)});function Ive(t,s){const r=Hb(t),n=Hb(s);if(t===s)return{valid:!0,data:t};if(r===da.object&&n===da.object){const a=Go.objectKeys(s),o=Go.objectKeys(t).filter(i=>a.indexOf(i)!==-1),l={...t,...s};for(const i of o){const c=Ive(t[i],s[i]);if(!c.valid)return{valid:!1};l[i]=c.data}return{valid:!0,data:l}}else if(r===da.array&&n===da.array){if(t.length!==s.length)return{valid:!1};const a=[];for(let o=0;o{if(h6e(o)||h6e(l))return Fi;const i=Ive(o.value,l.value);return i.valid?((m6e(o)||m6e(l))&&r.dirty(),{status:r.value,value:i.data}):(Zn(n,{code:nn.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}))}}koe.create=(t,s,r)=>new koe({left:t,right:s,typeName:zi.ZodIntersection,...ao(r)});class zS extends Uo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==da.array)return Zn(n,{code:nn.invalid_type,expected:da.array,received:n.parsedType}),Fi;if(n.data.lengththis._def.items.length&&(Zn(n,{code:nn.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 dw(n,l,n.path,i)):null}).filter(l=>!!l);return n.common.async?Promise.all(o).then(l=>Cf.mergeArray(r,l)):Cf.mergeArray(r,o)}get items(){return this._def.items}rest(s){return new zS({...this._def,rest:s})}}zS.create=(t,s)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new zS({items:t,typeName:zi.ZodTuple,rest:null,...ao(s)})};class _6e extends Uo{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!==da.map)return Zn(n,{code:nn.invalid_type,expected:da.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 dw(n,i,n.path,[u,"key"])),value:o._parse(new dw(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}}}}_6e.create=(t,s,r)=>new _6e({valueType:s,keyType:t,typeName:zi.ZodMap,...ao(r)});class Q8 extends Uo{_parse(s){const{status:r,ctx:n}=this._processInputParams(s);if(n.parsedType!==da.set)return Zn(n,{code:nn.invalid_type,expected:da.set,received:n.parsedType}),Fi;const a=this._def;a.minSize!==null&&n.data.sizea.maxSize.value&&(Zn(n,{code:nn.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 dw(n,c,n.path,u)));return n.common.async?Promise.all(i).then(c=>l(c)):l(i)}min(s,r){return new Q8({...this._def,minSize:{value:s,message:_a.toString(r)}})}max(s,r){return new Q8({...this._def,maxSize:{value:s,message:_a.toString(r)}})}size(s,r){return this.min(s,r).max(s,r)}nonempty(s){return this.min(1,s)}}Q8.create=(t,s)=>new Q8({valueType:t,minSize:null,maxSize:null,typeName:zi.ZodSet,...ao(s)});class w6e extends Uo{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})}}w6e.create=(t,s)=>new w6e({getter:t,typeName:zi.ZodLazy,...ao(s)});class Lve extends Uo{_parse(s){if(s.data!==this._def.value){const r=this._getOrReturnCtx(s);return Zn(r,{received:r.data,code:nn.invalid_literal,expected:this._def.value}),Fi}return{status:"valid",value:s.data}}get value(){return this._def.value}}Lve.create=(t,s)=>new Lve({value:t,typeName:zi.ZodLiteral,...ao(s)});function TGe(t,s){return new RT({values:t,typeName:zi.ZodEnum,...ao(s)})}class RT extends Uo{_parse(s){if(typeof s.data!="string"){const r=this._getOrReturnCtx(s),n=this._def.values;return Zn(r,{expected:Go.joinValues(n),received:r.parsedType,code:nn.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 Zn(r,{received:r.data,code:nn.invalid_enum_value,options:n}),Fi}return $x(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 RT.create(s,{...this._def,...r})}exclude(s,r=this._def){return RT.create(this.options.filter(n=>!s.includes(n)),{...this._def,...r})}}RT.create=TGe;class j6e extends Uo{_parse(s){const r=Go.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(s);if(n.parsedType!==da.string&&n.parsedType!==da.number){const a=Go.objectValues(r);return Zn(n,{expected:Go.joinValues(a),received:n.parsedType,code:nn.invalid_type}),Fi}if(this._cache||(this._cache=new Set(Go.getValidEnumValues(this._def.values))),!this._cache.has(s.data)){const a=Go.objectValues(r);return Zn(n,{received:n.data,code:nn.invalid_enum_value,options:a}),Fi}return $x(s.data)}get enum(){return this._def.values}}j6e.create=(t,s)=>new j6e({values:t,typeName:zi.ZodNativeEnum,...ao(s)});class Soe extends Uo{unwrap(){return this._def.type}_parse(s){const{ctx:r}=this._processInputParams(s);if(r.parsedType!==da.promise&&r.common.async===!1)return Zn(r,{code:nn.invalid_type,expected:da.promise,received:r.parsedType}),Fi;const n=r.parsedType===da.promise?r.data:Promise.resolve(r.data);return $x(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Soe.create=(t,s)=>new Soe({type:t,typeName:zi.ZodPromise,...ao(s)});class FT extends Uo{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=>{Zn(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"?bI(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"?bI(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(!DT(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=>DT(l)?Promise.resolve(a.transform(l.value,o)).then(i=>({status:r.value,value:i})):Fi);Go.assertNever(a)}}FT.create=(t,s,r)=>new FT({schema:t,typeName:zi.ZodEffects,effect:s,...ao(r)});FT.createWithPreprocess=(t,s,r)=>new FT({schema:s,effect:{type:"preprocess",transform:t},typeName:zi.ZodEffects,...ao(r)});class K_ extends Uo{_parse(s){return this._getType(s)===da.undefined?$x(void 0):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}K_.create=(t,s)=>new K_({innerType:t,typeName:zi.ZodOptional,...ao(s)});class zT extends Uo{_parse(s){return this._getType(s)===da.null?$x(null):this._def.innerType._parse(s)}unwrap(){return this._def.innerType}}zT.create=(t,s)=>new zT({innerType:t,typeName:zi.ZodNullable,...ao(s)});class Dve extends Uo{_parse(s){const{ctx:r}=this._processInputParams(s);let n=r.data;return r.parsedType===da.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Dve.create=(t,s)=>new Dve({innerType:t,typeName:zi.ZodDefault,defaultValue:typeof s.default=="function"?s.default:()=>s.default,...ao(s)});class Ove extends Uo{_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 woe(a)?a.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new k0(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new k0(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ove.create=(t,s)=>new Ove({innerType:t,typeName:zi.ZodCatch,catchValue:typeof s.catch=="function"?s.catch:()=>s.catch,...ao(s)});class N6e extends Uo{_parse(s){if(this._getType(s)!==da.nan){const n=this._getOrReturnCtx(s);return Zn(n,{code:nn.invalid_type,expected:da.nan,received:n.parsedType}),Fi}return{status:"valid",value:s.data}}}N6e.create=t=>new N6e({typeName:zi.ZodNaN,...ao(t)});class ZCt extends Uo{_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 gje extends Uo{_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(),bI(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 gje({in:s,out:r,typeName:zi.ZodPipeline})}}class Rve extends Uo{_parse(s){const r=this._def.innerType._parse(s),n=a=>(DT(a)&&(a.value=Object.freeze(a.value)),a);return woe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Rve.create=(t,s)=>new Rve({innerType:t,typeName:zi.ZodReadonly,...ao(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 pc=__.create,UL=OT.create,YCt=Pve.create;uw.create;v0.create;const hC=Zd.create;Noe.create;koe.create;zS.create;const Coe=Lve.create,AGe=RT.create;Soe.create;K_.create;zT.create;const Er=k.forwardRef(({className:t,...s},r)=>e.jsx("textarea",{className:Pt("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}));Er.displayName="Textarea";const XCt=["Excellent","Good","Neutral","Bad","Very Bad"],QCt=[5,4,3,2,1];function JCt({questions:t,visitorId:s,onComplete:r,onSkip:n}){const a=$kt(),[o,l]=k.useState({}),i=t.filter(g=>g.question_type==="rating"),c=t.filter(g=>g.question_type!=="rating"),u=(g,b)=>{l(_=>({..._,[g]:{rating_value:b}}))},p=(g,b)=>{l(_=>({..._,[g]:{text_value:b}}))},f=async()=>{const g=Object.entries(o).filter(([,b])=>b.rating_value!=null||b.text_value&&b.text_value.trim()).map(([b,_])=>{var j;return{visitor_id:s,question_id:b,rating_value:_.rating_value??null,text_value:((j=_.text_value)==null?void 0:j.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"}),XCt.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}),QCt.map(b=>{var _;return e.jsx("div",{className:"w-12 flex justify-center",children:e.jsx("button",{type:"button",onClick:()=>u(g.id,b),className:`w-6 h-6 rounded-full border-2 transition-all ${((_=o[g.id])==null?void 0:_.rating_value)===b?"bg-slate-900 border-slate-900":"border-slate-300 hover:border-slate-500"}`})},b)})]},g.id))]}),c.map(g=>{var b;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(Er,{value:((b=o[g.id])==null?void 0:b.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(ws,{className:"h-5 w-5 animate-spin"}):"Submit Feedback"})]})}const e3t=hC({first_name:pc().trim().min(1,"First name is required").max(50),last_name:pc().trim().max(50).optional(),email:pc().trim().email("Please enter a valid email").max(255).optional().or(Coe("")),phone:pc().trim().max(20).optional().or(Coe(""))}),t3t=[{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 EGe({slug:t}={}){var ne;const s=yo(),r=t||s.slug,{data:n,isLoading:a,error:o}=Fkt(r),l=Gkt(),[i,c]=k.useState("welcome"),[u,p]=k.useState(null),[f,g]=k.useState({first_name:"",last_name:"",email:"",phone:""}),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!1),[M,I]=k.useState(""),[L,R]=k.useState(""),{data:q,isLoading:U}=Bkt(n==null?void 0:n.id),B=!!(n!=null&&n.enable_survey);k.useEffect(()=>{i==="pending_survey"&&(U||c(B&&((q==null?void 0:q.length)??0)>0?"survey":"done"))},[i,U,B,q]);const V=re=>{if(!re)return"";const[le,pe]=re.split(":"),xe=parseInt(le),_e=xe>=12?"PM":"AM";return`${xe>12?xe-12:xe||12}:${pe} ${_e}`},Y=()=>{R("");const re=e3t.safeParse(f);if(!re.success){R(re.error.issues[0].message);return}if(!f.email&&!f.phone){R("Please provide either an email or phone number");return}c("intent")},J=async re=>{_(re);try{const le=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:j,has_agent:N,working_with_agent_name:N&&M.trim()?M.trim():void 0});p(le.id),B?!U&&q&&q.length>0?c("survey"):c("pending_survey"):c("done")}catch{R("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(Sn,{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 te=n.profiles,X=((ne=te==null?void 0:te.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(rd,{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(_n,{className:"h-16 w-16 mx-auto mb-3 ring-2 ring-white/20",children:[e.jsx(za,{src:(te==null?void 0:te.avatar_url)||"",alt:(te==null?void 0:te.name)||""}),e.jsx(wn,{className:"bg-white/10 text-white text-lg",children:X})]}),e.jsx("p",{className:"text-white/60 text-sm",children:te==null?void 0:te.name}),(te==null?void 0:te.title)&&e.jsx("p",{className:"text-white/40 text-xs",children:te.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(Ba,{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(cn,{className:"h-3 w-3"}),ps(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(mn,{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(wa,{className:"h-5 w-5 text-white"}):e.jsx(Sn,{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(Ba,{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(cn,{className:"h-3 w-3"}),ps(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(mn,{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(fi,{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(ri,{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(ye,{className:"text-slate-600 text-xs",children:"First Name *"}),e.jsx(ze,{value:f.first_name,onChange:re=>g(le=>({...le,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(ye,{className:"text-slate-600 text-xs",children:"Last Name"}),e.jsx(ze,{value:f.last_name,onChange:re=>g(le=>({...le,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(ye,{className:"text-slate-600 text-xs",children:"Email"}),e.jsx(ze,{type:"email",value:f.email,onChange:re=>g(le=>({...le,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(ye,{className:"text-slate-600 text-xs",children:"Phone"}),e.jsx(ze,{type:"tel",value:f.phone,onChange:re=>g(le=>({...le,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:j,onChange:re=>w(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:N?"Yes":"No"}),e.jsx($r,{checked:N,onCheckedChange:C})]})]}),N&&e.jsx(ze,{value:M,onChange:re=>I(re.target.value),placeholder:"Agent's name",className:"mt-1 h-10 rounded-xl border-slate-200 text-sm"})]}),L&&e.jsx("p",{className:"text-destructive text-sm",children:L}),e.jsxs(K,{onClick:Y,className:"w-full h-14 text-base bg-slate-900 hover:bg-slate-800 text-white rounded-xl",children:["Continue ",e.jsx(fi,{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(ri,{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:t3t.map(re=>e.jsxs("button",{onClick:()=>J(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))}),L&&e.jsx("p",{className:"text-destructive text-sm text-center",children:L})]}),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&&q&&e.jsx(JCt,{questions:q,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(la,{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!"]})]}),(te==null?void 0:te.name)&&e.jsxs("p",{className:"text-sm text-slate-400",children:["Your host today: ",e.jsx("strong",{className:"text-slate-600",children:te.name})]})]})]})]}),e.jsx("p",{className:"text-center text-white/30 text-xs mt-6",children:"Powered by LevelUp Guest Book"})]})})]})}function xMs(t){const{user:s}=Rs();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 gMs(){const t=es(),{user:s}=Rs();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 yMs(){const t=es();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 s3t(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 yje="ScrollArea",[PGe]=nd(yje),[n3t,qx]=PGe(yje),IGe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,type:n="hover",dir:a,scrollHideDelay:o=600,...l}=t,[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,C]=k.useState(0),[M,I]=k.useState(0),[L,R]=k.useState(!1),[q,U]=k.useState(!1),B=$a(s,Y=>c(Y)),V=Sw(a);return e.jsx(n3t,{scope:r,type:n,dir:V,scrollHideDelay:o,scrollArea:i,viewport:u,onViewportChange:p,content:f,onContentChange:g,scrollbarX:b,onScrollbarXChange:_,scrollbarXEnabled:L,onScrollbarXEnabledChange:R,scrollbarY:j,onScrollbarYChange:w,scrollbarYEnabled:q,onScrollbarYEnabledChange:U,onCornerWidthChange:C,onCornerHeightChange:I,children:e.jsx(sn.div,{dir:V,...l,ref:B,style:{position:"relative","--radix-scroll-area-corner-width":N+"px","--radix-scroll-area-corner-height":M+"px",...t.style}})})});IGe.displayName=yje;var LGe="ScrollAreaViewport",DGe=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,children:n,nonce:a,...o}=t,l=qx(LGe,r),i=k.useRef(null),c=$a(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(sn.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})})]})});DGe.displayName=LGe;var O0="ScrollAreaScrollbar",vje=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(O0,t.__scopeScrollArea),{onScrollbarXEnabledChange:o,onScrollbarYEnabledChange:l}=a,i=t.orientation==="horizontal";return k.useEffect(()=>(i?o(!0):l(!0),()=>{i?o(!1):l(!1)}),[i,o,l]),a.type==="hover"?e.jsx(a3t,{...n,ref:s,forceMount:r}):a.type==="scroll"?e.jsx(i3t,{...n,ref:s,forceMount:r}):a.type==="auto"?e.jsx(OGe,{...n,ref:s,forceMount:r}):a.type==="always"?e.jsx(bje,{...n,ref:s}):null});vje.displayName=O0;var a3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(O0,t.__scopeScrollArea),[o,l]=k.useState(!1);return k.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(Fd,{present:r||o,children:e.jsx(OGe,{"data-state":o?"visible":"hidden",...n,ref:s})})}),i3t=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=qx(O0,t.__scopeScrollArea),o=t.orientation==="horizontal",l=eue(()=>c("SCROLL_END"),100),[i,c]=r3t("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 k.useEffect(()=>{if(i==="idle"){const u=window.setTimeout(()=>c("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(u)}},[i,a.scrollHideDelay,c]),k.useEffect(()=>{const u=a.viewport,p=o?"scrollLeft":"scrollTop";if(u){let f=u[p];const g=()=>{const b=u[p];f!==b&&(c("SCROLL"),l()),f=b};return u.addEventListener("scroll",g),()=>u.removeEventListener("scroll",g)}},[a.viewport,o,c,l]),e.jsx(Fd,{present:r||i!=="hidden",children:e.jsx(bje,{"data-state":i==="hidden"?"hidden":"visible",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,()=>c("POINTER_ENTER")),onPointerLeave:Ir(t.onPointerLeave,()=>c("POINTER_LEAVE"))})})}),OGe=k.forwardRef((t,s)=>{const r=qx(O0,t.__scopeScrollArea),{forceMount:n,...a}=t,[o,l]=k.useState(!1),i=t.orientation==="horizontal",c=eue(()=>{if(r.viewport){const u=r.viewport.offsetWidth{const{orientation:r="vertical",...n}=t,a=qx(O0,t.__scopeScrollArea),o=k.useRef(null),l=k.useRef(0),[i,c]=k.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),u=$Ge(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,b){return h3t(g,l.current,i,b)}return r==="horizontal"?e.jsx(o3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollLeft,b=k6e(g,i,a.dir);o.current.style.transform=`translate3d(${b}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(l3t,{...p,ref:s,onThumbPositionChange:()=>{if(a.viewport&&o.current){const g=a.viewport.scrollTop,b=k6e(g,i);o.current.style.transform=`translate3d(0, ${b}px, 0)`}},onWheelScroll:g=>{a.viewport&&(a.viewport.scrollTop=g)},onDragScroll:g=>{a.viewport&&(a.viewport.scrollTop=f(g))}}):null}),o3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=qx(O0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=$a(s,c,o.onScrollbarXChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(FGe,{"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":Jde(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),UGe(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:Toe(l.paddingLeft),paddingEnd:Toe(l.paddingRight)}})}})}),l3t=k.forwardRef((t,s)=>{const{sizes:r,onSizesChange:n,...a}=t,o=qx(O0,t.__scopeScrollArea),[l,i]=k.useState(),c=k.useRef(null),u=$a(s,c,o.onScrollbarYChange);return k.useEffect(()=>{c.current&&i(getComputedStyle(c.current))},[c]),e.jsx(FGe,{"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":Jde(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),UGe(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:Toe(l.paddingTop),paddingEnd:Toe(l.paddingBottom)}})}})}),[c3t,RGe]=PGe(O0),FGe=k.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,b=qx(O0,r),[_,j]=k.useState(null),w=$a(s,B=>j(B)),N=k.useRef(null),C=k.useRef(""),M=b.viewport,I=n.content-n.viewport,L=gd(p),R=gd(c),q=eue(f,10);function U(B){if(N.current){const V=B.clientX-N.current.left,Y=B.clientY-N.current.top;u({x:V,y:Y})}}return k.useEffect(()=>{const B=V=>{const Y=V.target;(_==null?void 0:_.contains(Y))&&L(V,I)};return document.addEventListener("wheel",B,{passive:!1}),()=>document.removeEventListener("wheel",B,{passive:!1})},[M,_,I,L]),k.useEffect(R,[n,R]),BT(_,q),BT(b.content,q),e.jsx(c3t,{scope:r,scrollbar:_,hasThumb:a,onThumbChange:gd(o),onThumbPointerUp:gd(l),onThumbPositionChange:R,onThumbPointerDown:gd(i),children:e.jsx(sn.div,{...g,ref:w,style:{position:"absolute",...g.style},onPointerDown:Ir(t.onPointerDown,B=>{B.button===0&&(B.target.setPointerCapture(B.pointerId),N.current=_.getBoundingClientRect(),C.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",b.viewport&&(b.viewport.style.scrollBehavior="auto"),U(B))}),onPointerMove:Ir(t.onPointerMove,U),onPointerUp:Ir(t.onPointerUp,B=>{const V=B.target;V.hasPointerCapture(B.pointerId)&&V.releasePointerCapture(B.pointerId),document.body.style.webkitUserSelect=C.current,b.viewport&&(b.viewport.style.scrollBehavior=""),N.current=null})})})}),Moe="ScrollAreaThumb",zGe=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=RGe(Moe,t.__scopeScrollArea);return e.jsx(Fd,{present:r||a.hasThumb,children:e.jsx(d3t,{ref:s,...n})})}),d3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,style:n,...a}=t,o=qx(Moe,r),l=RGe(Moe,r),{onThumbPositionChange:i}=l,c=$a(s,f=>l.onThumbChange(f)),u=k.useRef(void 0),p=eue(()=>{u.current&&(u.current(),u.current=void 0)},100);return k.useEffect(()=>{const f=o.viewport;if(f){const g=()=>{if(p(),!u.current){const b=m3t(f,i);u.current=b,i()}};return i(),f.addEventListener("scroll",g),()=>f.removeEventListener("scroll",g)}},[o.viewport,p,i]),e.jsx(sn.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:Ir(t.onPointerDownCapture,f=>{const b=f.target.getBoundingClientRect(),_=f.clientX-b.left,j=f.clientY-b.top;l.onThumbPointerDown({x:_,y:j})}),onPointerUp:Ir(t.onPointerUp,l.onThumbPointerUp)})});zGe.displayName=Moe;var _je="ScrollAreaCorner",BGe=k.forwardRef((t,s)=>{const r=qx(_je,t.__scopeScrollArea),n=!!(r.scrollbarX&&r.scrollbarY);return r.type!=="scroll"&&n?e.jsx(u3t,{...t,ref:s}):null});BGe.displayName=_je;var u3t=k.forwardRef((t,s)=>{const{__scopeScrollArea:r,...n}=t,a=qx(_je,r),[o,l]=k.useState(0),[i,c]=k.useState(0),u=!!(o&&i);return BT(a.scrollbarX,()=>{var f;const p=((f=a.scrollbarX)==null?void 0:f.offsetHeight)||0;a.onCornerHeightChange(p),c(p)}),BT(a.scrollbarY,()=>{var f;const p=((f=a.scrollbarY)==null?void 0:f.offsetWidth)||0;a.onCornerWidthChange(p),l(p)}),u?e.jsx(sn.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 Toe(t){return t?parseInt(t,10):0}function $Ge(t,s){const r=t/s;return isNaN(r)?0:r}function Jde(t){const s=$Ge(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,n=(t.scrollbar.size-r)*s;return Math.max(n,18)}function h3t(t,s,r,n="ltr"){const a=Jde(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 qGe([c,u],f)(t)}function k6e(t,s,r="ltr"){const n=Jde(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=Y8(t,c);return qGe([0,l],[0,i])(u)}function qGe(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 UGe(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 eue(t,s){const r=gd(t),n=k.useRef(0);return k.useEffect(()=>()=>window.clearTimeout(n.current),[]),k.useCallback(()=>{window.clearTimeout(n.current),n.current=window.setTimeout(r,s)},[r,s])}function BT(t,s){const r=gd(s);wd(()=>{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 VGe=IGe,p3t=DGe,f3t=BGe;const Gi=k.forwardRef(({className:t,children:s,...r},n)=>e.jsxs(VGe,{ref:n,className:Pt("relative overflow-hidden",t),...r,children:[e.jsx(p3t,{className:"h-full w-full rounded-[inherit]",children:s}),e.jsx(tue,{}),e.jsx(f3t,{})]}));Gi.displayName=VGe.displayName;const tue=k.forwardRef(({className:t,orientation:s="vertical",...r},n)=>e.jsx(vje,{ref:n,orientation:s,className:Pt("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(zGe,{className:"relative flex-1 rounded-full bg-border"})}));tue.displayName=vje.displayName;const wje=k.createContext({});function jje(t){const s=k.useRef(null);return s.current===null&&(s.current=t()),s.current}const x3t=typeof window<"u",HGe=x3t?k.useLayoutEffect:k.useEffect,sue=k.createContext(null);function Nje(t,s){t.indexOf(s)===-1&&t.push(s)}function Aoe(t,s){const r=t.indexOf(s);r>-1&&t.splice(r,1)}const S0=(t,s,r)=>r>s?s:r{};const hw={},WGe=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t);function GGe(t){return typeof t=="object"&&t!==null}const KGe=t=>/^0[^.\s]+$/u.test(t);function ZGe(t){let s;return()=>(s===void 0&&(s=t()),s)}const Tx=t=>t,g3t=(t,s)=>r=>s(t(r)),PO=(...t)=>t.reduce(g3t),J8=(t,s,r)=>{const n=s-t;return n===0?1:(r-t)/n};class Sje{constructor(){this.subscriptions=[]}add(s){return Nje(this.subscriptions,s),()=>Aoe(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,bx=t=>t/1e3;function YGe(t,s){return s?t*(1e3/s):0}const XGe=(t,s,r)=>(((1-3*r+3*s)*t+(3*r-6*s))*t+3*s)*t,y3t=1e-7,v3t=12;function b3t(t,s,r,n,a){let o,l,i=0;do l=s+(r-s)/2,o=XGe(l,n,a)-t,o>0?r=l:s=l;while(Math.abs(o)>y3t&&++ib3t(o,0,1,t,r);return o=>o===0||o===1?o:XGe(a(o),s,n)}const QGe=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,JGe=t=>s=>1-t(1-s),eKe=IO(.33,1.53,.69,.99),Cje=JGe(eKe),tKe=QGe(Cje),sKe=t=>t>=1?1:(t*=2)<1?.5*Cje(t):.5*(2-Math.pow(2,-10*(t-1))),Mje=t=>1-Math.sin(Math.acos(t)),rKe=JGe(Mje),nKe=QGe(Mje),_3t=IO(.42,0,1,1),w3t=IO(0,0,.58,1),aKe=IO(.42,0,.58,1),j3t=t=>Array.isArray(t)&&typeof t[0]!="number",iKe=t=>Array.isArray(t)&&typeof t[0]=="number",N3t={linear:Tx,easeIn:_3t,easeInOut:aKe,easeOut:w3t,circIn:Mje,circInOut:nKe,circOut:rKe,backIn:Cje,backInOut:tKe,backOut:eKe,anticipate:sKe},k3t=t=>typeof t=="string",S6e=t=>{if(iKe(t)){kje(t.length===4);const[s,r,n,a]=t;return IO(s,r,n,a)}else if(k3t(t))return N3t[t];return t},ez=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function S3t(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 C3t=40;function oKe(t,s){let r=!1,n=!0;const a={delta:0,timestamp:0,isProcessing:!1},o=()=>r=!0,l=ez.reduce((M,I)=>(M[I]=S3t(o),M),{}),{setup:i,read:c,resolveKeyframes:u,preUpdate:p,update:f,preRender:g,render:b,postRender:_}=l,j=()=>{const M=hw.useManualTiming,I=M?a.timestamp:performance.now();r=!1,M||(a.delta=n?1e3/60:Math.max(Math.min(I-a.timestamp,C3t),1)),a.timestamp=I,a.isProcessing=!0,i.process(a),c.process(a),u.process(a),p.process(a),f.process(a),g.process(a),b.process(a),_.process(a),a.isProcessing=!1,r&&s&&(n=!1,t(j))},w=()=>{r=!0,n=!0,a.isProcessing||t(j)};return{schedule:ez.reduce((M,I)=>{const L=l[I];return M[I]=(R,q=!1,U=!1)=>(r||w(),L.schedule(R,q,U)),M},{}),cancel:M=>{for(let I=0;I(uie===void 0&&jm.set(gh.isProcessing||hw.useManualTiming?gh.timestamp:performance.now()),uie),set:t=>{uie=t,queueMicrotask(M3t)}},lKe=t=>s=>typeof s=="string"&&s.startsWith(t),cKe=lKe("--"),T3t=lKe("var(--"),Tje=t=>T3t(t)?A3t.test(t.split("/*")[0].trim()):!1,A3t=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function C6e(t){return typeof t!="string"?!1:t.split("/*")[0].includes("var(--")}const ZA={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},eD={...ZA,transform:t=>S0(0,1,t)},tz={...ZA,default:1},VL=t=>Math.round(t*1e5)/1e5,Aje=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function E3t(t){return t==null}const P3t=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Eje=(t,s)=>r=>!!(typeof r=="string"&&P3t.test(r)&&r.startsWith(t)||s&&!E3t(r)&&Object.prototype.hasOwnProperty.call(r,s)),dKe=(t,s,r)=>n=>{if(typeof n!="string")return n;const[a,o,l,i]=n.match(Aje);return{[t]:parseFloat(a),[s]:parseFloat(o),[r]:parseFloat(l),alpha:i!==void 0?parseFloat(i):1}},I3t=t=>S0(0,255,t),Sxe={...ZA,transform:t=>Math.round(I3t(t))},x4={test:Eje("rgb","red"),parse:dKe("red","green","blue"),transform:({red:t,green:s,blue:r,alpha:n=1})=>"rgba("+Sxe.transform(t)+", "+Sxe.transform(s)+", "+Sxe.transform(r)+", "+VL(eD.transform(n))+")"};function L3t(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 Fve={test:Eje("#"),parse:L3t,transform:x4.transform},LO=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),zb=LO("deg"),b0=LO("%"),na=LO("px"),D3t=LO("vh"),O3t=LO("vw"),M6e={...b0,parse:t=>b0.parse(t)/100,transform:t=>b0.transform(t*100)},tM={test:Eje("hsl","hue"),parse:dKe("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:r,alpha:n=1})=>"hsla("+Math.round(t)+", "+b0.transform(VL(s))+", "+b0.transform(VL(r))+", "+VL(eD.transform(n))+")"},Yd={test:t=>x4.test(t)||Fve.test(t)||tM.test(t),parse:t=>x4.test(t)?x4.parse(t):tM.test(t)?tM.parse(t):Fve.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?x4.transform(t):tM.transform(t),getAnimatableNone:t=>{const s=Yd.parse(t);return s.alpha=0,Yd.transform(s)}},R3t=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function F3t(t){var s,r;return isNaN(t)&&typeof t=="string"&&(((s=t.match(Aje))==null?void 0:s.length)||0)+(((r=t.match(R3t))==null?void 0:r.length)||0)>0}const uKe="number",hKe="color",z3t="var",B3t="var(",T6e="${}",$3t=/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 $T(t){const s=t.toString(),r=[],n={color:[],number:[],var:[]},a=[];let o=0;const i=s.replace($3t,c=>(Yd.test(c)?(n.color.push(o),a.push(hKe),r.push(Yd.parse(c))):c.startsWith(B3t)?(n.var.push(o),a.push(z3t),r.push(c)):(n.number.push(o),a.push(uKe),r.push(parseFloat(c))),++o,T6e)).split(T6e);return{values:r,split:i,indexes:n,types:a}}function q3t(t){return $T(t).values}function mKe({split:t,types:s}){const r=t.length;return n=>{let a="";for(let o=0;otypeof t=="number"?0:Yd.test(t)?Yd.getAnimatableNone(t):t,H3t=(t,s)=>typeof t=="number"?s!=null&&s.trim().endsWith("/")?t:0:V3t(t);function W3t(t){const s=$T(t);return mKe(s)(s.values.map((n,a)=>H3t(n,s.split[a])))}const ey={test:F3t,parse:q3t,createTransformer:U3t,getAnimatableNone:W3t};function Cxe(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 G3t({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=Cxe(c,i,t+1/3),o=Cxe(c,i,t),l=Cxe(c,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(o*255),blue:Math.round(l*255),alpha:n}}function Eoe(t,s){return r=>r>0?s:t}const yc=(t,s,r)=>t+(s-t)*r,Mxe=(t,s,r)=>{const n=t*t,a=r*(s*s-n)+n;return a<0?0:Math.sqrt(a)},K3t=[Fve,x4,tM],Z3t=t=>K3t.find(s=>s.test(t));function A6e(t){const s=Z3t(t);if(!s)return!1;let r=s.parse(t);return s===tM&&(r=G3t(r)),r}const E6e=(t,s)=>{const r=A6e(t),n=A6e(s);if(!r||!n)return Eoe(t,s);const a={...r};return o=>(a.red=Mxe(r.red,n.red,o),a.green=Mxe(r.green,n.green,o),a.blue=Mxe(r.blue,n.blue,o),a.alpha=yc(r.alpha,n.alpha,o),x4.transform(a))},zve=new Set(["none","hidden"]);function Y3t(t,s){return zve.has(t)?r=>r<=0?t:s:r=>r>=1?s:t}function X3t(t,s){return r=>yc(t,s,r)}function Pje(t){return typeof t=="number"?X3t:typeof t=="string"?Tje(t)?Eoe:Yd.test(t)?E6e:e5t:Array.isArray(t)?pKe:typeof t=="object"?Yd.test(t)?E6e:Q3t:Eoe}function pKe(t,s){const r=[...t],n=r.length,a=t.map((o,l)=>Pje(o)(o,s[l]));return o=>{for(let l=0;l{for(const o in n)r[o]=n[o](a);return r}}function J3t(t,s){const r=[],n={color:0,var:0,number:0};for(let a=0;a{const r=ey.createTransformer(s),n=$T(t),a=$T(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?zve.has(t)&&!a.values.length||zve.has(s)&&!n.values.length?Y3t(t,s):PO(pKe(J3t(n,a),a.values),r):Eoe(t,s)};function fKe(t,s,r){return typeof t=="number"&&typeof s=="number"&&typeof r=="number"?yc(t,s,r):Pje(t)(t,s)}const t5t=t=>{const s=({timestamp:r})=>t(r);return{start:(r=!0)=>Pl.update(s,r),stop:()=>mw(s),now:()=>gh.isProcessing?gh.timestamp:jm.now()}},xKe=(t,s,r=10)=>{let n="";const a=Math.max(Math.round(s/r),2);for(let o=0;o=Poe?1/0:s}function s5t(t,s=100,r){const n=r({...t,keyframes:[0,s]}),a=Math.min(Ije(n),Poe);return{type:"keyframes",ease:o=>n.next(a*o).value/s,duration:bx(a)}}const ud={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 Bve(t,s){return t*Math.sqrt(1-s*s)}const r5t=12;function n5t(t,s,r){let n=r;for(let a=1;a{const p=u*l,f=p*t,g=p-r,b=Bve(u,l),_=Math.exp(-f);return Txe-g/b*_},o=u=>{const f=u*l*t,g=f*r+r,b=Math.pow(l,2)*Math.pow(u,2)*t,_=Math.exp(-f),j=Bve(Math.pow(u,2),l);return(-a(u)+Txe>0?-1:1)*((g-b)*_)/j}):(a=u=>{const p=Math.exp(-u*t),f=(u-r)*t+1;return-Txe+p*f},o=u=>{const p=Math.exp(-u*t),f=(r-u)*(t*t);return p*f});const i=5/t,c=n5t(a,o,i);if(t=xf(t),isNaN(c))return{stiffness:ud.stiffness,damping:ud.damping,duration:t};{const u=Math.pow(c,2)*n;return{stiffness:u,damping:l*2*Math.sqrt(n*u),duration:t}}}const i5t=["duration","bounce"],o5t=["stiffness","damping","mass"];function P6e(t,s){return s.some(r=>t[r]!==void 0)}function l5t(t){let s={velocity:ud.velocity,stiffness:ud.stiffness,damping:ud.damping,mass:ud.mass,isResolvedFromDuration:!1,...t};if(!P6e(t,o5t)&&P6e(t,i5t))if(s.velocity=0,t.visualDuration){const r=t.visualDuration,n=2*Math.PI/(r*1.2),a=n*n,o=2*S0(.05,1,1-(t.bounce||0))*Math.sqrt(a);s={...s,mass:ud.mass,stiffness:a,damping:o}}else{const r=a5t({...t,velocity:0});s={...s,...r,mass:ud.mass},s.isResolvedFromDuration=!0}return s}function Ioe(t=ud.visualDuration,s=ud.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:b}=l5t({...r,velocity:-bx(r.velocity||0)}),_=g||0,j=u/(2*Math.sqrt(c*p)),w=l-o,N=bx(Math.sqrt(c/p)),C=Math.abs(w)<5;n||(n=C?ud.restSpeed.granular:ud.restSpeed.default),a||(a=C?ud.restDelta.granular:ud.restDelta.default);let M,I,L,R,q,U;if(j<1)L=Bve(N,j),R=(_+j*N*w)/L,M=V=>{const Y=Math.exp(-j*N*V);return l-Y*(R*Math.sin(L*V)+w*Math.cos(L*V))},q=j*N*R+w*L,U=j*N*w-R*L,I=V=>Math.exp(-j*N*V)*(q*Math.sin(L*V)+U*Math.cos(L*V));else if(j===1){M=Y=>l-Math.exp(-N*Y)*(w+(_+N*w)*Y);const V=_+N*w;I=Y=>Math.exp(-N*Y)*(N*V*Y-_)}else{const V=N*Math.sqrt(j*j-1);M=X=>{const ce=Math.exp(-j*N*X),ne=Math.min(V*X,300);return l-ce*((_+j*N*w)*Math.sinh(ne)+V*w*Math.cosh(ne))/V};const Y=(_+j*N*w)/V,J=j*N*Y-w*V,te=j*N*w-Y*V;I=X=>{const ce=Math.exp(-j*N*X),ne=Math.min(V*X,300);return ce*(J*Math.sinh(ne)+te*Math.cosh(ne))}}const B={calculatedDuration:b&&f||null,velocity:V=>xf(I(V)),next:V=>{if(!b&&j<1){const J=Math.exp(-j*N*V),te=Math.sin(L*V),X=Math.cos(L*V),ce=l-J*(R*te+w*X),ne=xf(J*(q*te+U*X));return i.done=Math.abs(ne)<=n&&Math.abs(l-ce)<=a,i.value=i.done?l:ce,i}const Y=M(V);if(b)i.done=V>=f;else{const J=xf(I(V));i.done=Math.abs(J)<=n&&Math.abs(l-Y)<=a}return i.value=i.done?l:Y,i},toString:()=>{const V=Math.min(Ije(B),Poe),Y=xKe(J=>B.next(V*J).value,V,30);return V+"ms "+Y},toTransition:()=>{}};return B}Ioe.applyToOptions=t=>{const s=s5t(t,100,Ioe);return t.ease=s.ease,t.duration=xf(s.duration),t.type="keyframes",t};const c5t=5;function gKe(t,s,r){const n=Math.max(s-c5t,0);return YGe(r-t(n),s-n)}function $ve({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},b=U=>i!==void 0&&Uc,_=U=>i===void 0?c:c===void 0||Math.abs(i-U)-j*Math.exp(-U/n),M=U=>N+C(U),I=U=>{const B=C(U),V=M(U);g.done=Math.abs(B)<=u,g.value=g.done?N:V};let L,R;const q=U=>{b(g.value)&&(L=U,R=Ioe({keyframes:[g.value,_(g.value)],velocity:gKe(M,U,g.value),damping:a,stiffness:o,restDelta:u,restSpeed:p}))};return q(0),{calculatedDuration:null,next:U=>{let B=!1;return!R&&L===void 0&&(B=!0,I(U),q(U)),L!==void 0&&U>=L?R.next(U-L):(!B&&I(U),g)}}}function d5t(t,s,r){const n=[],a=r||hw.mix||fKe,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=d5t(s,n,a),c=i.length,u=p=>{if(l&&p1)for(;fu(S0(t[0],t[o-1],p)):u}function h5t(t,s){const r=t[t.length-1];for(let n=1;n<=s;n++){const a=J8(0,s,n);t.push(yc(r,1,a))}}function m5t(t){const s=[0];return h5t(s,t.length-1),s}function p5t(t,s){return t.map(r=>r*s)}function f5t(t,s){return t.map(()=>s||aKe).splice(0,t.length-1)}function HL({duration:t=300,keyframes:s,times:r,ease:n="easeInOut"}){const a=j3t(n)?n.map(S6e):S6e(n),o={done:!1,value:s[0]},l=p5t(r&&r.length===s.length?r:m5t(s),t),i=u5t(l,s,{ease:Array.isArray(a)?a:f5t(s,a)});return{calculatedDuration:t,next:c=>(o.value=i(c),o.done=c>=t,o)}}const x5t=t=>t!==null;function rue(t,{repeat:s,repeatType:r="loop"},n,a=1){const o=t.filter(x5t),i=a<0||s&&r!=="loop"&&s%2===1?0:o.length-1;return!i||n===void 0?o[i]:n}const g5t={decay:$ve,inertia:$ve,tween:HL,keyframes:HL,spring:Ioe};function yKe(t){typeof t.type=="string"&&(t.type=g5t[t.type])}class Lje{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 y5t=t=>t/100;class Loe extends Lje{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!==jm.now()&&this.tick(jm.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;yKe(s);const{type:r=HL,repeat:n=0,repeatDelay:a=0,repeatType:o,velocity:l=0}=s;let{keyframes:i}=s;const c=r||HL;c!==HL&&typeof i[0]!="number"&&(this.mixKeyframes=PO(y5t,fKe(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=Ije(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:b,type:_,onUpdate:j,finalKeyframe:w}=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 N=this.currentTime-u*(this.playbackSpeed>=0?1:-1),C=this.playbackSpeed>=0?N<0:N>a;this.currentTime=Math.max(N,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=a);let M=this.currentTime,I=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,b&&(V-=b/i)):g==="mirror"&&(I=l)),M=S0(0,1,V)*i}let L;C?(this.delayState.value=p[0],L=this.delayState):L=I.next(M),o&&!C&&(L.value=o(L.value));let{done:R}=L;!C&&c!==null&&(R=this.playbackSpeed>=0?this.currentTime>=a:this.currentTime<=0);const q=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&R);return q&&_!==$ve&&(L.value=rue(p,this.options,w,this.speed)),j&&j(L.value),q&&this.finish(),L}then(s,r){return this.finished.then(s,r)}get duration(){return bx(this.calculatedDuration)}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+bx(s)}get time(){return bx(this.currentTime)}set time(s){s=xf(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 gKe(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(jm.now()),this.playbackSpeed=s,r&&this.driver&&(this.time=bx(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(jm.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 v5t(t){for(let s=1;st*180/Math.PI,qve=t=>{const s=g4(Math.atan2(t[1],t[0]));return Uve(s)},b5t={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:t=>(Math.abs(t[0])+Math.abs(t[3]))/2,rotate:qve,rotateZ:qve,skewX:t=>g4(Math.atan(t[1])),skewY:t=>g4(Math.atan(t[2])),skew:t=>(Math.abs(t[1])+Math.abs(t[2]))/2},Uve=t=>(t=t%360,t<0&&(t+=360),t),I6e=qve,L6e=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]),D6e=t=>Math.sqrt(t[4]*t[4]+t[5]*t[5]),_5t={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:L6e,scaleY:D6e,scale:t=>(L6e(t)+D6e(t))/2,rotateX:t=>Uve(g4(Math.atan2(t[6],t[5]))),rotateY:t=>Uve(g4(Math.atan2(-t[2],t[0]))),rotateZ:I6e,rotate:I6e,skewX:t=>g4(Math.atan(t[4])),skewY:t=>g4(Math.atan(t[1])),skew:t=>(Math.abs(t[1])+Math.abs(t[4]))/2};function Vve(t){return t.includes("scale")?1:0}function Hve(t,s){if(!t||t==="none")return Vve(s);const r=t.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let n,a;if(r)n=_5t,a=r;else{const i=t.match(/^matrix\(([-\d.e\s,]+)\)$/u);n=b5t,a=i}if(!a)return Vve(s);const o=n[s],l=a[1].split(",").map(j5t);return typeof o=="function"?o(l):l[o]}const w5t=(t,s)=>{const{transform:r="none"}=getComputedStyle(t);return Hve(r,s)};function j5t(t){return parseFloat(t.trim())}const YA=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],XA=new Set(YA),O6e=t=>t===ZA||t===na,N5t=new Set(["x","y","z"]),k5t=YA.filter(t=>!N5t.has(t));function S5t(t){const s=[];return k5t.forEach(r=>{const n=t.getValue(r);n!==void 0&&(s.push([r,n.get()]),n.set(r.startsWith("scale")?1:0))}),s}const w_={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})=>Hve(s,"x"),y:(t,{transform:s})=>Hve(s,"y")};w_.translateX=w_.x;w_.translateY=w_.y;const hS=new Set;let Wve=!1,Gve=!1,Kve=!1;function vKe(){if(Gve){const t=Array.from(hS).filter(n=>n.needsMeasurement),s=new Set(t.map(n=>n.element)),r=new Map;s.forEach(n=>{const a=S5t(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)})}Gve=!1,Wve=!1,hS.forEach(t=>t.complete(Kve)),hS.clear()}function bKe(){hS.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(Gve=!0)})}function C5t(){Kve=!0,bKe(),vKe(),Kve=!1}class Dje{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?(hS.add(this),Wve||(Wve=!0,Pl.read(bKe),Pl.resolveKeyframes(vKe))):(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])}v5t(s)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(s=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,s),hS.delete(this)}cancel(){this.state==="scheduled"&&(hS.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const M5t=t=>t.startsWith("--");function _Ke(t,s,r){M5t(s)?t.style.setProperty(s,r):t.style[s]=r}const T5t={};function wKe(t,s){const r=ZGe(t);return()=>T5t[s]??r()}const A5t=wKe(()=>window.ScrollTimeline!==void 0,"scrollTimeline"),jKe=wKe(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),_I=([t,s,r,n])=>`cubic-bezier(${t}, ${s}, ${r}, ${n})`,R6e={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:_I([0,.65,.55,1]),circOut:_I([.55,0,1,.45]),backIn:_I([.31,.01,.66,-.59]),backOut:_I([.33,1.53,.69,.99])};function NKe(t,s){if(t)return typeof t=="function"?jKe()?xKe(t,s):"ease-out":iKe(t)?_I(t):Array.isArray(t)?t.map(r=>NKe(r,s)||R6e.easeOut):R6e[t]}function E5t(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=NKe(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 kKe(t){return typeof t=="function"&&"applyToOptions"in t}function P5t({type:t,...s}){return kKe(t)&&jKe()?t.applyToOptions(s):(s.duration??(s.duration=300),s.ease??(s.ease="easeOut"),s)}class SKe extends Lje{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,kje(typeof s.type!="string");const u=P5t(s);this.animation=E5t(r,n,a,u,o),u.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const p=rue(a,this.options,i,this.speed);this.updateMotionValue&&this.updateMotionValue(p),_Ke(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 bx(Number(s))}get iterationDuration(){const{delay:s=0}=this.options||{};return this.duration+bx(s)}get time(){return bx(Number(this.animation.currentTime)||0)}set time(s){const r=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=xf(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&&A5t()?(this.animation.timeline=s,r&&(this.animation.rangeStart=r),n&&(this.animation.rangeEnd=n),Tx):a(this)}}const CKe={anticipate:sKe,backInOut:tKe,circInOut:nKe};function I5t(t){return t in CKe}function L5t(t){typeof t.ease=="string"&&I5t(t.ease)&&(t.ease=CKe[t.ease])}const Axe=10;class D5t extends SKe{constructor(s){L5t(s),yKe(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 Loe({...l,autoplay:!1}),c=Math.max(Axe,jm.now()-this.startTime),u=S0(0,Axe,c-Axe),p=i.sample(c).value,{name:f}=this.options;o&&f&&_Ke(o,f,p),r.setWithVelocity(i.sample(Math.max(0,c-u)).value,p,u),i.stop()}}const F6e=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ey.test(t)||t==="0")&&!t.startsWith("url("));function O5t(t){const s=t[0];if(t.length===1)return!0;for(let r=0;rObject.hasOwnProperty.call(Element.prototype,"animate"));function q5t(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 $5t()&&r&&(MKe.has(r)||B5t.has(r)&&z5t(i))&&(r!=="transform"||!p)&&!u&&!n&&a!=="mirror"&&o!==0&&l!=="inertia"}const U5t=40;class V5t extends Lje{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 j,w;this._animation&&(this._animation.stop(),(j=this.stopTimeline)==null||j.call(this)),(w=this.keyframeResolver)==null||w.cancel()},this.createdAt=jm.now();const g={autoplay:s,delay:r,type:n,repeat:a,repeatDelay:o,repeatType:l,name:c,motionValue:u,element:p,...f},b=(p==null?void 0:p.KeyframeResolver)||Dje;this.keyframeResolver=new b(i,(j,w,N)=>this.onKeyframesResolved(j,w,g,!N),c,u,p),(_=this.keyframeResolver)==null||_.scheduleResolve()}onKeyframesResolved(s,r,n,a){var N,C;this.keyframeResolver=void 0;const{name:o,type:l,velocity:i,delay:c,isHandoff:u,onUpdate:p}=n;this.resolvedAt=jm.now();let f=!0;R5t(s,o,l,i)||(f=!1,(hw.instantAnimations||!c)&&(p==null||p(rue(s,n,r))),s[0]=s[s.length-1],Zve(n),n.repeat=0);const b={startTime:a?this.resolvedAt?this.resolvedAt-this.createdAt>U5t?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:r,...n,keyframes:s},_=f&&!u&&q5t(b),j=(C=(N=b.motionValue)==null?void 0:N.owner)==null?void 0:C.current;let w;if(_)try{w=new D5t({...b,element:j})}catch{w=new Loe(b)}else w=new Loe(b);w.finished.then(()=>{this.notifyFinished()}).catch(Tx),this.pendingTimeline&&(this.stopTimeline=w.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=w}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(),C5t()),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 TKe(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 H5t=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function W5t(t){const s=H5t.exec(t);if(!s)return[,];const[,r,n,a]=s;return[`--${r??n}`,a]}function AKe(t,s,r=1){const[n,a]=W5t(t);if(!n)return;const o=window.getComputedStyle(s).getPropertyValue(n);if(o){const l=o.trim();return WGe(l)?parseFloat(l):l}return Tje(a)?AKe(a,s,r+1):a}const G5t={type:"spring",stiffness:500,damping:25,restSpeed:10},K5t=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),Z5t={type:"keyframes",duration:.8},Y5t={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},X5t=(t,{keyframes:s})=>s.length>2?Z5t:XA.has(t)?t.startsWith("scale")?K5t(s[1]):G5t:Y5t;function EKe(t,s){if(t!=null&&t.inherit&&s){const{inherit:r,...n}=t;return{...s,...n}}return t}function Oje(t,s){const r=(t==null?void 0:t[s])??(t==null?void 0:t.default)??t;return r!==t?EKe(r,t):r}const Q5t=new Set(["when","delay","delayChildren","staggerChildren","staggerDirection","repeat","repeatType","repeatDelay","from","elapsed"]);function J5t(t){for(const s in t)if(!Q5t.has(s))return!0;return!1}const Rje=(t,s,r,n={},a,o)=>l=>{const i=Oje(n,t)||{},c=i.delay||n.delay||0;let{elapsed:u=0}=n;u=u-xf(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};J5t(i)||Object.assign(p,X5t(t,p)),p.duration&&(p.duration=xf(p.duration)),p.repeatDelay&&(p.repeatDelay=xf(p.repeatDelay)),p.from!==void 0&&(p.keyframes[0]=p.from);let f=!1;if((p.type===!1||p.duration===0&&!p.repeatDelay)&&(Zve(p),p.delay===0&&(f=!0)),(hw.instantAnimations||hw.skipAnimations||a!=null&&a.shouldSkipAnimations)&&(f=!0,Zve(p),p.delay=0),p.allowFlatten=!i.type&&!i.ease,f&&!o&&s.get()!==void 0){const g=rue(p.keyframes,i);if(g!==void 0){Pl.update(()=>{p.onUpdate(g),p.onComplete()});return}}return i.isSync?new Loe(p):new V5t(p)};function z6e(t){const s=[{},{}];return t==null||t.values.forEach((r,n)=>{s[0][n]=r.get(),s[1][n]=r.getVelocity()}),s}function Fje(t,s,r,n){if(typeof s=="function"){const[a,o]=z6e(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]=z6e(n);s=s(r!==void 0?r:t.custom,a,o)}return s}function mS(t,s,r){const n=t.getProps();return Fje(n,s,r!==void 0?r:n.custom,t)}const PKe=new Set(["width","height","top","left","right","bottom",...YA]),B6e=30,eMt=t=>!isNaN(parseFloat(t));class tMt{constructor(s,r={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=n=>{var o;const a=jm.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=jm.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=eMt(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 Sje);const n=this.events[s].add(r);return s==="change"?()=>{n(),Pl.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=jm.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>B6e)return 0;const r=Math.min(this.updatedAt-this.prevUpdatedAt,B6e);return YGe(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 qT(t,s){return new tMt(t,s)}const Yve=t=>Array.isArray(t);function sMt(t,s,r){t.hasValue(s)?t.getValue(s).set(r):t.addValue(s,qT(r))}function rMt(t){return Yve(t)?t[t.length-1]||0:t}function nMt(t,s){const r=mS(t,s);let{transitionEnd:n={},transition:a={},...o}=r||{};o={...o,...n};for(const l in o){const i=rMt(o[l]);sMt(t,l,i)}}const _h=t=>!!(t&&t.getVelocity);function aMt(t){return!!(_h(t)&&t.add)}function Xve(t,s){const r=t.getValue("willChange");if(aMt(r))return r.add(s);if(!r&&hw.WillChange){const n=new hw.WillChange("auto");t.addValue("willChange",n),n.add(s)}}function zje(t){return t.replace(/([A-Z])/g,s=>`-${s.toLowerCase()}`)}const iMt="framerAppearId",IKe="data-"+zje(iMt);function LKe(t){return t.props[IKe]}function oMt({protectedKeys:t,needsAnimating:s},r){const n=t.hasOwnProperty(r)&&s[r]!==!0;return s[r]=!1,n}function DKe(t,s,{delay:r=0,transitionOverride:n,type:a}={}){let{transition:o,transitionEnd:l,...i}=s;const c=t.getDefaultTransition();o=o?EKe(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 b=t.getValue(g,t.latestValues[g]??null),_=i[g];if(_===void 0||f&&oMt(f,g))continue;const j={delay:r,...Oje(o||{},g)},w=b.get();if(w!==void 0&&!b.isAnimating()&&!Array.isArray(_)&&_===w&&!j.velocity){Pl.update(()=>b.set(_));continue}let N=!1;if(window.MotionHandoffAnimation){const I=LKe(t);if(I){const L=window.MotionHandoffAnimation(I,g,Pl);L!==null&&(j.startTime=L,N=!0)}}Xve(t,g);const C=u??t.shouldReduceMotion;b.start(Rje(g,b,_,C&&PKe.has(g)?{type:!1}:j,t,N));const M=b.animation;M&&p.push(M)}if(l){const g=()=>Pl.update(()=>{l&&nMt(t,l)});p.length?Promise.all(p).then(g):g()}return p}function Qve(t,s,r={}){var c;const n=mS(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(DKe(t,n,r)):()=>Promise.resolve(),l=t.variantChildren&&t.variantChildren.size?(u=0)=>{const{delayChildren:p=0,staggerChildren:f,staggerDirection:g}=a;return lMt(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 lMt(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(Qve(c,s,{...l,delay:r+(typeof n=="function"?0:n)+TKe(t.variantChildren,c,n,a,o)}).then(()=>c.notify("AnimationComplete",s)));return Promise.all(i)}function cMt(t,s,r={}){t.notify("AnimationStart",s);let n;if(Array.isArray(s)){const a=s.map(o=>Qve(t,o,r));n=Promise.all(a)}else if(typeof s=="string")n=Qve(t,s,r);else{const a=typeof s=="function"?mS(t,s,r.custom):s;n=Promise.all(DKe(t,a,r))}return n.then(()=>{t.notify("AnimationComplete",s)})}const dMt={test:t=>t==="auto",parse:t=>t},OKe=t=>s=>s.test(t),RKe=[ZA,na,b0,zb,O3t,D3t,dMt],$6e=t=>RKe.find(OKe(t));function uMt(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||KGe(t):!0}const hMt=new Set(["brightness","contrast","saturate","opacity"]);function mMt(t){const[s,r]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[n]=r.match(Aje)||[];if(!n)return t;const a=r.replace(n,"");let o=hMt.has(s)?1:0;return n!==r&&(o*=100),s+"("+o+a+")"}const pMt=/\b([a-z-]*)\(.*?\)/gu,Jve={...ey,getAnimatableNone:t=>{const s=t.match(pMt);return s?s.map(mMt).join(" "):t}},e1e={...ey,getAnimatableNone:t=>{const s=ey.parse(t);return ey.createTransformer(t)(s.map(n=>typeof n=="number"?0:typeof n=="object"?{...n,alpha:1}:n))}},q6e={...ZA,transform:Math.round},fMt={rotate:zb,rotateX:zb,rotateY:zb,rotateZ:zb,scale:tz,scaleX:tz,scaleY:tz,scaleZ:tz,skew:zb,skewX:zb,skewY:zb,distance:na,translateX:na,translateY:na,translateZ:na,x:na,y:na,z:na,perspective:na,transformPerspective:na,opacity:eD,originX:M6e,originY:M6e,originZ:na},Bje={borderWidth:na,borderTopWidth:na,borderRightWidth:na,borderBottomWidth:na,borderLeftWidth:na,borderRadius:na,borderTopLeftRadius:na,borderTopRightRadius:na,borderBottomRightRadius:na,borderBottomLeftRadius:na,width:na,maxWidth:na,height:na,maxHeight:na,top:na,right:na,bottom:na,left:na,inset:na,insetBlock:na,insetBlockStart:na,insetBlockEnd:na,insetInline:na,insetInlineStart:na,insetInlineEnd:na,padding:na,paddingTop:na,paddingRight:na,paddingBottom:na,paddingLeft:na,paddingBlock:na,paddingBlockStart:na,paddingBlockEnd:na,paddingInline:na,paddingInlineStart:na,paddingInlineEnd:na,margin:na,marginTop:na,marginRight:na,marginBottom:na,marginLeft:na,marginBlock:na,marginBlockStart:na,marginBlockEnd:na,marginInline:na,marginInlineStart:na,marginInlineEnd:na,fontSize:na,backgroundPositionX:na,backgroundPositionY:na,...fMt,zIndex:q6e,fillOpacity:eD,strokeOpacity:eD,numOctaves:q6e},xMt={...Bje,color:Yd,backgroundColor:Yd,outlineColor:Yd,fill:Yd,stroke:Yd,borderColor:Yd,borderTopColor:Yd,borderRightColor:Yd,borderBottomColor:Yd,borderLeftColor:Yd,filter:Jve,WebkitFilter:Jve,mask:e1e,WebkitMask:e1e},FKe=t=>xMt[t],gMt=new Set([Jve,e1e]);function zKe(t,s){let r=FKe(t);return gMt.has(r)||(r=ey),r.getAnimatableNone?r.getAnimatableNone(s):void 0}const yMt=new Set(["auto","none","0"]);function vMt(t,s,r){let n=0,a;for(;n{s.getValue(c).set(u)}),this.resolveNoneKeyframes()}}function $je(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 BKe=(t,s)=>s&&typeof t=="number"?s.transform(t):t;function hie(t){return GGe(t)&&"offsetHeight"in t&&!("ownerSVGElement"in t)}const{schedule:qje}=oKe(queueMicrotask,!1),Tg={x:!1,y:!1};function $Ke(){return Tg.x||Tg.y}function _Mt(t){return t==="x"||t==="y"?Tg[t]?null:(Tg[t]=!0,()=>{Tg[t]=!1}):Tg.x||Tg.y?null:(Tg.x=Tg.y=!0,()=>{Tg.x=Tg.y=!1})}function qKe(t,s){const r=$je(t),n=new AbortController,a={passive:!0,...s,signal:n.signal};return[r,a,()=>n.abort()]}function wMt(t){return!(t.pointerType==="touch"||$Ke())}function jMt(t,s,r={}){const[n,a,o]=qKe(t,r);return n.forEach(l=>{let i=!1,c=!1,u;const p=()=>{l.removeEventListener("pointerleave",_)},f=w=>{u&&(u(w),u=void 0),p()},g=w=>{i=!1,window.removeEventListener("pointerup",g),window.removeEventListener("pointercancel",g),c&&(c=!1,f(w))},b=()=>{i=!0,window.addEventListener("pointerup",g,a),window.addEventListener("pointercancel",g,a)},_=w=>{if(w.pointerType!=="touch"){if(i){c=!0;return}f(w)}},j=w=>{if(!wMt(w))return;c=!1;const N=s(l,w);typeof N=="function"&&(u=N,l.addEventListener("pointerleave",_,a))};l.addEventListener("pointerenter",j,a),l.addEventListener("pointerdown",b,a)}),o}const UKe=(t,s)=>s?t===s?!0:UKe(t,s.parentElement):!1,Uje=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1,NMt=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function kMt(t){return NMt.has(t.tagName)||t.isContentEditable===!0}const SMt=new Set(["INPUT","SELECT","TEXTAREA"]);function CMt(t){return SMt.has(t.tagName)||t.isContentEditable===!0}const mie=new WeakSet;function U6e(t){return s=>{s.key==="Enter"&&t(s)}}function Exe(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const MMt=(t,s)=>{const r=t.currentTarget;if(!r)return;const n=U6e(()=>{if(mie.has(r))return;Exe(r,"down");const a=U6e(()=>{Exe(r,"up")}),o=()=>Exe(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 V6e(t){return Uje(t)&&!$Ke()}const H6e=new WeakSet;function TMt(t,s,r={}){const[n,a,o]=qKe(t,r),l=i=>{const c=i.currentTarget;if(!V6e(i)||H6e.has(i))return;mie.add(c),r.stopPropagation&&H6e.add(i);const u=s(c,i),p=(b,_)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",g),mie.has(c)&&mie.delete(c),V6e(b)&&typeof u=="function"&&u(b,{success:_})},f=b=>{p(b,c===window||c===document||r.useGlobalTarget||UKe(c,b.target))},g=b=>{p(b,!1)};window.addEventListener("pointerup",f,a),window.addEventListener("pointercancel",g,a)};return n.forEach(i=>{(r.useGlobalTarget?window:i).addEventListener("pointerdown",l,a),hie(i)&&(i.addEventListener("focus",u=>MMt(u,a)),!kMt(i)&&!i.hasAttribute("tabindex")&&(i.tabIndex=0))}),o}function Vje(t){return GGe(t)&&"ownerSVGElement"in t}const pie=new WeakMap;let Bb;const VKe=(t,s,r)=>(n,a)=>a&&a[0]?a[0][t+"Size"]:Vje(n)&&"getBBox"in n?n.getBBox()[s]:n[r],AMt=VKe("inline","width","offsetWidth"),EMt=VKe("block","height","offsetHeight");function PMt({target:t,borderBoxSize:s}){var r;(r=pie.get(t))==null||r.forEach(n=>{n(t,{get width(){return AMt(t,s)},get height(){return EMt(t,s)}})})}function IMt(t){t.forEach(PMt)}function LMt(){typeof ResizeObserver>"u"||(Bb=new ResizeObserver(IMt))}function DMt(t,s){Bb||LMt();const r=$je(t);return r.forEach(n=>{let a=pie.get(n);a||(a=new Set,pie.set(n,a)),a.add(s),Bb==null||Bb.observe(n)}),()=>{r.forEach(n=>{const a=pie.get(n);a==null||a.delete(s),a!=null&&a.size||Bb==null||Bb.unobserve(n)})}}const fie=new Set;let sM;function OMt(){sM=()=>{const t={get width(){return window.innerWidth},get height(){return window.innerHeight}};fie.forEach(s=>s(t))},window.addEventListener("resize",sM)}function RMt(t){return fie.add(t),sM||OMt(),()=>{fie.delete(t),!fie.size&&typeof sM=="function"&&(window.removeEventListener("resize",sM),sM=void 0)}}function W6e(t,s){return typeof t=="function"?RMt(t):DMt(t,s)}function FMt(t){return Vje(t)&&t.tagName==="svg"}const zMt=[...RKe,Yd,ey],BMt=t=>zMt.find(OKe(t)),G6e=()=>({translate:0,scale:1,origin:0,originPoint:0}),rM=()=>({x:G6e(),y:G6e()}),K6e=()=>({min:0,max:0}),pu=()=>({x:K6e(),y:K6e()}),$Mt=new WeakMap;function nue(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}function tD(t){return typeof t=="string"||Array.isArray(t)}const Hje=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Wje=["initial",...Hje];function aue(t){return nue(t.animate)||Wje.some(s=>tD(t[s]))}function HKe(t){return!!(aue(t)||t.variants)}function qMt(t,s,r){for(const n in s){const a=s[n],o=r[n];if(_h(a))t.addValue(n,a);else if(_h(o))t.addValue(n,qT(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,qT(l!==void 0?l:a,{owner:t}))}}for(const n in r)s[n]===void 0&&t.removeValue(n);return s}const t1e={current:null},WKe={current:!1},UMt=typeof window<"u";function VMt(){if(WKe.current=!0,!!UMt)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>t1e.current=t.matches;t.addEventListener("change",s),s()}else t1e.current=!1}const Z6e=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];let Doe={};function GKe(t){Doe=t}function HMt(){return Doe}class WMt{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=Dje,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 b=jm.now();this.renderScheduledAtthis.bindToMotionValue(o,a)),this.reducedMotionConfig==="never"?this.shouldReduceMotion=!1:this.reducedMotionConfig==="always"?this.shouldReduceMotion=!0:(WKe.current||VMt(),this.shouldReduceMotion=t1e.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(),mw(this.notifyUpdate),mw(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&&MKe.has(s)&&this.current instanceof HTMLElement){const{factory:l,keyframes:i,times:c,ease:u,duration:p}=r.accelerate,f=new SKe({element:this.current,name:s,keyframes:i,times:c,ease:u,duration:xf(p)}),g=l(f);this.valueSubscriptions.set(s,()=>{g(),f.cancel()});return}const n=XA.has(s);n&&this.onBindTransform&&this.onBindTransform();const a=r.on("change",l=>{this.latestValues[s]=l,this.props.onUpdate&&Pl.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 Doe){const r=Doe[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):pu()}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=qT(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"&&(WGe(n)||KGe(n))?n=parseFloat(n):!BMt(n)&&ey.test(r)&&(n=zKe(s,r)),this.setBaseTarget(s,_h(n)?n.get():n)),_h(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=Fje(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&&!_h(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 Sje),this.events[s].add(r)}notify(s,...r){this.events[s]&&this.events[s].notify(...r)}scheduleRenderMicrotask(){qje.render(this.render)}}class KKe extends WMt{constructor(){super(...arguments),this.KeyframeResolver=bMt}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;_h(s)&&(this.childSubscription=s.on("change",r=>{this.current&&(this.current.textContent=`${r}`)}))}}class Ew{constructor(s){this.isMounted=!1,this.node=s}update(){}}function ZKe({top:t,left:s,right:r,bottom:n}){return{x:{min:s,max:r},y:{min:t,max:n}}}function GMt({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function KMt(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 Pxe(t){return t===void 0||t===1}function s1e({scale:t,scaleX:s,scaleY:r}){return!Pxe(t)||!Pxe(s)||!Pxe(r)}function t4(t){return s1e(t)||YKe(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function YKe(t){return Y6e(t.x)||Y6e(t.y)}function Y6e(t){return t&&t!=="0%"}function Ooe(t,s,r){const n=t-r,a=s*n;return r+a}function X6e(t,s,r,n,a){return a!==void 0&&(t=Ooe(t,a,n)),Ooe(t,r,n)+s}function r1e(t,s=0,r=1,n,a){t.min=X6e(t.min,s,r,n,a),t.max=X6e(t.max,s,r,n,a)}function XKe(t,{x:s,y:r}){r1e(t.x,s.translate,s.scale,s.originPoint),r1e(t.y,r.translate,r.scale,r.originPoint)}const Q6e=.999999999999,J6e=1.0000000000001;function ZMt(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;cQ6e&&(s.x=1),s.yQ6e&&(s.y=1)}function Jy(t,s){t.min+=s,t.max+=s}function ePe(t,s,r,n,a=.5){const o=yc(t.min,t.max,a);r1e(t,s,r,o,n)}function tPe(t,s){return typeof t=="string"?parseFloat(t)/100*(s.max-s.min):t}function xie(t,s,r){const n=r??t;ePe(t.x,tPe(s.x,n.x),s.scaleX,s.scale,s.originX),ePe(t.y,tPe(s.y,n.y),s.scaleY,s.scale,s.originY)}function QKe(t,s){return ZKe(KMt(t.getBoundingClientRect(),s))}function YMt(t,s,r){const n=QKe(t,r),{scroll:a}=s;return a&&(Jy(n.x,a.offset.x),Jy(n.y,a.offset.y)),n}const XMt={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},QMt=YA.length;function JMt(t,s,r){let n="",a=!0;for(let o=0;o{if(!s.target)return t;if(typeof t=="string")if(na.test(t))t=parseFloat(t);else return t;const r=sPe(t,s.target.x),n=sPe(t,s.target.y);return`${r}% ${n}%`}},eTt={correct:(t,{treeScale:s,projectionDelta:r})=>{const n=t,a=ey.parse(t);if(a.length>5)return n;const o=ey.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=yc(i,c,.5);return typeof a[2+l]=="number"&&(a[2+l]/=u),typeof a[3+l]=="number"&&(a[3+l]/=u),o(a)}},n1e={borderRadius:{...UP,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:UP,borderTopRightRadius:UP,borderBottomLeftRadius:UP,borderBottomRightRadius:UP,boxShadow:eTt};function eZe(t,{layout:s,layoutId:r}){return XA.has(t)||t.startsWith("origin")||(s||r!==void 0)&&(!!n1e[t]||t==="opacity")}function Kje(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)(_h(n[i])||a&&_h(a[i])||eZe(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 sTt extends KKe{constructor(){super(...arguments),this.type="html",this.renderInstance=JKe}readValueFromInstance(s,r){var n;if(XA.has(r))return(n=this.projection)!=null&&n.isProjecting?Vve(r):w5t(s,r);{const a=tTt(s),o=(cKe(r)?a.getPropertyValue(r):a[r])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(s,{transformPagePoint:r}){return QKe(s,r)}build(s,r,n){Gje(s,r,n.transformTemplate)}scrapeMotionValuesFromProps(s,r,n){return Kje(s,r,n)}}const rTt={offset:"stroke-dashoffset",array:"stroke-dasharray"},nTt={offset:"strokeDashoffset",array:"strokeDasharray"};function aTt(t,s,r=1,n=0,a=!0){t.pathLength=1;const o=a?rTt:nTt;t[o.offset]=`${-n}`,t[o.array]=`${s} ${r}`}const iTt=["offsetDistance","offsetPath","offsetRotate","offsetAnchor"];function tZe(t,{attrX:s,attrY:r,attrScale:n,pathLength:a,pathSpacing:o=1,pathOffset:l=0,...i},c,u,p){if(Gje(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 b of iTt)f[b]!==void 0&&(g[b]=f[b],delete f[b]);s!==void 0&&(f.x=s),r!==void 0&&(f.y=r),n!==void 0&&(f.scale=n),a!==void 0&&aTt(f,a,o,l,!1)}const sZe=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"]),rZe=t=>typeof t=="string"&&t.toLowerCase()==="svg";function oTt(t,s,r,n){JKe(t,s,void 0,n);for(const a in s.attrs)t.setAttribute(sZe.has(a)?a:zje(a),s.attrs[a])}function nZe(t,s,r){const n=Kje(t,s,r);for(const a in t)if(_h(t[a])||_h(s[a])){const o=YA.indexOf(a)!==-1?"attr"+a.charAt(0).toUpperCase()+a.substring(1):a;n[o]=t[a]}return n}class lTt extends KKe{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pu}getBaseTargetFromProps(s,r){return s[r]}readValueFromInstance(s,r){if(XA.has(r)){const n=FKe(r);return n&&n.default||0}return r=sZe.has(r)?r:zje(r),s.getAttribute(r)}scrapeMotionValuesFromProps(s,r,n){return nZe(s,r,n)}build(s,r,n){tZe(s,r,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(s,r,n,a){oTt(s,r,n,a)}mount(s){this.isSVGTag=rZe(s.tagName),super.mount(s)}}const cTt=Wje.length;function aZe(t){if(!t)return;if(!t.isControllingVariants){const r=t.parent?aZe(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})=>cMt(t,r,n)))}function mTt(t){let s=hTt(t),r=rPe(),n=!0,a=!1;const o=u=>(p,f)=>{var b;const g=mS(t,f,u==="exit"?(b=t.presenceContext)==null?void 0:b.custom:void 0);if(g){const{transition:_,transitionEnd:j,...w}=g;p={...p,...w,...j}}return p};function l(u){s=u(t)}function i(u){const{props:p}=t,f=aZe(t.parent)||{},g=[],b=new Set;let _={},j=1/0;for(let N=0;Nj&&L,V=!1;const Y=Array.isArray(I)?I:[I];let J=Y.reduce(o(C),{});R===!1&&(J={});const{prevResolvedValues:te={}}=M,X={...te,...J},ce=le=>{B=!0,b.has(le)&&(V=!0,b.delete(le)),M.needsAnimating[le]=!0;const pe=t.getValue(le);pe&&(pe.liveStyle=!1)};for(const le in X){const pe=J[le],xe=te[le];if(_.hasOwnProperty(le))continue;let _e=!1;Yve(pe)&&Yve(xe)?_e=!iZe(pe,xe):_e=pe!==xe,_e?pe!=null?ce(le):b.add(le):pe!==void 0&&b.has(le)?ce(le):M.protectedKeys[le]=!0}M.prevProp=I,M.prevResolvedValues=J,M.isActive&&(_={..._,...J}),(n||a)&&t.blockInitialAnimation&&(B=!1);const ne=q&&U;B&&(!ne||V)&&g.push(...Y.map(le=>{const pe={type:C};if(typeof le=="string"&&(n||a)&&!ne&&t.manuallyAnimateOnMount&&t.parent){const{parent:xe}=t,_e=mS(xe,le);if(xe.enteringChildren&&_e){const{delayChildren:fe}=_e.transition||{};pe.delay=TKe(xe.enteringChildren,t,fe)}}return{animation:le,options:pe}}))}if(b.size){const N={};if(typeof p.initial!="boolean"){const C=mS(t,Array.isArray(p.initial)?p.initial[0]:p.initial);C&&C.transition&&(N.transition=C.transition)}b.forEach(C=>{const M=t.getBaseTarget(C),I=t.getValue(C);I&&(I.liveStyle=!0),N[C]=M??null}),g.push({animation:N})}let w=!!g.length;return n&&(p.initial===!1||p.initial===p.animate)&&!t.manuallyAnimateOnMount&&(w=!1),n=!1,a=!1,w?s(g):Promise.resolve()}function c(u,p){var g;if(r[u].isActive===p)return Promise.resolve();(g=t.variantChildren)==null||g.forEach(b=>{var _;return(_=b.animationState)==null?void 0:_.setActive(u,p)}),r[u].isActive=p;const f=i(u);for(const b in r)r[b].protectedKeys={};return f}return{animateChanges:i,setActive:c,setAnimateFunction:l,getState:()=>r,reset:()=>{r=rPe(),a=!0}}}function pTt(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!iZe(s,t):!1}function D2(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function rPe(){return{animate:D2(!0),whileInView:D2(),whileHover:D2(),whileTap:D2(),whileDrag:D2(),whileFocus:D2(),exit:D2()}}function a1e(t,s){t.min=s.min,t.max=s.max}function jg(t,s){a1e(t.x,s.x),a1e(t.y,s.y)}function nPe(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}const oZe=1e-4,fTt=1-oZe,xTt=1+oZe,lZe=.01,gTt=0-lZe,yTt=0+lZe;function Nm(t){return t.max-t.min}function vTt(t,s,r){return Math.abs(t-s)<=r}function aPe(t,s,r,n=.5){t.origin=n,t.originPoint=yc(s.min,s.max,t.origin),t.scale=Nm(r)/Nm(s),t.translate=yc(r.min,r.max,t.origin)-t.originPoint,(t.scale>=fTt&&t.scale<=xTt||isNaN(t.scale))&&(t.scale=1),(t.translate>=gTt&&t.translate<=yTt||isNaN(t.translate))&&(t.translate=0)}function WL(t,s,r,n){aPe(t.x,s.x,r.x,n?n.originX:void 0),aPe(t.y,s.y,r.y,n?n.originY:void 0)}function iPe(t,s,r,n=0){const a=n?yc(r.min,r.max,n):r.min;t.min=a+s.min,t.max=t.min+Nm(s)}function bTt(t,s,r,n){iPe(t.x,s.x,r.x,n==null?void 0:n.x),iPe(t.y,s.y,r.y,n==null?void 0:n.y)}function oPe(t,s,r,n=0){const a=n?yc(r.min,r.max,n):r.min;t.min=s.min-a,t.max=t.min+Nm(s)}function Roe(t,s,r,n){oPe(t.x,s.x,r.x,n==null?void 0:n.x),oPe(t.y,s.y,r.y,n==null?void 0:n.y)}function lPe(t,s,r,n,a){return t-=s,t=Ooe(t,1/r,n),a!==void 0&&(t=Ooe(t,1/a,n)),t}function _Tt(t,s=0,r=1,n=.5,a,o=t,l=t){if(b0.test(s)&&(s=parseFloat(s),s=yc(l.min,l.max,s/100)-l.min),typeof s!="number")return;let i=yc(o.min,o.max,n);t===o&&(i-=s),t.min=lPe(t.min,s,r,i,a),t.max=lPe(t.max,s,r,i,a)}function cPe(t,s,[r,n,a],o,l){_Tt(t,s[r],s[n],s[a],s.scale,o,l)}const wTt=["x","scaleX","originX"],jTt=["y","scaleY","originY"];function dPe(t,s,r,n){cPe(t.x,s,wTt,r?r.x:void 0,n?n.x:void 0),cPe(t.y,s,jTt,r?r.y:void 0,n?n.y:void 0)}function uPe(t){return t.translate===0&&t.scale===1}function cZe(t){return uPe(t.x)&&uPe(t.y)}function hPe(t,s){return t.min===s.min&&t.max===s.max}function NTt(t,s){return hPe(t.x,s.x)&&hPe(t.y,s.y)}function mPe(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function dZe(t,s){return mPe(t.x,s.x)&&mPe(t.y,s.y)}function pPe(t){return Nm(t.x)/Nm(t.y)}function fPe(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}function Vy(t){return[t("x"),t("y")]}function kTt(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:b,skewY:_}=r;u&&(n=`perspective(${u}px) ${n}`),p&&(n+=`rotate(${p}deg) `),f&&(n+=`rotateX(${f}deg) `),g&&(n+=`rotateY(${g}deg) `),b&&(n+=`skewX(${b}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 uZe=["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],STt=uZe.length,xPe=t=>typeof t=="string"?parseFloat(t):t,gPe=t=>typeof t=="number"||na.test(t);function CTt(t,s,r,n,a,o){a?(t.opacity=yc(0,r.opacity??1,MTt(n)),t.opacityExit=yc(s.opacity??1,0,TTt(n))):o&&(t.opacity=yc(s.opacity??1,r.opacity??1,n));for(let l=0;lns?1:r(J8(t,s,n))}function ATt(t,s,r){const n=_h(t)?t:qT(t);return n.start(Rje("",n,s,r)),n.animation}function sD(t,s,r,n={passive:!0}){return t.addEventListener(s,r,n),()=>t.removeEventListener(s,r)}const ETt=(t,s)=>t.depth-s.depth;class PTt{constructor(){this.children=[],this.isDirty=!1}add(s){Nje(this.children,s),this.isDirty=!0}remove(s){Aoe(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(ETt),this.isDirty=!1,this.children.forEach(s)}}function ITt(t,s){const r=jm.now(),n=({timestamp:a})=>{const o=a-r;o>=s&&(mw(n),t(o-s))};return Pl.setup(n,!0),()=>mw(n)}function gie(t){return _h(t)?t.get():t}class LTt{constructor(){this.members=[]}add(s){Nje(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&&(Aoe(this.members,n),n.unmount())}s.scheduleRender()}remove(s){if(Aoe(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 yie={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Ixe=["","X","Y","Z"],DTt=1e3;let OTt=0;function Lxe(t,s,r,n){const{latestValues:a}=s;a[t]&&(r[t]=a[t],s.setStaticValue(t,0),n&&(n[t]=0))}function mZe(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const r=LKe(s);if(window.MotionHasOptimisedAnimation(r,"transform")){const{layout:a,layoutId:o}=t.options;window.MotionCancelOptimisedAnimation(r,"transform",Pl,!(a||o))}const{parent:n}=t;n&&!n.hasCheckedOptimisedAppear&&mZe(n)}function pZe({attachResizeListener:t,defaultParent:s,measureScroll:r,checkIsScrollRoot:n,resetTransform:a}){return class{constructor(l={},i=s==null?void 0:s()){this.id=OTt++,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(zTt),this.nodes.forEach(HTt),this.nodes.forEach(WTt),this.nodes.forEach(BTt)},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;Pl.read(()=>{f=window.innerWidth}),t(l,()=>{const b=window.innerWidth;b!==f&&(f=b,this.root.updateBlockedByResize=!0,p&&p(),p=ITt(g,250),yie.hasAnimatedSinceResize&&(yie.hasAnimatedSinceResize=!1,this.nodes.forEach(_Pe)))})}i&&this.root.registerSharedNode(i,this),this.options.animate!==!1&&u&&(i||c)&&this.addEventListener("didUpdate",({delta:p,hasLayoutChanged:f,hasRelativeLayoutChanged:g,layout:b})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const _=this.options.transition||u.getDefaultTransition()||XTt,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=u.getProps(),N=!this.targetLayout||!dZe(this.targetLayout,b),C=!f&&g;if(this.options.layoutRoot||this.resumeFrom||C||f&&(N||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const M={...Oje(_,"layout"),onPlay:j,onComplete:w};(u.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M),this.setAnimationOrigin(p,C)}else f||_Pe(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=b})}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(),mw(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(GTt),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&&mZe(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&&!Nm(this.snapshot.measuredBox.x)&&!Nm(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 L=I/1e3;wPe(f.x,l.x,L),wPe(f.y,l.y,L),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Roe(g,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),ZTt(this.relativeTarget,this.relativeTargetOrigin,g,L),M&&NTt(this.relativeTarget,M)&&(this.isProjectionDirty=!1),M||(M=pu()),jg(M,this.relativeTarget)),j&&(this.animationValues=p,CTt(p,u,this.latestValues,L,C,N)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=L},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&&(mw(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=Pl.update(()=>{yie.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=qT(0)),this.motionValue.jump(0,!1),this.currentAnimation=ATt(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(DTt),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&&fZe(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||pu();const f=Nm(this.layout.layoutBox.x);c.x.min=l.target.x.min,c.x.max=c.x.min+f;const g=Nm(this.layout.layoutBox.y);c.y.min=l.target.y.min,c.y.max=c.y.min+g}jg(i,c),xie(i,p),WL(this.projectionDeltaWithTransform,this.layoutCorrected,i,p)}}registerSharedNode(l,i){this.sharedNodes.has(l)||this.sharedNodes.set(l,new LTt),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&&Lxe("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(vPe),this.root.sharedNodes.clear()}}}function RTt(t){t.updateLayout()}function FTt(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")Vy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=Nm(g);g.min=n[f].min,g.max=g.min+b});else if(o==="x"||o==="y"){const f=o==="x"?"y":"x";a1e(l?s.measuredBox[f]:s.layoutBox[f],n[f])}else fZe(o,s.layoutBox,n)&&Vy(f=>{const g=l?s.measuredBox[f]:s.layoutBox[f],b=Nm(n[f]);g.max=g.min+b,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[f].max=t.relativeTarget[f].min+b)});const i=rM();WL(i,n,s.layoutBox);const c=rM();l?WL(c,t.applyTransform(a,!0),s.measuredBox):WL(c,n,s.layoutBox);const u=!cZe(i);let p=!1;if(!t.resumeFrom){const f=t.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:g,layout:b}=f;if(g&&b){const _=t.options.layoutAnchor||void 0,j=pu();Roe(j,s.layoutBox,g.layoutBox,_);const w=pu();Roe(w,n,b.layoutBox,_),dZe(j,w)||(p=!0),f.options.layoutRoot&&(t.relativeTarget=w,t.relativeTargetOrigin=j,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 zTt(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 BTt(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function $Tt(t){t.clearSnapshot()}function vPe(t){t.clearMeasurements()}function qTt(t){t.isLayoutDirty=!0,t.updateLayout()}function bPe(t){t.isLayoutDirty=!1}function UTt(t){t.isAnimationBlocked&&t.layout&&!t.isLayoutDirty&&(t.snapshot=t.layout,t.isLayoutDirty=!0)}function VTt(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function _Pe(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function HTt(t){t.resolveTargetDelta()}function WTt(t){t.calcProjection()}function GTt(t){t.resetSkewAndRotation()}function KTt(t){t.removeLeadSnapshot()}function wPe(t,s,r){t.translate=yc(s.translate,0,r),t.scale=yc(s.scale,1,r),t.origin=s.origin,t.originPoint=s.originPoint}function jPe(t,s,r,n){t.min=yc(s.min,r.min,n),t.max=yc(s.max,r.max,n)}function ZTt(t,s,r,n){jPe(t.x,s.x,r.x,n),jPe(t.y,s.y,r.y,n)}function YTt(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const XTt={duration:.45,ease:[.4,0,.1,1]},NPe=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),kPe=NPe("applewebkit/")&&!NPe("chrome/")?Math.round:Tx;function SPe(t){t.min=kPe(t.min),t.max=kPe(t.max)}function QTt(t){SPe(t.x),SPe(t.y)}function fZe(t,s,r){return t==="position"||t==="preserve-aspect"&&!vTt(pPe(s),pPe(r),.2)}function JTt(t){var s;return t!==t.root&&((s=t.scroll)==null?void 0:s.wasRoot)}const eAt=pZe({attachResizeListener:(t,s)=>sD(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}),Dxe={current:void 0},xZe=pZe({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Dxe.current){const t=new eAt({});t.mount(window),t.setOptions({layoutScroll:!0}),Dxe.current=t}return Dxe.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),Zje=k.createContext({transformPagePoint:t=>t,isStatic:!1,reducedMotion:"never"});function CPe(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=CPe(a,s);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a{const{width:b,height:_,top:j,left:w,right:N,bottom:C}=c.current;if(s||o===!1||!i.current||!b||!_)return;const M=r==="left"?`left: ${w}`:`right: ${N}`,I=n==="bottom"?`bottom: ${C}`:`top: ${j}`;i.current.dataset.motionPopId=l;const L=document.createElement("style");u&&(L.nonce=u);const R=a??document.head;return R.appendChild(L),L.sheet&&L.sheet.insertRule(` [data-motion-pop-id="${l}"] { position: absolute !important; width: ${b}px !important; height: ${_}px !important; ${M}px !important; ${I}px !important; } `),()=>{var q;(q=i.current)==null||q.removeAttribute("data-motion-pop-id"),R.contains(L)&&R.removeChild(L)}},[s]),e.jsx(rAt,{isPresent:s,childRef:i,sizeRef:c,pop:o,children:o===!1?t:k.cloneElement(t,{ref:f})})}const aAt=({children:t,initial:s,isPresent:r,onExitComplete:n,custom:a,presenceAffectsLayout:o,mode:l,anchorX:i,anchorY:c,root:u})=>{const p=jje(iAt),f=k.useId();let g=!0,b=k.useMemo(()=>(g=!1,{id:f,initial:s,isPresent:r,custom:a,onExitComplete:_=>{p.set(_,!0);for(const j of p.values())if(!j)return;n&&n()},register:_=>(p.set(_,!1),()=>p.delete(_))}),[r,p,n]);return o&&g&&(b={...b}),k.useMemo(()=>{p.forEach((_,j)=>p.set(j,!1))},[r]),k.useEffect(()=>{!r&&!p.size&&n&&n()},[r]),t=e.jsx(nAt,{pop:l==="popLayout",isPresent:r,anchorX:i,anchorY:c,root:u,children:t}),e.jsx(sue.Provider,{value:b,children:t})};function iAt(){return new Map}function gZe(t=!0){const s=k.useContext(sue);if(s===null)return[!0,null];const{isPresent:r,onExitComplete:n,register:a}=s,o=k.useId();k.useEffect(()=>{if(t)return a(o)},[t]);const l=k.useCallback(()=>t&&n&&n(o),[o,n,t]);return!r&&n?[!1,l]:[!0]}const sz=t=>t.key||"";function MPe(t){const s=[];return k.Children.forEach(t,r=>{k.isValidElement(r)&&s.push(r)}),s}const yZe=({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]=gZe(l),g=k.useMemo(()=>MPe(t),[t]),b=l&&!p?[]:g.map(sz),_=k.useRef(!0),j=k.useRef(g),w=jje(()=>new Map),N=k.useRef(new Set),[C,M]=k.useState(g),[I,L]=k.useState(g);HGe(()=>{_.current=!1,j.current=g;for(let U=0;U{const B=sz(U),V=l&&!p?!1:g===I||b.includes(B),Y=()=>{if(N.current.has(B))return;if(w.has(B))N.current.add(B),w.set(B,!0);else return;let J=!0;w.forEach(te=>{te||(J=!1)}),J&&(q==null||q(),L(j.current),l&&(f==null||f()),n&&n())};return e.jsx(aAt,{isPresent:V,initial:!_.current||r?void 0:!1,custom:s,presenceAffectsLayout:a,mode:o,root:u,onExitComplete:V?void 0:Y,anchorX:i,anchorY:c,children:U},B)})})},vZe=k.createContext({strict:!1}),TPe={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 APe=!1;function oAt(){if(APe)return;const t={};for(const s in TPe)t[s]={isEnabled:r=>TPe[s].some(n=>!!r[n])};GKe(t),APe=!0}function bZe(){return oAt(),HMt()}function lAt(t){const s=bZe();for(const r in t)s[r]={...s[r],...t[r]};GKe(s)}const cAt=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 Foe(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||cAt.has(t)}let _Ze=t=>!Foe(t);function dAt(t){typeof t=="function"&&(_Ze=s=>s.startsWith("on")?!Foe(s):t(s))}try{dAt(require("@emotion/is-prop-valid").default)}catch{}function uAt(t,s,r){const n={};for(const a in t)a==="values"&&typeof t.values=="object"||_h(t[a])||(_Ze(a)||r===!0&&Foe(a)||!s&&!Foe(a)||t.draggable&&a.startsWith("onDrag"))&&(n[a]=t[a]);return n}const iue=k.createContext({});function hAt(t,s){if(aue(t)){const{initial:r,animate:n}=t;return{initial:r===!1||tD(r)?r:void 0,animate:tD(n)?n:void 0}}return t.inherit!==!1?s:{}}function mAt(t){const{initial:s,animate:r}=hAt(t,k.useContext(iue));return k.useMemo(()=>({initial:s,animate:r}),[EPe(s),EPe(r)])}function EPe(t){return Array.isArray(t)?t.join(" "):t}const Yje=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function wZe(t,s,r){for(const n in s)!_h(s[n])&&!eZe(n,r)&&(t[n]=s[n])}function pAt({transformTemplate:t},s){return k.useMemo(()=>{const r=Yje();return Gje(r,s,t),Object.assign({},r.vars,r.style)},[s])}function fAt(t,s){const r=t.style||{},n={};return wZe(n,r,t),Object.assign(n,pAt(t,s)),n}function xAt(t,s){const r={},n=fAt(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 jZe=()=>({...Yje(),attrs:{}});function gAt(t,s,r,n){const a=k.useMemo(()=>{const o=jZe();return tZe(o,s,rZe(n),t.transformTemplate,t.style),{...o.attrs,style:{...o.style}}},[s]);if(t.style){const o={};wZe(o,t.style,t),a.style={...o,...a.style}}return a}const yAt=["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 Xje(t){return typeof t!="string"||t.includes("-")?!1:!!(yAt.indexOf(t)>-1||/[A-Z]/u.test(t))}function vAt(t,s,r,{latestValues:n},a,o=!1,l){const c=(l??Xje(t)?gAt:xAt)(s,n,a,t),u=uAt(s,typeof t=="string",o),p=t!==k.Fragment?{...u,...c,ref:r}:{},{children:f}=s,g=k.useMemo(()=>_h(f)?f.get():f,[f]);return k.createElement(t,{...p,children:g})}function bAt({scrapeMotionValuesFromProps:t,createRenderState:s},r,n,a){return{latestValues:_At(r,n,a,t),renderState:s()}}function _At(t,s,r,n){const a={},o=n(t,{});for(const g in o)a[g]=gie(o[g]);let{initial:l,animate:i}=t;const c=aue(t),u=HKe(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"&&!nue(f)){const g=Array.isArray(f)?f:[f];for(let b=0;b(s,r)=>{const n=k.useContext(iue),a=k.useContext(sue),o=()=>bAt(t,s,n,a);return r?o():jje(o)},wAt=NZe({scrapeMotionValuesFromProps:Kje,createRenderState:Yje}),jAt=NZe({scrapeMotionValuesFromProps:nZe,createRenderState:jZe}),NAt=Symbol.for("motionComponentSymbol");function kAt(t,s,r){const n=k.useRef(r);k.useInsertionEffect(()=>{n.current=r});const a=k.useRef(null);return k.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 kZe=k.createContext({});function L5(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function SAt(t,s,r,n,a,o){var M,I;const{visualElement:l}=k.useContext(iue),i=k.useContext(vZe),c=k.useContext(sue),u=k.useContext(Zje),p=u.reducedMotion,f=u.skipAnimations,g=k.useRef(null),b=k.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}),b.current&&g.current&&(g.current.manuallyAnimateOnMount=!0));const _=g.current,j=k.useContext(kZe);_&&!_.projection&&a&&(_.type==="html"||_.type==="svg")&&CAt(g.current,r,a,j);const w=k.useRef(!1);k.useInsertionEffect(()=>{_&&w.current&&_.update(r,c)});const N=r[IKe],C=k.useRef(!!N&&typeof window<"u"&&!((M=window.MotionHandoffIsComplete)!=null&&M.call(window,N))&&((I=window.MotionHasOptimisedAnimation)==null?void 0:I.call(window,N)));return HGe(()=>{b.current=!0,_&&(w.current=!0,window.MotionIsMounted=!0,_.updateFeatures(),_.scheduleRenderMicrotask(),C.current&&_.animationState&&_.animationState.animateChanges())}),k.useEffect(()=>{_&&(!C.current&&_.animationState&&_.animationState.animateChanges(),C.current&&(queueMicrotask(()=>{var L;(L=window.MotionHandoffMarkAsComplete)==null||L.call(window,N)}),C.current=!1),_.enteringChildren=void 0)}),_}function CAt(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:SZe(t.parent)),t.projection.setOptions({layoutId:a,layout:o,alwaysMeasureLayout:!!l||i&&L5(i),visualElement:t,animationType:typeof o=="string"?o:"both",initialPromotionConfig:n,crossfade:f,layoutScroll:c,layoutRoot:u,layoutAnchor:p})}function SZe(t){if(t)return t.options.allowProjection!==!1?t.projection:SZe(t.parent)}function Oxe(t,{forwardMotionProps:s=!1,type:r}={},n,a){n&&lAt(n);const o=r?r==="svg":Xje(t),l=o?jAt:wAt;function i(u,p){let f;const g={...k.useContext(Zje),...u,layoutId:MAt(u)},{isStatic:b}=g,_=mAt(u),j=l(u,b);if(!b&&typeof window<"u"){TAt();const w=AAt(g);f=w.MeasureLayout,_.visualElement=SAt(t,j,g,a,w.ProjectionNode,o)}return e.jsxs(iue.Provider,{value:_,children:[f&&_.visualElement?e.jsx(f,{visualElement:_.visualElement,...g}):null,vAt(t,u,kAt(j,_.visualElement,p),j,b,s,o)]})}i.displayName=`motion.${typeof t=="string"?t:`create(${t.displayName??t.name??""})`}`;const c=k.forwardRef(i);return c[NAt]=t,c}function MAt({layoutId:t}){const s=k.useContext(wje).id;return s&&t!==void 0?s+"-"+t:t}function TAt(t,s){k.useContext(vZe).strict}function AAt(t){const s=bZe(),{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 EAt(t,s){if(typeof Proxy>"u")return Oxe;const r=new Map,n=(o,l)=>Oxe(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,Oxe(l,void 0,t,s)),r.get(l))})}const PAt=(t,s)=>s.isSVG??Xje(t)?new lTt(s):new sTt(s,{allowProjection:t!==k.Fragment});class IAt extends Ew{constructor(s){super(s),s.animationState||(s.animationState=mTt(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();nue(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 LAt=0;class DAt extends Ew{constructor(){super(...arguments),this.id=LAt++,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=mS(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 OAt={animation:{Feature:IAt},exit:{Feature:DAt}};function DO(t){return{point:{x:t.pageX,y:t.pageY}}}const RAt=t=>s=>Uje(s)&&t(s,DO(s));function GL(t,s,r,n){return sD(t,s,RAt(r),n)}const CZe=({current:t})=>t?t.ownerDocument.defaultView:null,PPe=(t,s)=>Math.abs(t-s);function FAt(t,s){const r=PPe(t.x,s.x),n=PPe(t.y,s.y);return Math.sqrt(r**2+n**2)}const IPe=new Set(["auto","scroll"]);class MZe{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=b=>{this.handleScroll(b.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=rz(this.lastRawMoveEventInfo,this.transformPagePoint));const b=Rxe(this.lastMoveEventInfo,this.history),_=this.startEvent!==null,j=FAt(b.offset,{x:0,y:0})>=this.distanceThreshold;if(!_&&!j)return;const{point:w}=b,{timestamp:N}=gh;this.history.push({...w,timestamp:N});const{onStart:C,onMove:M}=this.handlers;_||(C&&C(this.lastMoveEvent,b),this.startEvent=this.lastMoveEvent),M&&M(this.lastMoveEvent,b)},this.handlePointerMove=(b,_)=>{this.lastMoveEvent=b,this.lastRawMoveEventInfo=_,this.lastMoveEventInfo=rz(_,this.transformPagePoint),Pl.update(this.updatePoint,!0)},this.handlePointerUp=(b,_)=>{this.end();const{onEnd:j,onSessionEnd:w,resumeAnimation:N}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const C=Rxe(b.type==="pointercancel"?this.lastMoveEventInfo:rz(_,this.transformPagePoint),this.history);this.startEvent&&j&&j(b,C),w&&w(b,C)},!Uje(s))return;this.dragSnapToOrigin=o,this.handlers=r,this.transformPagePoint=n,this.distanceThreshold=l,this.contextWindow=a||window;const c=DO(s),u=rz(c,this.transformPagePoint),{point:p}=u,{timestamp:f}=gh;this.history=[{...p,timestamp:f}];const{onSessionStart:g}=r;g&&g(s,Rxe(u,this.history)),this.removeListeners=PO(GL(this.contextWindow,"pointermove",this.handlePointerMove),GL(this.contextWindow,"pointerup",this.handlePointerUp),GL(this.contextWindow,"pointercancel",this.handlePointerUp)),i&&this.startScrollTracking(i)}startScrollTracking(s){let r=s.parentElement;for(;r;){const n=getComputedStyle(r);(IPe.has(n.overflowX)||IPe.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),Pl.update(this.updatePoint,!0))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),mw(this.updatePoint)}}function rz(t,s){return s?{point:s(t.point)}:t}function LPe(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Rxe({point:t},s){return{point:t,delta:LPe(t,TZe(s)),offset:LPe(t,zAt(s)),velocity:BAt(s,.1)}}function zAt(t){return t[0]}function TZe(t){return t[t.length-1]}function BAt(t,s){if(t.length<2)return{x:0,y:0};let r=t.length-1,n=null;const a=TZe(t);for(;r>=0&&(n=t[r],!(a.timestamp-n.timestamp>xf(s)));)r--;if(!n)return{x:0,y:0};n===t[0]&&t.length>2&&a.timestamp-n.timestamp>xf(s)*2&&(n=t[1]);const o=bx(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 $At(t,{min:s,max:r},n){return s!==void 0&&tr&&(t=n?yc(r,t,n.max):Math.min(t,r)),t}function DPe(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 qAt(t,{top:s,left:r,bottom:n,right:a}){return{x:DPe(t.x,r,a),y:DPe(t.y,s,n)}}function OPe(t,s){let r=s.min-t.min,n=s.max-t.max;return s.max-s.minn?r=J8(s.min,s.max-n,t.min):n>a&&(r=J8(t.min,t.max-a,s.min)),S0(0,1,r)}function HAt(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 i1e=.35;function WAt(t=i1e){return t===!1?t=0:t===!0&&(t=i1e),{x:RPe(t,"left","right"),y:RPe(t,"top","bottom")}}function RPe(t,s,r){return{min:FPe(t,s),max:FPe(t,r)}}function FPe(t,s){return typeof t=="number"?t:t[s]||0}const GAt=new WeakMap;class KAt{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=pu(),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(DO(f).point),this.stopAnimation()},l=(f,g)=>{const{drag:b,dragPropagation:_,onDragStart:j}=this.getProps();if(b&&!_&&(this.openDragLock&&this.openDragLock(),this.openDragLock=_Mt(b),!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),Vy(N=>{let C=this.getAxisMotionValue(N).get()||0;if(b0.test(C)){const{projection:M}=this.visualElement;if(M&&M.layout){const I=M.layout.layoutBox[N];I&&(C=Nm(I)*(parseFloat(C)/100))}}this.originPoint[N]=C}),j&&Pl.update(()=>j(f,g),!1,!0),Xve(this.visualElement,"transform");const{animationState:w}=this.visualElement;w&&w.setActive("whileDrag",!0)},i=(f,g)=>{this.latestPointerEvent=f,this.latestPanInfo=g;const{dragPropagation:b,dragDirectionLock:_,onDirectionLock:j,onDrag:w}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:N}=g;if(_&&this.currentDirection===null){this.currentDirection=YAt(N),this.currentDirection!==null&&j&&j(this.currentDirection);return}this.updateAxis("x",g.point,N),this.updateAxis("y",g.point,N),this.visualElement.render(),w&&Pl.update(()=>w(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 MZe(s,{onSessionStart:o,onStart:l,onMove:i,onSessionEnd:c,resumeAnimation:u},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:p,distanceThreshold:n,contextWindow:CZe(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&&Pl.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||!nz(s,a,this.currentDirection))return;const o=this.getAxisMotionValue(s);let l=this.originPoint[s]+n[s];this.constraints&&this.constraints[s]&&(l=$At(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&&L5(s)?this.constraints||(this.constraints=this.resolveRefConstraints()):s&&n?this.constraints=qAt(n.layoutBox,s):this.constraints=!1,this.elastic=WAt(r),a!==this.constraints&&!L5(s)&&n&&this.constraints&&!this.hasMutatedConstraints&&Vy(l=>{this.constraints!==!1&&this.getAxisMotionValue(l)&&(this.constraints[l]=HAt(n.layoutBox[l],this.constraints[l]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:r}=this.getProps();if(!s||!L5(s))return!1;const n=s.current,{projection:a}=this.visualElement;if(!a||!a.layout)return!1;const o=YMt(n,a.root,this.visualElement.getTransformPagePoint());let l=UAt(a.layout.layoutBox,o);if(r){const i=r(GMt(l));this.hasMutatedConstraints=!!i,i&&(l=ZKe(i))}return l}startAnimation(s){const{drag:r,dragMomentum:n,dragElastic:a,dragTransition:o,dragSnapToOrigin:l,onDragTransitionEnd:i}=this.getProps(),c=this.constraints||{},u=Vy(p=>{if(!nz(p,r,this.currentDirection))return;let f=c&&c[p]||{};(l===!0||l===p)&&(f={min:0,max:0});const g=a?200:1e6,b=a?40:1e7,_={type:"inertia",velocity:n?s[p]:0,bounceStiffness:g,bounceDamping:b,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 Xve(this.visualElement,s),n.start(Rje(s,n,0,r,this.visualElement,!1))}stopAnimation(){Vy(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){Vy(r=>{const{drag:n}=this.getProps();if(!nz(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]-yc(l,i,.5)+c)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:r}=this.getProps(),{projection:n}=this.visualElement;if(!L5(r)||!n||!this.constraints)return;this.stopAnimation();const a={x:0,y:0};Vy(l=>{const i=this.getAxisMotionValue(l);if(i&&this.constraints!==!1){const c=i.get();a[l]=VAt({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(),Vy(l=>{if(!nz(l,s,null))return;const i=this.getAxisMotionValue(l),{min:c,max:u}=this.constraints[l];i.set(yc(c,u,a[l]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;GAt.set(this.visualElement,this);const s=this.visualElement.current,r=GL(s,"pointerdown",u=>{const{drag:p,dragListener:f=!0}=this.getProps(),g=u.target,b=g!==s&&CMt(g);p&&f&&!b&&this.start(u)});let n;const a=()=>{const{dragConstraints:u}=this.getProps();L5(u)&&u.current&&(this.constraints=this.resolveRefConstraints(),n||(n=ZAt(s,u.current,()=>this.scalePositionWithinConstraints())))},{projection:o}=this.visualElement,l=o.addEventListener("measure",a);o&&!o.layout&&(o.root&&o.root.updateScroll(),o.updateLayout()),Pl.read(a);const i=sD(window,"resize",()=>this.scalePositionWithinConstraints()),c=o.addEventListener("didUpdate",({delta:u,hasLayoutChanged:p})=>{this.isDragging&&p&&(Vy(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=i1e,dragMomentum:i=!0}=s;return{...s,drag:r,dragDirectionLock:n,dragPropagation:a,dragConstraints:o,dragElastic:l,dragMomentum:i}}}function zPe(t){let s=!0;return()=>{if(s){s=!1;return}t()}}function ZAt(t,s,r){const n=W6e(t,zPe(r)),a=W6e(s,zPe(r));return()=>{n(),a()}}function nz(t,s,r){return(s===!0||s===t)&&(r===null||r===t)}function YAt(t,s=10){let r=null;return Math.abs(t.y)>s?r="y":Math.abs(t.x)>s&&(r="x"),r}class XAt extends Ew{constructor(s){super(s),this.removeGroupControls=Tx,this.removeListeners=Tx,this.controls=new KAt(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Tx}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 Fxe=t=>(s,r)=>{t&&Pl.update(()=>t(s,r),!1,!0)};class QAt extends Ew{constructor(){super(...arguments),this.removePointerDownListener=Tx}onPointerDown(s){this.session=new MZe(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:CZe(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:r,onPan:n,onPanEnd:a}=this.node.getProps();return{onSessionStart:Fxe(s),onStart:Fxe(r),onMove:Fxe(n),onEnd:(o,l)=>{delete this.session,a&&Pl.postRender(()=>a(o,l))}}}mount(){this.removePointerDownListener=GL(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 zxe=!1;class JAt extends k.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),zxe&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),yie.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}),zxe=!0,a||s.layoutDependency!==r||r===void 0||s.isPresent!==o?l.willUpdate():this.safeToRemove(),s.isPresent!==o&&(o?l.promote():l.relegate()||Pl.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(),qje.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:r,switchLayoutGroup:n}=this.props,{projection:a}=s;zxe=!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 AZe(t){const[s,r]=gZe(),n=k.useContext(wje);return e.jsx(JAt,{...t,layoutGroup:n,switchLayoutGroup:k.useContext(kZe),isPresent:s,safeToRemove:r})}const eEt={pan:{Feature:QAt},drag:{Feature:XAt,ProjectionNode:xZe,MeasureLayout:AZe}};function BPe(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&&Pl.postRender(()=>o(s,DO(s)))}class tEt extends Ew{mount(){const{current:s}=this.node;s&&(this.unmount=jMt(s,(r,n)=>(BPe(this.node,n,"Start"),a=>BPe(this.node,a,"End"))))}unmount(){}}class sEt extends Ew{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=PO(sD(this.node.current,"focus",()=>this.onFocus()),sD(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function $Pe(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&&Pl.postRender(()=>o(s,DO(s)))}class rEt extends Ew{mount(){const{current:s}=this.node;if(!s)return;const{globalTapTarget:r,propagate:n}=this.node.props;this.unmount=TMt(s,(a,o)=>($Pe(this.node,o,"Start"),(l,{success:i})=>$Pe(this.node,l,i?"End":"Cancel")),{useGlobalTarget:r,stopPropagation:(n==null?void 0:n.tap)===!1})}unmount(){}}const o1e=new WeakMap,Bxe=new WeakMap,nEt=t=>{const s=o1e.get(t.target);s&&s(t)},aEt=t=>{t.forEach(nEt)};function iEt({root:t,...s}){const r=t||document;Bxe.has(r)||Bxe.set(r,{});const n=Bxe.get(r),a=JSON.stringify(s);return n[a]||(n[a]=new IntersectionObserver(aEt,{root:t,...s})),n[a]}function oEt(t,s,r){const n=iEt(s);return o1e.set(t,r),n.observe(t),()=>{o1e.delete(t),n.unobserve(t)}}const lEt={some:0,all:1};class cEt extends Ew{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:lEt[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(),b=p?f:g;b&&b(u)};this.stopObserver=oEt(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(dEt(s,r))&&this.startObserver()}unmount(){var s;(s=this.stopObserver)==null||s.call(this),this.hasEnteredView=!1,this.isInView=!1}}function dEt({viewport:t={}},{viewport:s={}}={}){return r=>t[r]!==s[r]}const uEt={inView:{Feature:cEt},tap:{Feature:rEt},focus:{Feature:sEt},hover:{Feature:tEt}},hEt={layout:{ProjectionNode:xZe,MeasureLayout:AZe}},mEt={...OAt,...uEt,...eEt,...hEt},Ws=EAt(mEt,PAt),pEt={some:0,all:1};function fEt(t,s,{root:r,margin:n,amount:a="some"}={}){const o=$je(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:pEt[a]});return o.forEach(u=>c.observe(u)),()=>c.disconnect()}function xEt(t,{root:s,margin:r,amount:n,once:a=!1,initial:o=!1}={}){const[l,i]=k.useState(o);return k.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 fEt(t.current,c,u)},[s,t,r,a,n]),l}function gEt(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 qPe(t){return t.visitor_intent==="buying"&&!t.has_agent}function yEt({token:t}={}){var _;const s=yo(),r=t||s.token,{data:n,isLoading:a,isError:o}=s3t(r),l=es(),i=(_=n==null?void 0:n.open_houses)==null?void 0:_.id,{data:c}=mt({queryKey:["cohost-visitors",i],queryFn:async()=>{const{data:j,error:w}=await H.from("open_house_visitors").select("*").eq("open_house_id",i).order("created_at",{ascending:!1});if(w)throw w;return j},enabled:!!i});if(k.useEffect(()=>{if(!i)return;const j=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(j)}},[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(j=>j.visitor_intent==="buying").length)||0,g=(c==null?void 0:c.filter(qPe).length)||0,b=j=>{if(!j)return"";const[w,N]=j.split(":"),C=parseInt(w);return`${C>12?C-12:C||12}:${N} ${C>=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(mr,{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(Qu,{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(Sn,{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:ps(new Date(u.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy")}),u.start_time&&e.jsxs("span",{children:[b(u.start_time),u.end_time?` – ${b(u.end_time)}`:""]})]}),e.jsx(Gi,{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(yZe,{children:c.map((j,w)=>{var M;const N=gEt(j.visitor_intent),C=qPe(j);return e.jsxs(Ws.div,{initial:{opacity:0,x:-40,scale:.95},animate:{opacity:1,x:0,scale:1},transition:{duration:.4,delay:w*.05},className:`flex items-center gap-4 p-4 rounded-xl border ${C?"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 ${C?"bg-gradient-to-br from-orange-500 to-amber-500 text-white":"bg-white/10 text-white/80"}`,children:(M=j.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:[j.first_name," ",j.last_name||""]}),C&&e.jsx(tt,{className:"bg-orange-500/20 text-orange-300 border-orange-500/40 text-[10px] px-1.5 py-0",children:"🔥 HOT"}),j.has_agent&&e.jsx(tt,{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(tt,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${N.color}`,children:[N.emoji," ",N.label]}),e.jsx("span",{className:"text-white/30 text-xs",children:ps(new Date(j.created_at),"h:mm a")})]})]})]},j.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(l1,{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 vEt(){const s=nu().pathname.slice(1);if(k.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(yEt,{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(EGe,{slug:s})}function bEt({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(Sn,{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(Ba,{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(Un,{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(dr,{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(zc,{className:"w-4 h-4 text-[#406E71]"}),e.jsx("span",{className:"text-sm font-medium text-[#406E71]",children:"Text"})]})]})})})]})}function _Et({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(fi,{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 Il(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 NEt(t,s){const r=ps(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 kEt(t,s){const r=ps(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 SEt({targetCloseDate:t,contractDate:s,inspectionDate:r,appraisalDate:n,actualCloseDate:a}){const o=[{label:"Contract Date",date:s,icon:wM,color:"text-blue-600 bg-blue-50"},{label:"Inspection",date:r,icon:hn,color:"text-amber-600 bg-amber-50"},{label:"Appraisal",date:n,icon:Sn,color:"text-purple-600 bg-purple-50"},{label:a?"Closed":"Target Close",date:a||t,icon:cn,color:"text-emerald-600 bg-emerald-50"}].filter(i=>i.date);if(o.length===0)return null;const l=(i,c,u)=>{const p=Il(c);if(u==="google")window.open(NEt(i,p),"_blank");else{const f=kEt(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=Il(c),g=y0(f)&&!vu(f),b=vu(f),_=!g&&!b;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 ${b?"text-emerald-600":g?"text-slate-400":"text-slate-800"}`,children:[ps(f,"MMM d, yyyy"),b&&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(D_,{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 CEt({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(En,{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(Ci,{className:"w-4 h-4 text-slate-300 group-hover:text-blue-500 transition-colors"})]},n.id))})]})}function MEt({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(yd,{className:"w-3.5 h-3.5 text-emerald-600"}):e.jsx(Pm,{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:ps(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 TEt({portal:t,dealData:s,agentProfile:r,customQuestions:n,deviceFingerprint:a,onComplete:o}){var _,j;const[l,i]=k.useState({first_name:((_=t.client_name)==null?void 0:_.split(" ")[0])||"",last_name:((j=t.client_name)==null?void 0:j.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]=k.useState({}),[p,f]=k.useState(!1),g=Lt({mutationFn:async()=>{const{error:w}=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(w)throw w},onSuccess:o,onError:w=>{console.error("[PortalOnboarding] Submit failed:",w),he.error("Something went wrong. Please try again.")}}),b=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"}),b&&e.jsxs("div",{className:"flex items-center justify-center gap-1 text-slate-500 text-sm mt-1",children:[e.jsx(Ba,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:b.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:w=>{w.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(ye,{className:"text-xs text-slate-600",children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:w=>i(N=>({...N,first_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"John"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.last_name,onChange:w=>i(N=>({...N,last_name:w.target.value})),className:"mt-1 rounded-xl",placeholder:"Doe"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:w=>i(N=>({...N,email:w.target.value})),className:"mt-1 rounded-xl",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.phone,onChange:w=>i(N=>({...N,phone:w.target.value})),className:"mt-1 rounded-xl",placeholder:"(555) 123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{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(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,preferred_contact_method:w.value})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.preferred_contact_method===w.value?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.label},w.value))})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Your Role"}),e.jsx("div",{className:"flex gap-2 mt-1.5",children:["buyer","seller","both"].map(w=>e.jsx("button",{type:"button",onClick:()=>i(N=>({...N,client_role:w})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${l.client_role===w?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200 hover:border-slate-300"}`,children:w.charAt(0).toUpperCase()+w.slice(1)},w))})]}),n.map(w=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-xs text-slate-600",children:[w.question_text," ",w.is_required&&"*"]}),w.field_type==="text"&&e.jsx(ze,{required:w.is_required,value:c[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.target.value})),className:"mt-1 rounded-xl"}),w.field_type==="textarea"&&e.jsx("textarea",{required:w.is_required,value:c[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.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"}),w.field_type==="dropdown"&&e.jsxs("select",{required:w.is_required,value:c[w.id]||"",onChange:N=>u(C=>({...C,[w.id]:N.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..."}),(w.options||[]).map(N=>e.jsx("option",{value:N,children:N},N))]}),w.field_type==="toggle"&&e.jsx("div",{className:"mt-1.5 flex gap-2",children:["Yes","No"].map(N=>e.jsx("button",{type:"button",onClick:()=>u(C=>({...C,[w.id]:N})),className:`px-3.5 py-1.5 rounded-full text-xs font-medium border transition-colors ${c[w.id]===N?"bg-slate-800 text-white border-slate-800":"bg-white text-slate-600 border-slate-200"}`,children:N},N))})]},w.id)),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Notes for your agent"}),e.jsx("textarea",{value:l.notes,onChange:w=>i(N=>({...N,notes:w.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(ye,{className:"text-xs text-slate-600",children:"First Name"}),e.jsx(ze,{value:l.spouse_first_name,onChange:w=>i(N=>({...N,spouse_first_name:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Last Name"}),e.jsx(ze,{value:l.spouse_last_name,onChange:w=>i(N=>({...N,spouse_last_name:w.target.value})),className:"mt-1 rounded-xl"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Email"}),e.jsx(ze,{type:"email",value:l.spouse_email,onChange:w=>i(N=>({...N,spouse_email:w.target.value})),className:"mt-1 rounded-xl"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs text-slate-600",children:"Phone"}),e.jsx(ze,{type:"tel",value:l.spouse_phone,onChange:w=>i(N=>({...N,spouse_phone:w.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 AEt(t){return t==="buy-side"?"Home Search in Progress":t==="listing"?"Your Home Is On The Market":"Active Phase"}function EEt(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 PEt={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. 🎉"}},EZe=["Lead","Consultation","Agreement Signed","Active","Under Contract","Closing","Closed Won"];function Qje(t){return EZe.map(s=>{if(s==="Active")return{key:"Active",label:AEt(t),description:EEt(t)};const r=PEt[s];return{key:s,label:r.label,description:r.description}})}function UPe(t){if(!t)return 0;const s=EZe.indexOf(t);return s>=0?s:0}function IEt(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 LEt(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 PZe({slug:t}){var te,X,ce,ne,re,le;const[s,r]=k.useState(!1),[n,a]=k.useState("primary"),[o]=k.useState(()=>{const pe=`portal_fp_${t}`;let xe=localStorage.getItem(pe);return xe||(xe=localStorage.getItem("portal_fp"),xe?localStorage.setItem(pe,xe):(xe=crypto.randomUUID(),localStorage.setItem(pe,xe),localStorage.setItem("portal_fp",xe))),xe});k.useEffect(()=>(document.body.classList.add("client-portal-page"),()=>document.body.classList.remove("client-portal-page")),[]);const{data:l,isLoading:i,error:c}=IEt(t,!0),u=l==null?void 0:l.linked_portal_id,{data:p}=LEt(u),f=(te=l==null?void 0:l.deal_pipeline)==null?void 0:te.owner_user_id,{data:g}=mt({queryKey:["portal-stages",f],queryFn:async()=>{const{data:pe,error:xe}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",f).order("sort_order",{ascending:!0});if(xe)throw xe;return pe},enabled:!!f}),{data:b}=mt({queryKey:["portal-agent",f],queryFn:async()=>{const{data:pe,error:xe}=await H.from("profiles").select("id, name, avatar_url, phone, email").eq("id",f).single();if(xe)throw xe;return pe},enabled:!!f}),_=n==="linked"&&p?p:l,j=_==null?void 0:_.id,{data:w}=mt({queryKey:["portal-updates-public",j],queryFn:async()=>{const{data:pe,error:xe}=await H.from("portal_updates").select("*").eq("portal_id",j).order("created_at",{ascending:!1});if(xe)throw xe;return pe},enabled:!!j}),N=(X=_==null?void 0:_.deal_pipeline)==null?void 0:X.id,{data:C}=mt({queryKey:["portal-documents",N],queryFn:async()=>{const{data:pe,error:xe}=await H.from("deal_files").select("*").eq("deal_id",N).eq("visible_on_portal",!0).order("created_at",{ascending:!1});if(xe)throw xe;return pe},enabled:!!N}),M=l==null?void 0:l.id,{data:I,isLoading:L}=mt({queryKey:["portal-onboarding-check",M,o],queryFn:async()=>{const{data:pe,error:xe}=await H.from("portal_onboarding_submissions").select("id").eq("portal_id",M).eq("device_fingerprint",o).maybeSingle();if(xe)throw xe;return pe},enabled:!!M&&!!(l!=null&&l.require_onboarding)}),{data:R}=mt({queryKey:["portal-custom-questions-public",f],queryFn:async()=>{const{data:pe,error:xe}=await H.from("portal_custom_questions").select("*").eq("owner_user_id",f).eq("is_active",!0).order("sort_order",{ascending:!0});if(xe)throw xe;return pe},enabled:!!f&&!!(l!=null&&l.require_onboarding)}),q=!!I||s||!(l!=null&&l.require_onboarding);if(i||l!=null&&l.require_onboarding&&L)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(!q){const pe=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(TEt,{portal:l,dealData:pe,agentProfile:b,customQuestions:R||[],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,Y=pe=>pe==="listing"?"Your Sale":pe==="buy-side"?"Your Purchase":"Transaction",J=pe=>pe==="listing"?e.jsx(Sn,{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(bEt,{dealData:_==null?void 0:_.deal_pipeline,agentProfile:b,welcomeMessage:_==null?void 0:_.welcome_message,isWon:(le=(re=_==null?void 0:_.deal_pipeline)==null?void 0:re.deal_pipeline_stages)==null?void 0:le.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:[J(U),Y(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:[J(B),Y(B)]})]}),e.jsx(DEt,{portal:_,updates:w,documents:C}),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(Th,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"text-xs",children:"Secure Client Portal"})]}),b&&e.jsxs("p",{className:"text-xs text-slate-400",children:["Managed by ",e.jsx("span",{className:"font-medium text-slate-500",children:b.name})]}),e.jsx("p",{className:"text-[10px] text-slate-300",children:"Powered by ReLevelUp"})]})]})]})}function DEt({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=Qje(i);c&&c.length>0&&(u=c.map((b,_)=>{var j,w;return{key:`custom-${_}`,label:b.label||((j=u[_])==null?void 0:j.label)||`Stage ${_+1}`,description:b.description||((w=u[_])==null?void 0:w.description)||"",video_url:b.video_url||void 0}}));const p=c&&c.length>0?Math.min(UPe(o==null?void 0:o.name),u.length-1):UPe(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(wEt,{targetCloseDate:a==null?void 0:a.target_close_date,actualCloseDate:a==null?void 0:a.actual_close_date,clientName:t.client_name}),e.jsx(_Et,{journeyStages:u,currentIndex:p}),f&&e.jsx(jEt,{currentStage:f,nextStepText:t.next_step_text,nextStepVideoUrl:g||t.next_step_video_url}),e.jsx(SEt,{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(CEt,{documents:r}),s&&s.length>0&&e.jsx(MEt,{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 OEt(){const s=nu().pathname.slice(1);return k.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(PZe,{slug:s})}const l1e="levelup_affiliate_ref",REt=30,FEt=()=>{const[t]=qc();k.useEffect(()=>{const s=t.get("ref");if(s){const r={code:s.toUpperCase(),timestamp:Date.now()};localStorage.setItem(l1e,JSON.stringify(r)),console.log("[Affiliate] Stored referral code:",s)}},[t])},zEt=()=>{try{const t=localStorage.getItem(l1e);if(!t)return null;const s=JSON.parse(t),r=REt*24*60*60*1e3;return Date.now()-s.timestamp>r?(localStorage.removeItem(l1e),console.log("[Affiliate] Referral code expired"),null):s.code}catch{return null}},zoe="/assets/levelup-logo-header-_ZX7DvlA.png",BEt="/assets/scale-your-team-ku4MPatU.png";function $Et({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(_s,{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(wa,{className:"h-5 w-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(bs,{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 $u={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"]}},qEt=[{icon:mp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:sc,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:cn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:zc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:En,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:No,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],UEt=[{icon:mr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:un,title:"Smart Touchpoint Plans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Sh,title:"Birthday & Anniversary Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ba,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Ro,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ii,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fm,title:"Daily Action Cards",description:"Wake up to a prioritized list of exactly who to reach out to today."}],VEt=[{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."}],HEt=()=>{const{user:t,loading:s}=Rs(),r=pr(),[n]=qc();k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=window.location.pathname==="/";if(q&&U){r("/public/listings",{replace:!0});return}},[r]);const[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(!1),[C,M]=k.useState(!1),I=(q,U=!1)=>{i({tier:q,skipTrial:U}),u(!0)};FEt(),k.useEffect(()=>{const q=window.location.host==="listings.relevelup.com",U=location.pathname.startsWith("/public/");!s&&t&&!q&&!U&&r("/dashboard")},[t,s,r,location.pathname]),k.useEffect(()=>{n.get("canceled")==="true"&&he.error("Checkout was canceled. Feel free to try again when you're ready!")},[n]);const L=async(q,U=!1)=>{if(!p){he.error("Please enter your email address");return}if(!g.trim()){he.error("Please enter your full name");return}N(!0),o(q+(U?"_direct":""));const B=zEt();try{const{data:V,error:Y}=await H.functions.invoke("create-checkout",{body:{tier:q,email:p,name:g.trim(),couponCode:_.trim()||void 0,skipTrial:U,referralCode:B}});if(Y)throw Y;if(V!=null&&V.url)window.open(V.url,"_blank","noopener,noreferrer"),he.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(V){console.error("Checkout error:",V),he.error(V.message||"Failed to start checkout. Please try again.")}finally{N(!1),o(null),u(!1),i(null)}},R=()=>{l&&L(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:zoe,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 q;return(q=document.getElementById("features"))==null?void 0:q.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 q;return(q=document.getElementById("pricing"))==null?void 0:q.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 q;return(q=document.getElementById("free-trial"))==null?void 0:q.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(fi,{className:"ml-2 w-5 h-5 group-hover:translate-x-1 transition-transform"})]}),e.jsx(K,{size:"lg",variant:"outline",onClick:()=>{var q;return(q=document.getElementById("features"))==null?void 0:q.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 q;return(q=document.getElementById("brokerage"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"border-[#4a6b6d] text-[#4a6b6d] hover:bg-[#4a6b6d]/5",children:[e.jsx(wa,{className:"mr-2 h-5 w-5"}),"Brokerage Partnership"]}),e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:[e.jsx(to,{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:qEt.map((q,U)=>e.jsxs(Pe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Dt,{children:[e.jsx("div",{className:"w-14 h-14 rounded-2xl bg-[#4a6b6d]/10 flex items-center justify-center mb-4",children:e.jsx(q.icon,{className:"w-7 h-7 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:q.title})]}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground leading-relaxed",children:q.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(un,{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:UEt.map((q,U)=>e.jsxs(Pe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Dt,{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(q.icon,{className:"w-6 h-6 text-white"})}),e.jsx(zt,{className:"text-lg font-semibold text-white",children:q.title})]}),e.jsx(Re,{children:e.jsx("p",{className:"text-white/70 text-sm leading-relaxed",children:q.description})})]},U))}),e.jsx("div",{className:"text-center mt-12",children:e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.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(fi,{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(wa,{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((q,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(fa,{className:"w-4 h-4 text-[#4a6b6d]"})}),e.jsx("span",{className:"text-foreground",children:q})]},U))}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 mt-4",children:[e.jsxs(K,{size:"lg",onClick:()=>{var q;return(q=document.getElementById("pricing"))==null?void 0:q.scrollIntoView({behavior:"smooth"})},className:"bg-[#4a6b6d] hover:bg-[#3d5a5c]",children:["See Brokerage Plans",e.jsx(xa,{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(cn,{className:"mr-2 w-5 h-5"}),"Schedule Info Session"]})]})]}),e.jsx("div",{className:"relative hidden md:block",children:e.jsx("img",{src:BEt,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:VEt.map((q,U)=>e.jsx(Pe,{className:"bg-muted/30 border-0",children:e.jsxs(Re,{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:['"',q.quote,'"']}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:q.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:q.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:()=>I("individual_agent"),children:["Start Free Trial",e.jsx(fi,{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(Pe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Dt,{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(to,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsx(zt,{className:"text-xl font-sans",children:$u.individual_agent.name})]}),e.jsxs("div",{className:"flex items-baseline gap-1 mt-4",children:[e.jsx("span",{className:"text-5xl font-bold",children:$u.individual_agent.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:$u.individual_agent.period})]}),e.jsx(xr,{className:"text-base mt-2",children:$u.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(mn,{className:"w-4 h-4"}),$u.individual_agent.trial]})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:$u.individual_agent.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsxs(BL,{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:()=>I("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:()=>I("individual_agent",!0),children:"Skip Trial, Subscribe Now"})]})]}),e.jsxs(Pe,{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(Dt,{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(wa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:$u.brokerage_under_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:$u.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:$u.brokerage_under_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:$u.brokerage_under_25.period})]}),e.jsx(xr,{className:"text-base mt-2",children:$u.brokerage_under_25.description})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:$u.brokerage_under_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx(BL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg shadow-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("brokerage_under_25"),children:"Get Started"})})]}),e.jsxs(Pe,{className:"relative flex flex-col border hover:border-[#4a6b6d]/50 transition-all hover:shadow-xl bg-background",children:[e.jsxs(Dt,{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(wa,{className:"w-5 h-5 text-[#4a6b6d]"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-xl font-sans",children:$u.brokerage_over_25.name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:$u.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:$u.brokerage_over_25.price}),e.jsx("span",{className:"text-muted-foreground text-lg",children:$u.brokerage_over_25.period})]}),e.jsx(xr,{className:"text-base mt-2",children:$u.brokerage_over_25.description})]}),e.jsx(Re,{className:"flex-1 pt-0",children:e.jsx("ul",{className:"space-y-3",children:$u.brokerage_over_25.features.map((q,U)=>e.jsxs("li",{className:"flex items-center gap-3",children:[e.jsx(fa,{className:"w-5 h-5 text-[#4a6b6d] flex-shrink-0"}),e.jsx("span",{children:q})]},U))})}),e.jsx(BL,{className:"pt-4",children:e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:()=>I("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 q;return(q=document.getElementById("pricing"))==null?void 0:q.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(fi,{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:zoe,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($Et,{open:C,onOpenChange:M}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{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:q=>b(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ye,{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:q=>f(q.target.value),className:"mt-1",required:!0})]}),e.jsxs("div",{children:[e.jsxs(ye,{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:q=>j(q.target.value),className:"mt-1"})]})]}),e.jsx(K,{className:"w-full py-6 text-lg bg-[#4a6b6d] hover:bg-[#3d5a5c]",onClick:R,disabled:w,children:w?"Loading...":"Continue to Checkout"})]})})]})},WEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(rd,{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"})]})]})]})]})})]}),GEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(rd,{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"})]})]})]})]})})]}),KEt=()=>e.jsxs(e.Fragment,{children:[e.jsxs(rd,{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"})]})]})]})]})})]}),ZEt=hC({email:pc().email("Invalid email address"),password:pc().min(6,"Password must be at least 6 characters")}),YEt=()=>{const{signIn:t,user:s}=Rs(),r=pr(),[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState(!1);k.useEffect(()=>{s&&r("/dashboard")},[s,r]);const b=async j=>{j.preventDefault(),l({}),a(!0);const w=new FormData(j.currentTarget),N=w.get("email"),C=w.get("password");try{ZEt.parse({email:N,password:C}),await t(N,C)}catch(M){if(M instanceof k0){const I={};M.errors.forEach(L=>{L.path[0]&&(I[L.path[0]]=L.message)}),l(I)}}finally{a(!1)}},_=async()=>{if(!i){he.error("Please enter your email address");return}p(!0);try{const{error:j}=await H.functions.invoke("send-password-reset",{body:{email:i,redirectTo:"https://dashboard.relevelup.com/profile?reset=true"}});if(j)throw j;he.success("Password reset email sent! Check your inbox."),g(!1),c("")}catch(j){he.error(j.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(Ei,{to:"/",className:"inline-flex items-center gap-2 text-sm text-white/80 hover:text-white transition-colors",children:[e.jsx(ri,{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:cWe,alt:"LevelUp",className:"h-12 w-auto"})})}),e.jsxs(Pe,{className:"border-0 shadow-2xl bg-white/95 backdrop-blur-sm",children:[e.jsxs(Dt,{className:"space-y-1 text-center pb-4",children:[e.jsx(zt,{className:"text-3xl font-bold text-[#2a4347]",style:{fontFamily:"'Libre Baskerville', serif"},children:"Welcome Back"}),e.jsx(xr,{className:"text-gray-600",children:"Sign in to access your dashboard"})]}),e.jsx(Re,{children:e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{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(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"reset-email",className:"text-gray-700",children:"Email"}),e.jsx(ze,{id:"reset-email",type:"email",placeholder:"your@email.com",value:i,onChange:j=>c(j.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(Ei,{to:"/",className:"text-white hover:underline font-medium",children:"View Plans"})]})]})})]})]})},XEt=()=>{const[t]=qc(),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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Dt,{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(xi,{className:"w-10 h-10 text-green-500"})}),e.jsx(zt,{className:"text-2xl",children:"Welcome to LevelUp!"}),e.jsx(xr,{className:"text-lg",children:"Your subscription has been activated successfully."})]}),e.jsxs(Re,{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(dr,{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."})})]})]})})},IZe=t=>{const[s,r]=k.useState(null),[n,a]=k.useState(!0);return k.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)}}}},LZe=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},QEt=t=>{const[s,r]=k.useState({isTrial:!1,isExpired:!1,expiresAt:null,daysLeft:null,loading:!0});return k.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},DZe=()=>{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")}},VPe="community_last_seen_post_at";function JEt(){const{user:t}=Rs(),s=nu(),[r,n]=k.useState(0),[a,o]=k.useState(null);k.useEffect(()=>{if(!t)return;const i=localStorage.getItem(`${VPe}_${t.id}`);o(i)},[t]),k.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]),k.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(j=>j+1);const{data:f}=await H.from("profiles").select("name").eq("id",u.user_id).single(),g=(f==null?void 0:f.name)||"Someone",b=u.content.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),_=b.length>50?b.substring(0,50)+"...":b;p||he("New Community Post",{description:`${g}: ${_}`,action:{label:"View",onClick:()=>{window.location.href="/community"}}})}).subscribe();return()=>{H.removeChannel(i)}},[t,s.pathname]);const l=k.useCallback(()=>{if(!t)return;const i=new Date().toISOString();localStorage.setItem(`${VPe}_${t.id}`,i),o(i),n(0)},[t]);return k.useEffect(()=>{s.pathname==="/community"&&r>0&&l()},[s.pathname,r,l]),{unreadCount:r,markAsRead:l}}function e6t(){const{isAdmin:t}=Rs(),{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 QA=zde,Jje=nje,t6t=Bde,OZe=k.forwardRef(({className:t,...s},r)=>e.jsx(WA,{className:Pt("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}));OZe.displayName=WA.displayName;const s6t=lC("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"}}),mC=k.forwardRef(({side:t="right",className:s,children:r,...n},a)=>e.jsxs(t6t,{children:[e.jsx(OZe,{}),e.jsxs(GA,{ref:a,className:Pt(s6t({side:t}),s),...n,children:[r,e.jsxs(TO,{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(Or,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));mC.displayName=GA.displayName;const JA=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});JA.displayName="SheetHeader";const eE=k.forwardRef(({className:t,...s},r)=>e.jsx(CO,{ref:r,className:Pt("text-lg font-semibold text-foreground",t),...s}));eE.displayName=CO.displayName;const RZe=k.forwardRef(({className:t,...s},r)=>e.jsx(MO,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));RZe.displayName=MO.displayName;var oue="Collapsible",[r6t]=nd(oue),[n6t,eNe]=r6t(oue),FZe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,open:n,defaultOpen:a,disabled:o,onOpenChange:l,...i}=t,[c,u]=rh({prop:n,defaultProp:a??!1,onChange:l,caller:oue});return e.jsx(n6t,{scope:r,disabled:o,contentId:Mu(),open:c,onOpenToggle:k.useCallback(()=>u(p=>!p),[u]),children:e.jsx(sn.div,{"data-state":sNe(c),"data-disabled":o?"":void 0,...i,ref:s})})});FZe.displayName=oue;var zZe="CollapsibleTrigger",BZe=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,...n}=t,a=eNe(zZe,r);return e.jsx(sn.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":sNe(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...n,ref:s,onClick:Ir(t.onClick,a.onOpenToggle)})});BZe.displayName=zZe;var tNe="CollapsibleContent",$Ze=k.forwardRef((t,s)=>{const{forceMount:r,...n}=t,a=eNe(tNe,t.__scopeCollapsible);return e.jsx(Fd,{present:r||a.open,children:({present:o})=>e.jsx(a6t,{...n,ref:s,present:o})})});$Ze.displayName=tNe;var a6t=k.forwardRef((t,s)=>{const{__scopeCollapsible:r,present:n,children:a,...o}=t,l=eNe(tNe,r),[i,c]=k.useState(n),u=k.useRef(null),p=$a(s,u),f=k.useRef(0),g=f.current,b=k.useRef(0),_=b.current,j=l.open||i,w=k.useRef(j),N=k.useRef(void 0);return k.useEffect(()=>{const C=requestAnimationFrame(()=>w.current=!1);return()=>cancelAnimationFrame(C)},[]),wd(()=>{const C=u.current;if(C){N.current=N.current||{transitionDuration:C.style.transitionDuration,animationName:C.style.animationName},C.style.transitionDuration="0s",C.style.animationName="none";const M=C.getBoundingClientRect();f.current=M.height,b.current=M.width,w.current||(C.style.transitionDuration=N.current.transitionDuration,C.style.animationName=N.current.animationName),c(n)}},[l.open,n]),e.jsx(sn.div,{"data-state":sNe(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!j,...o,ref:p,style:{"--radix-collapsible-content-height":g?`${g}px`:void 0,"--radix-collapsible-content-width":_?`${_}px`:void 0,...t.style},children:j&&a})});function sNe(t){return t?"open":"closed"}var i6t=FZe;const gf=i6t,yf=BZe,vf=$Ze,o6t="/assets/levelup-logo-Eif24dqY.png",l6t="/assets/levelup-logo-icon-C-7iromj.png",c6t="/assets/levelup-logo-mobile-B9skSjUG.png";var OO=t=>t.type==="checkbox",y4=t=>t instanceof Date,_m=t=>t==null;const qZe=t=>typeof t=="object";var Rd=t=>!_m(t)&&!Array.isArray(t)&&qZe(t)&&!y4(t),UZe=t=>Rd(t)&&t.target?OO(t.target)?t.target.checked:t.target.value:t,d6t=t=>t.substring(0,t.search(/\.\d+(\.|$)/))||t,VZe=(t,s)=>t.has(d6t(s)),u6t=t=>{const s=t.constructor&&t.constructor.prototype;return Rd(s)&&s.hasOwnProperty("isPrototypeOf")},rNe=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function mu(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(!(rNe&&(t instanceof Blob||n))&&(r||Rd(t)))if(s=r?[]:{},!r&&!u6t(t))s=t;else for(const a in t)t.hasOwnProperty(a)&&(s[a]=mu(t[a]));else return t;return s}var lue=t=>/^\w*$/.test(t),Ad=t=>t===void 0,nNe=t=>Array.isArray(t)?t.filter(Boolean):[],aNe=t=>nNe(t.replace(/["|']|\]/g,"").split(/\.|\[/)),kn=(t,s,r)=>{if(!s||!Rd(t))return r;const n=(lue(s)?[s]:aNe(s)).reduce((a,o)=>_m(a)?a:a[o],t);return Ad(n)||n===t?Ad(t[s])?r:t[s]:n},sf=t=>typeof t=="boolean",hl=(t,s,r)=>{let n=-1;const a=lue(s)?[s]:aNe(s),o=a.length,l=o-1;for(;++nht.useContext(iNe),h6t=t=>{const{children:s,...r}=t;return ht.createElement(iNe.Provider,{value:r},s)};var HZe=(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]!==Bg.all&&(s._proxyFormState[l]=!n||Bg.all),r&&(r[l]=!0),t[l]}});return a};const oNe=typeof window<"u"?ht.useLayoutEffect:ht.useEffect;function m6t(t){const s=cue(),{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 oNe(()=>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(()=>HZe(l,r,c.current,!1),[l,r])}var a0=t=>typeof t=="string",WZe=(t,s,r,n,a)=>a0(t)?(n&&s.watch.add(t),kn(r,t,a)):Array.isArray(t)?t.map(o=>(n&&s.watch.add(o),kn(r,o))):(n&&(s.watchAll=!0),r),c1e=t=>_m(t)||!qZe(t);function qv(t,s,r=new WeakSet){if(c1e(t)||c1e(s))return t===s;if(y4(t)&&y4(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(y4(l)&&y4(i)||Rd(l)&&Rd(i)||Array.isArray(l)&&Array.isArray(i)?!qv(l,i,r):l!==i)return!1}}return!0}function p6t(t){const s=cue(),{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,b]=ht.useState(u.current?u.current(f):f);return oNe(()=>r._subscribe({name:n,formState:{values:!0},exact:l,callback:_=>{if(!o){const j=WZe(n,r._names,_.values||r._formValues,!1,c.current);if(u.current){const w=u.current(j);qv(w,p.current)||(b(w),p.current=w)}else b(j)}}}),[r,o,n,l]),ht.useEffect(()=>r._removeUnmounted()),g}function f6t(t){const s=cue(),{name:r,disabled:n,control:a=s.control,shouldUnregister:o,defaultValue:l}=t,i=VZe(a._names.array,r),c=ht.useMemo(()=>kn(a._formValues,r,kn(a._defaultValues,r,l)),[a,r,l]),u=p6t({control:a,name:r,defaultValue:c,exact:!0}),p=m6t({control:a,name:r,exact:!0}),f=ht.useRef(t),g=ht.useRef(a.register(r,{...t.rules,value:u,...sf(t.disabled)?{disabled:t.disabled}:{}}));f.current=t;const b=ht.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!kn(p.errors,r)},isDirty:{enumerable:!0,get:()=>!!kn(p.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!kn(p.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!kn(p.validatingFields,r)},error:{enumerable:!0,get:()=>kn(p.errors,r)}}),[p,r]),_=ht.useCallback(C=>g.current.onChange({target:{value:UZe(C),name:r},type:Boe.CHANGE}),[r]),j=ht.useCallback(()=>g.current.onBlur({target:{value:kn(a._formValues,r),name:r},type:Boe.BLUR}),[r,a._formValues]),w=ht.useCallback(C=>{const M=kn(a._fields,r);M&&C&&(M._f.ref={focus:()=>C.focus&&C.focus(),select:()=>C.select&&C.select(),setCustomValidity:I=>C.setCustomValidity(I),reportValidity:()=>C.reportValidity()})},[a._fields,r]),N=ht.useMemo(()=>({name:r,value:u,...sf(n)||p.disabled?{disabled:p.disabled||n}:{},onChange:_,onBlur:j,ref:w}),[r,n,p.disabled,_,j,w,u]);return ht.useEffect(()=>{const C=a._options.shouldUnregister||o;a.register(r,{...f.current.rules,...sf(f.current.disabled)?{disabled:f.current.disabled}:{}});const M=(I,L)=>{const R=kn(a._fields,I);R&&R._f&&(R._f.mount=L)};if(M(r,!0),C){const I=mu(kn(a._options.defaultValues,r));hl(a._defaultValues,r,I),Ad(kn(a._formValues,r))&&hl(a._formValues,r,I)}return!i&&a.register(r),()=>{(i?C&&!a._state.action:C)?a.unregister(r):M(r,!1)}},[r,a,i,o]),ht.useEffect(()=>{a._setDisabledField({disabled:n,name:r})},[n,r,a]),ht.useMemo(()=>({field:N,formState:p,fieldState:b}),[N,p,b])}const x6t=t=>t.render(f6t(t));var GZe=(t,s,r,n,a)=>s?{...r[t],types:{...r[t]&&r[t].types?r[t].types:{},[n]:a||!0}}:{},KL=t=>Array.isArray(t)?t:[t],HPe=()=>{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=[]}}},cp=t=>Rd(t)&&!Object.keys(t).length,lNe=t=>t.type==="file",$g=t=>typeof t=="function",$oe=t=>{if(!rNe)return!1;const s=t?t.ownerDocument:0;return t instanceof(s&&s.defaultView?s.defaultView.HTMLElement:HTMLElement)},KZe=t=>t.type==="select-multiple",cNe=t=>t.type==="radio",g6t=t=>cNe(t)||OO(t),$xe=t=>$oe(t)&&t.isConnected;function y6t(t,s){const r=s.slice(0,-1).length;let n=0;for(;n{for(const s in t)if($g(t[s]))return!0;return!1};function qoe(t,s={}){const r=Array.isArray(t);if(Rd(t)||r)for(const n in t)Array.isArray(t[n])||Rd(t[n])&&!ZZe(t[n])?(s[n]=Array.isArray(t[n])?[]:{},qoe(t[n],s[n])):_m(t[n])||(s[n]=!0);return s}function YZe(t,s,r){const n=Array.isArray(t);if(Rd(t)||n)for(const a in t)Array.isArray(t[a])||Rd(t[a])&&!ZZe(t[a])?Ad(s)||c1e(r[a])?r[a]=Array.isArray(t[a])?qoe(t[a],[]):{...qoe(t[a])}:YZe(t[a],_m(s)?{}:s[a],r[a]):r[a]=!qv(t[a],s[a]);return r}var VP=(t,s)=>YZe(t,s,qoe(s));const WPe={value:!1,isValid:!1},GPe={value:!0,isValid:!0};var XZe=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&&!Ad(t[0].attributes.value)?Ad(t[0].value)||t[0].value===""?GPe:{value:t[0].value,isValid:!0}:GPe:WPe}return WPe},QZe=(t,{valueAsNumber:s,valueAsDate:r,setValueAs:n})=>Ad(t)?t:s?t===""?NaN:t&&+t:r&&a0(t)?new Date(t):n?n(t):t;const KPe={isValid:!1,value:null};var JZe=t=>Array.isArray(t)?t.reduce((s,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:s,KPe):KPe;function ZPe(t){const s=t.ref;return lNe(s)?s.files:cNe(s)?JZe(t.refs).value:KZe(s)?[...s.selectedOptions].map(({value:r})=>r):OO(s)?XZe(t.refs).value:QZe(Ad(s.value)?t.ref.value:s.value,t)}var b6t=(t,s,r,n)=>{const a={};for(const o of t){const l=kn(s,o);l&&hl(a,o,l._f)}return{criteriaMode:r,names:[...t],fields:a,shouldUseNativeValidation:n}},Uoe=t=>t instanceof RegExp,HP=t=>Ad(t)?t:Uoe(t)?t.source:Rd(t)?Uoe(t.value)?t.value.source:t.value:t,YPe=t=>({isOnSubmit:!t||t===Bg.onSubmit,isOnBlur:t===Bg.onBlur,isOnChange:t===Bg.onChange,isOnAll:t===Bg.all,isOnTouch:t===Bg.onTouched});const XPe="AsyncFunction";var _6t=t=>!!t&&!!t.validate&&!!($g(t.validate)&&t.validate.constructor.name===XPe||Rd(t.validate)&&Object.values(t.validate).find(s=>s.constructor.name===XPe)),w6t=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate),QPe=(t,s,r)=>!r&&(s.watchAll||s.watch.has(t)||[...s.watch].some(n=>t.startsWith(n)&&/^\.\w+/.test(t.slice(n.length))));const ZL=(t,s,r,n)=>{for(const a of r||Object.keys(t)){const o=kn(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(ZL(i,s))break}else if(Rd(i)&&ZL(i,s))break}}};function JPe(t,s,r){const n=kn(t,r);if(n||lue(r))return{error:n,name:r};const a=r.split(".");for(;a.length;){const o=a.join("."),l=kn(s,o),i=kn(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 j6t=(t,s,r,n)=>{r(t);const{name:a,...o}=t;return cp(o)||Object.keys(o).length>=Object.keys(s).length||Object.keys(o).find(l=>s[l]===(!n||Bg.all))},N6t=(t,s,r)=>!t||!s||t===s||KL(t).some(n=>n&&(r?n===s:n.startsWith(s)||s.startsWith(n))),k6t=(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,S6t=(t,s)=>!nNe(kn(t,s)).length&&Wd(t,s),C6t=(t,s,r)=>{const n=KL(kn(t,r));return hl(n,"root",s[r]),hl(t,r,n),t},vie=t=>a0(t);function eIe(t,s,r="validate"){if(vie(t)||Array.isArray(t)&&t.every(vie)||sf(t)&&!t)return{type:r,message:vie(t)?t:"",ref:s}}var x5=t=>Rd(t)&&!Uoe(t)?t:{value:t,message:""},tIe=async(t,s,r,n,a,o)=>{const{ref:l,refs:i,required:c,maxLength:u,minLength:p,min:f,max:g,pattern:b,validate:_,name:j,valueAsNumber:w,mount:N}=t._f,C=kn(r,j);if(!N||s.has(j))return{};const M=i?i[0]:l,I=J=>{a&&M.reportValidity&&(M.setCustomValidity(sf(J)?"":J||""),M.reportValidity())},L={},R=cNe(l),q=OO(l),U=R||q,B=(w||lNe(l))&&Ad(l.value)&&Ad(C)||$oe(l)&&l.value===""||C===""||Array.isArray(C)&&!C.length,V=GZe.bind(null,j,n,L),Y=(J,te,X,ce=vv.maxLength,ne=vv.minLength)=>{const re=J?te:X;L[j]={type:J?ce:ne,message:re,ref:l,...V(J?ce:ne,re)}};if(o?!Array.isArray(C)||!C.length:c&&(!U&&(B||_m(C))||sf(C)&&!C||q&&!XZe(i).isValid||R&&!JZe(i).isValid)){const{value:J,message:te}=vie(c)?{value:!!c,message:c}:x5(c);if(J&&(L[j]={type:vv.required,message:te,ref:M,...V(vv.required,te)},!n))return I(te),L}if(!B&&(!_m(f)||!_m(g))){let J,te;const X=x5(g),ce=x5(f);if(!_m(C)&&!isNaN(C)){const ne=l.valueAsNumber||C&&+C;_m(X.value)||(J=ne>X.value),_m(ce.value)||(te=nenew Date(new Date().toDateString()+" "+xe),le=l.type=="time",pe=l.type=="week";a0(X.value)&&C&&(J=le?re(C)>re(X.value):pe?C>X.value:ne>new Date(X.value)),a0(ce.value)&&C&&(te=le?re(C)+J.value,ce=!_m(te.value)&&C.length<+te.value;if((X||ce)&&(Y(X,J.message,te.message),!n))return I(L[j].message),L}if(b&&!B&&a0(C)){const{value:J,message:te}=x5(b);if(Uoe(J)&&!C.match(J)&&(L[j]={type:vv.pattern,message:te,ref:l,...V(vv.pattern,te)},!n))return I(te),L}if(_){if($g(_)){const J=await _(C,r),te=eIe(J,M);if(te&&(L[j]={...te,...V(vv.validate,te.message)},!n))return I(te.message),L}else if(Rd(_)){let J={};for(const te in _){if(!cp(J)&&!n)break;const X=eIe(await _[te](C,r),M,te);X&&(J={...X,...V(te,X.message)},I(X.message),n&&(L[j]=J))}if(!cp(J)&&(L[j]={ref:M,...J},!n))return L}}return I(!0),L};const M6t={mode:Bg.onSubmit,reValidateMode:Bg.onChange,shouldFocusError:!0};function T6t(t={}){let s={...M6t,...t},r={submitCount:0,isDirty:!1,isReady:!1,isLoading:$g(s.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{},errors:s.errors||{},disabled:s.disabled||!1},n={},a=Rd(s.defaultValues)||Rd(s.values)?mu(s.defaultValues||s.values)||{}:{},o=s.shouldUnregister?{}:mu(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:HPe(),state:HPe()},b=s.criteriaMode===Bg.all,_=Ge=>lt=>{clearTimeout(u),u=setTimeout(Ge,lt)},j=async Ge=>{if(!s.disabled&&(p.isValid||f.isValid||Ge)){const lt=s.resolver?cp((await q()).errors):await B(n,!0);lt!==r.isValid&&g.state.next({isValid:lt})}},w=(Ge,lt)=>{!s.disabled&&(p.isValidating||p.validatingFields||f.isValidating||f.validatingFields)&&((Ge||Array.from(i.mount)).forEach(qe=>{qe&&(lt?hl(r.validatingFields,qe,lt):Wd(r.validatingFields,qe))}),g.state.next({validatingFields:r.validatingFields,isValidating:!cp(r.validatingFields)}))},N=(Ge,lt=[],qe,Ze,Je=!0,He=!0)=>{if(Ze&&qe&&!s.disabled){if(l.action=!0,He&&Array.isArray(kn(n,Ge))){const Qe=qe(kn(n,Ge),Ze.argA,Ze.argB);Je&&hl(n,Ge,Qe)}if(He&&Array.isArray(kn(r.errors,Ge))){const Qe=qe(kn(r.errors,Ge),Ze.argA,Ze.argB);Je&&hl(r.errors,Ge,Qe),S6t(r.errors,Ge)}if((p.touchedFields||f.touchedFields)&&He&&Array.isArray(kn(r.touchedFields,Ge))){const Qe=qe(kn(r.touchedFields,Ge),Ze.argA,Ze.argB);Je&&hl(r.touchedFields,Ge,Qe)}(p.dirtyFields||f.dirtyFields)&&(r.dirtyFields=VP(a,o)),g.state.next({name:Ge,isDirty:Y(Ge,lt),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else hl(o,Ge,lt)},C=(Ge,lt)=>{hl(r.errors,Ge,lt),g.state.next({errors:r.errors})},M=Ge=>{r.errors=Ge,g.state.next({errors:r.errors,isValid:!1})},I=(Ge,lt,qe,Ze)=>{const Je=kn(n,Ge);if(Je){const He=kn(o,Ge,Ad(qe)?kn(a,Ge):qe);Ad(He)||Ze&&Ze.defaultChecked||lt?hl(o,Ge,lt?He:ZPe(Je._f)):X(Ge,He),l.mount&&j()}},L=(Ge,lt,qe,Ze,Je)=>{let He=!1,Qe=!1;const at={name:Ge};if(!s.disabled){if(!qe||Ze){(p.isDirty||f.isDirty)&&(Qe=r.isDirty,r.isDirty=at.isDirty=Y(),He=Qe!==at.isDirty);const It=qv(kn(a,Ge),lt);Qe=!!kn(r.dirtyFields,Ge),It?Wd(r.dirtyFields,Ge):hl(r.dirtyFields,Ge,!0),at.dirtyFields=r.dirtyFields,He=He||(p.dirtyFields||f.dirtyFields)&&Qe!==!It}if(qe){const It=kn(r.touchedFields,Ge);It||(hl(r.touchedFields,Ge,qe),at.touchedFields=r.touchedFields,He=He||(p.touchedFields||f.touchedFields)&&It!==qe)}He&&Je&&g.state.next(at)}return He?at:{}},R=(Ge,lt,qe,Ze)=>{const Je=kn(r.errors,Ge),He=(p.isValid||f.isValid)&&sf(lt)&&r.isValid!==lt;if(s.delayError&&qe?(c=_(()=>C(Ge,qe)),c(s.delayError)):(clearTimeout(u),c=null,qe?hl(r.errors,Ge,qe):Wd(r.errors,Ge)),(qe?!qv(Je,qe):Je)||!cp(Ze)||He){const Qe={...Ze,...He&&sf(lt)?{isValid:lt}:{},errors:r.errors,name:Ge};r={...r,...Qe},g.state.next(Qe)}},q=async Ge=>{w(Ge,!0);const lt=await s.resolver(o,s.context,b6t(Ge||i.mount,n,s.criteriaMode,s.shouldUseNativeValidation));return w(Ge),lt},U=async Ge=>{const{errors:lt}=await q(Ge);if(Ge)for(const qe of Ge){const Ze=kn(lt,qe);Ze?hl(r.errors,qe,Ze):Wd(r.errors,qe)}else r.errors=lt;return lt},B=async(Ge,lt,qe={valid:!0})=>{for(const Ze in Ge){const Je=Ge[Ze];if(Je){const{_f:He,...Qe}=Je;if(He){const at=i.array.has(He.name),It=Je._f&&_6t(Je._f);It&&p.validatingFields&&w([Ze],!0);const Ut=await tIe(Je,i.disabled,o,b,s.shouldUseNativeValidation&&!lt,at);if(It&&p.validatingFields&&w([Ze]),Ut[He.name]&&(qe.valid=!1,lt))break;!lt&&(kn(Ut,He.name)?at?C6t(r.errors,Ut,He.name):hl(r.errors,He.name,Ut[He.name]):Wd(r.errors,He.name))}!cp(Qe)&&await B(Qe,lt,qe)}}return qe.valid},V=()=>{for(const Ge of i.unMount){const lt=kn(n,Ge);lt&&(lt._f.refs?lt._f.refs.every(qe=>!$xe(qe)):!$xe(lt._f.ref))&&Fe(Ge)}i.unMount=new Set},Y=(Ge,lt)=>!s.disabled&&(Ge&<&&hl(o,Ge,lt),!qv(xe(),a)),J=(Ge,lt,qe)=>WZe(Ge,i,{...l.mount?o:Ad(lt)?a:a0(Ge)?{[Ge]:lt}:lt},qe,lt),te=Ge=>nNe(kn(l.mount?o:a,Ge,s.shouldUnregister?kn(a,Ge,[]):[])),X=(Ge,lt,qe={})=>{const Ze=kn(n,Ge);let Je=lt;if(Ze){const He=Ze._f;He&&(!He.disabled&&hl(o,Ge,QZe(lt,He)),Je=$oe(He.ref)&&_m(lt)?"":lt,KZe(He.ref)?[...He.ref.options].forEach(Qe=>Qe.selected=Je.includes(Qe.value)):He.refs?OO(He.ref)?He.refs.forEach(Qe=>{(!Qe.defaultChecked||!Qe.disabled)&&(Array.isArray(Je)?Qe.checked=!!Je.find(at=>at===Qe.value):Qe.checked=Je===Qe.value||!!Je)}):He.refs.forEach(Qe=>Qe.checked=Qe.value===Je):lNe(He.ref)?He.ref.value="":(He.ref.value=Je,He.ref.type||g.state.next({name:Ge,values:mu(o)})))}(qe.shouldDirty||qe.shouldTouch)&&L(Ge,Je,qe.shouldTouch,qe.shouldDirty,!0),qe.shouldValidate&&pe(Ge)},ce=(Ge,lt,qe)=>{for(const Ze in lt){if(!lt.hasOwnProperty(Ze))return;const Je=lt[Ze],He=Ge+"."+Ze,Qe=kn(n,He);(i.array.has(Ge)||Rd(Je)||Qe&&!Qe._f)&&!y4(Je)?ce(He,Je,qe):X(He,Je,qe)}},ne=(Ge,lt,qe={})=>{const Ze=kn(n,Ge),Je=i.array.has(Ge),He=mu(lt);hl(o,Ge,He),Je?(g.array.next({name:Ge,values:mu(o)}),(p.isDirty||p.dirtyFields||f.isDirty||f.dirtyFields)&&qe.shouldDirty&&g.state.next({name:Ge,dirtyFields:VP(a,o),isDirty:Y(Ge,He)})):Ze&&!Ze._f&&!_m(He)?ce(Ge,He,qe):X(Ge,He,qe),QPe(Ge,i)&&g.state.next({...r,name:Ge}),g.state.next({name:l.mount?Ge:void 0,values:mu(o)})},re=async Ge=>{l.mount=!0;const lt=Ge.target;let qe=lt.name,Ze=!0;const Je=kn(n,qe),He=It=>{Ze=Number.isNaN(It)||y4(It)&&isNaN(It.getTime())||qv(It,kn(o,qe,It))},Qe=YPe(s.mode),at=YPe(s.reValidateMode);if(Je){let It,Ut;const hs=lt.type?ZPe(Je._f):UZe(Ge),Yt=Ge.type===Boe.BLUR||Ge.type===Boe.FOCUS_OUT,ts=!w6t(Je._f)&&!s.resolver&&!kn(r.errors,qe)&&!Je._f.deps||k6t(Yt,kn(r.touchedFields,qe),r.isSubmitted,at,Qe),Ds=QPe(qe,i,Yt);hl(o,qe,hs),Yt?(Je._f.onBlur&&Je._f.onBlur(Ge),c&&c(0)):Je._f.onChange&&Je._f.onChange(Ge);const vr=L(qe,hs,Yt),Ct=!cp(vr)||Ds;if(!Yt&&g.state.next({name:qe,type:Ge.type,values:mu(o)}),ts)return(p.isValid||f.isValid)&&(s.mode==="onBlur"?Yt&&j():Yt||j()),Ct&&g.state.next({name:qe,...Ds?{}:vr});if(!Yt&&Ds&&g.state.next({...r}),s.resolver){const{errors:As}=await q([qe]);if(He(hs),Ze){const Us=JPe(r.errors,n,qe),kr=JPe(As,n,Us.name||qe);It=kr.error,qe=kr.name,Ut=cp(As)}}else w([qe],!0),It=(await tIe(Je,i.disabled,o,b,s.shouldUseNativeValidation))[qe],w([qe]),He(hs),Ze&&(It?Ut=!1:(p.isValid||f.isValid)&&(Ut=await B(n,!0)));Ze&&(Je._f.deps&&pe(Je._f.deps),R(qe,Ut,It,vr))}},le=(Ge,lt)=>{if(kn(r.errors,lt)&&Ge.focus)return Ge.focus(),1},pe=async(Ge,lt={})=>{let qe,Ze;const Je=KL(Ge);if(s.resolver){const He=await U(Ad(Ge)?Ge:Je);qe=cp(He),Ze=Ge?!Je.some(Qe=>kn(He,Qe)):qe}else Ge?(Ze=(await Promise.all(Je.map(async He=>{const Qe=kn(n,He);return await B(Qe&&Qe._f?{[He]:Qe}:Qe)}))).every(Boolean),!(!Ze&&!r.isValid)&&j()):Ze=qe=await B(n);return g.state.next({...!a0(Ge)||(p.isValid||f.isValid)&&qe!==r.isValid?{}:{name:Ge},...s.resolver||!Ge?{isValid:qe}:{},errors:r.errors}),lt.shouldFocus&&!Ze&&ZL(n,le,Ge?Je:i.mount),Ze},xe=Ge=>{const lt={...l.mount?o:a};return Ad(Ge)?lt:a0(Ge)?kn(lt,Ge):Ge.map(qe=>kn(lt,qe))},_e=(Ge,lt)=>({invalid:!!kn((lt||r).errors,Ge),isDirty:!!kn((lt||r).dirtyFields,Ge),error:kn((lt||r).errors,Ge),isValidating:!!kn(r.validatingFields,Ge),isTouched:!!kn((lt||r).touchedFields,Ge)}),fe=Ge=>{Ge&&KL(Ge).forEach(lt=>Wd(r.errors,lt)),g.state.next({errors:Ge?r.errors:{}})},we=(Ge,lt,qe)=>{const Ze=(kn(n,Ge,{_f:{}})._f||{}).ref,Je=kn(r.errors,Ge)||{},{ref:He,message:Qe,type:at,...It}=Je;hl(r.errors,Ge,{...It,...lt,ref:Ze}),g.state.next({name:Ge,errors:r.errors,isValid:!1}),qe&&qe.shouldFocus&&Ze&&Ze.focus&&Ze.focus()},Ie=(Ge,lt)=>$g(Ge)?g.state.subscribe({next:qe=>"values"in qe&&Ge(J(void 0,lt),qe)}):J(Ge,lt,!0),Ne=Ge=>g.state.subscribe({next:lt=>{N6t(Ge.name,lt.name,Ge.exact)&&j6t(lt,Ge.formState||p,et,Ge.reRenderRoot)&&Ge.callback({values:{...o},...r,...lt,defaultValues:a})}}).unsubscribe,Ae=Ge=>(l.mount=!0,f={...f,...Ge.formState},Ne({...Ge,formState:f})),Fe=(Ge,lt={})=>{for(const qe of Ge?KL(Ge):i.mount)i.mount.delete(qe),i.array.delete(qe),lt.keepValue||(Wd(n,qe),Wd(o,qe)),!lt.keepError&&Wd(r.errors,qe),!lt.keepDirty&&Wd(r.dirtyFields,qe),!lt.keepTouched&&Wd(r.touchedFields,qe),!lt.keepIsValidating&&Wd(r.validatingFields,qe),!s.shouldUnregister&&!lt.keepDefaultValue&&Wd(a,qe);g.state.next({values:mu(o)}),g.state.next({...r,...lt.keepDirty?{isDirty:Y()}:{}}),!lt.keepIsValid&&j()},Ce=({disabled:Ge,name:lt})=>{(sf(Ge)&&l.mount||Ge||i.disabled.has(lt))&&(Ge?i.disabled.add(lt):i.disabled.delete(lt))},Me=(Ge,lt={})=>{let qe=kn(n,Ge);const Ze=sf(lt.disabled)||sf(s.disabled);return hl(n,Ge,{...qe||{},_f:{...qe&&qe._f?qe._f:{ref:{name:Ge}},name:Ge,mount:!0,...lt}}),i.mount.add(Ge),qe?Ce({disabled:sf(lt.disabled)?lt.disabled:s.disabled,name:Ge}):I(Ge,!0,lt.value),{...Ze?{disabled:lt.disabled||s.disabled}:{},...s.progressive?{required:!!lt.required,min:HP(lt.min),max:HP(lt.max),minLength:HP(lt.minLength),maxLength:HP(lt.maxLength),pattern:HP(lt.pattern)}:{},name:Ge,onChange:re,onBlur:re,ref:Je=>{if(Je){Me(Ge,lt),qe=kn(n,Ge);const He=Ad(Je.value)&&Je.querySelectorAll&&Je.querySelectorAll("input,select,textarea")[0]||Je,Qe=g6t(He),at=qe._f.refs||[];if(Qe?at.find(It=>It===He):He===qe._f.ref)return;hl(n,Ge,{_f:{...qe._f,...Qe?{refs:[...at.filter($xe),He,...Array.isArray(kn(a,Ge))?[{}]:[]],ref:{type:He.type,name:Ge}}:{ref:He}}}),I(Ge,!1,void 0,He)}else qe=kn(n,Ge,{}),qe._f&&(qe._f.mount=!1),(s.shouldUnregister||lt.shouldUnregister)&&!(VZe(i.array,Ge)&&l.action)&&i.unMount.add(Ge)}}},$e=()=>s.shouldFocusError&&ZL(n,le,i.mount),ct=Ge=>{sf(Ge)&&(g.state.next({disabled:Ge}),ZL(n,(lt,qe)=>{const Ze=kn(n,qe);Ze&&(lt.disabled=Ze._f.disabled||Ge,Array.isArray(Ze._f.refs)&&Ze._f.refs.forEach(Je=>{Je.disabled=Ze._f.disabled||Ge}))},0,!1))},Te=(Ge,lt)=>async qe=>{let Ze;qe&&(qe.preventDefault&&qe.preventDefault(),qe.persist&&qe.persist());let Je=mu(o);if(g.state.next({isSubmitting:!0}),s.resolver){const{errors:He,values:Qe}=await q();r.errors=He,Je=mu(Qe)}else await B(n);if(i.disabled.size)for(const He of i.disabled)Wd(Je,He);if(Wd(r.errors,"root"),cp(r.errors)){g.state.next({errors:{}});try{await Ge(Je,qe)}catch(He){Ze=He}}else lt&&await lt({...r.errors},qe),$e(),setTimeout($e);if(g.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:cp(r.errors)&&!Ze,submitCount:r.submitCount+1,errors:r.errors}),Ze)throw Ze},ft=(Ge,lt={})=>{kn(n,Ge)&&(Ad(lt.defaultValue)?ne(Ge,mu(kn(a,Ge))):(ne(Ge,lt.defaultValue),hl(a,Ge,mu(lt.defaultValue))),lt.keepTouched||Wd(r.touchedFields,Ge),lt.keepDirty||(Wd(r.dirtyFields,Ge),r.isDirty=lt.defaultValue?Y(Ge,mu(kn(a,Ge))):Y()),lt.keepError||(Wd(r.errors,Ge),p.isValid&&j()),g.state.next({...r}))},me=(Ge,lt={})=>{const qe=Ge?mu(Ge):a,Ze=mu(qe),Je=cp(Ge),He=Je?a:Ze;if(lt.keepDefaultValues||(a=qe),!lt.keepValues){if(lt.keepDirtyValues){const Qe=new Set([...i.mount,...Object.keys(VP(a,o))]);for(const at of Array.from(Qe))kn(r.dirtyFields,at)?hl(He,at,kn(o,at)):ne(at,kn(He,at))}else{if(rNe&&Ad(Ge))for(const Qe of i.mount){const at=kn(n,Qe);if(at&&at._f){const It=Array.isArray(at._f.refs)?at._f.refs[0]:at._f.ref;if($oe(It)){const Ut=It.closest("form");if(Ut){Ut.reset();break}}}}if(lt.keepFieldsRef)for(const Qe of i.mount)ne(Qe,kn(He,Qe));else n={}}o=s.shouldUnregister?lt.keepDefaultValues?mu(a):{}:mu(He),g.array.next({values:{...He}}),g.state.next({values:{...He}})}i={mount:lt.keepDirtyValues?i.mount:new Set,unMount:new Set,array:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},l.mount=!p.isValid||!!lt.keepIsValid||!!lt.keepDirtyValues,l.watch=!!s.shouldUnregister,g.state.next({submitCount:lt.keepSubmitCount?r.submitCount:0,isDirty:Je?!1:lt.keepDirty?r.isDirty:!!(lt.keepDefaultValues&&!qv(Ge,a)),isSubmitted:lt.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:Je?{}:lt.keepDirtyValues?lt.keepDefaultValues&&o?VP(a,o):r.dirtyFields:lt.keepDefaultValues&&Ge?VP(a,Ge):lt.keepDirty?r.dirtyFields:{},touchedFields:lt.keepTouched?r.touchedFields:{},errors:lt.keepErrors?r.errors:{},isSubmitSuccessful:lt.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1})},Ve=(Ge,lt)=>me($g(Ge)?Ge(o):Ge,lt),nt=(Ge,lt={})=>{const qe=kn(n,Ge),Ze=qe&&qe._f;if(Ze){const Je=Ze.refs?Ze.refs[0]:Ze.ref;Je.focus&&(Je.focus(),lt.shouldSelect&&$g(Je.select)&&Je.select())}},et=Ge=>{r={...r,...Ge}},rt={control:{register:Me,unregister:Fe,getFieldState:_e,handleSubmit:Te,setError:we,_subscribe:Ne,_runSchema:q,_focusError:$e,_getWatch:J,_getDirty:Y,_setValid:j,_setFieldArray:N,_setDisabledField:Ce,_setErrors:M,_getFieldArray:te,_reset:me,_resetDefaultValues:()=>$g(s.defaultValues)&&s.defaultValues().then(Ge=>{Ve(Ge,s.resetOptions),g.state.next({isLoading:!1})}),_removeUnmounted:V,_disableForm:ct,_subjects:g,_proxyFormState:p,get _fields(){return n},get _formValues(){return o},get _state(){return l},set _state(Ge){l=Ge},get _defaultValues(){return a},get _names(){return i},set _names(Ge){i=Ge},get _formState(){return r},get _options(){return s},set _options(Ge){s={...s,...Ge}}},subscribe:Ae,trigger:pe,register:Me,handleSubmit:Te,watch:Ie,setValue:ne,getValues:xe,reset:Ve,resetField:ft,clearErrors:fe,unregister:Fe,setError:we,setFocus:nt,getFieldState:_e};return{...rt,formControl:rt}}function due(t={}){const s=ht.useRef(void 0),r=ht.useRef(void 0),[n,a]=ht.useState({isDirty:!1,isValidating:!1,isLoading:$g(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:$g(t.defaultValues)?void 0:t.defaultValues});if(!s.current)if(t.formControl)s.current={...t.formControl,formState:n},t.defaultValues&&!$g(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...i}=T6t(t);s.current={...i,formState:n}}const o=s.current.control;return o._options=t,oNe(()=>{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&&!qv(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=HZe(n,o),s.current}const sIe=(t,s,r)=>{if(t&&"reportValidity"in t){const n=kn(r,s);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},eYe=(t,s)=>{for(const r in s.fields){const n=s.fields[r];n&&n.ref&&"reportValidity"in n.ref?sIe(n.ref,r,t):n.refs&&n.refs.forEach(a=>sIe(a,r,t))}},A6t=(t,s)=>{s.shouldUseNativeValidation&&eYe(t,s);const r={};for(const n in t){const a=kn(s.fields,n),o=Object.assign(t[n]||{},{ref:a&&a.ref});if(E6t(s.names||Object.keys(t),n)){const l=Object.assign({},kn(r,n));hl(l,"root",o),hl(r,n,l)}else hl(r,n,o)}return r},E6t=(t,s)=>t.some(r=>r.startsWith(s+"."));var P6t=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]=GZe(l,s,r,a,u?[].concat(u,n.message):n.message)}t.shift()}return r},uue=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&&eYe({},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:A6t(P6t(l.errors,!o.shouldUseNativeValidation&&o.criteriaMode==="all"),o)};throw l}))}catch(l){return Promise.reject(l)}}};const hue=h6t,tYe=k.createContext({}),Wc=({...t})=>e.jsx(tYe.Provider,{value:{name:t.name},children:e.jsx(x6t,{...t})}),mue=()=>{const t=k.useContext(tYe),s=k.useContext(sYe),{getFieldState:r,formState:n}=cue(),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}},sYe=k.createContext({}),Ac=k.forwardRef(({className:t,...s},r)=>{const n=k.useId();return e.jsx(sYe.Provider,{value:{id:n},children:e.jsx("div",{ref:r,className:Pt("space-y-2",t),...s})})});Ac.displayName="FormItem";const Ec=k.forwardRef(({className:t,...s},r)=>{const{error:n,formItemId:a}=mue();return e.jsx(ye,{ref:r,className:Pt(n&&"text-destructive",t),htmlFor:a,...s})});Ec.displayName="FormLabel";const Pc=k.forwardRef(({...t},s)=>{const{error:r,formItemId:n,formDescriptionId:a,formMessageId:o}=mue();return e.jsx(o2e,{ref:s,id:n,"aria-describedby":r?`${a} ${o}`:`${a}`,"aria-invalid":!!r,...t})});Pc.displayName="FormControl";const bie=k.forwardRef(({className:t,...s},r)=>{const{formDescriptionId:n}=mue();return e.jsx("p",{ref:r,id:n,className:Pt("text-sm text-muted-foreground",t),...s})});bie.displayName="FormDescription";const km=k.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:Pt("text-sm font-medium text-destructive",t),...r,children:l}):null});km.displayName="FormMessage";const I6t=hC({category:AGe(["general","technology","crm","marketing"]),subject:pc().min(5,"Subject must be at least 5 characters").max(200),description:pc().min(20,"Please provide more details (at least 20 characters)").max(2e3)}),L6t={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function d1e({trigger:t}){const[s,r]=k.useState(!1),[n,a]=k.useState(!1),{user:o}=Rs(),l=due({resolver:uue(I6t),defaultValues:{category:"general",subject:"",description:""}}),i=async c=>{if(!o){he.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:L6t[c.category],subject:c.subject}})}catch(p){console.log("Notification send attempted:",p)}he.success("Support ticket submitted successfully!"),l.reset(),r(!1)}catch(u){console.error("Error submitting ticket:",u),he.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(uL,{className:"h-5 w-5"}),e.jsx("span",{className:"sr-only",children:"Support"})]})}),e.jsxs(fs,{className:"sm:max-w-[500px]",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(Un,{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(hue,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(i),className:"space-y-4",children:[e.jsx(Wc,{control:l.control,name:"category",render:({field:c})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Category"}),e.jsxs(Ys,{onValueChange:c.onChange,defaultValue:c.value,children:[e.jsx(Pc,{children:e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a category"})})}),e.jsxs(Ks,{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(km,{})]})}),e.jsx(Wc,{control:l.control,name:"subject",render:({field:c})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Subject"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"Brief description of your issue",...c})}),e.jsx(km,{})]})}),e.jsx(Wc,{control:l.control,name:"description",render:({field:c})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Description"}),e.jsx(Pc,{children:e.jsx(Er,{placeholder:"Please describe your issue in detail...",className:"min-h-[120px]",...c})}),e.jsx(km,{})]})}),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 D6t=()=>{const{user:t}=Rs(),s=pr(),[r,n]=k.useState([]),[a,o]=k.useState(0),[l,i]=k.useState(!1),[c,u]=k.useState(null);k.useEffect(()=>{if(!t)return;const _=`notification_last_read_${t.id}`;let j=c;if(!j){const C=localStorage.getItem(_);C&&(j=C,u(C))}(async()=>{const{data:C,error:M}=await H.from("push_notifications").select("*").order("created_at",{ascending:!1}).limit(20);if(!M&&C){n(C);const I=j?new Date(j):null,L=C.filter(R=>I?new Date(R.created_at)>I:!0);o(L.length)}})();const N=H.channel("push-notifications").on("postgres_changes",{event:"INSERT",schema:"public",table:"push_notifications"},C=>{const M=C.new;n(L=>[M,...L].slice(0,20));const I=j?new Date(j):null;(!I||new Date(M.created_at)>I)&&o(L=>L+1),Notification.permission==="granted"&&new Notification(M.title,{body:M.body,icon:"/favicon.ico"})}).subscribe();return()=>{H.removeChannel(N)}},[t,c]);const p=_=>{const j=_.toLowerCase();return j.includes("community")||j.includes("post")?io:j.includes("academy")||j.includes("video")?Cn:j.includes("template")?sc:j.includes("event")?cn:j.includes("newsletter")?i1:j.includes("brokerage")?Wh:j.includes("swag")||j.includes("social")?No:j.includes("toolbox")||j.includes("tool")?Jg:j.includes("brief")?un:io},f=_=>{i(!1),_.url&&_.url!=="/"&&s(_.url)},g=()=>{if(!t)return;const _=new Date().toISOString(),j=`notification_last_read_${t.id}`;localStorage.setItem(j,_),u(_),o(0)},b=_=>{i(_),_&&a>0&&g()};return e.jsxs(au,{open:l,onOpenChange:b,children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",children:[e.jsx(Pm,{className:"h-5 w-5"}),a>0&&e.jsx(tt,{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(zd,{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(Gi,{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 j=p(_.title);return e.jsxs(Ca,{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(j,{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:_d(new Date(_.created_at),{addSuffix:!0})})]})]},_.id)})})]})]})};var rIe=1,O6t=.9,R6t=.8,F6t=.17,qxe=.1,Uxe=.999,z6t=.9999,B6t=.99,$6t=/[\\\/_+.#"@\[\(\{&]/,q6t=/[\\\/_+.#"@\[\(\{&]/g,U6t=/[\s-]/,rYe=/[\s-]/g;function u1e(t,s,r,n,a,o,l){if(o===s.length)return a===t.length?rIe:B6t;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,b,_;u>=0;)f=u1e(t,s,r,n,u+1,o+1,l),f>p&&(u===a?f*=rIe:$6t.test(t.charAt(u-1))?(f*=R6t,b=t.slice(a,u-1).match(q6t),b&&a>0&&(f*=Math.pow(Uxe,b.length))):U6t.test(t.charAt(u-1))?(f*=O6t,_=t.slice(a,u-1).match(rYe),_&&a>0&&(f*=Math.pow(Uxe,_.length))):(f*=F6t,a>0&&(f*=Math.pow(Uxe,u-a))),t.charAt(u)!==s.charAt(o)&&(f*=z6t)),(ff&&(f=g*qxe)),f>p&&(p=f),u=r.indexOf(c,u+1);return l[i]=p,p}function nIe(t){return t.toLowerCase().replace(rYe," ")}function V6t(t,s,r){return t=r&&r.length>0?`${t+" "+r.join(" ")}`:t,u1e(t,s,nIe(t),nIe(s),0,0,{})}var WP='[cmdk-group=""]',Vxe='[cmdk-group-items=""]',H6t='[cmdk-group-heading=""]',nYe='[cmdk-item=""]',aIe=`${nYe}:not([aria-disabled="true"])`,h1e="cmdk-item-select",D5="data-value",W6t=(t,s,r)=>V6t(t,s,r),aYe=k.createContext(void 0),RO=()=>k.useContext(aYe),iYe=k.createContext(void 0),dNe=()=>k.useContext(iYe),oYe=k.createContext(void 0),lYe=k.forwardRef((t,s)=>{let r=O5(()=>{var fe,we;return{search:"",value:(we=(fe=t.value)!=null?fe:t.defaultValue)!=null?we:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=O5(()=>new Set),a=O5(()=>new Map),o=O5(()=>new Map),l=O5(()=>new Set),i=cYe(t),{label:c,children:u,value:p,onValueChange:f,filter:g,shouldFilter:b,loop:_,disablePointerSelection:j=!1,vimBindings:w=!0,...N}=t,C=Mu(),M=Mu(),I=Mu(),L=k.useRef(null),R=rPt();BS(()=>{if(p!==void 0){let fe=p.trim();r.current.value=fe,q.emit()}},[p]),BS(()=>{R(6,te)},[]);let q=k.useMemo(()=>({subscribe:fe=>(l.current.add(fe),()=>l.current.delete(fe)),snapshot:()=>r.current,setState:(fe,we,Ie)=>{var Ne,Ae,Fe,Ce;if(!Object.is(r.current[fe],we)){if(r.current[fe]=we,fe==="search")J(),V(),R(1,Y);else if(fe==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let Me=document.getElementById(I);Me?Me.focus():(Ne=document.getElementById(C))==null||Ne.focus()}if(R(7,()=>{var Me;r.current.selectedItemId=(Me=X())==null?void 0:Me.id,q.emit()}),Ie||R(5,te),((Ae=i.current)==null?void 0:Ae.value)!==void 0){let Me=we??"";(Ce=(Fe=i.current).onValueChange)==null||Ce.call(Fe,Me);return}}q.emit()}},emit:()=>{l.current.forEach(fe=>fe())}}),[]),U=k.useMemo(()=>({value:(fe,we,Ie)=>{var Ne;we!==((Ne=o.current.get(fe))==null?void 0:Ne.value)&&(o.current.set(fe,{value:we,keywords:Ie}),r.current.filtered.items.set(fe,B(we,Ie)),R(2,()=>{V(),q.emit()}))},item:(fe,we)=>(n.current.add(fe),we&&(a.current.has(we)?a.current.get(we).add(fe):a.current.set(we,new Set([fe]))),R(3,()=>{J(),V(),r.current.value||Y(),q.emit()}),()=>{o.current.delete(fe),n.current.delete(fe),r.current.filtered.items.delete(fe);let Ie=X();R(4,()=>{J(),(Ie==null?void 0:Ie.getAttribute("id"))===fe&&Y(),q.emit()})}),group:fe=>(a.current.has(fe)||a.current.set(fe,new Set),()=>{o.current.delete(fe),a.current.delete(fe)}),filter:()=>i.current.shouldFilter,label:c||t["aria-label"],getDisablePointerSelection:()=>i.current.disablePointerSelection,listId:C,inputId:I,labelId:M,listInnerRef:L}),[]);function B(fe,we){var Ie,Ne;let Ae=(Ne=(Ie=i.current)==null?void 0:Ie.filter)!=null?Ne:W6t;return fe?Ae(fe,r.current.search,we):0}function V(){if(!r.current.search||i.current.shouldFilter===!1)return;let fe=r.current.filtered.items,we=[];r.current.filtered.groups.forEach(Ne=>{let Ae=a.current.get(Ne),Fe=0;Ae.forEach(Ce=>{let Me=fe.get(Ce);Fe=Math.max(Me,Fe)}),we.push([Ne,Fe])});let Ie=L.current;ce().sort((Ne,Ae)=>{var Fe,Ce;let Me=Ne.getAttribute("id"),$e=Ae.getAttribute("id");return((Fe=fe.get($e))!=null?Fe:0)-((Ce=fe.get(Me))!=null?Ce:0)}).forEach(Ne=>{let Ae=Ne.closest(Vxe);Ae?Ae.appendChild(Ne.parentElement===Ae?Ne:Ne.closest(`${Vxe} > *`)):Ie.appendChild(Ne.parentElement===Ie?Ne:Ne.closest(`${Vxe} > *`))}),we.sort((Ne,Ae)=>Ae[1]-Ne[1]).forEach(Ne=>{var Ae;let Fe=(Ae=L.current)==null?void 0:Ae.querySelector(`${WP}[${D5}="${encodeURIComponent(Ne[0])}"]`);Fe==null||Fe.parentElement.appendChild(Fe)})}function Y(){let fe=ce().find(Ie=>Ie.getAttribute("aria-disabled")!=="true"),we=fe==null?void 0:fe.getAttribute(D5);q.setState("value",we||void 0)}function J(){var fe,we,Ie,Ne;if(!r.current.search||i.current.shouldFilter===!1){r.current.filtered.count=n.current.size;return}r.current.filtered.groups=new Set;let Ae=0;for(let Fe of n.current){let Ce=(we=(fe=o.current.get(Fe))==null?void 0:fe.value)!=null?we:"",Me=(Ne=(Ie=o.current.get(Fe))==null?void 0:Ie.keywords)!=null?Ne:[],$e=B(Ce,Me);r.current.filtered.items.set(Fe,$e),$e>0&&Ae++}for(let[Fe,Ce]of a.current)for(let Me of Ce)if(r.current.filtered.items.get(Me)>0){r.current.filtered.groups.add(Fe);break}r.current.filtered.count=Ae}function te(){var fe,we,Ie;let Ne=X();Ne&&(((fe=Ne.parentElement)==null?void 0:fe.firstChild)===Ne&&((Ie=(we=Ne.closest(WP))==null?void 0:we.querySelector(H6t))==null||Ie.scrollIntoView({block:"nearest"})),Ne.scrollIntoView({block:"nearest"}))}function X(){var fe;return(fe=L.current)==null?void 0:fe.querySelector(`${nYe}[aria-selected="true"]`)}function ce(){var fe;return Array.from(((fe=L.current)==null?void 0:fe.querySelectorAll(aIe))||[])}function ne(fe){let we=ce()[fe];we&&q.setState("value",we.getAttribute(D5))}function re(fe){var we;let Ie=X(),Ne=ce(),Ae=Ne.findIndex(Ce=>Ce===Ie),Fe=Ne[Ae+fe];(we=i.current)!=null&&we.loop&&(Fe=Ae+fe<0?Ne[Ne.length-1]:Ae+fe===Ne.length?Ne[0]:Ne[Ae+fe]),Fe&&q.setState("value",Fe.getAttribute(D5))}function le(fe){let we=X(),Ie=we==null?void 0:we.closest(WP),Ne;for(;Ie&&!Ne;)Ie=fe>0?tPt(Ie,WP):sPt(Ie,WP),Ne=Ie==null?void 0:Ie.querySelector(aIe);Ne?q.setState("value",Ne.getAttribute(D5)):re(fe)}let pe=()=>ne(ce().length-1),xe=fe=>{fe.preventDefault(),fe.metaKey?pe():fe.altKey?le(1):re(1)},_e=fe=>{fe.preventDefault(),fe.metaKey?ne(0):fe.altKey?le(-1):re(-1)};return k.createElement(sn.div,{ref:s,tabIndex:-1,...N,"cmdk-root":"",onKeyDown:fe=>{var we;(we=N.onKeyDown)==null||we.call(N,fe);let Ie=fe.nativeEvent.isComposing||fe.keyCode===229;if(!(fe.defaultPrevented||Ie))switch(fe.key){case"n":case"j":{w&&fe.ctrlKey&&xe(fe);break}case"ArrowDown":{xe(fe);break}case"p":case"k":{w&&fe.ctrlKey&&_e(fe);break}case"ArrowUp":{_e(fe);break}case"Home":{fe.preventDefault(),ne(0);break}case"End":{fe.preventDefault(),pe();break}case"Enter":{fe.preventDefault();let Ne=X();if(Ne){let Ae=new Event(h1e);Ne.dispatchEvent(Ae)}}}}},k.createElement("label",{"cmdk-label":"",htmlFor:U.inputId,id:U.labelId,style:aPt},c),pue(t,fe=>k.createElement(iYe.Provider,{value:q},k.createElement(aYe.Provider,{value:U},fe))))}),G6t=k.forwardRef((t,s)=>{var r,n;let a=Mu(),o=k.useRef(null),l=k.useContext(oYe),i=RO(),c=cYe(t),u=(n=(r=c.current)==null?void 0:r.forceMount)!=null?n:l==null?void 0:l.forceMount;BS(()=>{if(!u)return i.item(a,l==null?void 0:l.id)},[u]);let p=dYe(a,o,[t.value,t.children,o],t.keywords),f=dNe(),g=pw(R=>R.value&&R.value===p.current),b=pw(R=>u||i.filter()===!1?!0:R.search?R.filtered.items.get(a)>0:!0);k.useEffect(()=>{let R=o.current;if(!(!R||t.disabled))return R.addEventListener(h1e,_),()=>R.removeEventListener(h1e,_)},[b,t.onSelect,t.disabled]);function _(){var R,q;j(),(q=(R=c.current).onSelect)==null||q.call(R,p.current)}function j(){f.setState("value",p.current,!0)}if(!b)return null;let{disabled:w,value:N,onSelect:C,forceMount:M,keywords:I,...L}=t;return k.createElement(sn.div,{ref:k1(o,s),...L,id:a,"cmdk-item":"",role:"option","aria-disabled":!!w,"aria-selected":!!g,"data-disabled":!!w,"data-selected":!!g,onPointerMove:w||i.getDisablePointerSelection()?void 0:j,onClick:w?void 0:_},t.children)}),K6t=k.forwardRef((t,s)=>{let{heading:r,children:n,forceMount:a,...o}=t,l=Mu(),i=k.useRef(null),c=k.useRef(null),u=Mu(),p=RO(),f=pw(b=>a||p.filter()===!1?!0:b.search?b.filtered.groups.has(l):!0);BS(()=>p.group(l),[]),dYe(l,i,[t.value,t.heading,c]);let g=k.useMemo(()=>({id:l,forceMount:a}),[a]);return k.createElement(sn.div,{ref:k1(i,s),...o,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},r&&k.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:u},r),pue(t,b=>k.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":r?u:void 0},k.createElement(oYe.Provider,{value:g},b))))}),Z6t=k.forwardRef((t,s)=>{let{alwaysRender:r,...n}=t,a=k.useRef(null),o=pw(l=>!l.search);return!r&&!o?null:k.createElement(sn.div,{ref:k1(a,s),...n,"cmdk-separator":"",role:"separator"})}),Y6t=k.forwardRef((t,s)=>{let{onValueChange:r,...n}=t,a=t.value!=null,o=dNe(),l=pw(u=>u.search),i=pw(u=>u.selectedItemId),c=RO();return k.useEffect(()=>{t.value!=null&&o.setState("search",t.value)},[t.value]),k.createElement(sn.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)}})}),X6t=k.forwardRef((t,s)=>{let{children:r,label:n="Suggestions",...a}=t,o=k.useRef(null),l=k.useRef(null),i=pw(u=>u.selectedItemId),c=RO();return k.useEffect(()=>{if(l.current&&o.current){let u=l.current,p=o.current,f,g=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let b=u.offsetHeight;p.style.setProperty("--cmdk-list-height",b.toFixed(1)+"px")})});return g.observe(u),()=>{cancelAnimationFrame(f),g.unobserve(u)}}},[]),k.createElement(sn.div,{ref:k1(o,s),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":i,"aria-label":n,id:c.listId},pue(t,u=>k.createElement("div",{ref:k1(l,c.listInnerRef),"cmdk-list-sizer":""},u)))}),Q6t=k.forwardRef((t,s)=>{let{open:r,onOpenChange:n,overlayClassName:a,contentClassName:o,container:l,...i}=t;return k.createElement(zde,{open:r,onOpenChange:n},k.createElement(Bde,{container:l},k.createElement(WA,{"cmdk-overlay":"",className:a}),k.createElement(GA,{"aria-label":t.label,"cmdk-dialog":"",className:o},k.createElement(lYe,{ref:s,...i}))))}),J6t=k.forwardRef((t,s)=>pw(r=>r.filtered.count===0)?k.createElement(sn.div,{ref:s,...t,"cmdk-empty":"",role:"presentation"}):null),ePt=k.forwardRef((t,s)=>{let{progress:r,children:n,label:a="Loading...",...o}=t;return k.createElement(sn.div,{ref:s,...o,"cmdk-loading":"",role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},pue(t,l=>k.createElement("div",{"aria-hidden":!0},l)))}),Ep=Object.assign(lYe,{List:X6t,Item:G6t,Input:Y6t,Group:K6t,Separator:Z6t,Dialog:Q6t,Empty:J6t,Loading:ePt});function tPt(t,s){let r=t.nextElementSibling;for(;r;){if(r.matches(s))return r;r=r.nextElementSibling}}function sPt(t,s){let r=t.previousElementSibling;for(;r;){if(r.matches(s))return r;r=r.previousElementSibling}}function cYe(t){let s=k.useRef(t);return BS(()=>{s.current=t}),s}var BS=typeof window>"u"?k.useEffect:k.useLayoutEffect;function O5(t){let s=k.useRef();return s.current===void 0&&(s.current=t()),s}function pw(t){let s=dNe(),r=()=>t(s.snapshot());return k.useSyncExternalStore(s.subscribe,r,r)}function dYe(t,s,r,n=[]){let a=k.useRef(),o=RO();return BS(()=>{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(D5,i),a.current=i}),a}var rPt=()=>{let[t,s]=k.useState(),r=O5(()=>new Map);return BS(()=>{r.current.forEach(n=>n()),r.current=new Map},[t]),(n,a)=>{r.current.set(n,a),s({})}};function nPt(t){let s=t.type;return typeof s=="function"?s(t.props):"render"in s?s.render(t.props):t}function pue({asChild:t,children:s},r){return t&&k.isValidElement(s)?k.cloneElement(nPt(s),{ref:s.ref},r(s.props.children)):r(s)}var aPt={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const Lx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep,{ref:r,className:Pt("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",t),...s}));Lx.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(Lx,{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})})}),Dx=k.forwardRef(({className:t,...s},r)=>e.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[e.jsx(hn,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),e.jsx(Ep.Input,{ref:r,className:Pt("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})]}));Dx.displayName=Ep.Input.displayName;const Ox=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.List,{ref:r,className:Pt("max-h-[300px] overflow-y-auto overflow-x-hidden",t),...s}));Ox.displayName=Ep.List.displayName;const Rx=k.forwardRef((t,s)=>e.jsx(Ep.Empty,{ref:s,className:"py-6 text-center text-sm",...t}));Rx.displayName=Ep.Empty.displayName;const Fx=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Group,{ref:r,className:Pt("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}));Fx.displayName=Ep.Group.displayName;const oPt=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Separator,{ref:r,className:Pt("-mx-1 h-px bg-border",t),...s}));oPt.displayName=Ep.Separator.displayName;const vp=k.forwardRef(({className:t,...s},r)=>e.jsx(Ep.Item,{ref:r,className:Pt("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}));vp.displayName=Ep.Item.displayName;const lPt={event:{label:"Events",icon:Dd,color:"bg-blue-500/10 text-blue-600"},template:{label:"Templates",icon:sc,color:"bg-purple-500/10 text-purple-600"},academy:{label:"Academy",icon:Gh,color:"bg-amber-500/10 text-amber-600"},toolbox:{label:"Toolbox",icon:Jg,color:"bg-green-500/10 text-green-600"},"social-swag":{label:"Social Swag",icon:un,color:"bg-fuchsia-500/10 text-fuchsia-600"}},iIe=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(""),[a,o]=k.useState([]),[l,i]=k.useState(!1),c=pr();k.useEffect(()=>{const g=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),s(_=>!_))};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[]);const u=k.useCallback(async g=>{if(!g.trim()){o([]);return}i(!0);const b=`%${g}%`;try{const[_,j,w,N,C]=await Promise.all([H.from("events").select("id, title, description, event_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("canva_templates").select("id, name, description, publish_date").or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("academy_videos").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5),H.from("resource_kits").select("id, name, description, publish_date").eq("is_published",!0).or(`name.ilike.${b},description.ilike.${b}`).limit(5),H.from("social_swag").select("id, title, description, publish_date").eq("is_published",!0).or(`title.ilike.${b},description.ilike.${b}`).limit(5)]),M=[];_.data&&_.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"event",date:I.event_date,path:`/event/${I.id}`})}),j.data&&j.data.forEach(I=>{M.push({id:I.id,title:I.name,description:I.description,type:"template",date:I.publish_date,path:`/templates/${I.id}`})}),w.data&&w.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"academy",date:I.publish_date,path:`/academy/${I.id}`})}),N.data&&N.data.forEach(I=>{M.push({id:I.id,title:I.name,description:I.description,type:"toolbox",date:I.publish_date,path:`/toolbox/${I.id}`})}),C.data&&C.data.forEach(I=>{M.push({id:I.id,title:I.title,description:I.description,type:"social-swag",date:I.publish_date,path:`/social-swag/${I.id}`})}),o(M)}catch(_){console.error("Search error:",_)}finally{i(!1)}},[]);k.useEffect(()=>{const g=setTimeout(()=>{u(r)},300);return()=>clearTimeout(g)},[r,u]);const p=g=>{s(!1),n(""),c(g)},f=a.reduce((g,b)=>(g[b.type]||(g[b.type]=[]),g[b.type].push(b),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(hn,{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(Dx,{placeholder:"Search events, templates, academy, toolbox, social swag...",value:r,onValueChange:n}),e.jsxs(Ox,{children:[l&&e.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"Searching..."}),!l&&r&&a.length===0&&e.jsxs(Rx,{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,b])=>{const _=lPt[g],j=_.icon;return e.jsx(Fx,{heading:_.label,children:b.map(w=>e.jsxs(vp,{value:`${w.type}-${w.id}-${w.title}`,onSelect:()=>p(w.path),className:"flex items-start gap-3 py-3 cursor-pointer",children:[e.jsx("div",{className:`p-2 rounded-md ${_.color}`,children:e.jsx(j,{className:"h-4 w-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-medium truncate",children:w.title}),w.description&&e.jsx("div",{className:"text-sm text-muted-foreground truncate group-data-[selected=true]:text-primary-foreground/80",children:w.description})]}),e.jsxs("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[e.jsx(tt,{variant:"secondary",className:"text-xs",children:_.label}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_d(new Date(w.date),{addSuffix:!0})})]})]},`${w.type}-${w.id}`))},g)})]})]})]})},cPt=({expiresAt:t,className:s,showUpgradeButton:r=!0})=>{const[n,a]=k.useState(null),o=pr();if(k.useEffect(()=>{const u=()=>{const f=new Date().getTime(),b=new Date(t).getTime()-f;if(b<=0){a({days:0,hours:0,minutes:0});return}const _=Math.floor(b/(1e3*60*60*24)),j=Math.floor(b%(1e3*60*60*24)/(1e3*60*60)),w=Math.floor(b%(1e3*60*60)/(1e3*60));a({days:_,hours:j,minutes:w})};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:Pt("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(Gu,{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(un,{className:"h-3 w-3 mr-1"}),"Upgrade Now"]})]}):e.jsxs("div",{className:Pt("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(mn,{className:Pt("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:Pt("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:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.days,"d"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.hours,"h"]}),e.jsxs("span",{className:Pt("text-sm font-bold",i?"text-destructive":c?"text-amber-600":"text-primary"),children:[n.minutes,"m"]}),e.jsx("span",{className:Pt("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:Pt("text-xs h-7 px-3",c&&"bg-amber-500 hover:bg-amber-600 text-white"),children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"Upgrade"]})]})},dPt=()=>{const t=pr();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(Pe,{className:"w-full max-w-2xl shadow-2xl border-destructive/20 my-8",children:[e.jsxs(Dt,{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(Gu,{className:"h-8 w-8 text-destructive"})}),e.jsx(zt,{className:"text-2xl",children:"Your Free Trial Has Ended"}),e.jsx(xr,{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(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[e.jsx(Pe,{className:"border-2 border-primary/20 hover:border-primary/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Re,{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(mr,{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(un,{className:"h-4 w-4 mr-2"}),"Choose Individual"]})]})}),e.jsx(Pe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors cursor-pointer",onClick:()=>t("/subscription"),children:e.jsxs(Re,{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(wa,{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(wa,{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(Un,{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(dr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})]})]})})},uPt=({hasUnseenBrief:t,onClick:s,className:r})=>e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"icon",onClick:s,className:Pt("relative transition-colors",t&&"text-primary hover:text-primary",r),children:[e.jsx(Kh,{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(gc,{children:e.jsx("p",{children:"The LevelUp Brief"})})]});var fue="Checkbox",[hPt]=nd(fue),[mPt,uNe]=hPt(fue);function pPt(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,b]=rh({prop:r,defaultProp:a??!1,onChange:c,caller:fue}),[_,j]=k.useState(null),[w,N]=k.useState(null),C=k.useRef(!1),M=_?!!l||!!_.closest("form"):!0,I={checked:g,disabled:o,setChecked:b,control:_,setControl:j,name:i,form:l,value:p,hasConsumerStoppedPropagationRef:C,required:u,defaultChecked:Z_(a)?!1:a,isFormControl:M,bubbleInput:w,setBubbleInput:N};return e.jsx(mPt,{scope:s,...I,children:fPt(f)?f(I):n})}var uYe="CheckboxTrigger",hYe=k.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:b,bubbleInput:_}=uNe(uYe,t),j=$a(a,p),w=k.useRef(c);return k.useEffect(()=>{const N=o==null?void 0:o.form;if(N){const C=()=>f(w.current);return N.addEventListener("reset",C),()=>N.removeEventListener("reset",C)}},[o,f]),e.jsx(sn.button,{type:"button",role:"checkbox","aria-checked":Z_(c)?"mixed":c,"aria-required":u,"data-state":gYe(c),"data-disabled":i?"":void 0,disabled:i,value:l,...n,ref:j,onKeyDown:Ir(s,N=>{N.key==="Enter"&&N.preventDefault()}),onClick:Ir(r,N=>{f(C=>Z_(C)?!0:!C),_&&b&&(g.current=N.isPropagationStopped(),g.current||N.stopPropagation())})})});hYe.displayName=uYe;var hNe=k.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(pPt,{__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(hYe,{...f,ref:s,__scopeCheckbox:r}),g&&e.jsx(xYe,{__scopeCheckbox:r})]})})});hNe.displayName=fue;var mYe="CheckboxIndicator",pYe=k.forwardRef((t,s)=>{const{__scopeCheckbox:r,forceMount:n,...a}=t,o=uNe(mYe,r);return e.jsx(Fd,{present:n||Z_(o.checked)||o.checked===!0,children:e.jsx(sn.span,{"data-state":gYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s,style:{pointerEvents:"none",...t.style}})})});pYe.displayName=mYe;var fYe="CheckboxBubbleInput",xYe=k.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:b}=uNe(fYe,t),_=$a(r,b),j=AO(o),w=gO(n);k.useEffect(()=>{const C=g;if(!C)return;const M=window.HTMLInputElement.prototype,L=Object.getOwnPropertyDescriptor(M,"checked").set,R=!a.current;if(j!==o&&L){const q=new Event("click",{bubbles:R});C.indeterminate=Z_(o),L.call(C,Z_(o)?!1:o),C.dispatchEvent(q)}},[g,j,o,a]);const N=k.useRef(Z_(o)?!1:o);return e.jsx(sn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:l??N.current,required:i,disabled:c,name:u,value:p,form:f,...s,tabIndex:-1,ref:_,style:{...s.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});xYe.displayName=fYe;function fPt(t){return typeof t=="function"}function Z_(t){return t==="indeterminate"}function gYe(t){return Z_(t)?"indeterminate":t?"checked":"unchecked"}const Lo=k.forwardRef(({className:t,...s},r)=>e.jsx(hNe,{ref:r,className:Pt("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(pYe,{className:Pt("flex items-center justify-center text-current"),children:e.jsx(fa,{className:"h-4 w-4"})})}));Lo.displayName=hNe.displayName;var mNe="Radio",[xPt,yYe]=nd(mNe),[gPt,yPt]=xPt(mNe),vYe=k.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]=k.useState(null),b=$a(s,w=>g(w)),_=k.useRef(!1),j=f?u||!!f.closest("form"):!0;return e.jsxs(gPt,{scope:r,checked:a,disabled:l,children:[e.jsx(sn.button,{type:"button",role:"radio","aria-checked":a,"data-state":jYe(a),"data-disabled":l?"":void 0,disabled:l,value:i,...p,ref:b,onClick:Ir(t.onClick,w=>{a||c==null||c(),j&&(_.current=w.isPropagationStopped(),_.current||w.stopPropagation())})}),j&&e.jsx(wYe,{control:f,bubbles:!_.current,name:n,value:i,checked:a,required:o,disabled:l,form:u,style:{transform:"translateX(-100%)"}})]})});vYe.displayName=mNe;var bYe="RadioIndicator",_Ye=k.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...a}=t,o=yPt(bYe,r);return e.jsx(Fd,{present:n||o.checked,children:e.jsx(sn.span,{"data-state":jYe(o.checked),"data-disabled":o.disabled?"":void 0,...a,ref:s})})});_Ye.displayName=bYe;var vPt="RadioBubbleInput",wYe=k.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...a},o)=>{const l=k.useRef(null),i=$a(l,o),c=AO(r),u=gO(s);return k.useEffect(()=>{const p=l.current;if(!p)return;const f=window.HTMLInputElement.prototype,b=Object.getOwnPropertyDescriptor(f,"checked").set;if(c!==r&&b){const _=new Event("click",{bubbles:n});b.call(p,r),p.dispatchEvent(_)}},[c,r,n]),e.jsx(sn.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}})});wYe.displayName=vPt;function jYe(t){return t?"checked":"unchecked"}var bPt=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],xue="RadioGroup",[_Pt]=nd(xue,[Cw,yYe]),NYe=Cw(),kYe=yYe(),[wPt,jPt]=_Pt(xue),SYe=k.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,b=NYe(r),_=Sw(u),[j,w]=rh({prop:o,defaultProp:a??null,onChange:f,caller:xue});return e.jsx(wPt,{scope:r,name:n,required:l,disabled:i,value:j,onValueChange:w,children:e.jsx(Ede,{asChild:!0,...b,orientation:c,dir:_,loop:p,children:e.jsx(sn.div,{role:"radiogroup","aria-required":l,"aria-orientation":c,"data-disabled":i?"":void 0,dir:_,...g,ref:s})})})});SYe.displayName=xue;var CYe="RadioGroupItem",MYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...a}=t,o=jPt(CYe,r),l=o.disabled||n,i=NYe(r),c=kYe(r),u=k.useRef(null),p=$a(s,u),f=o.value===a.value,g=k.useRef(!1);return k.useEffect(()=>{const b=j=>{bPt.includes(j.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",b),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",b),document.removeEventListener("keyup",_)}},[]),e.jsx(Pde,{asChild:!0,...i,focusable:!l,active:f,children:e.jsx(vYe,{disabled:l,required:o.required,checked:f,...c,...a,name:o.name,ref:p,onCheck:()=>o.onValueChange(a.value),onKeyDown:Ir(b=>{b.key==="Enter"&&b.preventDefault()}),onFocus:Ir(a.onFocus,()=>{var b;g.current&&((b=u.current)==null||b.click())})})})});MYe.displayName=CYe;var NPt="RadioGroupIndicator",TYe=k.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,a=kYe(r);return e.jsx(_Ye,{...a,...n,ref:s})});TYe.displayName=NPt;var AYe=SYe,EYe=MYe,kPt=TYe;const pNe=k.forwardRef(({className:t,...s},r)=>e.jsx(AYe,{className:Pt("grid gap-2",t),...s,ref:r}));pNe.displayName=AYe.displayName;const Voe=k.forwardRef(({className:t,...s},r)=>e.jsx(EYe,{ref:r,className:Pt("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(kPt,{className:"flex items-center justify-center",children:e.jsx(vd,{className:"h-2.5 w-2.5 fill-current text-current"})})}));Voe.displayName=EYe.displayName;const SPt=({brief:t,open:s,onClose:r,onDismiss:n})=>{const{user:a}=Rs(),[o,l]=k.useState({}),[i,c]=k.useState({}),[u,p]=k.useState([]);k.useEffect(()=>{s&&a&&t.polls.length>0&&f()},[s,a,t.polls]);const f=async()=>{if(!a)return;const w=t.polls.map(C=>C.id),{data:N}=await H.from("levelup_brief_poll_responses").select("poll_id, option_id").eq("user_id",a.id).in("poll_id",w);if(N){const C={};N.forEach(M=>{C[M.poll_id]||(C[M.poll_id]=[]),C[M.poll_id].push(M.option_id)}),c(C)}},g=(w,N)=>{l(C=>({...C,[w]:N}))},b=(w,N,C)=>{l(M=>{const I=M[w]||[];return C?{...M,[w]:[...I,N]}:{...M,[w]:I.filter(L=>L!==N)}})},_=async w=>{if(!a)return;const N=o[w];if(!N||Array.isArray(N)&&N.length===0){he.error("Please select an option");return}p(C=>[...C,w]);try{await H.from("levelup_brief_poll_responses").delete().eq("poll_id",w).eq("user_id",a.id);const C=Array.isArray(N)?N:[N],M=C.map(L=>({poll_id:w,option_id:L,user_id:a.id})),{error:I}=await H.from("levelup_brief_poll_responses").insert(M);if(I)throw I;c(L=>({...L,[w]:C})),he.success("Response submitted!")}catch(C){console.error("Error submitting poll response:",C),he.error("Failed to submit response")}finally{p(C=>C.filter(M=>M!==w))}},j=w=>(w.includes("mediadelivery.net")||w.includes("bunny"),w);return e.jsx(xs,{open:s,onOpenChange:w=>!w&&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(Or,{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(Kh,{className:"h-6 w-6"})}),e.jsxs("div",{children:[e.jsx(tt,{variant:"secondary",className:"mb-1 bg-white/20 text-white border-0",children:"The LevelUp Brief"}),e.jsx(bs,{className:"text-xl font-bold text-white",children:t.brief.title})]})]})]}),e.jsx(Gi,{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:j(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(w=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>window.open(w.url,"_blank"),className:"gap-2",children:[e.jsx(an,{className:"h-4 w-4"}),w.title]},w.id))})]}),t.polls.map(w=>{var M,I;const N=((M=i[w.id])==null?void 0:M.length)>0,C=u.includes(w.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:w.question}),N&&e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(la,{className:"h-3 w-3"}),"Responded"]})]}),w.poll_type==="single"?e.jsx(pNe,{value:o[w.id]||((I=i[w.id])==null?void 0:I[0])||"",onValueChange:L=>g(w.id,L),className:"space-y-2",children:w.options.map(L=>e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Voe,{value:L.id,id:L.id}),e.jsx(ye,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id))}):e.jsx("div",{className:"space-y-2",children:w.options.map(L=>{const q=(o[w.id]||i[w.id]||[]).includes(L.id);return e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Lo,{id:L.id,checked:q,onCheckedChange:U=>b(w.id,L.id,U)}),e.jsx(ye,{htmlFor:L.id,className:"cursor-pointer",children:L.option_text})]},L.id)})}),e.jsx(K,{size:"sm",onClick:()=>_(w.id),disabled:C,children:C?"Submitting...":N?"Update Response":"Submit"})]},w.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"})]})]})})},CPt=()=>{const{user:t}=Rs(),[s,r]=k.useState(null),[n,a]=k.useState(!1),[o,l]=k.useState(!0),[i,c]=k.useState(!1),u=k.useCallback(async()=>{if(!t){l(!1);return}try{const{data:_,error:j}=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(j||!_){l(!1);return}const{data:w}=await H.from("levelup_brief_views").select("*").eq("brief_id",_.id).eq("user_id",t.id).maybeSingle(),[N,C]=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(C.data)for(const U of C.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 I={brief:_,links:N.data||[],polls:M};r(I);const L=!!w,R=(w==null?void 0:w.dismissed_at)!=null,q=localStorage.getItem(`brief-dismissed-${_.id}`)==="true";if(R||q)c(!1),a(!1);else if(!L)a(!0),c(!0);else if(_.show_frequency==="every_login")a(!0),c(!0);else if(_.show_frequency==="daily"){const U=new Date(w.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]);k.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:j}=await H.from("levelup_brief_views").select("id").eq("brief_id",s.brief.id).eq("user_id",t.id).maybeSingle();if(j&&console.error("Error checking existing brief view:",j),_){const{error:w}=await H.from("levelup_brief_views").update({dismissed_at:new Date().toISOString()}).eq("id",_.id).eq("user_id",t.id);w&&console.error("Error updating brief dismiss:",w)}else{const{error:w}=await H.from("levelup_brief_views").insert({brief_id:s.brief.id,user_id:t.id,dismissed_at:new Date().toISOString()});w&&console.error("Error inserting brief dismiss:",w)}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 MPt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1),[a,o]=k.useState(null);k.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=b=>{b.preventDefault(),o(b)};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(Ci,{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(kL,{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(Or,{className:"h-4 w-4"})})]})]})}):null}const TPt=({children:t,onRefresh:s})=>{const[r,n]=k.useState(!1),[a,o]=k.useState(0),[l,i]=k.useState(!1),c=k.useRef(null),u=k.useRef(0),p=es(),f=80,g=120,b=k.useCallback(C=>{const M=c.current;M&&M.scrollTop<=0&&(u.current=C.touches[0].clientY,n(!0))},[]),_=k.useCallback(C=>{if(!r||l)return;const M=c.current;if(!M||M.scrollTop>0){n(!1),o(0);return}const L=C.touches[0].clientY-u.current;if(L>0){const q=Math.min(L*.5,g);o(q),q>10&&C.preventDefault()}},[r,l]),j=k.useCallback(async()=>{if(r)if(n(!1),a>=f&&!l){i(!0),o(f);try{s?await s():await p.invalidateQueries()}catch(C){console.error("Refresh failed:",C)}finally{i(!1),o(0)}}else o(0)},[r,a,l,s,p]),w=Math.min(a/f,1),N=w*180;return e.jsxs("div",{ref:c,className:"h-full overflow-auto",onTouchStart:b,onTouchMove:_,onTouchEnd:j,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:w},children:e.jsx("div",{className:`p-2 rounded-full bg-primary/10 ${l?"animate-spin":""}`,style:{transform:l?void 0:`rotate(${N}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})]})},PYe=()=>{const{user:t}=Rs(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(0),[i,c]=k.useState(!0);k.useEffect(()=>{(async()=>{if(!t){c(!1);return}try{const{data:b}=await H.from("membership_reviews").select("id").eq("user_id",t.id).maybeSingle();if(b){a(!0),r(!1),c(!1);return}const{data:_}=await H.from("profiles").select("login_count").eq("id",t.id).single(),j=(_==null?void 0:_.login_count)||0;l(j);const w=sessionStorage.getItem("review-prompt-dismissed");r(j>=4&&!w)}catch(b){console.error("Error checking review eligibility:",b)}finally{c(!1)}})()},[t]);const u=k.useCallback(()=>{sessionStorage.setItem("review-prompt-dismissed","true"),r(!1)},[]),p=k.useCallback(async(g,b)=>{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:b});if(_)throw _;return a(!0),r(!1),{success:!0,pointsAwarded:25}}catch(_){return console.error("Error submitting review:",_),{success:!1,error:_.message}}},[t]),f=k.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}},APt="https://search.google.com/local/writereview?placeid=ChIJM73ERQD1QogRPxupMFObuck&source=g.page.m.ia._&laa=nmx-review-solicitation-ia2",EPt=()=>{const{shouldShowPrompt:t,isLoading:s,dismissPrompt:r,submitReview:n,markPostedToGoogle:a}=PYe(),[o,l]=k.useState(!1),[i,c]=k.useState("review"),[u,p]=k.useState(0),[f,g]=k.useState(0),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!1);if(s||!t&&!N)return null;const M=async()=>{if(u===0){vn({title:"Please select a rating",variant:"destructive"});return}w(!0);const R=await n(u,b);w(!1),R.success?(C(!0),vn({title:"Thank you for your feedback!",description:"Your review helps us improve."}),c("google")):vn({title:"Error submitting review",description:R.error,variant:"destructive"})},I=async R=>{R&&(await navigator.clipboard.writeText(b||`${u} star rating for LevelUp!`),vn({title:"Review copied!",description:"Paste it on Google Reviews."}),await a(),window.open(APt,"_blank")),l(!1),r()},L=()=>{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:L,children:e.jsx(fs,{className:"sm:max-w-md",children:i==="review"?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(R=>e.jsx("button",{type:"button",onClick:()=>p(R),onMouseEnter:()=>g(R),onMouseLeave:()=>g(0),className:"p-1 transition-transform hover:scale-110",children:e.jsx(Jn,{className:Pt("h-8 w-8 transition-colors",(f||u)>=R?"fill-yellow-400 text-yellow-400":"text-muted-foreground")})},R))}),e.jsx(Er,{placeholder:"Tell us about your experience (optional)",value:b,onChange:R=>_(R.target.value),rows:4,className:"resize-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",onClick:L,className:"flex-1",children:"Maybe Later"}),e.jsx(K,{onClick:M,disabled:j||u===0,className:"flex-1",children:j?"Submitting...":"Submit Review"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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:()=>I(!1),className:"flex-1",children:"No Thanks"}),e.jsx(K,{onClick:()=>I(!0),className:"flex-1",children:"Yes, Open Google"})]})]})]})})})]})};function PPt(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 j="vapid_public_key";let w=localStorage.getItem(j);if(!w){const{data:M,error:I}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(I)throw I;if(w=(M==null?void 0:M.vapidPublicKey)??null,!w)throw new Error("Missing VAPID public key");localStorage.setItem(j,w)}p(w);const N=await navigator.serviceWorker.register("/push-sw.js");c(N),r(Notification.permission);const C=await N.pushManager.getSubscription();a(!!C)}catch(j){console.error("Error initializing push notifications:",j)}finally{l(!1)}})()},[f]);const g=k.useCallback(async()=>{if(!f||!i||!t)return console.error("Push notifications not supported or user not logged in"),!1;if(!u)return he.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(I){console.warn("Failed to unsubscribe existing push subscription:",I)}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"?he.error("Notifications blocked. Please enable them in your browser settings (click the lock icon in the address bar)."):he.error("Notification permission was dismissed. Please try again."),!1}const j=PPt(u);let w;try{w=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:j})}catch(M){console.error("PushManager.subscribe() failed:",M);const I=(M==null?void 0:M.message)||String(M);return I.includes("permission")?he.error("Push permission denied. Check your browser notification settings."):I.includes("key")||I.includes("VAPID")?he.error("Push configuration error. Please contact support."):I.includes("AbortError")?he.error("Push subscription was cancelled. Please try again."):he.error(`Failed to subscribe: ${I}`),!1}const N=w.toJSON(),{error:C}=await H.from("push_subscriptions").upsert({user_id:t.id,endpoint:N.endpoint,p256dh_key:N.keys.p256dh,auth_key:N.keys.auth},{onConflict:"user_id,endpoint"});if(C)throw console.error("Error saving subscription:",C),he.error("Failed to save notification preferences. Please try again."),C;return a(!0),he.success("Push notifications enabled!"),!0}catch(_){if(console.error("Error subscribing to push notifications:",_),!(_ instanceof Error&&_.message.includes("toast"))){const j=_ instanceof Error?_.message:"Unknown error";he.error("Failed to enable push notifications: "+j)}return!1}finally{l(!1)}},[f,i,t,u]),b=k.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),he.success("Push notifications disabled"),!0}catch(_){console.error("Error unsubscribing:",_);const j=_ instanceof Error?_.message:"Unknown error";return he.error("Failed to disable push notifications: "+j),!1}finally{l(!1)}},[i,t]);return{isSupported:f,permission:s,isSubscribed:n,isLoading:o,vapidPublicKey:u,subscribe:g,unsubscribe:b}}const Hxe="push_notification_prompt_dismissed",IPt=()=>{const{user:t}=Rs(),{isSupported:s,isSubscribed:r,isLoading:n,subscribe:a}=IYe(),[o,l]=k.useState(!1),[i,c]=k.useState(!1);k.useEffect(()=>{if(!t||!s||r||n||localStorage.getItem(`${Hxe}_${t.id}`))return;const g=setTimeout(()=>{l(!0)},2e3);return()=>clearTimeout(g)},[t,s,r,n]);const u=async()=>{c(!0);const f=await a();c(!1),f&&(t&&localStorage.setItem(`${Hxe}_${t.id}`,"true"),l(!1))},p=()=>{t&&localStorage.setItem(`${Hxe}_${t.id}`,"true"),l(!1)};return!s||r?null:e.jsx(xs,{open:o,onOpenChange:f=>!f&&p(),children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(_s,{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(Pm,{className:"h-6 w-6 text-primary"})}),e.jsx(bs,{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:u,disabled:i,className:"w-full",children:i?"Enabling...":"Enable Notifications"}),e.jsx(K,{variant:"ghost",onClick:p,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."})]})})},oIe=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(b=>b(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},LPt=t=>t?oIe(t):oIe,DPt=t=>t;function OPt(t,s=DPt){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 lIe=t=>{const s=LPt(t),r=n=>OPt(s,n);return Object.assign(r,s),r},RPt=t=>t?lIe(t):lIe;function FPt(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 m1e=t=>s=>{try{const r=t(s);return r instanceof Promise?r:{then(n){return m1e(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return m1e(n)(r)}}}},zPt=(t,s)=>(r,n,a)=>{let o={storage:FPt(()=>localStorage),partialize:j=>j,version:0,merge:(j,w)=>({...w,...j}),...s},l=!1;const i=new Set,c=new Set;let u=o.storage;if(!u)return t((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${o.name}', the given storage is currently unavailable.`),r(...j)},n,a);const p=()=>{const j=o.partialize({...n()});return u.setItem(o.name,{state:j,version:o.version})},f=a.setState;a.setState=(j,w)=>(f(j,w),p());const g=t((...j)=>(r(...j),p()),n,a);a.getInitialState=()=>g;let b;const _=()=>{var j,w;if(!u)return;l=!1,i.forEach(C=>{var M;return C((M=n())!=null?M:g)});const N=((w=o.onRehydrateStorage)==null?void 0:w.call(o,(j=n())!=null?j:g))||void 0;return m1e(u.getItem.bind(u))(o.name).then(C=>{if(C)if(typeof C.version=="number"&&C.version!==o.version){if(o.migrate){const M=o.migrate(C.state,C.version);return M instanceof Promise?M.then(I=>[!0,I]):[!0,M]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,C.state];return[!1,void 0]}).then(C=>{var M;const[I,L]=C;if(b=o.merge(L,(M=n())!=null?M:g),r(b,!0),I)return p()}).then(()=>{N==null||N(b,void 0),b=n(),l=!0,c.forEach(C=>C(b))}).catch(C=>{N==null||N(void 0,C)})};return a.persist={setOptions:j=>{o={...o,...j},j.storage&&(u=j.storage)},clearStorage:()=>{u==null||u.removeItem(o.name)},getOptions:()=>o,rehydrate:()=>_(),hasHydrated:()=>l,onHydrate:j=>(i.add(j),()=>{i.delete(j)}),onFinishHydration:j=>(c.add(j),()=>{c.delete(j)})},o.skipHydration||_(),b||g},BPt=zPt,gue=RPt()(BPt((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 yue(){const{user:t}=Rs(),{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).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 LYe=k.createContext({onlineUsers:[],totalOnline:0}),$Pt=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{}},qPt=({children:t})=>{const{user:s,brokerageId:r,isAdmin:n}=Rs(),[a,o]=k.useState([]),[l,i]=k.useState(null);k.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,b])=>{if(b&&b.length>0){const _=b[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(),b=await $Pt(s.id);await u.track({name:(g==null?void 0:g.name)||((f=s.email)==null?void 0:f.split("@")[0])||"User",avatarUrl:b,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(LYe.Provider,{value:{onlineUsers:c,totalOnline:a.length},children:t})},DYe=()=>k.useContext(LYe),cIe="dashboard-sidebar-collapsed",Ts=({children:t,title:s})=>{var ft;const{user:r,signOut:n,isAdmin:a,isBrokerageManager:o,brokerageId:l}=Rs(),{isAssistant:i,actingAsAgent:c,hasPermission:u}=H2e(),{isImpersonating:p}=V2e(),g=(i&&!!c?40:0)+(p?40:0),{avatarUrl:b}=IZe(r==null?void 0:r.id),{isTrial:_,isExpired:j,expiresAt:w}=QEt(r==null?void 0:r.id),{isMarketplaceEnabled:N}=DZe(),{currentBrief:C,shouldShowPopup:M,hasUnseenBrief:I,openBrief:L,closeBrief:R,dismissBrief:q}=CPt(),{unreadCount:U}=JEt(),{openCount:B}=e6t(),{data:V}=Bx(),Y=!!V,te=gue(me=>me.cartItems).reduce((me,Ve)=>me+Ve.quantity,0),{leadSite:X,hasLeadSite:ce,siteUrl:ne}=yue(),re=pr(),le=nu(),[pe,xe]=k.useState(null);k.useEffect(()=>{r!=null&&r.id&&H.from("profiles").select("name").eq("id",r.id).single().then(({data:me})=>{me!=null&&me.name&&xe(me.name)})},[r==null?void 0:r.id]);const _e=pe||((ft=r==null?void 0:r.user_metadata)==null?void 0:ft.name)||(r==null?void 0:r.email)||"User",[fe,we]=k.useState(()=>typeof window<"u"?localStorage.getItem(cIe)==="true":!1);k.useEffect(()=>{localStorage.setItem(cIe,String(fe))},[fe]);const[Ie,Ne]=k.useState({agentos:!0,tools:!0,marketing:!0,learning:!0,community:!0,contacts:!0,website:!0,help:!1}),Ae=me=>{Ne(Ve=>({...Ve,[me]:!Ve[me]}))},Fe=me=>me.split(" ").map(Ve=>Ve[0]).join("").toUpperCase().slice(0,2),Ce=me=>le.pathname===me,Me=me=>me.some(Ve=>le.pathname===Ve),$e=({path:me,icon:Ve,label:nt,badgeCount:et})=>{const Se=e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Ce(me)&&"bg-sidebar-accent text-sidebar-accent-foreground",fe?"w-10 h-10 p-0 justify-center":"w-full justify-start gap-2"),onClick:()=>re(me),children:[e.jsxs("div",{className:"relative",children:[e.jsx(Ve,{className:"h-4 w-4 shrink-0"}),fe&&et!=null&&et>0&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-muted-foreground/40 border border-background"})]}),!fe&&nt,!fe&&et!=null&&et>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:et>9?"9+":et})]});return fe?e.jsxs(Oc,{delayDuration:0,children:[e.jsx(Rc,{asChild:!0,children:Se}),e.jsxs(gc,{side:"right",className:"flex items-center gap-2",children:[nt,et!=null&&et>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:et>9?"9+":et})]})]}):Se},ct=({id:me,label:Ve,icon:nt,children:et,activePaths:Se,showBetaBadge:rt,defaultPath:Ge,badgeCount:lt})=>{if(fe){const qe=Ge||Se[0];return e.jsxs(Oc,{delayDuration:0,children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground relative",Me(Se)&&"text-primary"),onClick:()=>re(qe),children:e.jsxs("div",{className:"relative",children:[e.jsx(nt,{className:"h-4 w-4"}),lt!=null&<>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(gc,{side:"right",className:"flex items-center gap-2",children:[Ve,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"}),lt!=null&<>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:lt>9?"9+":lt})]})]})}return e.jsxs(gf,{open:Ie[me],onOpenChange:()=>Ae(me),children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(Se)&&"text-primary"),children:[e.jsxs("span",{className:"flex items-center gap-2 font-semibold text-[15px]",children:[e.jsx(nt,{className:"h-4 w-4"}),Ve,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:[lt!=null&<>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:lt>9?"9+":lt}),e.jsx(To,{className:Pt("h-4 w-4 transition-transform duration-200",Ie[me]&&"rotate-180")})]})]})}),e.jsx(vf,{className:"pl-4 space-y-1 mt-1",children:et})]})},Te=({isMobile:me=!1})=>{const Ve=me?!1:fe;return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:Pt("p-3 border-b border-sidebar-border",Ve?"flex flex-col items-center gap-2":"flex items-center justify-between"),children:[Ve?e.jsx("img",{src:l6t,alt:"LevelUp",className:"h-8 w-auto"}):e.jsx("img",{src:o6t,alt:"LevelUp",className:"h-8 w-auto"}),!me&&e.jsxs(Oc,{delayDuration:0,children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>we(!Ve),children:e.jsx(ll,{className:Pt("h-4 w-4 transition-transform duration-300",Ve&&"rotate-180")})})}),e.jsx(gc,{side:"right",children:Ve?"Expand sidebar":"Collapse sidebar"})]})]}),e.jsx(Gi,{className:"flex-1 [&_[data-radix-scroll-area-scrollbar]]:w-1.5",children:e.jsxs("nav",{className:Pt("p-3 space-y-1",Ve&&"flex flex-col items-center"),children:[e.jsx($e,{path:"/dashboard",icon:eS,label:"Dashboard"}),e.jsx($e,{path:"/apps",icon:nx,label:"Apps & Tools"}),fe?e.jsxs(Oc,{delayDuration:0,children:[e.jsx(Rc,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-10 h-10 p-0 justify-center relative text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Gh,{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(gc,{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:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/levelup-u")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/levelup-u"),children:[e.jsx(Gh,{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($e,{path:"/events",icon:Dd,label:"Events"}),e.jsxs(ct,{id:"agentos",label:"Agent OS",icon:bM,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($e,{path:"/mission-control",icon:ii,label:"Mission Control"}),u("contacts")&&!Ve&&e.jsxs(gf,{open:Ie.contacts,onOpenChange:()=>Ae("contacts"),children:[e.jsx(yf,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-between gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Me(["/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(mr,{className:"h-4 w-4"}),"Contacts"]}),e.jsx(To,{className:Pt("h-3.5 w-3.5 transition-transform duration-200",Ie.contacts&&"rotate-180")})]})}),e.jsxs(vf,{className:"pl-4 pr-1 space-y-0.5 mt-0.5",children:[e.jsx($e,{path:"/mission-control/contacts",icon:mr,label:"All Contacts"}),e.jsx($e,{path:"/mission-control/relationship-scorecard",icon:jh,label:"Relationship Report"}),e.jsx($e,{path:"/mission-control/sphere-gaps",icon:jL,label:"Sphere Gaps"}),e.jsx($e,{path:"/mission-control/connect-page",icon:cl,label:"Connect Page"})]})]}),u("contacts")&&Ve&&e.jsx($e,{path:"/mission-control/contacts",icon:mr,label:"Contacts"}),u("contacts")&&e.jsx($e,{path:"/mission-control/plans",icon:Dd,label:"TouchPlans"}),u("pipeline")&&e.jsx($e,{path:"/mission-control/pipeline",icon:u0,label:"Deal Pipeline"}),u("pipeline")&&e.jsx($e,{path:"/mission-control/tasks",icon:Fv,label:"Tasks"}),u("popbys")&&e.jsx($e,{path:"/mission-control/popbys",icon:No,label:"Popbys"}),u("videos")&&e.jsx($e,{path:"/mission-control/video-library",icon:Cn,label:"Video Library"}),u("scorecard")&&e.jsx($e,{path:"/mission-control/scorecard",icon:Ro,label:"Scorecard"}),u("listings")&&e.jsx($e,{path:"/mission-control/listings",icon:wa,label:"Listing Exchange"}),!Ve&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/mission-control/smart-drips")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/mission-control/smart-drips"),children:[e.jsx(Fm,{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"})]}),Ve&&e.jsx($e,{path:"/mission-control/smart-drips",icon:Fm,label:"Smart Drips"})]}),ce&&X&&e.jsxs(ct,{id:"website",label:"My Website",icon:Su,activePaths:[`/admin/lead-sites/${X.id}/edit`],defaultPath:`/admin/lead-sites/${X.id}/edit`,children:[Ve?e.jsxs(Oc,{delayDuration:0,children:[e.jsx(Rc,{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(qn,{className:"h-4 w-4"})})}),e.jsx(gc,{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(qn,{className:"h-4 w-4"}),"View Site",e.jsx(an,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsx($e,{path:`/my-website/${X.id}/edit`,icon:Da,label:"Edit Website"}),e.jsx($e,{path:"/my-website/mls-listings",icon:Sn,label:"MLS Listings"}),e.jsx($e,{path:"/my-website/market-report",icon:Ro,label:"Market Reports"}),e.jsx($e,{path:`/my-website/${X.id}/activity`,icon:jh,label:"Website Activity"})]}),e.jsxs(ct,{id:"marketing",label:"Marketing",icon:Kh,activePaths:["/templates","/social-swag-2","/newsletters"],defaultPath:"/templates",children:[e.jsx($e,{path:"/templates",icon:sc,label:"Templates"}),e.jsx($e,{path:"/social-swag-2",icon:u1,label:"Social Swag"}),e.jsx($e,{path:"/newsletters",icon:i1,label:"Newsletters"})]}),e.jsxs(ct,{id:"learning",label:"Learning",icon:kh,activePaths:["/academy","/toolbox"],defaultPath:"/academy",children:[e.jsx($e,{path:"/academy",icon:Gh,label:"Academy"}),e.jsx($e,{path:"/toolbox",icon:Jg,label:"Toolbox"})]}),e.jsxs(ct,{id:"community",label:"Community",icon:io,activePaths:["/community","/wishlist"],defaultPath:"/community",badgeCount:U,children:[e.jsx($e,{path:"/community",icon:mr,label:"Community",badgeCount:U}),e.jsx($e,{path:"/wishlist",icon:B_,label:"Wishlist",badgeCount:B}),!Ve&&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(an,{className:"h-4 w-4"}),"Facebook Group"]})]}),e.jsxs(ct,{id:"goods",label:"The Goods",icon:yp,activePaths:["/marketplace","/reward-store"],defaultPath:"/reward-store",children:[N&&!Ve&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",le.pathname.startsWith("/marketplace")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/marketplace"),children:[e.jsx(yp,{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"})]}),N&&Ve&&e.jsx($e,{path:"/marketplace",icon:yp,label:"Marketplace"}),e.jsx($e,{path:"/reward-store",icon:xo,label:"Reward Store"})]}),e.jsxs(ct,{id:"help",label:"Help & Services",icon:Lv,activePaths:["/support","/additional-services"],defaultPath:"/support",children:[e.jsx($e,{path:"/support",icon:AM,label:"Support"}),e.jsx($e,{path:"/additional-services",icon:un,label:"Additional Services"})]}),a&&e.jsxs(e.Fragment,{children:[!Ve&&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"})}),Ve?e.jsx("div",{className:"pt-3 border-t border-sidebar-border mt-3 space-y-1",children:e.jsx($e,{path:"/admin",icon:Mh,label:"Admin Dashboard"})}):e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",le.pathname==="/admin"&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/admin"),children:[e.jsx(Mh,{className:"h-4 w-4"}),"Admin Dashboard"]})]}),(l||o)&&!a&&e.jsxs(e.Fragment,{children:[!Ve&&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"})}),Ve?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($e,{path:"/my-brokerage",icon:wa,label:"My Brokerage"}),e.jsx($e,{path:"/brokerage-content",icon:kh,label:"Brokerage Content"})]}),Y&&!o&&e.jsx($e,{path:"/my-team",icon:mr,label:"My Team"}),o&&e.jsxs(e.Fragment,{children:[e.jsx($e,{path:"/brokerage/dashboard",icon:Yo,label:"Manage Brokerages"}),e.jsx($e,{path:"/brokerage/teams",icon:mr,label:"Teams"}),e.jsx($e,{path:"/brokerage/recruiting",icon:Kh,label:"Recruiting"}),e.jsx($e,{path:"/brokerage-resources",icon:Wh,label:"Brokerage Resources"})]})]}):e.jsxs(e.Fragment,{children:[l&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/my-brokerage")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-brokerage"),children:[e.jsx(wa,{className:"h-4 w-4"}),"My Brokerage"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/brokerage-content")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-content"),children:[e.jsx(kh,{className:"h-4 w-4"}),"Brokerage Content"]})]}),Y&&!o&&e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/my-team")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/my-team"),children:[e.jsx(mr,{className:"h-4 w-4"}),"My Team"]}),o&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/brokerage/dashboard")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/dashboard"),children:[e.jsx(Yo,{className:"h-4 w-4"}),"Manage Brokerages"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/brokerage/teams")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/teams"),children:[e.jsx(mr,{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:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/brokerage/recruiting")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage/recruiting"),children:[e.jsx(Kh,{className:"h-4 w-4"}),"Recruiting"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/brokerage-resources")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/brokerage-resources"),children:[e.jsx(Wh,{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:Pt("w-full justify-start gap-2 text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",Ce("/profile")&&"bg-sidebar-accent text-sidebar-accent-foreground"),onClick:()=>re("/profile"),children:[e.jsx(to,{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(sS,{className:"h-4 w-4"}),"Sign Out"]})]})]})};return e.jsx(qPt,{children:e.jsx(F1,{children:e.jsxs("div",{className:"min-h-screen bg-background flex",children:[_&&j&&e.jsx(dPt,{}),typeof document<"u"&&gp.createPortal(e.jsx("aside",{className:Pt("hidden md:flex flex-col bg-card border-r border-border fixed left-0 z-30 !pointer-events-auto transition-[width] duration-300",fe?"w-16":"w-56"),style:{top:`${g}px`,height:`calc(100vh - ${g}px)`},children:e.jsx(Te,{})}),document.body),e.jsxs("div",{className:Pt("flex-1 flex flex-col overflow-hidden transition-all duration-300",fe?"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(QA,{children:[e.jsx(Jje,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"md:hidden",children:e.jsx(IM,{className:"h-5 w-5"})})}),e.jsx(mC,{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:c6t,alt:"LevelUp",className:"h-8 w-auto"})}),e.jsx("div",{className:"hidden md:flex flex-1 justify-center",children:e.jsx(iIe,{})}),e.jsxs("div",{className:"flex items-center gap-3 ml-auto",children:[_&&!j&&w&&e.jsx(cPt,{expiresAt:w,className:"hidden lg:flex"}),e.jsx("div",{className:"md:hidden",children:e.jsx(iIe,{})}),C&&e.jsx(uPt,{hasUnseenBrief:I,onClick:L}),N&&e.jsxs(K,{variant:"ghost",size:"icon",className:"relative",onClick:()=>re("/marketplace/cart"),children:[e.jsx(yp,{className:"h-5 w-5"}),te>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:te>99?"99+":te})]}),e.jsx(D6t,{}),e.jsx(d1e,{}),e.jsxs("span",{className:"hidden sm:block text-sm font-medium text-foreground",children:["Hello, ",_e.split(" ")[0],"!"]}),e.jsxs(au,{children:[e.jsx(iu,{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(_n,{className:"h-9 w-9 cursor-pointer hover:opacity-80 transition-opacity",children:[e.jsx(za,{src:b||void 0}),e.jsx(wn,{className:"bg-primary text-primary-foreground font-medium text-sm",children:Fe(_e)})]})})}),e.jsxs(zd,{align:"end",className:"w-48",children:[e.jsxs(Ca,{onClick:()=>re("/profile"),className:"cursor-pointer",children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"Profile"]}),e.jsxs(Ca,{onClick:()=>re("/mission-control/integrations"),className:"cursor-pointer",children:[e.jsx(xL,{className:"h-4 w-4 mr-2"}),"Integrations"]}),e.jsx(lw,{}),e.jsxs(Ca,{onClick:n,className:"cursor-pointer text-destructive focus:text-destructive",children:[e.jsx(sS,{className:"h-4 w-4 mr-2"}),"Sign Out"]})]})]})]})]})}),e.jsx(TPt,{children:e.jsx("main",{className:"p-4 sm:p-6 lg:p-8 overflow-x-hidden",children:t})}),C&&e.jsx(SPt,{brief:C,open:M,onClose:R,onDismiss:q}),e.jsx(MPt,{}),e.jsx(EPt,{}),e.jsx(IPt,{})]})]})})})},UPt=()=>{const{user:t}=Rs(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(""),i=async f=>{var g;if(!(t!=null&&t.email)){he.error("Please sign in to upgrade");return}r(!0),a(f);try{const{data:b,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(b!=null&&b.url)window.open(b.url,"_blank","noopener,noreferrer"),he.success("Checkout opened in a new tab");else throw new Error("No checkout URL returned")}catch(b){console.error("Checkout error:",b),he.error(b.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(ye,{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(Pe,{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(Dt,{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(mr,{className:"h-7 w-7 text-primary"})}),e.jsx(zt,{className:"text-xl",children:"Individual Agent"}),e.jsx(xr,{children:"Perfect for solo agents ready to level up"})]}),e.jsxs(Re,{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(fa,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(un,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{className:"border-2 border-amber-500/20 hover:border-amber-500/50 transition-colors",children:[e.jsxs(Dt,{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(wa,{className:"h-7 w-7 text-amber-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage"}),e.jsx(xr,{children:"For teams and brokerages up to 25 agents"})]}),e.jsxs(Re,{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(fa,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(wa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]}),e.jsxs(Pe,{className:"border-2 border-purple-500/20 hover:border-purple-500/50 transition-colors",children:[e.jsxs(Dt,{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(wa,{className:"h-7 w-7 text-purple-600"})}),e.jsx(zt,{className:"text-xl",children:"Brokerage 25+"}),e.jsx(xr,{children:"For larger brokerages with 25+ agents"})]}),e.jsxs(Re,{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(fa,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(wa,{className:"h-4 w-4 mr-2"}),"Get Started"]})]})]})]}),e.jsx(Pe,{className:"bg-muted/50",children:e.jsxs(Re,{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(Un,{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(dr,{className:"h-4 w-4"}),e.jsx("span",{children:"support@relevelup.com"})]})]})]})})]})})},VPt=()=>{const{user:t,loading:s,isBrokerageManager:r,brokerageId:n}=Rs(),a=pr(),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,p]=k.useState(!1);k.useEffect(()=>{!s&&!t&&a("/auth")},[t,s,a]),k.useEffect(()=>{!s&&t&&n&&a("/profile?setup=true")},[t,s,n,a]);const f=async()=>{if(!o.trim()){he.error("Please enter a brokerage name");return}const{data:g}=await H.auth.getSession(),b=g.session;if(!t||!b){he.error("Please sign in again to create your brokerage."),a("/auth");return}c(!0);try{console.log("[SetupBrokerage] Creating brokerage…",{hasUser:!!t,hasSession:!!b,userId:t==null?void 0:t.id});const{data:_,error:j}=await H.functions.invoke("create-brokerage",{body:{name:o.trim()}});if(console.log("[SetupBrokerage] create-brokerage response",{data:_,error:j}),j)throw j;if(!(_!=null&&_.ok))throw new Error((_==null?void 0:_.error)||"Failed to create brokerage");c(!1),p(!0),he.success("Brokerage created! Setting up your account..."),setTimeout(()=>{a("/profile?setup=true")},2e3)}catch(_){console.error("Error creating brokerage:",_),he.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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Dt,{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(ws,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx(zt,{className:"text-2xl",children:"Setting Up Your Brokerage"}),e.jsx(xr,{className:"text-lg",children:"We're assigning you as the brokerage manager and preparing your dashboard..."})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[e.jsx(xi,{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(ws,{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(Pe,{className:"max-w-lg w-full",children:[e.jsxs(Dt,{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(wa,{className:"w-10 h-10 text-primary"})}),e.jsx(zt,{className:"text-2xl",children:"Set Up Your Brokerage"}),e.jsx(xr,{className:"text-lg",children:"Create your brokerage to start managing your team"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(mr,{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(xi,{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(xi,{className:"w-4 h-4 text-green-500"}),"Access exclusive brokerage resources"]}),e.jsxs("li",{className:"flex items-center gap-2",children:[e.jsx(xi,{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(xi,{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(fi,{className:"w-4 h-4 ml-2"})]})]})]})})},dIe=()=>{const t=pr(),[s,r]=k.useState("verifying"),[n,a]=k.useState("");k.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{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(zt,{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(xr,{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(Re,{children:e.jsx(K,{onClick:o,className:"w-full",children:"Go to Login"})})]})})},HPt=()=>{const t=pr(),[s]=qc(),[r,n]=k.useState(s.get("code")||""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[C,M]=k.useState(null),[I,L]=k.useState(null),[R,q]=k.useState(null),[U,B]=k.useState(null);k.useEffect(()=>{const te=s.get("code");te&&(n(te),V(te))},[s]);const V=async te=>{j(!0);const{data:X,error:ce}=await H.from("invite_codes").select("id, code, max_uses, uses_count, expires_at, is_active, brokerage_id, trial_days").eq("code",te.toUpperCase().trim()).single();if(ce||!X){he.error("Invalid invite code"),j(!1);return}if(!X.is_active){he.error("This invite code is no longer active"),j(!1);return}if(X.max_uses&&X.uses_count>=X.max_uses){he.error("This invite code has reached its maximum uses"),j(!1);return}if(X.expires_at&&new Date(X.expires_at){te.preventDefault(),V(r)},J=async te=>{var X;if(te.preventDefault(),!c.trim()){he.error("Please enter your name");return}if(l.length<6){he.error("Password must be at least 6 characters");return}b(!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")?he.error("This email is already registered. Please sign in instead."):he.error(re.message);return}ne.user&&(await H.rpc("add_default_signup_tag",{user_id:ne.user.id}),I?await H.functions.invoke("assign-brokerage",{body:{userId:ne.user.id,brokerageId:I}}):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}}),C&&await H.from("invite_codes").update({uses_count:((X=(await H.from("invite_codes").select("uses_count").eq("id",C).single()).data)==null?void 0:X.uses_count)+1}).eq("id",C),he.success("Account created! You can now access the dashboard."),t("/dashboard"))}catch(ce){console.error("Signup error:",ce),he.error("An unexpected error occurred")}finally{b(!1)}};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background p-4",children:e.jsxs(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[e.jsx(zt,{className:"text-2xl font-bold text-primary",children:R?`Join ${R}`:"Join LevelUp"}),e.jsx(xr,{children:w?R?`Create your account to join ${R}`:"Create your account to get started":"Enter your invite code to continue"})]}),e.jsx(Re,{children:w?e.jsxs("form",{onSubmit:J,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Full Name"}),e.jsx(ze,{id:"name",type:"text",placeholder:"John Doe",value:c,onChange:te=>u(te.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:a,onChange:te=>o(te.target.value),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"password",children:"Password"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"password",type:p?"text":"password",placeholder:"••••••••",value:l,onChange:te=>i(te.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(qn,{className:"h-4 w-4"})})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:g,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating Account..."]}):"Create Account"})]}):e.jsxs("form",{onSubmit:Y,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"inviteCode",children:"Invite Code"}),e.jsx(ze,{id:"inviteCode",type:"text",placeholder:"Enter your invite code",value:r,onChange:te=>n(te.target.value),required:!0,autoFocus:!0})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:_,children:_?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Verifying..."]}):"Verify Code"})]})})]})})},WPt="/assets/testimonial-avatar-1-BsCQFauB.jpg",GPt="/assets/testimonial-avatar-2-B6VPVc2t.jpg",KPt="/assets/testimonial-avatar-3-GuEFwYUE.jpg",ZPt="/assets/testimonial-avatar-4-98iKMtkB.jpg",YPt="/assets/testimonial-avatar-5-ZsZfyxMX.jpg",XPt=[WPt,GPt,KPt,ZPt,YPt],QPt=hC({name:pc().trim().min(2,"Name must be at least 2 characters").max(100),email:pc().trim().email("Please enter a valid email address").max(255),phone:pc().trim().min(10,"Please enter a valid phone number").max(20).optional().or(Coe("")),brokerage:pc().trim().max(200).optional().or(Coe(""))}),JPt=[{icon:mp,title:"Academy Training",description:"Access a library of on-demand video training covering lead generation, marketing, technology, and more."},{icon:sc,title:"300+ Templates",description:"Professional Canva templates for social media, flyers, postcards, and marketing materials."},{icon:cn,title:"Live Events",description:"Weekly live training sessions, workshops, and Q&A events with industry experts."},{icon:zc,title:"Agent Community",description:"Connect with fellow agents, share wins, ask questions, and network in our private community."},{icon:En,title:"Resource Kits",description:"Downloadable toolkits with scripts, checklists, guides, and everything you need to close more deals."},{icon:No,title:"Social Swag",description:"Fresh social media content and designs updated regularly to help you stand out online."}],eIt=[{icon:mr,title:"Contact Management",description:"Organize your sphere into relationship tiers—Top 25, Past Clients, Referral Partners, and more."},{icon:un,title:"Smart TouchPlans",description:"Automated action plans that tell you exactly who to contact and how, based on relationship type."},{icon:Un,title:"One-Tap Actions",description:"Call, text, or email contacts directly with pre-written scripts tailored to each relationship."},{icon:Sh,title:"Birthday Alerts",description:"Never miss an important date—get reminders for birthdays and home anniversaries."},{icon:Ba,title:"Pop-by Map",description:"See all your contacts on a map and plan efficient pop-by routes in your area."},{icon:Ro,title:"Momentum Tracking",description:"Track your touch streaks, weekly goals, and relationship health scores."},{icon:ii,title:"Relationship Health",description:"Visual dashboard showing which contacts need attention based on last touch date."},{icon:Fm,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."}],sIt=()=>{const t=pr(),[s,r]=k.useState(!1),[n,a]=k.useState({name:"",email:"",phone:"",brokerage:""}),[o,l]=k.useState({}),i=async c=>{var p,f;c.preventDefault(),l({});const u=QPt.safeParse(n);if(!u.success){const g={};u.error.errors.forEach(b=>{b.path[0]&&(g[b.path[0]]=b.message)}),l(g);return}r(!0);try{const{data:g,error:b}=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(b){console.error("Trial signup error:",b),he.error(b.message||"Something went wrong. Please try again.");return}if(g!=null&&g.error){he.error(g.error);return}he.success("🎉 Welcome aboard! Check your email to claim your account."),t("/trial/success")}catch(g){console.error("Trial signup error:",g),he.error("Something went wrong. Please try again.")}finally{r(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(rd,{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:zoe,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(un,{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(la,{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(la,{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:XPt.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(Pe,{className:"bg-white shadow-2xl border-0",children:e.jsxs(Re,{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(p0,{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(ye,{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(ye,{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(ye,{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(ye,{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(ws,{className:"mr-2 h-5 w-5 animate-spin"}),"Creating Your Account..."]}):e.jsxs(e.Fragment,{children:["Start My Free Trial",e.jsx(fi,{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:JPt.map((c,u)=>e.jsxs(Pe,{className:"group relative overflow-hidden border hover:border-[#4a6b6d]/50 transition-all duration-300 hover:shadow-lg bg-background",children:[e.jsxs(Dt,{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(zt,{className:"text-xl font-sans",children:c.title})]}),e.jsx(Re,{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(un,{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:eIt.map((c,u)=>e.jsxs(Pe,{className:"group relative overflow-hidden border-0 bg-white/10 backdrop-blur-sm hover:bg-white/20 transition-all duration-300",children:[e.jsxs(Dt,{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(zt,{className:"text-lg font-semibold text-white",children:c.title})]}),e.jsx(Re,{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(Pe,{className:"border hover:shadow-lg transition-shadow",children:e.jsxs(Re,{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(Th,{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(Fm,{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(mr,{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(Pe,{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(Re,{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(fi,{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:aje,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."})]})})})]})]})},rIt=()=>{const t=pr();return e.jsxs(e.Fragment,{children:[e.jsx(rd,{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:zoe,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(Pe,{className:"max-w-lg w-full bg-white shadow-2xl border-0",children:e.jsxs(Re,{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(la,{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(tu,{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(dr,{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(fi,{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:aje,alt:"LevelUp",className:"h-8"}),e.jsxs("p",{className:"text-sm text-white/40",children:["© ",new Date().getFullYear()," LevelUp Consulting Group. All rights reserved."]})]})})})]})]})},nIt=hC({viewerName:pc().min(1,"Name is required").max(100,"Name must be less than 100 characters"),viewerEmail:pc().email("Please enter a valid email").max(255,"Email must be less than 255 characters"),viewerPhone:pc().max(20,"Phone must be less than 20 characters").optional(),message:pc().min(1,"Message is required").max(1e3,"Message must be less than 1000 characters")});function aIt({shareToken:t,agentName:s,hasContact:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),u=due({resolver:uue(nIt),defaultValues:{viewerName:"",viewerEmail:"",viewerPhone:"",message:""}}),p=async f=>{a(!0),c(null);try{const{data:g,error:b}=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(b)throw new Error(b.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(Pe,{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10",children:e.jsxs(Re,{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(la,{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(Pe,{children:[e.jsxs(Dt,{className:"pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(zc,{className:"h-5 w-5 text-primary"}),e.jsx(zt,{className:"text-lg",children:"Reply to this video"})]}),e.jsx(xr,{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(Re,{children:e.jsx(hue,{...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(Wc,{control:u.control,name:"viewerName",render:({field:f})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Your Name *"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"John Smith",...f})}),e.jsx(km,{})]})}),e.jsx(Wc,{control:u.control,name:"viewerEmail",render:({field:f})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Email *"}),e.jsx(Pc,{children:e.jsx(ze,{type:"email",placeholder:"john@example.com",...f})}),e.jsx(km,{})]})})]}),!r&&e.jsx(Wc,{control:u.control,name:"viewerPhone",render:({field:f})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Phone (optional)"}),e.jsx(Pc,{children:e.jsx(ze,{type:"tel",placeholder:"(555) 123-4567",...f})}),e.jsx(km,{})]})}),e.jsx(Wc,{control:u.control,name:"message",render:({field:f})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Message *"}),e.jsx(Pc,{children:e.jsx(Er,{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(km,{})]})}),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(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{className:"h-4 w-4"}),"Send Message"]})})]})})})]})}const iIt=()=>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(r1,{className:"absolute bottom-[20%] right-[10%] w-12 h-12 text-blue-600/15 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-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(un,{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(un,{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(r1,{className:"absolute top-[8%] left-[5%] w-10 h-10 text-red-500/20 rotate-12"})]}),lIt=()=>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(Vg,{className:"w-20 h-20 text-pink-400 rotate-12"})}),e.jsx("div",{className:"absolute top-[2%] right-[8%] opacity-15",children:e.jsx(Vg,{className:"w-16 h-16 text-rose-400 -rotate-12"})}),e.jsx("div",{className:"absolute bottom-[15%] left-[8%] opacity-15",children:e.jsx(Vg,{className:"w-14 h-14 text-purple-400 rotate-45"})}),e.jsx("div",{className:"absolute bottom-[20%] right-[5%] opacity-20",children:e.jsx(Vg,{className:"w-16 h-16 text-pink-300 -rotate-6"})}),e.jsx(ii,{className:"absolute top-[15%] left-[30%] w-5 h-5 text-rose-300/40 fill-rose-300/20 animate-pulse"}),e.jsx(ii,{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(ii,{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"})]}),cIt=()=>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(bc,{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(bc,{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"}})]}),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-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(Vg,{className:"absolute top-[20%] left-[32%] w-7 h-7 text-purple-400/30"}),e.jsx(Vg,{className:"absolute top-[12%] right-[28%] w-6 h-6 text-pink-400/30"}),e.jsx(jM,{className:"absolute top-[18%] left-[52%] w-5 h-5 text-sky-400/35"})]}),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-orange-900/12 via-purple-900/8 to-slate-900/12"}),e.jsx(X4,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-orange-400/25"}),e.jsx(X4,{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(un,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-purple-400/35 animate-pulse"}),e.jsx(un,{className:"absolute bottom-[28%] right-[25%] w-5 h-5 text-orange-400/30 animate-pulse",style:{animationDelay:"0.5s"}})]}),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-red-900/8 via-green-900/5 to-emerald-900/8"}),e.jsx(m1,{className:"absolute bottom-[8%] left-[5%] w-20 h-20 text-green-600/18"}),e.jsx(m1,{className:"absolute bottom-[12%] right-[8%] w-16 h-16 text-emerald-600/15"}),e.jsx(m1,{className:"absolute bottom-[10%] left-[28%] w-12 h-12 text-green-500/12"}),e.jsx(r0,{className:"absolute top-[5%] left-[15%] w-10 h-10 text-sky-300/30 animate-pulse"}),e.jsx(r0,{className:"absolute top-[10%] right-[20%] w-8 h-8 text-blue-300/25 animate-pulse",style:{animationDelay:"0.3s"}}),e.jsx(r0,{className:"absolute top-[18%] left-[45%] w-6 h-6 text-sky-200/25 animate-pulse",style:{animationDelay:"0.6s"}}),e.jsx(r0,{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"})]}),mIt=()=>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(ii,{className:"absolute top-[8%] left-[55%] w-6 h-6 text-red-400/22 fill-red-400/12"}),e.jsx(ii,{className:"absolute top-[20%] right-[25%] w-5 h-5 text-orange-400/22 fill-orange-400/12"})]}),pIt=()=>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(un,{className:"absolute top-[3%] left-[50%] w-10 h-10 text-yellow-400/40"}),e.jsx(tu,{className:"absolute bottom-[18%] left-[10%] w-12 h-12 text-purple-400/18 rotate-12"}),e.jsx(tu,{className:"absolute bottom-[20%] right-[12%] w-10 h-10 text-amber-400/15 -rotate-12"})]}),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-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(un,{className:"absolute top-[5%] left-[20%] w-7 h-7 text-blue-400/35"}),e.jsx(un,{className:"absolute top-[10%] right-[18%] w-6 h-6 text-sky-400/30"})]}),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-green-900/12 via-emerald-900/6 to-teal-900/10"}),e.jsx(Gv,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-green-500/25"}),e.jsx(Gv,{className:"absolute top-[8%] right-[12%] w-12 h-12 text-emerald-500/20"}),e.jsx(Gv,{className:"absolute bottom-[18%] left-[12%] w-14 h-14 text-green-400/22"}),e.jsx(Gv,{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"})]})]})]}),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-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(bc,{className:"absolute bottom-[20%] right-[12%] w-12 h-12 text-blue-500/18"}),e.jsx(bc,{className:"absolute top-[18%] left-[28%] w-8 h-8 text-indigo-400/15"}),e.jsx(r1,{className:"absolute top-[8%] left-[60%] w-10 h-10 text-indigo-400/18"})]}),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-amber-900/6 via-rose-900/6 to-purple-900/6"}),e.jsx(Sh,{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(tu,{className:"absolute top-[8%] left-[45%] w-10 h-10 text-purple-400/22 rotate-12"}),e.jsx(No,{className:"absolute bottom-[18%] right-[15%] w-12 h-12 text-rose-400/18"})]}),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-rose-900/12 via-pink-900/8 to-red-900/12"}),e.jsx(ii,{className:"absolute top-[5%] left-[10%] w-16 h-16 text-rose-400/28 fill-rose-400/18"}),e.jsx(ii,{className:"absolute top-[8%] right-[12%] w-14 h-14 text-pink-400/25 fill-pink-400/15"}),e.jsx(ii,{className:"absolute bottom-[15%] left-[12%] w-12 h-12 text-red-400/22 fill-red-400/12"}),e.jsx(ii,{className:"absolute bottom-[18%] right-[10%] w-13 h-13 text-rose-300/25 fill-rose-300/15"}),e.jsx(ii,{className:"absolute top-[15%] left-[30%] w-6 h-6 text-pink-300/35 fill-pink-300/20 animate-pulse"}),e.jsx(ii,{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(ii,{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(ii,{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"})]}),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-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(h1,{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(h1,{className:"absolute top-[15%] left-[18%] w-10 h-10 text-yellow-400/30"}),e.jsx(un,{className:"absolute top-[10%] left-[42%] w-7 h-7 text-amber-400/35"}),e.jsx(h1,{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"})]}),_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-teal-900/10 via-cyan-900/6 to-emerald-900/10"}),e.jsx(Sn,{className:"absolute top-[8%] left-[10%] w-14 h-14 text-teal-500/22"}),e.jsx(Sn,{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(ii,{className:"absolute top-[18%] left-[40%] w-6 h-6 text-rose-400/22 fill-rose-400/12"}),e.jsx(ii,{className:"absolute top-[22%] right-[35%] w-5 h-5 text-teal-400/20 fill-teal-400/10"}),e.jsx(un,{className:"absolute top-[5%] left-[55%] w-8 h-8 text-teal-400/30"}),e.jsx(tu,{className:"absolute bottom-[20%] left-[48%] w-10 h-10 text-cyan-400/18 rotate-12"})]}),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-emerald-900/10 via-teal-900/6 to-cyan-900/10"}),e.jsx(tu,{className:"absolute top-[5%] left-[12%] w-14 h-14 text-emerald-400/25 rotate-12"}),e.jsx(tu,{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(Sn,{className:"absolute bottom-[15%] right-[12%] w-14 h-14 text-teal-500/18"}),e.jsx(un,{className:"absolute top-[15%] left-[42%] w-10 h-10 text-emerald-400/35"}),e.jsx(un,{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"})]}),jIt=()=>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(Sn,{className:"absolute top-[8%] left-[42%] w-12 h-12 text-teal-500/18"}),e.jsx(tu,{className:"absolute bottom-[22%] right-[18%] w-12 h-12 text-orange-400/18 rotate-12"}),e.jsx(un,{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"})]}),NIt=()=>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(Sn,{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(ii,{className:"absolute top-[8%] left-[18%] w-8 h-8 text-rose-400/25 fill-rose-400/15"}),e.jsx(un,{className:"absolute top-[12%] left-[45%] w-8 h-8 text-teal-400/30"}),e.jsx(t1,{className:"absolute top-[15%] right-[28%] w-10 h-10 text-emerald-400/20"})]}),uIe=()=>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"})]}),kIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(ii,{className:"absolute top-6 left-[12%] w-4 h-4 text-rose-300/50 fill-rose-300/30 animate-pulse"}),e.jsx(ii,{className:"absolute top-10 right-[18%] w-3 h-3 text-pink-300/50 fill-pink-300/30 animate-pulse delay-150"}),e.jsx(ii,{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(ii,{className:"absolute top-14 right-[35%] w-3.5 h-3.5 text-pink-300/40 fill-pink-300/20 animate-pulse delay-200"})]}),SIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(t1,{className:"absolute top-5 left-[10%] w-4 h-4 text-blue-400/50 animate-pulse"}),e.jsx(un,{className:"absolute top-10 right-[15%] w-3 h-3 text-amber-400/50 animate-pulse delay-100"}),e.jsx(Sn,{className:"absolute top-8 left-[38%] w-3 h-3 text-teal-300/40 animate-pulse delay-200"})]}),CIt=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Z4,{className:"absolute top-5 left-[12%] w-4 h-4 text-amber-500/50 animate-pulse"}),e.jsx(LM,{className:"absolute top-10 right-[15%] w-3 h-3 text-rose-400/50 animate-pulse delay-100"}),e.jsx(Z4,{className:"absolute top-8 left-[40%] w-3 h-3 text-amber-400/40 animate-pulse delay-200"})]}),GP=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(un,{className:"absolute top-5 left-[10%] w-4 h-4 text-emerald-400/50 animate-pulse"}),e.jsx(tu,{className:"absolute top-10 right-[12%] w-5 h-5 text-amber-400/50 animate-pulse delay-150"}),e.jsx(un,{className:"absolute top-8 left-[45%] w-3 h-3 text-sky-400/40 animate-pulse delay-300"})]}),hIe=()=>e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx(Sn,{className:"absolute top-6 left-[12%] w-4 h-4 text-teal-400/40 animate-pulse"}),e.jsx(un,{className:"absolute top-10 right-[15%] w-3 h-3 text-emerald-400/50 animate-pulse delay-100"}),e.jsx(Sn,{className:"absolute top-4 right-[40%] w-3 h-3 text-cyan-400/30 animate-pulse delay-200"})]}),p1e=[{id:"default",name:"Classic",description:"Clean, professional look for any occasion",icon:e.jsx(un,{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(ii,{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(kIt,{})},{id:"thinking_of_you",name:"Thinking of You",description:"Let them know they're on your mind",icon:e.jsx(KI,{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(GP,{})},{id:"check_in",name:"Check-in",description:"Touch base with your contacts",icon:e.jsx(Z4,{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(CIt,{})},{id:"market_update",name:"Market Update",description:"Share real estate market insights",icon:e.jsx(Ro,{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(mr,{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(GP,{})},{id:"congratulations",name:"Congratulations",description:"Celebrate their achievements",icon:e.jsx(bc,{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(uIe,{})},{id:"welcome_neighborhood",name:"Welcome to the Neighborhood",description:"Greet new neighbors",icon:e.jsx(Ba,{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(hIe,{})},{id:"just_because",name:"Just Because",description:"No reason needed to connect",icon:e.jsx(LM,{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(GP,{})},{id:"birthday",name:"Birthday",description:"Celebrate their special day",icon:e.jsx(Sh,{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(yIt,{})},{id:"valentines_day",name:"Valentine's Day",description:"Show appreciation on this special day",icon:e.jsx(ii,{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(vIt,{})},{id:"groundhog_day",name:"Groundhog Day",description:"A fun seasonal greeting",icon:e.jsx(h1,{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(bIt,{})},{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(pIt,{})},{id:"easter",name:"Easter",description:"Celebrate the spring season",icon:e.jsx(jM,{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(dIt,{})},{id:"mothers_day",name:"Mother's Day",description:"Celebrate the amazing moms",icon:e.jsx(Vg,{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(lIt,{})},{id:"fathers_day",name:"Father's Day",description:"Celebrate the amazing dads",icon:e.jsx(bc,{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(cIt,{})},{id:"memorial_day",name:"Memorial Day",description:"Honor those who served",icon:e.jsx(r1,{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(iIt,{})},{id:"independence_day",name:"4th of July",description:"Celebrate Independence Day",icon:e.jsx(Qu,{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(oIt,{})},{id:"labor_day",name:"Labor Day",description:"Celebrate the workers",icon:e.jsx(bc,{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(gIt,{})},{id:"halloween",name:"Halloween",description:"Spooky seasonal greetings",icon:e.jsx(X4,{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(uIt,{})},{id:"thanksgiving",name:"Thanksgiving",description:"Express gratitude this season",icon:e.jsx(ii,{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(mIt,{})},{id:"christmas",name:"Christmas",description:"Spread holiday cheer",icon:e.jsx(m1,{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(hIt,{})},{id:"hanukkah",name:"Hanukkah",description:"Celebrate the Festival of Lights",icon:e.jsx(un,{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(fIt,{})},{id:"st_patricks_day",name:"St. Patrick's Day",description:"Celebrate the luck of the Irish",icon:e.jsx(Gv,{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(xIt,{})},{id:"home_anniversary",name:"Home Anniversary",description:"Celebrate their home ownership milestone",icon:e.jsx(Sn,{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(_It,{})},{id:"under_contract",name:"Under Contract",description:"Celebrate this exciting milestone",icon:e.jsx(tu,{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(wIt,{})},{id:"just_listed",name:"Just Listed",description:"Announce a new listing",icon:e.jsx(cn,{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(hIe,{})},{id:"just_sold",name:"Just Sold",description:"Celebrate a successful sale",icon:e.jsx(wc,{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(GP,{})},{id:"price_reduction",name:"Price Reduction",description:"Notify about a price change",icon:e.jsx(cS,{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(t1,{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(SIt,{})},{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(jIt,{})},{id:"move_in_day",name:"Move-in Day",description:"Welcome them to their new home",icon:e.jsx(Sn,{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(NIt,{})},{id:"offer_accepted",name:"Offer Accepted",description:"Celebrate their accepted offer",icon:e.jsx(eh,{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(GP,{})},{id:"pre_approval",name:"Pre-Approval Congrats",description:"Congratulate on pre-approval",icon:e.jsx(bc,{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(uIe,{})}],MIt=[{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 TIt(t){return p1e.filter(s=>s.category===t)}function YM(t){return p1e.find(s=>s.id===t)||p1e[0]}function mIe(){const{shareToken:t,recipientToken:s}=yo(),[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(null),[c,u]=k.useState(!0),[p,f]=k.useState(null),[g,b]=k.useState(!0),_=k.useRef(null),j=k.useRef(0),w=k.useRef(0),N=(()=>{const J=new URLSearchParams(window.location.search);return s||J.get("rt")||null})(),C=k.useCallback((J,te=!1)=>{if(!N||J<=0)return;const X=Math.max(1,Math.round(J));if(X<=w.current)return;const ne=`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${encodeURIComponent(N)}&e=watch&ws=${X}`;te&&navigator.sendBeacon?navigator.sendBeacon(ne):fetch(ne,{method:"GET",keepalive:te}).catch(()=>{}),w.current=Math.max(w.current,X)},[N]);k.useEffect(()=>{var le;if(!g||!(r!=null&&r.playback_url)||!N)return;let J=!1;const te=()=>{j.current>0&&C(j.current,!0)},X=()=>{document.visibilityState==="hidden"&&te()},ce=()=>{te()},ne=()=>{var xe;if(J||!_.current||!((xe=window.playerjs)!=null&&xe.Player))return;const pe=new window.playerjs.Player(_.current);pe.on("timeupdate",_e=>{const fe=Math.floor(Number((_e==null?void 0:_e.seconds)??0));!Number.isFinite(fe)||fe<=0||(j.current=Math.max(j.current,fe))}),pe.on("pause",()=>{j.current>0&&C(j.current)}),pe.on("ended",()=>{j.current>0&&C(j.current,!0)})},re=document.querySelector('script[data-bunny-playerjs="true"]');if((le=window.playerjs)!=null&&le.Player)ne();else if(re)re.addEventListener("load",ne,{once:!0});else{const pe=document.createElement("script");pe.src="https://assets.mediadelivery.net/playerjs/playerjs-latest.min.js",pe.async=!0,pe.defer=!0,pe.dataset.bunnyPlayerjs="true",pe.onload=ne,document.body.appendChild(pe)}return document.addEventListener("visibilitychange",X),window.addEventListener("beforeunload",ce),()=>{J=!0,document.removeEventListener("visibilitychange",X),window.removeEventListener("beforeunload",ce),te()}},[g,r==null?void 0:r.playback_url,N,C]),k.useEffect(()=>{j.current=0,w.current=0},[N,t]),k.useEffect(()=>{const J=()=>{['[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"})})};J();const te=[setTimeout(J,500),setTimeout(J,1500),setTimeout(J,3e3)],X=new MutationObserver(J);return X.observe(document.body,{childList:!0,subtree:!0}),()=>{te.forEach(clearTimeout),X.disconnect()}},[]),k.useEffect(()=>{(async()=>{if(!t){f("Invalid share link"),u(!1);return}const{data:te,error:X}=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(X||!te){f("Video not found or has been removed"),u(!1);return}n(te);try{await H.rpc("log_video_view",{p_video_id:te.id,p_user_agent:navigator.userAgent,p_referrer:document.referrer||null})}catch(ce){console.warn("Failed to log video view:",ce)}if(te.owner_user_id){const{data:ce}=await H.from("profiles").select("id, name, email, phone").eq("id",te.owner_user_id).single();if(ce){o(ce);try{const{data:ne}=await H.storage.from("avatars").list(`${te.owner_user_id}`);if(ne&&ne.length>0){const{data:re}=H.storage.from("avatars").getPublicUrl(`${te.owner_user_id}/${ne[0].name}`);i(re.publicUrl)}}catch{}}}u(!1)})()},[t]);const M=J=>{if(!J)return"0:00";const te=Math.floor(J/60),X=J%60;return`${te}:${X.toString().padStart(2,"0")}`},I=J=>J.includes("iframe.mediadelivery.net/play/")?J.replace("/play/","/embed/")+"?autoplay=true&responsive=true":J,L=J=>{if(!J)return"?";const te=J.split(" ");return te.length>=2?`${te[0][0]}${te[1][0]}`.toUpperCase():J.substring(0,2).toUpperCase()},R=YM((r==null?void 0:r.page_template)||"default"),q=(r==null?void 0:r.recipient_name)||null,U=R.headerText(q),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(ws,{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(Pe,{className:"max-w-md w-full",children:e.jsxs(Re,{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 Y=R.id!=="default";return e.jsxs(e.Fragment,{children:[e.jsxs(rd,{children:[e.jsx("title",{children:U}),e.jsx("meta",{name:"description",content:R.subText}),e.jsx("meta",{property:"og:title",content:U}),e.jsx("meta",{property:"og:description",content:R.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:R.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:Pt("min-h-screen flex items-center justify-center p-4 bg-gradient-to-b relative",R.gradientClasses),children:[Y&&R.decorativeElement,e.jsxs("div",{className:"max-w-2xl w-full space-y-6 relative z-10",children:[Y&&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:Pt("w-14 h-14 rounded-full flex items-center justify-center shadow-sm",R.accentColor==="primary"&&"bg-primary/10 text-primary",R.accentColor==="amber"&&"bg-amber-100 text-amber-600 dark:bg-amber-900/50 dark:text-amber-400",R.accentColor==="teal"&&"bg-teal-100 text-teal-600 dark:bg-teal-900/50 dark:text-teal-400",R.accentColor==="rose"&&"bg-rose-100 text-rose-600 dark:bg-rose-900/50 dark:text-rose-400",R.accentColor==="emerald"&&"bg-emerald-100 text-emerald-600 dark:bg-emerald-900/50 dark:text-emerald-400",R.accentColor==="yellow"&&"bg-yellow-100 text-yellow-600 dark:bg-yellow-900/50 dark:text-yellow-400",R.accentColor==="pink"&&"bg-pink-100 text-pink-600 dark:bg-pink-900/50 dark:text-pink-400",R.accentColor==="blue"&&"bg-blue-100 text-blue-600 dark:bg-blue-900/50 dark:text-blue-400",R.accentColor==="red"&&"bg-red-100 text-red-600 dark:bg-red-900/50 dark:text-red-400",R.accentColor==="orange"&&"bg-orange-100 text-orange-600 dark:bg-orange-900/50 dark:text-orange-400",R.accentColor==="green"&&"bg-green-100 text-green-600 dark:bg-green-900/50 dark:text-green-400",R.accentColor==="violet"&&"bg-violet-100 text-violet-600 dark:bg-violet-900/50 dark:text-violet-400",R.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:R.icon})})}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold mb-2",children:U}),e.jsx("p",{className:"text-muted-foreground",children:R.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(_n,{className:"h-14 w-14 border-2 border-primary/20",children:[e.jsx(za,{src:l||void 0,alt:a.name||"Agent"}),e.jsx(wn,{className:"bg-primary/10 text-primary font-semibold",children:L(a.name)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:Y?"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(Un,{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(dr,{className:"h-4 w-4"})})})]})]}),e.jsx(Pe,{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:I(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:()=>b(!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:J=>{var X;J.currentTarget.style.display="none";const te=(X=J.currentTarget.parentElement)==null?void 0:X.querySelector(".video-fallback");te&&(te.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(rl,{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)})]})}),!Y&&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:()=>b(!0),className:"gap-2",children:[e.jsx(rl,{className:"h-5 w-5"}),"Watch Video"]})}),e.jsx(aIt,{shareToken:t,agentName:(a==null?void 0:a.name)||null,hasContact:!!r.contact_id})]})]})]})}function AIt(){return k.useEffect(()=>(document.body.classList.add("video-landing-page"),()=>{document.body.classList.remove("video-landing-page")}),[]),e.jsx(s1t,{})}function EIt(){const{token:t}=yo();return k.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(ws,{className:"h-5 w-5 animate-spin"}),e.jsx("span",{children:"Loading video preview…"})]})})}const PIt={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},IIt={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},g5={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function LIt(){var X,ce,ne,re;const{slugOrId:t}=yo(),[s]=qc(),{data:r,isLoading:n}=ZWe(t||""),a=YWe(),o=GNt(),l=s.get("ref"),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!1),[M,I]=k.useState(null),[L,R]=k.useState(!1);k.useEffect(()=>{l&&o.mutate(l)},[l]);const q=le=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(le),U=async le=>{if(le.preventDefault(),!(!i.trim()||!f.trim()||!r)){w(!0);try{await a.mutateAsync({listingId:r.id,agentId:r.agent_id,firstName:i.trim(),lastName:u.trim(),email:f.trim(),phone:b.trim(),shareToken:l}),C(!0),he.success("Thanks! The agent will be in touch soon.")}catch(pe){console.error("Lead submission error:",pe),he.error(`Failed to submit: ${pe.message||"Please try again"}`)}finally{w(!1)}}},B=(r==null?void 0:r.photos)||[],V=B.find(le=>le.is_primary)||B[0],Y=()=>{M!==null&&I(M===0?B.length-1:M-1)},J=()=>{M!==null&&I(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(Ei,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:boe,alt:"LevelUp",className:"h-8"})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx(Sn,{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(Ei,{to:"/public/listings",children:"Browse All Listings"})})]})]});const te=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(rd,{children:[e.jsxs("title",{children:[te," | LevelUp Listings"]}),e.jsx("meta",{name:"description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${r.square_footage?r.square_footage.toLocaleString()+" sqft":""} ${g5[r.property_type]} in ${r.city}, ${r.state}. ${((X=r.description)==null?void 0:X.slice(0,150))||""}`}),e.jsx("link",{rel:"canonical",href:`https://listings.relevelup.com/${r.slug||r.id}`}),e.jsx("meta",{property:"og:title",content:te}),e.jsx("meta",{property:"og:description",content:`${q(r.price)} - ${r.bedrooms||""}BD ${r.bathrooms||""}BA ${g5[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} - ${g5[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:te}),e.jsx("meta",{name:"twitter:description",content:`${q(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||`${g5[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(le=>le.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(Ei,{to:"/public/listings",className:"flex items-center gap-2",children:e.jsx("img",{src:boe,alt:"LevelUp",className:"h-8"})})})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsxs(Ei,{to:"/public/listings",className:"inline-flex items-center text-muted-foreground hover:text-foreground mb-6",children:[e.jsx(ri,{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:()=>I(0),children:e.jsx("img",{src:V==null?void 0:V.photo_url,alt:`${r.property_address||r.city+", "+r.state} - ${g5[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((le,pe)=>e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer relative",onClick:()=>I(pe+1),children:[e.jsx("img",{src:le.photo_url,alt:`${r.property_address||r.city} - Photo ${pe+2} of ${B.length}`,className:"w-full h-full object-cover hover:scale-105 transition-transform duration-300"}),pe===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"]})]},le.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(tt,{className:`${PIt[r.status]} text-white border-0`,children:IIt[r.status]})}),e.jsx("h1",{className:"text-4xl font-bold text-primary mb-2",children:q(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(Ba,{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(Np,{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(Nh,{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(x0,{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(cn,{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(tt,{variant:"secondary",children:[e.jsx(wa,{className:"h-3 w-3 mr-1"}),g5[r.property_type]]}),r.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",r.lot_size]}),r.has_hoa&&e.jsx(tt,{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(an,{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(Pe,{className:"overflow-hidden bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:e.jsxs(Re,{className:"p-0",children:[e.jsxs("div",{className:"relative aspect-video bg-muted cursor-pointer group",onClick:()=>R(!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(rl,{className:"h-8 w-8 text-primary fill-primary ml-1"})})})]}),e.jsxs("div",{className:"p-4",children:[e.jsxs(K,{onClick:()=>R(!0),className:"w-full gap-2",size:"lg",children:[e.jsx(rl,{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(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(to,{className:"h-5 w-5"}),"Listing Agent"]})}),e.jsxs(Re,{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(Pe,{className:"border-primary",children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Interested in this property?"})}),e.jsx(Re,{children:N?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(dr,{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(ye,{htmlFor:"firstName",children:"First Name *"}),e.jsx(ze,{id:"firstName",type:"text",placeholder:"John",value:i,onChange:le=>c(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ze,{id:"lastName",type:"text",placeholder:"Doe",value:u,onChange:le=>p(le.target.value)})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email *"}),e.jsx(ze,{id:"email",type:"email",placeholder:"you@example.com",value:f,onChange:le=>g(le.target.value),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"(555) 123-4567",value:b,onChange:le=>_(le.target.value)})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:j,children:j?"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:()=>I(null),children:e.jsxs(fs,{className:"max-w-5xl p-0 bg-black/95",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(bs,{children:"Photo Gallery"})}),e.jsx("button",{onClick:()=>I(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(Or,{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:Y,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(ll,{className:"h-6 w-6"})}),e.jsx("button",{onClick:J,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(xa,{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:L,onOpenChange:R,children:e.jsxs(fs,{className:"max-w-4xl p-0 bg-black overflow-hidden",children:[e.jsx(_s,{className:"sr-only",children:e.jsx(bs,{children:"Video Tour"})}),e.jsx("button",{onClick:()=>R(!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(Or,{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 DIt(){var o;const{slug:t}=yo(),{data:s,isLoading:r,error:n}=eGe(t);if(k.useEffect(()=>(document.body.classList.add("agent-card-page"),()=>{document.body.classList.remove("agent-card-page")}),[]),k.useEffect(()=>{s!=null&&s.id&&fo(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(rd,{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(oje,{card:s})]})}function OYe({slugOverride:t}={}){var Se;const{slug:s}=yo(),r=t||s,[n]=qc(),a=n.get("t"),[o,l]=k.useState(!0),[i,c]=k.useState(null),[u,p]=k.useState(null),f=k.useRef(null),g=k.useRef(null),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,C]=k.useState(!1),[M,I]=k.useState(!1),[L,R]=k.useState(0),[q,U]=k.useState(!1),[B,V]=k.useState(""),[Y,J]=k.useState(""),[te,X]=k.useState(""),[ce,ne]=k.useState(""),[re,le]=k.useState(""),[pe,xe]=k.useState(""),[_e,fe]=k.useState(""),[we,Ie]=k.useState(""),[Ne,Ae]=k.useState(""),[Fe,Ce]=k.useState(""),[Me,$e]=k.useState(""),[ct,Te]=k.useState("");k.useEffect(()=>{ft()},[r,a]);const ft=async()=>{if(!r)return;l(!0);const{data:rt,error:Ge}=await H.from("contact_intake_pages").select("*").eq("slug",r).eq("is_active",!0).maybeSingle();if(Ge||!rt){U(!0),l(!1);return}p(rt),g.current=rt;const{data:lt}=await H.from("profiles").select("name, avatar_url, title, phone, email, brokerage_id").eq("id",rt.user_id).single();if(lt){let qe;if(lt.brokerage_id){const{data:He}=await H.from("brokerages").select("name").eq("id",lt.brokerage_id).single();qe=(He==null?void 0:He.name)||void 0}let Ze=lt.avatar_url||null;if(!Ze){const{data:He}=H.storage.from("avatars").getPublicUrl(`${rt.user_id}/avatar.jpg`);He!=null&&He.publicUrl&&(Ze=`${He.publicUrl}?t=${Date.now()}`)}const Je={...lt,avatar_url:Ze,brokerage_name:qe};c(Je),f.current=Je}if(a)try{console.log("[ConnectPage] Resolving token:",a,"for page:",rt.id);const{data:qe,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:qe,resolveErr:Ze}),!Ze&&(qe!=null&&qe.contact_id)){w(qe.contact_id);const Je=qe.contact;Je&&(_(Je),V(Je.first_name||""),J(Je.last_name||""),X(Je.email||""),ne(Je.phone||""),le(Je.address||""),xe(Je.city||""),fe(Je.state||""),Ie(Je.zip||""),Ae(Je.birthday||""),Ce(Je.home_anniversary||""))}}catch(qe){console.error("Failed to resolve token:",qe)}l(!1)},me=async()=>{var rt,Ge;if(!B.trim()){he.error("Please enter your first name");return}if(!r){he.error("Invalid page. Please refresh.");return}I(!0);try{let lt=(rt=g.current)==null?void 0:rt.id,qe=(Ge=g.current)==null?void 0:Ge.user_id;if(!lt||!qe){const{data:Je}=await H.from("contact_intake_pages").select("id, user_id").eq("slug",r).eq("is_active",!0).maybeSingle();if(!Je){he.error("This page is no longer active. Please contact the agent directly."),I(!1);return}lt=Je.id,qe=Je.user_id}const{error:Ze}=await H.from("contact_intake_submissions").insert({intake_page_id:lt,agent_user_id:qe,existing_contact_id:j,first_name:B.trim(),last_name:Y.trim()||null,email:te.trim()||null,phone:ce.trim()||null,address:re.trim()||null,city:pe.trim()||null,state:_e.trim()||null,zip:we.trim()||null,birthday:Ne||null,home_anniversary:Fe||null,real_estate_interest:Me||null,message:ct.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(),Y.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:qe,contactName:Je,contactEmail:te.trim()||null,contactPhone:ce.trim()||null,slug:r})})}catch(Je){console.warn("Connect page notification failed (non-blocking):",Je)}C(!0)}catch(lt){console.error(lt),he.error("Something went wrong. Please try again.")}finally{I(!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(ws,{className:"h-8 w-8 animate-spin text-slate-400"})});if(q)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(N)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(rd,{children:e.jsxs("title",{children:["Thank You | ",i==null?void 0:i.name]})}),e.jsxs(Ws.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(Ws.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(la,{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(ii,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})]})]});const Ve=!!a&&!!b,nt=3,et=[{title:Ve?"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:Y,onChange:rt=>J(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:te,onChange:rt=>X(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=>le(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:pe,onChange:rt=>xe(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:_e,onChange:rt=>fe(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:we,onChange:rt=>Ie(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:Ne,onChange:rt=>Ae(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:Fe,onChange:rt=>Ce(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:()=>$e(Me===rt.value?"":rt.value),className:`p-3.5 rounded-xl border-2 text-left transition-all ${Me===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:ct,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(rd,{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(Ws.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:((Se=i==null?void 0:i.name)==null?void 0:Se.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(Un,{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(dr,{className:"h-4.5 w-4.5"})})]})]}),e.jsx(Ws.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:nt}).map((rt,Ge)=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-500 ${Ge<=L?"bg-blue-500":"bg-slate-200"}`},Ge))}),e.jsxs(Ws.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(yZe,{mode:"wait",children:e.jsxs(Ws.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(un,{className:"h-5 w-5 text-blue-500"}),e.jsx("h2",{className:"text-lg font-semibold text-slate-800",children:et[L].title})]}),et[L].fields]},L)}),e.jsxs("div",{className:"flex justify-between mt-8",children:[L>0?e.jsx("button",{type:"button",onClick:()=>R(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",{}),L{if(L===0&&!B.trim()){he.error("Please enter your first name");return}R(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:()=>me(),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(ws,{className:"h-4 w-4 animate-spin"}),"Sending..."]}):"Submit"})]}),L>0&&LR(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(ii,{className:"h-3 w-3"}),e.jsx("span",{children:"Powered by ReLevelUp"})]})})]})]})}function KP({banners:t,autoPlayInterval:s=5e3,className:r}){const[n,a]=k.useState(0),[o,l]=k.useState(!1),i=k.useCallback(()=>{a(f=>(f+1)%t.length)},[t.length]),c=k.useCallback(()=>{a(f=>(f-1+t.length)%t.length)},[t.length]),u=k.useCallback(f=>{a(f)},[]);if(k.useEffect(()=>{if(t.length<=1||o)return;const f=setInterval(i,s);return()=>clearInterval(f)},[t.length,o,s,i]),!t||t.length===0)return null;const p=t[n];return e.jsxs("div",{className:Pt("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:p.image_url,alt:p.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:Pt("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:c,children:e.jsx(ll,{className:"h-6 w-6"})}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("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:i,children:e.jsx(xa,{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((f,g)=>e.jsx("button",{onClick:()=>u(g),className:Pt("w-2 h-2 rounded-full transition-all duration-300",g===n?"bg-white w-6":"bg-white/50 hover:bg-white/70"),"aria-label":`Go to slide ${g+1}`},g))})]}),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:p.title}),p.description&&e.jsx("p",{className:"text-xs text-background/70 truncate",children:p.description})]}),p.link_url&&e.jsx("a",{href:p.link_url,target:"_blank",rel:"noopener noreferrer",className:"shrink-0",children:e.jsx(K,{size:"sm",className:"bg-primary text-primary-foreground font-semibold transition-colors hover:bg-background hover:text-foreground",children:p.link_text||"Learn More"})})]})]})}function OIt(t){return"EST"}function rD(t){const r=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"2-digit",hour12:!0,timeZone:"America/New_York"}).format(t),n=OIt();return`${r} ${n}`}function XM(t){const s=new Date,r=new Date(t),n=eM(r,-15),a=eM(r,30);return s>a?"ended":Og(s,{start:r,end:a})?"live":Og(s,{start:n,end:r})?"starting_soon":"upcoming"}function fNe(t){const s=XM(t);return s==="starting_soon"||s==="live"}const pIe=fNe,RIt=({events:t,registrations:s,onNavigateToEvents:r})=>{const[n,a]=k.useState(new Date);k.useEffect(()=>{const b=setInterval(()=>{a(new Date)},3e4);return()=>clearInterval(b)},[]);const o=t.filter(b=>fNe(b.event_date));if(o.length===0)return null;const l=o[0],i=XM(l.event_date),c=s.find(b=>b.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(l1,{className:"h-4 w-4"}),"Live Now"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{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 ${rD(new Date(l.event_date))}`:`Starts at ${rD(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(an,{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(mr,{className:"h-4 w-4"}),"Register & Join"]})})]})})]})};var xNe="Progress",gNe=100,[FIt]=nd(xNe),[zIt,BIt]=FIt(xNe),RYe=k.forwardRef((t,s)=>{const{__scopeProgress:r,value:n=null,max:a,getValueLabel:o=$It,...l}=t;(a||a===0)&&!fIe(a)&&console.error(qIt(`${a}`,"Progress"));const i=fIe(a)?a:gNe;n!==null&&!xIe(n,i)&&console.error(UIt(`${n}`,"Progress"));const c=xIe(n,i)?n:null,u=Hoe(c)?o(c,i):void 0;return e.jsx(zIt,{scope:r,value:c,max:i,children:e.jsx(sn.div,{"aria-valuemax":i,"aria-valuemin":0,"aria-valuenow":Hoe(c)?c:void 0,"aria-valuetext":u,role:"progressbar","data-state":BYe(c,i),"data-value":c??void 0,"data-max":i,...l,ref:s})})});RYe.displayName=xNe;var FYe="ProgressIndicator",zYe=k.forwardRef((t,s)=>{const{__scopeProgress:r,...n}=t,a=BIt(FYe,r);return e.jsx(sn.div,{"data-state":BYe(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...n,ref:s})});zYe.displayName=FYe;function $It(t,s){return`${Math.round(t/s*100)}%`}function BYe(t,s){return t==null?"indeterminate":t===s?"complete":"loading"}function Hoe(t){return typeof t=="number"}function fIe(t){return Hoe(t)&&!isNaN(t)&&t>0}function xIe(t,s){return Hoe(t)&&!isNaN(t)&&t<=s&&t>=0}function qIt(t,s){return`Invalid prop \`max\` of value \`${t}\` supplied to \`${s}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${gNe}\`.`}function UIt(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 ${gNe} if no \`max\` prop is set) - \`null\` or \`undefined\` if the progress is indeterminate. Defaulting to \`null\`.`}var $Ye=RYe,VIt=zYe;const Bi=k.forwardRef(({className:t,value:s,...r},n)=>e.jsx($Ye,{ref:n,className:Pt("relative h-4 w-full overflow-hidden rounded-full bg-secondary",t),...r,children:e.jsx(VIt,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(s||0)}%)`}})}));Bi.displayName=$Ye.displayName;function HIt(){const{user:t,isBrokerageManager:s}=Rs(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState(!1),[c,u]=k.useState(!0),p=s?"brokerage_manager":"agent";k.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:I,error:L}=await H.from("onboarding_checklist_items").select("*").eq("target_role",p).eq("is_active",!0).order("sort_order");if(L)throw L;const{data:R,error:q}=await H.from("onboarding_checklist_progress").select("item_id, completed_at").eq("user_id",t.id);if(q)throw q;const{data:U,error:B}=await H.from("onboarding_checklist_dismissed").select("id").eq("user_id",t.id).maybeSingle();if(B)throw B;n(I||[]),o(R||[]),i(!!U),I&&I.length>0&&await g(I,R||[])}catch(I){console.error("Error fetching checklist data:",I)}finally{u(!1)}},g=async(I,L)=>{var Ce,Me;if(!(t!=null&&t.id))return;const R=L.map($e=>$e.item_id),q=I.filter($e=>!R.includes($e.id));if(q.length===0)return;const[U,B,V,Y,J,te,X,ce,ne,re,le,pe,xe,_e,fe]=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)]),we={},Ie=(Ce=U.data)==null?void 0:Ce.brokerage_id;we.share_resource=(B.count||0)>0,we.post_community=(V.count||0)>0,we.register_event=(Y.count||0)>0,we.view_template=(J.count||0)>0,we.watch_academy=(te.count||0)>0,we.use_toolbox=(X.count||0)>0,we.launch_app=(ce.count||0)>0,we.add_contact=(ne.count||0)>0,we.create_video=(re.count||0)>0,we.complete_touch=(le.count||0)>0,we.add_transaction=(pe.count||0)>0,we.add_listing=(xe.count||0)>0,we.add_deal=(fe.count||0)>0;const Ne=((Me=_e.data)==null?void 0:Me.map($e=>$e.id))||[],Ae=[];Ie?Ae.push(H.from("profiles").select("id").eq("brokerage_id",Ie).neq("id",t.id).then($e=>{var ct;we.add_agent=(((ct=$e.data)==null?void 0:ct.length)||0)>0})):we.add_agent=!1,Ne.length>0?(Ae.push(H.from("contact_plan_cycles").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then($e=>{we.add_plan=($e.count||0)>0})),Ae.push(H.from("contact_popby_settings").select("id",{count:"exact",head:!0}).in("contact_id",Ne).then($e=>{we.schedule_popby=($e.count||0)>0}))):(we.add_plan=!1,we.schedule_popby=!1),await Promise.all(Ae);const Fe=q.filter($e=>we[$e.action_type]);if(Fe.length>0){const $e=Fe.map(Te=>({user_id:t.id,item_id:Te.id})),{error:ct}=await H.from("onboarding_checklist_progress").upsert($e,{onConflict:"user_id,item_id",ignoreDuplicates:!0});if(!ct){const Te=Fe.map(ft=>({item_id:ft.id,completed_at:new Date().toISOString()}));o(ft=>[...ft,...Te])}}},b=async I=>{if(t!=null&&t.id)try{const{error:L}=await H.from("onboarding_checklist_progress").insert({user_id:t.id,item_id:I});if(L)throw L;o(R=>[...R,{item_id:I,completed_at:new Date().toISOString()}])}catch(L){console.error("Error marking item complete:",L)}},_=async()=>{if(t!=null&&t.id)try{const{error:I}=await H.from("onboarding_checklist_dismissed").insert({user_id:t.id});if(I)throw I;i(!0)}catch(I){console.error("Error dismissing checklist:",I)}},j=a.length,w=r.length,N=w>0&&j>=w,C=w>0?j/w*100:0;return{items:r,progress:a,isDismissed:l,loading:c,completedCount:j,totalCount:w,isComplete:N,progressPercentage:C,isItemComplete:I=>a.some(L=>L.item_id===I),markComplete:b,dismiss:_,refetch:f}}const WIt={add_agent:e.jsx(mr,{className:"h-4 w-4"}),share_resource:e.jsx(bd,{className:"h-4 w-4"}),post_community:e.jsx(io,{className:"h-4 w-4"}),register_event:e.jsx(cn,{className:"h-4 w-4"}),view_template:e.jsx(Ov,{className:"h-4 w-4"}),watch_academy:e.jsx(Gh,{className:"h-4 w-4"}),use_toolbox:e.jsx(Jg,{className:"h-4 w-4"}),launch_app:e.jsx(qI,{className:"h-4 w-4"}),add_deal:e.jsx(u0,{className:"h-4 w-4"}),add_listing:e.jsx(Sn,{className:"h-4 w-4"})},GIt={add_deal:"/mission-control/pipeline",add_listing:"/mission-control/listings/new",post_community:"/community",add_contact:"/mission-control/contacts"};function KIt(){const{items:t,isDismissed:s,loading:r,completedCount:n,totalCount:a,isComplete:o,progressPercentage:l,isItemComplete:i,markComplete:c,dismiss:u}=HIt(),p=pr(),[f,g]=k.useState(!0);return r||s||a===0||o?null:e.jsxs(Pe,{className:"mb-6 border-primary/20 bg-gradient-to-r from-primary/5 to-transparent",children:[e.jsxs(Dt,{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(p0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{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(pf,{className:"h-4 w-4"}):e.jsx(To,{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(Or,{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(Re,{className:"pt-0",children:e.jsx("div",{className:"space-y-3",children:t.map(b=>{const _=i(b.id);return e.jsxs("div",{className:Pt("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 j=GIt[b.action_type];j?p(j):c(b.id)},children:[e.jsx("div",{className:"mt-0.5",children:_?e.jsx(la,{className:"h-5 w-5 text-primary"}):e.jsx(vd,{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:WIt[b.action_type]||e.jsx(vd,{className:"h-4 w-4"})}),e.jsx("span",{className:Pt("font-medium",_&&"line-through text-muted-foreground"),children:b.title})]}),b.description&&e.jsx("p",{className:Pt("text-sm text-muted-foreground mt-1",_&&"line-through"),children:b.description})]})]},b.id)})})})]})}const Ux=()=>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=li(),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})},ZIt=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}),qYe=()=>{const t=li();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})},vue=()=>{const t=es(),s=li();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"]}),vn({title:"Contact created successfully"})},onError:r=>{vn({title:"Error creating contact",description:r.message,variant:"destructive"})}})},yNe=()=>{const t=es();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"]}),vn({title:"Contact updated successfully"})},onError:s=>{vn({title:"Error updating contact",description:s.message,variant:"destructive"})}})},UYe=()=>{const t=es();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"]}),vn({title:"Spouse link updated"})},onError:s=>{vn({title:"Error linking spouse",description:s.message,variant:"destructive"})}})},vNe=()=>{const t=es();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"]}),vn({title:"Contact deleted successfully"})},onError:s=>{vn({title:"Error deleting contact",description:s.message,variant:"destructive"})}})},FO=()=>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}}),YIt=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}}),XIt=()=>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}}),QIt=()=>{const t=es(),s=li();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"]}),vn({title:"Plan created successfully"})},onError:r=>{vn({title:"Error creating plan",description:r.message,variant:"destructive"})}})},JIt=()=>{const t=es(),s=li();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"]}),vn({title:"Plan duplicated successfully",description:"You can now edit your copy of this plan."})},onError:r=>{vn({title:"Error duplicating plan",description:r.message,variant:"destructive"})}})},eLt=()=>{const t=es();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"]}),vn({title:"Plan updated successfully"})}})},tLt=()=>{const t=es();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"]}),vn({title:"Plan deleted successfully"})}})},sLt=()=>{const t=es();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"]}),vn({title:"Plan schedule updated"})}})},rLt=()=>{const t=es();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"]}),vn({title:"Script created successfully"})},onError:s=>{vn({title:"Error creating script",description:s.message,variant:"destructive"})}})},nLt=()=>{const t=li();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})},aLt=()=>{const t=es(),s=li();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"]}),vn({title:"Plan enrollment updated"})}})},zO=(t=7)=>{const s=li();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})},VYe=()=>{const t=li();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})},iLt=(t=90)=>{const{data:s}=Wm(),{data:r}=VYe();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=es(),s=li();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"]}),vn({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{}}})},HYe="agentos_weekly_touch_goal",gIe=20,Woe=()=>{if(typeof window>"u")return gIe;const t=localStorage.getItem(HYe);if(t){const s=parseInt(t,10);if(!isNaN(s)&&s>0)return s}return gIe},WYe=t=>{localStorage.setItem(HYe,t.toString())},_Ne=()=>{const{data:t}=zO(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=Woe();return{actionsThisWeek:n,weeklyGoal:o,streak:a,progress:Math.min(n/o*100,100)}},oLt=()=>{const t=li();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})},lLt=()=>{const t=es();return li(),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&&vn({title:`${s} contact(s) enrolled in plans`})}})},GYe=()=>{const t=li(),{data:s}=oLt(),{data:r}=zO(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(j=>j.contact_id))||[]),o=new Date,l=[],i=new Date(o.getFullYear(),o.getMonth(),1),c=new Set((r==null?void 0:r.filter(j=>new Date(j.completed_at)>=i).map(j=>`${j.contact_id}-${j.action_type_id}`))||[]);for(const j of s){if(!((_=j.plan)!=null&&_.items)||j.plan.items.length===0||!j.contact||a.has(j.contact_id))continue;const w=new Date(j.cycle_start_date),C=Math.floor((o.getTime()-w.getTime())/(30.44*24*60*60*1e3))%12+1,M=j.plan.items.find(I=>I.month_number===C);if(M&&M.action_type){const I=`${j.contact_id}-${M.action_type_id}`;if(!c.has(I)){const{data:L}=await H.from("relationship_types").select("name").eq("id",j.relationship_type_id).single();l.push({contact:j.contact,actionType:M.action_type,script:M.default_script||void 0,planName:j.plan.name,relationshipTypeName:(L==null?void 0:L.name)||"",monthNumber:C})}}}const u=5,p=o.getDate(),f=l.sort((j,w)=>j.contact.first_name.localeCompare(w.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 cLt(){const t=pr(),{data:s,isLoading:r}=GYe(),{data:n}=Wm(),a=_Ne(),[o,l]=k.useState(Woe()),[i,c]=k.useState(""),[u,p]=k.useState(!1);k.useEffect(()=>{l(Woe())},[]);const f=()=>{const R=parseInt(i,10);if(isNaN(R)||R<1){vn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}l(R),WYe(R),p(!1),vn({title:"Goal updated",description:`Weekly touch goal set to ${R}`})},g=()=>{c(o.toString()),p(!0)},b=Bm(new Date),_=Tl(b,7),j=R=>{if(!R)return null;const q=R.split(/[-/T]/);if(q.length<3)return null;const U=parseInt(q[1],10)-1,B=parseInt(q[2],10);return isNaN(U)||isNaN(B)?null:new Date(b.getFullYear(),U,B)},w=(n==null?void 0:n.map(R=>{const q=j(R.birthday),U=j(R.home_anniversary),B=[];return q&&q>=b&&q<=_&&B.push({contact:R,type:"birthday",date:q,isToday:Sl(q,b)}),U&&U>=b&&U<=_&&B.push({contact:R,type:"anniversary",date:U,isToday:Sl(U,b)}),B}).flat().sort((R,q)=>R.date.getTime()-q.date.getTime()).slice(0,3))||[],N=(n==null?void 0:n.filter(R=>{const q=j(R.birthday),U=j(R.home_anniversary);return q&&Sl(q,b)||U&&Sl(U,b)}).length)||0,C=(s==null?void 0:s.length)||0,M=N+C,I=(a==null?void 0:a.actionsThisWeek)||0,L=(a==null?void 0:a.streak)||0;return r?e.jsx(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:e.jsx(Re,{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(Pe,{className:"bg-gradient-to-br from-primary/5 via-primary/10 to-primary/5 border-primary/20",children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),"Agent OS"]}),e.jsx("div",{className:"flex items-center gap-2",children:L>0&&e.jsxs(tt,{variant:"secondary",className:"gap-1 bg-orange-500/10 text-orange-600 border-orange-200",children:[e.jsx(Qu,{className:"h-3 w-3"}),L," 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",I>0&&e.jsxs("span",{className:"ml-2",children:["• ",e.jsx("span",{className:"text-emerald-600 font-medium",children:I})," touches this week"]})]})]}),e.jsxs(Re,{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:R=>{R.stopPropagation(),t("/mission-control/contacts?new=true")},children:[e.jsx(rc,{className:"h-3.5 w-3.5"}),"Add Contact"]}),e.jsxs(K,{size:"sm",variant:"outline",className:"gap-1.5",onClick:R=>{R.stopPropagation(),t("/mission-control")},children:[e.jsx(Un,{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:R=>{R.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:R=>{R.stopPropagation(),t("/mission-control/popbys")},children:[e.jsx(Ba,{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:R=>{R.stopPropagation(),t("/mission-control/pipeline")},children:[e.jsx(u0,{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(Rm,{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(Yo,{className:"h-3.5 w-3.5 text-muted-foreground hover:text-primary"})})}),e.jsxs(fs,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"weekly-goal",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal",type:"number",min:"1",value:i,onChange:R=>c(R.target.value),placeholder:"20",onKeyDown:R=>{R.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:I}),e.jsxs("span",{className:"text-muted-foreground",children:[" / ",o," touches"]})]})]}),e.jsx(Bi,{value:Math.min(I/o*100,100),className:"h-2 bg-muted [&>div]:bg-primary"}),I>=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."]}),I0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1.5",children:[o-I," more to hit your weekly goal"]})]}),w.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(Sh,{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:w.map((R,q)=>e.jsxs("div",{className:`flex items-center justify-between p-2 rounded-lg cursor-pointer transition-colors ${R.isToday?"bg-pink-500/10 hover:bg-pink-500/15":"bg-muted/50 hover:bg-muted"}`,onClick:U=>{U.stopPropagation(),t(`/mission-control/contacts/${R.contact.id}`)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[R.type==="birthday"?e.jsx(Sh,{className:"h-3.5 w-3.5 text-pink-500"}):e.jsx(Sn,{className:"h-3.5 w-3.5 text-blue-500"}),e.jsxs("span",{className:"text-sm",children:[R.contact.first_name," ",R.contact.last_name]}),R.isToday&&e.jsx(tt,{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:R.isToday?R.type==="birthday"?"🎂":"🏠":ps(R.date,"EEE, MMM d")}),e.jsx(xa,{className:"h-3 w-3"})]})]},`${R.contact.id}-${R.type}-${q}`))})]}),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(fi,{className:"h-4 w-4"})]})]})]})}function dLt(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 uLt(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 hLt(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 mLt(t){const s=es();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 pLt(){const t=es();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 fLt(t){const s=es();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 xLt(){const t=es();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 gLt(t){const s=es();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 yLt={video:rl,pdf:En,link:cl,event:cn,graphic:sc},vLt={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 bLt(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 _Lt(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 wLt({item:t}){const s=pr(),r=yLt[t.content_type]||cl,n=vLt[t.content_type]||"",[a,o]=k.useState(null),l=t.thumbnail_url||(t.content_type==="graphic"&&t.file_url?t.file_url:null)||(t.content_type==="video"?bLt(t.url):null);k.useEffect(()=>{l||!t.url||t.content_type!=="video"||!_Lt(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(Pe,{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(Re,{className:"p-3",children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsxs(tt,{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:ps(new Date(t.event_date),"MMM d · h:mm a")})]})]})}function jLt(){const{brokerageId:t}=Rs(),s=pr(),{data:r=[],isLoading:n}=hLt(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(wa,{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(fi,{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(wLt,{item:a},a.id))})]})}const KYe=()=>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}}),ZYe=t=>{const{user:s,brokerageId:r}=Rs();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(b=>b.id)),g=p.filter(b=>!f.has(b.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}})},YYe=()=>{const{user:t}=Rs();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})},XYe=t=>{const{user:s}=Rs();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})},NLt=()=>{const t=es(),{user:s}=Rs();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"]})}})},kLt=()=>{const t=es();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"]})}})},SLt=()=>{const t=es();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]})}})},QYe=()=>{const t=es();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"]})}})},CLt=()=>{const t=es();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"]})}})},MLt=()=>{const t=es();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"]})}})},TLt=()=>{const t=es();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"]})}})},ALt=()=>{const t=es();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"]})}})},ELt=()=>{const{user:t}=Rs();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})},JYe=()=>{const t=es(),{user:s}=Rs();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"]})}})},eXe=t=>{const{user:s}=Rs();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})},PLt=()=>{const t=es(),{user:s}=Rs();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"]})}})},ILt=t=>{const{user:s}=Rs();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})},LLt=()=>{const{user:t}=Rs();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}})},DLt=()=>{const{user:t}=Rs();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})},OLt=()=>{const t=es(),{user:s}=Rs();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"]})}})},RLt=()=>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}}}),FLt=()=>{const{user:t,brokerageId:s}=Rs();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})},tXe=({className:t,variant:s="default"})=>e.jsx(tt,{variant:"outline",className:Pt("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"}),zLt={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"},BLt={coming_soon:"Coming Soon",active:"Active",under_contract:"Under Contract",sold:"Sold",withdrawn:"Withdrawn"};function $Lt(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function qLt(){const t=pr(),{data:s,isLoading:r}=KYe(),{data:n,isLoading:a}=ZYe({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(Pe,{className:"bg-gradient-to-br from-emerald-500/5 via-emerald-500/10 to-emerald-500/5 border-emerald-500/20",children:e.jsx(Re,{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(tXe,{})]}),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(fi,{className:"h-4 w-4"})]})]}),c.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Sn,{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,b;const f=((g=p.photos)==null?void 0:g.find(_=>_.is_primary))||((b=p.photos)==null?void 0:b[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(Sn,{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(tt,{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(tt,{className:`text-[10px] px-1.5 py-0.5 ${zLt[p.status]}`,children:BLt[p.status]})})]}),e.jsxs("div",{className:"p-2",children:[e.jsx("p",{className:"font-bold text-sm text-foreground",children:$Lt(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 sXe(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(b=>b.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 rXe(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 nXe(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 aXe(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 ULt(){const{user:t,brokerageId:s,isAdmin:r}=Rs();pr();const n=!!s,[a,o]=k.useState("brokerage"),l=()=>{if(r)return null;if(n)return a==="global"?null:s},{data:i,isLoading:c}=sXe(5,l()),{data:u}=rXe(t==null?void 0:t.id),{data:p}=aXe(t==null?void 0:t.id,l()),{data:f}=nXe(t==null?void 0:t.id),g=r||n,b=()=>r?"Agent Leaderboard":n?a==="global"?"All LevelUp":"My Brokerage":"My Points";if(c)return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:[...Array(g?5:3)].map((j,w)=>e.jsx(vs,{className:"h-10 w-full"},w))})})]});const _=j=>j===0?e.jsx(xo,{className:"h-4 w-4 text-yellow-500 mx-auto"}):j===1?e.jsx("span",{className:"text-sm font-medium text-gray-400",children:"2"}):j===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:j+1});if(g){const j=(i==null?void 0:i.slice(0,5))||[];return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),b()]}),!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(Re,{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:[j.map((w,N)=>{var C,M,I;return e.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg ${w.user_id===(t==null?void 0:t.id)?"bg-primary/10 border border-primary/20":N===0?"bg-yellow-500/10":""}`,children:[e.jsx("div",{className:"w-5 text-center",children:_(N)}),e.jsx(_n,{className:"h-6 w-6",children:e.jsx(wn,{className:"text-xs",children:((M=(C=w.profile)==null?void 0:C.name)==null?void 0:M.charAt(0))||"?"})}),e.jsx("span",{className:"flex-1 text-sm font-medium truncate",children:((I=w.profile)==null?void 0:I.name)||"Unknown"}),e.jsx("span",{className:"text-sm font-bold text-primary",children:w.total_points})]},w.user_id)}),j.length===0&&e.jsx("div",{className:"text-center text-muted-foreground py-2 text-sm",children:"No data yet"})]}),e.jsxs(Ei,{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(No,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(xa,{className:"h-4 w-4"})]})]})]})}return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(xo,{className:"h-4 w-4 text-yellow-500"}),"My Points"]})}),e.jsx(Re,{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(Qu,{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(bc,{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(j=>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:j.badge_name},j.id)),f.length>4&&e.jsxs("span",{className:"text-xs text-muted-foreground px-2 py-1",children:["+",f.length-4," more"]})]})]}),e.jsxs(Ei,{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(No,{className:"h-4 w-4"}),"Spend Points in Reward Store",e.jsx(xa,{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(Ei,{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(No,{className:"h-4 w-4"}),"Visit Reward Store",e.jsx(xa,{className:"h-4 w-4"})]})]})})]})}const tE=()=>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}}),wNe=()=>{const t=es(),{user:s}=Rs();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"]}),he.success("Lead source added")},onError:r=>{he.error("Failed to add lead source"),console.error(r)}})},VLt=()=>{const t=es();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"]}),he.success("Lead source updated")},onError:s=>{he.error(s.message||"Failed to update lead source")}})},HLt=()=>{const t=es();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"]}),he.success("Lead source removed")},onError:s=>{he.error(s.message||"Failed to remove lead source")}})},jNe=(t,s)=>{const{user:r,isAdmin:n}=Rs(),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})},NNe=t=>{const{user:s,isAdmin:r}=Rs(),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})},bue=()=>{const t=es(),{user:s}=Rs();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"]}),he.success("Transaction added")},onError:r=>{he.error("Failed to add transaction"),console.error(r)}})},WLt=()=>{const t=es();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"]}),he.success("Transaction updated")},onError:s=>{he.error("Failed to update transaction"),console.error(s)}})},GLt=()=>{const t=es();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"]}),he.success("Transaction deleted")},onError:s=>{he.error("Failed to delete transaction"),console.error(s)}})},iXe=(t,s)=>{const{user:r,isAdmin:n}=Rs(),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})},KLt=()=>{const t=es(),{user:s}=Rs();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]}),he.success("Goals saved")},onError:r=>{he.error("Failed to save goals"),console.error(r)}})},_ue=()=>{const{user:t}=Rs();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)})},ZLt=()=>{const t=es(),{user:s}=Rs();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"]}),he.success("Settings saved")},onError:r=>{he.error("Failed to save settings"),console.error(r)}})},oXe=(t,s)=>{const{data:r,isLoading:n}=jNe(t,s),{data:a,isLoading:o}=NNe(s),{data:l}=_ue(),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(L=>L.transaction_type==="buyer").length,f=u.filter(L=>L.transaction_type==="seller").length,g=u.reduce((L,R)=>L+Number(R.sale_price),0),b=u.reduce((L,R)=>L+(Number(R.commission_amount)||0),0),_=u.reduce((L,R)=>{const q=Number(R.commission_amount)||0;if(!q)return L;let U=q;return R.brokerage_split_pct&&(U-=q*(R.brokerage_split_pct/100)),R.team_split_pct&&(U-=q*(R.team_split_pct/100)),R.franchise_fee_pct&&(U-=q*(R.franchise_fee_pct/100)),R.referral_fee_pct&&(U-=q*(R.referral_fee_pct/100)),R.transaction_fee&&(U-=R.transaction_fee),L+Math.max(0,U)},0),j={};u.forEach(L=>{var q;const R=((q=L.lead_source)==null?void 0:q.name)||"Unknown";j[R]=(j[R]||0)+1});const w=Object.entries(j).map(([L,R])=>({name:L,count:R})).sort((L,R)=>R.count-L.count),N=w[0]||null,C={};u.forEach(L=>{const R=Il(L.close_date).toLocaleString("default",{month:"short"});C[R]=(C[R]||0)+1});const I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(L=>({month:L,count:C[L]||0}));return{totalTransactions:u.length,buyerCount:p,sellerCount:f,totalVolume:g,averagePrice:u.length>0?g/u.length:0,totalCommission:i?b:0,totalNetToAgent:i?_:0,topLeadSource:N,transactionsByMonth:I,leadSourceBreakdown:w}};return{yearStats:c(r),lifetimeStats:c(a),isLoading:n||o,showCommission:i}},YLt=()=>{const{isAdmin:t}=Rs();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})},Wb={recency:40,touchpoints:30,transactions:20},yIe={warm:70,cooling:40};function XLt(t){return t===null?0:t<=14?Wb.recency:t<=30?Wb.recency*.85:t<=60?Wb.recency*.65:t<=90?Wb.recency*.4:t<=180?Wb.recency*.2:Wb.recency*.05}function QLt(t){const s=Math.min(t/12,1);return Math.round(Wb.touchpoints*s)}function JLt(t){return t?Wb.transactions:0}function e8t(){return 0}function t8t(t){return t>=yIe.warm?"warm":t>=yIe.cooling?"cooling":"at-risk"}function wue(){const{data:t,isLoading:s}=Wm(),{data:r}=VYe(),{data:n}=zO(365),{data:a}=NNe(),o=k.useMemo(()=>{if(!t)return[];const i=new Date,c=f4(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,b=g?iy(i,new Date(g)):null,_=u[f.id]||0,j=p.has(f.id),w=XLt(b),N=QLt(_),C=JLt(j),M=e8t(),I=Math.round(w+N+C+M),L={score:I,status:t8t(I),breakdown:{recency:Math.round(w),touchpoints:Math.round(N),transactions:Math.round(C),referrals:Math.round(M)},lastTouchDate:g,daysSinceTouch:b,touchCountLast12Months:_,hasTransaction:j};return{...f,relationshipScore:L}})},[t,r,n,a]),l=k.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,b)=>g+b.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 lXe(){const t=pr(),{stats:s,contactsWithScores:r,isLoading:n}=wue();if(n)return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(vs,{className:"h-5 w-40"})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Relationship Health"]})}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Ol,{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(Re,{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(cS,{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(xa,{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(xa,{className:"h-4 w-4 ml-1"})]})]})]})}const s8t=()=>{var ne;const{user:t,isAdmin:s}=Rs(),r=pr(),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState([]),[b,_]=k.useState([]),[j,w]=k.useState(new Set),[N,C]=k.useState([]),[M,I]=k.useState([]),[L,R]=k.useState([]),[q,U]=k.useState(null),[B,V]=k.useState(!0);k.useEffect(()=>{Y()},[t]);const Y=async()=>{var re,le,pe,xe,_e;try{const[fe,we,Ie,Ne,Ae,Fe,Ce,Me,$e,ct,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 ft=((le=fe.data)==null?void 0:le.map(rt=>rt.tag))||[],me=new Set(((pe=Ie.data)==null?void 0:pe.map(rt=>rt.app_id))||[]);w(me);const nt=(((xe=we.data)==null?void 0:xe.filter(rt=>!rt.required_tags||rt.required_tags.length===0?!0:rt.required_tags.some(Ge=>ft.includes(Ge))))||[]).sort((rt,Ge)=>rt.name==="LevelUp Members Portal"?-1:Ge.name==="LevelUp Members Portal"?1:0);a(nt.slice(0,6));const et=((_e=Ne.data)==null?void 0:_e.filter(rt=>XM(rt.event_date)!=="ended"))||[];l(et.slice(0,4)),C(Ae.data||[]),c(Fe.data||[]),p(Ce.data||[]),g(Me.data||[]),_($e.data||[]);const Se=ct.data||[];I(Se.filter(rt=>rt.placement==="top")),R(Se.filter(rt=>rt.placement==="between"))}catch(fe){console.error("Error loading dashboard:",fe),he.error("Failed to load dashboard data")}finally{V(!1)}},J=async re=>{var pe;const le=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:xe,error:_e}=await H.functions.invoke("sso-launch",{body:{app_id:re.app_id}});if(_e)throw _e;xe!=null&&xe.redirect_url?le&&!le.closed?(le.location.href=xe.redirect_url,(pe=le.focus)==null||pe.call(le)):window.location.assign(xe.redirect_url):(le==null||le.close(),he.error("Launch link unavailable"))}catch(xe){le==null||le.close(),console.error("Error launching app:",xe),he.error("Failed to launch app")}},te=re=>N==null?void 0:N.some(le=>le.event_id===re),X=re=>{const le=N==null?void 0:N.find(pe=>pe.event_id===re);return le==null?void 0:le.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=>L.filter(le=>le.section_after===re);return e.jsxs(Ts,{title:"Dashboard",children:[e.jsx(RIt,{events:o,registrations:N,onNavigateToEvents:()=>r("/events")}),M.length>0&&e.jsx("div",{className:"mb-8",children:e.jsx(KP,{banners:M})}),e.jsx(KIt,{}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-foreground",children:["Welcome back, ",(q||((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(cLt,{}),e.jsx(lXe,{}),e.jsx(ULt,{})]}),e.jsx(jLt,{}),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(fi,{className:"h-4 w-4"})]})]}),o.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(cn,{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 le=te(re.id),pe=X(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 ${pIe(re.event_date)?"bg-red-500/5 border-l-2 border-l-red-500":""}`,onClick:()=>r("/events"),children:[pIe(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(l1,{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 ",rD(new Date(re.event_date))]})]}),e.jsx("div",{className:"hidden sm:flex flex-shrink-0",children:le?e.jsxs(K,{size:"sm",variant:"default",className:"gap-1",onClick:xe=>{xe.stopPropagation(),window.open(pe,"_blank")},children:[e.jsx(an,{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(xa,{className:"h-4 w-4"})]})})]},re.id)})})]}),ce("events").length>0&&e.jsx("div",{className:"mb-10",children:e.jsx(KP,{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(fi,{className:"h-4 w-4"})]})]}),f.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(mp,{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(mp,{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(KP,{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(fi,{className:"h-4 w-4"})]})]}),u.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Lm,{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(Lm,{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(KP,{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(fi,{className:"h-4 w-4"})]})]}),i.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(R_,{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(R_,{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(KP,{banners:ce("templates")})}),e.jsx("div",{className:"mb-10",children:e.jsx(qLt,{})}),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(fi,{className:"h-4 w-4"})]})]}),n.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Nx,{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 le=j.has(re.id);return e.jsxs("div",{onClick:()=>J(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})]}),le&&e.jsx(Nx,{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(fi,{className:"h-4 w-4"})]})]}),b.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsxs("div",{className:"text-center",children:[e.jsx(un,{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:b.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(un,{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 cXe="AlertDialog",[r8t]=nd(cXe,[WHe]),z1=WHe(),dXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=z1(s);return e.jsx(zde,{...n,...r,modal:!0})};dXe.displayName=cXe;var n8t="AlertDialogTrigger",uXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=z1(r);return e.jsx(nje,{...a,...n,ref:s})});uXe.displayName=n8t;var a8t="AlertDialogPortal",hXe=t=>{const{__scopeAlertDialog:s,...r}=t,n=z1(s);return e.jsx(Bde,{...n,...r})};hXe.displayName=a8t;var i8t="AlertDialogOverlay",mXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=z1(r);return e.jsx(WA,{...a,...n,ref:s})});mXe.displayName=i8t;var QM="AlertDialogContent",[o8t,l8t]=r8t(QM),c8t=T$e("AlertDialogContent"),pXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,children:n,...a}=t,o=z1(r),l=k.useRef(null),i=$a(s,l),c=k.useRef(null);return e.jsx(aNt,{contentName:QM,titleName:fXe,docsSlug:"alert-dialog",children:e.jsx(o8t,{scope:r,cancelRef:c,children:e.jsxs(GA,{role:"alertdialog",...o,...a,ref:i,onOpenAutoFocus:Ir(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(c8t,{children:n}),e.jsx(u8t,{contentRef:l})]})})})});pXe.displayName=QM;var fXe="AlertDialogTitle",xXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=z1(r);return e.jsx(CO,{...a,...n,ref:s})});xXe.displayName=fXe;var gXe="AlertDialogDescription",yXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=z1(r);return e.jsx(MO,{...a,...n,ref:s})});yXe.displayName=gXe;var d8t="AlertDialogAction",vXe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,a=z1(r);return e.jsx(TO,{...a,...n,ref:s})});vXe.displayName=d8t;var bXe="AlertDialogCancel",_Xe=k.forwardRef((t,s)=>{const{__scopeAlertDialog:r,...n}=t,{cancelRef:a}=l8t(bXe,r),o=z1(r),l=$a(s,a);return e.jsx(TO,{...o,...n,ref:l})});_Xe.displayName=bXe;var u8t=({contentRef:t})=>{const s=`\`${QM}\` requires a description for the component to be accessible for screen reader users. You can add a description to the \`${QM}\` by passing a \`${gXe}\` 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 \`${QM}\`. 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 k.useEffect(()=>{var n;document.getElementById((n=t.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(s)},[s,t]),null},h8t=dXe,m8t=uXe,p8t=hXe,wXe=mXe,jXe=pXe,NXe=vXe,kXe=_Xe,SXe=xXe,CXe=yXe;const _c=h8t,Sm=m8t,f8t=p8t,MXe=k.forwardRef(({className:t,...s},r)=>e.jsx(wXe,{className:Pt("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}));MXe.displayName=wXe.displayName;const Zl=k.forwardRef(({className:t,...s},r)=>e.jsxs(f8t,{children:[e.jsx(MXe,{}),e.jsx(jXe,{ref:r,className:Pt("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})]}));Zl.displayName=jXe.displayName;const Yl=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col space-y-2 text-center sm:text-left",t),...s});Yl.displayName="AlertDialogHeader";const Xl=({className:t,...s})=>e.jsx("div",{className:Pt("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...s});Xl.displayName="AlertDialogFooter";const Ql=k.forwardRef(({className:t,...s},r)=>e.jsx(SXe,{ref:r,className:Pt("text-lg font-semibold",t),...s}));Ql.displayName=SXe.displayName;const Jl=k.forwardRef(({className:t,...s},r)=>e.jsx(CXe,{ref:r,className:Pt("text-sm text-muted-foreground",t),...s}));Jl.displayName=CXe.displayName;const Ll=k.forwardRef(({className:t,...s},r)=>e.jsx(NXe,{ref:r,className:Pt(G8(),t),...s}));Ll.displayName=NXe.displayName;const ec=k.forwardRef(({className:t,...s},r)=>e.jsx(kXe,{ref:r,className:Pt(G8({variant:"outline"}),"mt-2 sm:mt-0",t),...s}));ec.displayName=kXe.displayName;const x8t=[{key:"contacts",label:"Contacts",icon:Un,description:"View, add, and edit contacts"},{key:"pipeline",label:"Deal Pipeline",icon:eS,description:"View, add, and move deals"},{key:"client_portal",label:"Client Portals",icon:Lm,description:"Manage client portals on deals"},{key:"videos",label:"Videos",icon:Cn,description:"View and upload videos"},{key:"listings",label:"Listings",icon:Sn,description:"View, create, and edit listings"},{key:"scorecard",label:"Scorecard",icon:O_,description:"View and add transactions"},{key:"popbys",label:"Pop-bys",icon:Ba,description:"View and log pop-bys"},{key:"digital_card",label:"Digital Card",icon:Cx,description:"Create and edit digital business card"},{key:"guest_book",label:"Guest Book",icon:kh,description:"Manage open house guest books"},{key:"presentations",label:"Presentations",icon:Qg,description:"Create and manage smart presentations"}];function g8t(){var q;const{user:t}=Rs(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState({email:"",name:"",password:""}),[b,_]=k.useState("create"),[j,w]=k.useState(!1),[N,C]=k.useState(null);k.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(te=>te.assistant_id),{data:Y}=await H.from("profiles").select("id, name, email").in("id",V),J=U.map(te=>{const X=Y==null?void 0:Y.find(ce=>ce.id===te.assistant_id);return{...te,permissions:te.permissions,assistant_profile:X?{name:X.name||"",email:X.email||""}:void 0}});r(J)}else r([])}catch(U){console.error("Error loading assistants:",U)}finally{a(!1)}}},I=async()=>{if(t){if(b==="link"){if(!f.email.trim()){he.error("Please enter the assistant's email");return}w(!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){he.error("No account found with that email. Try creating a new assistant instead.");return}const{data:Y}=await H.from("agent_assistant_assignments").select("id").eq("agent_id",t.id).eq("assistant_id",B.id);if(Y&&Y.length>0){he.error("This assistant is already assigned to you");return}const J=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})}),te=await J.json();if(!J.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:X}=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(X)throw X;he.success(`${B.name||B.email} linked as your assistant`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error linking assistant:",U),he.error(U.message||"Failed to link assistant")}finally{w(!1)}return}if(!f.email.trim()||!f.name.trim()||!f.password.trim()){he.error("Please fill in all fields");return}if(f.password.length<6){he.error("Password must be at least 6 characters");return}w(!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 Y=V.userId||V.id;if(!Y)throw new Error("No user ID returned");const J=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:Y,role:"assistant",action:"add",agentId:t.id})}),te=await J.json();if(!J.ok)throw new Error(te.error||"Failed to assign assistant role");const{error:X}=await H.from("agent_assistant_assignments").insert({agent_id:t.id,assistant_id:Y,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(X)throw X;he.success(`Assistant account created for ${f.name.trim()}`),l(!1),g({email:"",name:"",password:""}),M()}catch(U){console.error("Error adding assistant:",U),he.error(U.message||"Failed to add assistant")}finally{w(!1)}}},L=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"})}),he.success("Assistant removed"),c(!1),p(null),M()}catch(U){console.error("Error removing assistant:",U),he.error(U.message||"Failed to remove assistant")}},R=async(U,B,V)=>{C(U);try{const Y=s.find(X=>X.id===U);if(!Y)return;const J={...Y.permissions,[B]:V},{error:te}=await H.from("agent_assistant_assignments").update({permissions:J}).eq("id",U);if(te)throw te;r(X=>X.map(ce=>ce.id===U?{...ce,permissions:J}:ce))}catch(Y){console.error("Error updating permissions:",Y),he.error("Failed to update permissions")}finally{C(null)}};return n?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"My Assistants"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"My Assistants"]}),e.jsx(xr,{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(Re,{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,Y,J;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(_n,{className:"h-10 w-10",children:e.jsx(wn,{children:((V=(B=U.assistant_profile)==null?void 0:B.name)==null?void 0:V.split(" ").map(te=>te[0]).join("").toUpperCase())||"A"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Y=U.assistant_profile)==null?void 0:Y.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:((J=U.assistant_profile)==null?void 0:J.email)||""})]}),e.jsxs(tt,{variant:"secondary",className:"ml-2",children:[e.jsx(Th,{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:x8t.map(te=>{const X=te.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(X,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:te.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:te.description})]})]}),e.jsx($r,{checked:U.permissions[te.key]||!1,onCheckedChange:ce=>R(U.id,te.key,ce),disabled:N===U.id})]},te.key)})})]})]},U.id)})})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Add Assistant"}),e.jsx(Wr,{children:b==="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:b==="create"?"default":"outline",size:"sm",onClick:()=>_("create"),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Create New"]}),e.jsxs(K,{variant:b==="link"?"default":"outline",size:"sm",onClick:()=>_("link"),children:[e.jsx(zo,{className:"h-3 w-3 mr-1"}),"Link Existing"]})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{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"})]}),b==="create"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:I,disabled:j,children:[j&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),b==="create"?"Create Assistant":"Link Assistant"]})]})]})}),e.jsx(_c,{open:i,onOpenChange:c,children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Remove Assistant?"}),e.jsxs(Jl,{children:["This will remove ",(q=u==null?void 0:u.assistant_profile)==null?void 0:q.name,"'s access to your Agent OS. Their account will remain active but they won't be able to manage your data."]})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:L,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})})]})}function xh(t){this.content=t}xh.prototype={constructor:xh,find:function(t){for(var s=0;s>1}};xh.from=function(t){if(t instanceof xh)return t;var s=[];if(t)for(var r in t)s.push(r,t[r]);return new xh(s)};function TXe(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=TXe(a.content,o.content,r+1);if(l!=null)return l}r+=a.nodeSize}}function AXe(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 Lr(n,a)}cutByIndex(s,r){return s==r?Lr.empty:s==0&&r==this.content.length?this:new Lr(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 Lr(a,o)}addToStart(s){return new Lr([s].concat(this.content),this.size+s.nodeSize)}addToEnd(s){return new Lr(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?az(r+1,o):az(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 Lr.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new Lr(r.map(s.nodeFromJSON))}static fromArray(s){if(!s.length)return Lr.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}};El.none=[];class Koe extends Error{}class bn{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=PXe(this.content,s+this.openStart,r);return n&&new bn(n,this.openStart,this.openEnd)}removeBetween(s,r){return new bn(EXe(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 bn.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 bn(Lr.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 bn(s,n,a)}}bn.empty=new bn(Lr.empty,0,0);function EXe(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(EXe(o.content,s-a-1,r-a-1)))}function PXe(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=PXe(l.content,s-o-1,r,l);return i&&t.replaceChild(a,l.copy(i))}function y8t(t,s,r){if(r.openStart>t.depth)throw new Koe("Inserted content deeper than insertion position");if(t.depth-r.openStart!=s.depth-r.openEnd)throw new Koe("Inconsistent open depths");return IXe(t,s,r,0)}function IXe(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 YL(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&&(pS(t.nodeAfter,n),o++));for(let i=o;ia&&x1e(t,s,a+1),l=n.depth>a&&x1e(r,n,a+1),i=[];return YL(null,t,a,i),o&&l&&s.index(a)==r.index(a)?(LXe(o,l),pS(fS(o,DXe(t,s,r,n,a+1)),i)):(o&&pS(fS(o,Zoe(t,s,a+1)),i),YL(s,r,a,i),l&&pS(fS(l,Zoe(r,n,a+1)),i)),YL(n,null,a,i),new Lr(i)}function Zoe(t,s,r){let n=[];if(YL(null,t,r,n),t.depth>r){let a=x1e(t,s,r+1);pS(fS(a,Zoe(t,s,r+1)),n)}return YL(s,null,r,n),new Lr(n)}function v8t(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(Lr.from(a));return{start:a.resolveNoCache(t.openStart+r),end:a.resolveNoCache(a.content.size-t.openEnd-r)}}class nD{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 Yoe(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 nD(r,n,o)}static resolveCached(s,r){let n=vIe.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()+")"),OXe(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=Lr.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=Lr.fromJSON(s,r.content),o=s.nodeType(r.type).create(r.attrs,a,n);return o.type.checkAttrs(o.attrs),o}};Y_.prototype.text=void 0;class Xoe extends Y_{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):OXe(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 Xoe(this.type,this.attrs,this.text,s)}withText(s){return s==this.text?this:new Xoe(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 OXe(t,s){for(let r=t.length-1;r>=0;r--)s=t[r].type.name+"("+s+")";return s}class $S{constructor(s){this.validEnd=s,this.next=[],this.wrapCache=[]}static parse(s,r){let n=new j8t(s,r);if(n.next==null)return $S.empty;let a=RXe(n);n.next&&n.err("Unexpected trailing text");let o=A8t(T8t(a));return E8t(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(` `)}}$S.empty=new $S(!0);class j8t{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 RXe(t){let s=[];do s.push(N8t(t));while(t.eat("|"));return s.length==1?s[0]:{type:"choice",exprs:s}}function N8t(t){let s=[];do s.push(k8t(t));while(t.next&&t.next!=")"&&t.next!="|");return s.length==1?s[0]:{type:"seq",exprs:s}}function k8t(t){let s=M8t(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=S8t(t,s);else break;return s}function bIe(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let s=Number(t.next);return t.pos++,s}function S8t(t,s){let r=bIe(t),n=r;return t.eat(",")&&(t.next!="}"?n=bIe(t):n=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:s}}function C8t(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 M8t(t){if(t.eat("(")){let s=RXe(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=C8t(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 T8t(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 $S(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:BXe(this.attrs,s)}create(s=null,r,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Y_(this,this.computeAttrs(s),Lr.from(r),El.setFrom(n))}createChecked(s=null,r,n){return r=Lr.from(r),this.checkContent(r),new Y_(this,this.computeAttrs(s),r,El.setFrom(n))}createAndFill(s=null,r,n){if(s=this.computeAttrs(s),r=Lr.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(Lr.empty,!0);return o?new Y_(this,s,r.append(o),El.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 UXe(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 P8t(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 I8t{constructor(s,r,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?P8t(s,r,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class jue{constructor(s,r,n,a){this.name=s,this.rank=r,this.schema=n,this.spec=a,this.attrs=qXe(s,a.attrs),this.excluded=null;let o=zXe(this.attrs);this.instance=o?new El(this,o):null}create(s=null){return!s&&this.instance?this.instance:new El(this,BXe(this.attrs,s))}static compile(s,r){let n=Object.create(null),a=0;return s.forEach((o,l)=>n[o]=new jue(o,a++,r,l)),n}removeFromSet(s){for(var r=0;r-1}}class VXe{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=xh.from(s.nodes),r.marks=xh.from(s.marks||{}),this.nodes=wIe.compile(this.spec.nodes,this),this.marks=jue.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]=$S.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?jIe(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==""?[]:jIe(this,l.split(" "))}this.nodeFromJSON=a=>Y_.fromJSON(this,a),this.markFromJSON=a=>El.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 wIe){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 Xoe(n,n.defaultAttrs,s,El.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 jIe(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 L8t(t){return t.tag!=null}function D8t(t){return t.style!=null}let XL=class y1e{constructor(s,r){this.schema=s,this.rules=r,this.tags=[],this.styles=[];let n=this.matchedStyles=[];r.forEach(a=>{if(L8t(a))this.tags.push(a);else if(D8t(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 kIe(this,r,!1);return n.addAll(s,El.none,r.from,r.to),n.finish()}parseSlice(s,r={}){let n=new kIe(this,r,!0);return n.addAll(s,El.none,r.from,r.to),bn.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=SIe(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=SIe(l)),l.node||l.ignore||l.mark||(l.node=a)})}return r}static fromSchema(s){return s.cached.domParser||(s.cached.domParser=new y1e(s,y1e.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},O8t={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},WXe={ol:!0,ul:!0},aD=1,v1e=2,QL=4;function NIe(t,s,r){return s!=null?(s?aD:0)|(s==="full"?v1e:0):t&&t.whitespace=="pre"?aD|v1e:r&~QL}class iz{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=El.none,this.match=o||(l&QL?null:s.contentMatch)}findWrapping(s){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(Lr.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&aD)){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=Lr.from(this.content);return!s&&this.match&&(r=r.append(this.match.fillBefore(Lr.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 kIe{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=NIe(null,r.preserveWhitespace,0)|(n?QL:0);a?o=new iz(a.type,a.attrs,El.none,!0,r.topMatch||a.type.contentMatch,l):n?o=new iz(null,null,El.none,!0,null,l):o=new iz(s.schema.topNodeType,null,El.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&v1e?"full":this.localPreserveWS||(a.options&aD)>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):CIe(u.type,s))?(c=u.addToSet(c),!1):!0),this.nodes.push(new iz(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|=aD)}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 R8t(t){for(let s=t.firstChild,r=null;s;s=s.nextSibling){let n=s.nodeType==1?s.nodeName.toLowerCase():null;n&&WXe.hasOwnProperty(n)&&r?(r.appendChild(s),s=r):n=="li"?r=s:n&&(r=null)}}function F8t(t,s){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,s)}function SIe(t){let s={};for(let r in t)s[r]=t[r];return s}function CIe(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&&_ie(Gxe(n),a(s,r),null,s.attrs)}static renderSpec(s,r,n=null,a){return _ie(s,r,n,a)}static fromSchema(s){return s.cached.domSerializer||(s.cached.domSerializer=new pC(this.nodesFromSchema(s),this.marksFromSchema(s)))}static nodesFromSchema(s){let r=MIe(s.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(s){return MIe(s.marks)}}function MIe(t){let s={};for(let r in t){let n=t[r].spec.toDOM;n&&(s[r]=n)}return s}function Gxe(t){return t.document||window.document}const TIe=new WeakMap;function z8t(t){let s=TIe.get(t);return s===void 0&&TIe.set(t,s=B8t(t)),s}function B8t(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:b,contentDOM:_}=_ie(t,g,r,n);if(c.appendChild(b),_){if(i)throw new RangeError("Multiple content holes");i=_}}}return{dom:c,contentDOM:i}}const GXe=65535,KXe=Math.pow(2,16);function $8t(t,s){return t+s*KXe}function AIe(t){return t&GXe}function q8t(t){return(t-(t&GXe))/KXe}const ZXe=1,YXe=2,wie=4,XXe=8;class b1e{constructor(s,r,n){this.pos=s,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&XXe)>0}get deletedBefore(){return(this.delInfo&(ZXe|wie))>0}get deletedAfter(){return(this.delInfo&(YXe|wie))>0}get deletedAcross(){return(this.delInfo&wie)>0}}class lf{constructor(s,r=!1){if(this.ranges=s,this.inverted=r,!s.length&&lf.empty)return lf.empty}recover(s){let r=0,n=AIe(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,b=c+a+(g<0?0:p);if(n)return b;let _=s==(r<0?c:f)?null:$8t(i/3,s-c),j=s==c?YXe:s==f?ZXe:wie;return(r<0?s!=c:s!=f)&&(j|=XXe),new b1e(b,j,_)}a+=p-u}return n?s+a:new b1e(s+a,0,null)}touches(s,r){let n=0,a=AIe(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 iD;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 Jd.fromReplace(s,this.from,this.to,o)}invert(){return new i0(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 j_(r.pos,n.pos,this.mark)}merge(s){return s instanceof j_&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new j_(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 j_(r.from,r.to,s.markFromJSON(r.mark))}}Jh.jsonID("addMark",j_);class i0 extends Jh{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 bn(kNe(r.content,a=>a.mark(this.mark.removeFromSet(a.marks)),s),r.openStart,r.openEnd);return Jd.fromReplace(s,this.from,this.to,n)}invert(){return new j_(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 i0(r.pos,n.pos,this.mark)}merge(s){return s instanceof i0&&s.mark.eq(this.mark)&&this.from<=s.to&&this.to>=s.from?new i0(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 i0(r.from,r.to,s.markFromJSON(r.mark))}}Jh.jsonID("removeMark",i0);class N_ extends Jh{constructor(s,r){super(),this.pos=s,this.mark=r}apply(s){let r=s.nodeAt(this.pos);if(!r)return Jd.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return Jd.fromReplace(s,this.pos,this.pos+1,new bn(Lr.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 th(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 th(r.from,r.to,r.gapFrom,r.gapTo,bn.fromJSON(s,r.slice),r.insert,!!r.structure)}}Jh.jsonID("replaceAround",th);function _1e(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 U8t(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),b=Math.min(u+c.nodeSize,r),_=n.addToSet(f);for(let j=0;jt.step(c)),o.forEach(c=>t.step(c))}function V8t(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 jue){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 i0(l.from,l.to,l.style)))}function SNe(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 H8t(t,s,r){return(s==0||t.canReplace(s,t.childCount))&&(r==t.childCount||t.canReplace(0,r))}function sE(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;_--)j||n.index(_)>0?(j=!0,p=Lr.from(n.node(_).copy(p)),f++):c--;let g=Lr.empty,b=0;for(let _=o,j=!1;_>r;_--)j||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=Lr.from(r[l].type.create(r[l].attrs,n))}let a=s.start,o=s.end;t.step(new th(a,o,a,o,new bn(n,0,0),r.length,!0))}function Y8t(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)&&X8t(t.doc,t.mapping.slice(o).map(i),n)){let u=null;if(n.schema.linebreakReplacement){let b=n.whitespace=="pre",_=!!n.contentMatch.matchType(n.schema.linebreakReplacement);b&&!_?u=!1:!b&&_&&(u=!0)}u===!1&&JXe(t,l,i,o),SNe(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 th(f,g,f+1,g-1,new bn(Lr.from(n.create(c,null,l.marks)),0,0),1,!0)),u===!0&&QXe(t,l,i,o),!1}})}function QXe(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 JXe(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 X8t(t,s,r){let n=t.resolve(s),a=n.index();return n.parent.canReplaceWith(a,a+1,r)}function Q8t(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 th(s,s+o.nodeSize,s+1,s+o.nodeSize-1,new bn(Lr.from(l),0,0),1,!0))}function p1(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 b=f.content.cutByIndex(g,f.childCount),_=n&&n[p+1];_&&(b=b.replaceChild(0,_.type.create(_.attrs)));let j=n&&n[p]||f;if(!f.canReplace(g+1,f.childCount)||!j.type.validContent(b))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 J8t(t,s,r=1,n){let a=t.doc.resolve(s),o=Lr.empty,l=Lr.empty;for(let i=a.depth,c=a.depth-r,u=r-1;i>c;i--,u--){o=Lr.from(a.node(i).copy(o));let p=n&&n[u];l=Lr.from(p?p.type.create(p.attrs,l):a.node(i).copy(l))}t.step(new Ku(s,s,new bn(o.append(l),r,r),!0))}function Pw(t,s){let r=t.resolve(s),n=r.index();return eQe(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function eDt(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&&eQe(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);JXe(t,p.node(),p.before(),i)}l.inlineContent&&SNe(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 Ku(u,c.map(s+r,-1),bn.empty,!0)),n===!0){let p=t.doc.resolve(u);QXe(t,p.node(),p.before(),t.steps.length)}return t}function sDt(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 kue(t,s,r=s,n=bn.empty){if(s==r&&!n.size)return null;let a=t.resolve(s),o=t.resolve(r);return sQe(a,o,n)?new Ku(s,r,n):new rDt(a,o,n).fit()}function sQe(t,s,r){return!r.openStart&&!r.openEnd&&t.start()==s.start()&&t.parent.canReplace(t.index(),s.index(),r.content)}class rDt{constructor(s,r,n){this.$from=s,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=Lr.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=Lr.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 bn(o,l,i);return s>-1?new th(n.pos,s,this.$to.pos,this.$to.end(),c,r):c.size||n.pos!=this.$to.pos?new Ku(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=Zxe(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(Lr.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=Zxe(s,r);return!a.childCount||a.firstChild.isLeaf?!1:(this.unplaced=new bn(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=Zxe(s,r);if(a.childCount<=1&&r>0){let o=s.size-r<=r+a.size;this.unplaced=new bn(wI(s,r-1,1),r-1,o?r-1:n)}else this.unplaced=new bn(wI(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 j=0;j1||c==0||j.content.size)&&(f=w,p.push(rQe(j.mark(g.allowedMarks(j.marks)),u==1?c:0,u==i.childCount?b:-1)))}let _=u==i.childCount;_||(b=-1),this.placed=jI(this.placed,r,Lr.from(p)),this.frontier[r].match=f,_&&b<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let j=0,w=i;j1&&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=Yxe(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=jI(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=jI(this.placed,this.depth,Lr.from(s.create(r,n))),this.frontier.push({type:s,match:s.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(Lr.empty,!0);r.childCount&&(this.placed=jI(this.placed,this.frontier.length,r))}}function wI(t,s,r){return s==0?t.cutByIndex(r,t.childCount):t.replaceChild(0,t.firstChild.copy(wI(t.firstChild.content,s-1,r)))}function jI(t,s,r){return s==0?t.append(r):t.replaceChild(t.childCount-1,t.lastChild.copy(jI(t.lastChild.content,s-1,r)))}function Zxe(t,s){for(let r=0;r1&&(n=n.replaceChild(0,rQe(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(Lr.empty,!0)))),t.copy(n)}function Yxe(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&&!nDt(r,o.content,l)?i:null}function nDt(t,s,r){for(let n=r;n0;g--,b--){let _=a.node(g).type.spec;if(_.defining||_.definingAsContext||_.isolating)break;l.indexOf(g)>-1?i=g:a.before(g)==b&&l.splice(1,0,-g)}let c=l.indexOf(i),u=[],p=n.openStart;for(let g=n.content,b=0;;b++){let _=g.firstChild;if(u.push(_),b==n.openStart)break;g=_.content}for(let g=p-1;g>=0;g--){let b=u[g],_=aDt(b.type);if(_&&!b.sameMarkup(a.node(Math.abs(i)-1)))p=g;else if(_||!b.type.isTextblock)break}for(let g=n.openStart;g>=0;g--){let b=(g+p+1)%(n.openStart+1),_=u[b];if(_)for(let j=0;j=0&&(t.replace(s,r,n),!(t.steps.length>f));g--){let b=l[g];b<0||(s=a.before(b),r=o.after(b))}}function nQe(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(Lr.empty,!0))}return t}function oDt(t,s,r,n){if(!n.isInline&&s==r&&t.doc.resolve(s).parent.content.size){let a=sDt(t.doc,s,n.type);a!=null&&(s=r=a)}t.replaceRange(s,r,new bn(Lr.from(n),0,0))}function lDt(t,s,r){let n=t.doc.resolve(s),a=t.doc.resolve(r),o=aQe(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 aQe(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 JM extends Jh{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 Jd.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 Jd.fromReplace(s,this.pos,this.pos+1,new bn(Lr.from(a),0,r.isLeaf?0:1))}getMap(){return lf.empty}invert(s){return new JM(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 JM(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 JM(r.pos,r.attr,r.value)}}Jh.jsonID("attr",JM);class oD extends Jh{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 Jd.ok(n)}getMap(){return lf.empty}invert(s){return new oD(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 oD(r.attr,r.value)}}Jh.jsonID("docAttr",oD);let UT=class extends Error{};UT=function t(s){let r=Error.call(this,s);return r.__proto__=t.prototype,r};UT.prototype=Object.create(Error.prototype);UT.prototype.constructor=UT;UT.prototype.name="TransformError";class MNe{constructor(s){this.doc=s,this.steps=[],this.docs=[],this.mapping=new iD}get before(){return this.docs.length?this.docs[0]:this.doc}step(s){let r=this.maybeStep(s);if(r.failed)throw new UT(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=bn.empty){let a=kue(this.doc,s,r,n);return a&&this.step(a),this}replaceWith(s,r,n){return this.replace(s,r,new bn(Lr.from(n),0,0))}delete(s,r){return this.replace(s,r,bn.empty)}insert(s,r){return this.replaceWith(s,s,r)}replaceRange(s,r,n){return iDt(this,s,r,n),this}replaceRangeWith(s,r,n){return oDt(this,s,r,n),this}deleteRange(s,r){return lDt(this,s,r),this}lift(s,r){return W8t(this,s,r),this}join(s,r=1){return tDt(this,s,r),this}wrap(s,r){return Z8t(this,s,r),this}setBlockType(s,r=s,n,a=null){return Y8t(this,s,r,n,a),this}setNodeMarkup(s,r,n=null,a){return Q8t(this,s,r,n,a),this}setNodeAttribute(s,r,n){return this.step(new JM(s,r,n)),this}setDocAttribute(s,r){return this.step(new oD(s,r)),this}addNodeMark(s,r){return this.step(new N_(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 El)r.isInSet(n.marks)&&this.step(new qS(s,r));else{let a=n.marks,o,l=[];for(;o=r.isInSet(a);)l.push(new qS(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 J8t(this,s,r,n),this}addMark(s,r,n){return U8t(this,s,r,n),this}removeMark(s,r,n){return V8t(this,s,r,n),this}clearIncompatible(s,r,n){return SNe(this,s,r,n),this}}const Xxe=Object.create(null);class pi{constructor(s,r,n){this.$anchor=s,this.$head=r,this.ranges=n||[new iQe(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?R5(s.node(0),s.node(o),s.before(o+1),s.index(o),r,n):R5(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 bf(s.node(0))}static atStart(s){return R5(s,s,0,0,1)||new bf(s)}static atEnd(s){return R5(s,s,s.content.size,s.childCount,-1)||new bf(s)}static fromJSON(s,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Xxe[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 Xxe)throw new RangeError("Duplicate use of selection JSON ID "+s);return Xxe[s]=r,r.prototype.jsonID=s,r}getBookmark(){return Qa.between(this.$anchor,this.$head).getBookmark()}}pi.prototype.visible=!0;class iQe{constructor(s,r){this.$from=s,this.$to=r}}let PIe=!1;function IIe(t){!PIe&&!t.parent.inlineContent&&(PIe=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Qa extends pi{constructor(s,r=s){IIe(s),IIe(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 pi.near(n);let a=s.resolve(r.map(this.anchor));return new Qa(a.parent.inlineContent?a:n,n)}replace(s,r=bn.empty){if(super.replace(s,r),r==bn.empty){let n=this.$from.marksAcross(this.$to);n&&s.ensureMarks(n)}}eq(s){return s instanceof Qa&&s.anchor==this.anchor&&s.head==this.head}getBookmark(){return new Sue(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 Qa(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=pi.findFrom(r,n,!0)||pi.findFrom(r,-n,!0);if(o)r=o.$head;else return pi.near(r,n)}return s.parent.inlineContent||(a==0?s=r:(s=(pi.findFrom(s,-n,!0)||pi.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&&Ha.isSelectable(i))return Ha.create(t,r-(a<0?i.nodeSize:0))}else{let c=R5(t,i,r+a,a<0?i.childCount:0,a,o);if(c)return c}r+=i.nodeSize*a}return null}function LIe(t,s,r){let n=t.steps.length-1;if(n{l==null&&(l=p)}),t.setSelection(pi.near(t.doc.resolve(l),r))}const DIe=1,oz=2,OIe=4;class dDt extends MNe{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|=oz,this}ensureMarks(s){return El.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&oz)>0}addStep(s,r){super.addStep(s,r),this.updated=this.updated&~oz,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)||El.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(pi.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|=OIe,this}get scrolledIntoView(){return(this.updated&OIe)>0}}function RIe(t,s){return!s||!t?t:t.bind(s)}class NI{constructor(s,r,n){this.name=s,this.init=RIe(r.init,n),this.apply=RIe(r.apply,n)}}const uDt=[new NI("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new NI("selection",{init(t,s){return t.selection||pi.atStart(s.doc)},apply(t){return t.selection}}),new NI("storedMarks",{init(t){return t.storedMarks||null},apply(t,s,r,n){return n.selection.$cursor?t.storedMarks:null}}),new NI("scrollToSelection",{init(){return 0},apply(t,s){return t.scrolledIntoView?s+1:s}})];class Qxe{constructor(s,r){this.schema=s,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=uDt.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 NI(n.key,n.spec.state,n))})}}class nM{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 Qxe(s.schema,s.plugins),o=new nM(a);return a.fields.forEach(l=>{if(l.name=="doc")o.doc=Y_.fromJSON(s.schema,r.doc);else if(l.name=="selection")o.selection=pi.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 oQe(t,s,r){for(let n in t){let a=t[n];a instanceof Function?a=a.bind(s):n=="handleDOMEvents"&&(a=oQe(a,s,{})),r[n]=a}return r}class Pu{constructor(s){this.spec=s,this.props={},s.props&&oQe(s.props,this,this.props),this.key=s.key?s.key.key:lQe("plugin")}getState(s){return s[this.key]}}const Jxe=Object.create(null);function lQe(t){return t in Jxe?t+"$"+ ++Jxe[t]:(Jxe[t]=0,t+"$")}class em{constructor(s="key"){this.key=lQe(s)}get(s){return s.config.pluginsByKey[this.key]}getState(s){return s[this.key]}}const yh=function(t){for(var s=0;;s++)if(t=t.previousSibling,!t)return s},VT=function(t){let s=t.assignedSlot||t.parentNode;return s&&s.nodeType==11?s.host:s};let w1e=null;const Ev=function(t,s,r){let n=w1e||(w1e=document.createRange());return n.setEnd(t,r??t.nodeValue.length),n.setStart(t,s||0),n},hDt=function(){w1e=null},US=function(t,s,r,n){return r&&(FIe(t,s,r,n,-1)||FIe(t,s,r,n,1))},mDt=/^(img|br|input|textarea|hr)$/i;function FIe(t,s,r,n,a){for(var o;;){if(t==r&&s==n)return!0;if(s==(a<0?0:xx(t))){let l=t.parentNode;if(!l||l.nodeType!=1||BO(t)||mDt.test(t.nodeName)||t.contentEditable=="false")return!1;s=yh(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?xx(t):0}else return!1}}function xx(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function pDt(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=xx(t)}else if(t.parentNode&&!BO(t))s=yh(t),t=t.parentNode;else return null}}function fDt(t,s){for(;;){if(t.nodeType==3&&s2),cx=HT||(C0?/Mac/.test(C0.platform):!1),uQe=C0?/Win/.test(C0.platform):!1,Kv=/Android \d/.test(Iw),$O=!!zIe&&"webkitFontSmoothing"in zIe.documentElement.style,vDt=$O?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bDt(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 bv(t,s){return typeof t=="number"?t:t[s]}function _Dt(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 BIe(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=VT(l);continue}let i=l,c=i==o.body,u=c?bDt(o):_Dt(i),p=0,f=0;if(s.topu.bottom-bv(n,"bottom")&&(f=s.bottom-s.top>u.bottom-u.top?s.top+bv(a,"top")-u.top:s.bottom-u.bottom+bv(a,"bottom")),s.leftu.right-bv(n,"right")&&(p=s.right-u.right+bv(a,"right")),p||f)if(c)o.defaultView.scrollBy(p,f);else{let b=i.scrollLeft,_=i.scrollTop;f&&(i.scrollTop+=f),p&&(i.scrollLeft+=p);let j=i.scrollLeft-b,w=i.scrollTop-_;s={left:s.left-j,top:s.top-w,right:s.right-j,bottom:s.bottom-w}}let g=c?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(g))break;l=g=="absolute"?l.offsetParent:VT(l)}}function wDt(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:hQe(t.dom)}}function hQe(t){let s=[],r=t.ownerDocument;for(let n=t;n&&(s.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),t!=r);n=VT(n));return s}function jDt({refDOM:t,refTop:s,stack:r}){let n=t?t.getBoundingClientRect().top:0;mQe(r,n==0?0:n-s)}function mQe(t,s){for(let r=0;r=i){l=Math.max(_.bottom,l),i=Math.min(_.top,i);let j=_.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?kDt(r,a):!r||n&&r.nodeType==1?{node:t,offset:o}:pQe(r,a)}function kDt(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 ANe(t,s){return t.left>=s.left-1&&t.left<=s.right+1&&t.top>=s.top-1&&t.top<=s.bottom+1}function SDt(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 MDt(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 fQe(t,s,r){let n=t.childNodes.length;if(n&&r.tops.top&&a++}let u;$O&&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=MDt(t,n,a,s))}i==null&&(i=CDt(t,l,s));let c=t.docView.nearestDesc(l,!0);return{pos:i,inside:c?c.posAtStart-c.border:-1}}function $Ie(t){return t.top=0&&a==n.nodeValue.length?(c--,p=1):r<0?c--:u++,ZP($b(Ev(n,c,u),p),p<0)}if(!t.state.doc.resolve(s-(o||0)).parent.inlineContent){if(o==null&&a&&(r<0||a==xx(n))){let c=n.childNodes[a-1];if(c.nodeType==1)return ege(c.getBoundingClientRect(),!1)}if(o==null&&a=0)}if(o==null&&a&&(r<0||a==xx(n))){let c=n.childNodes[a-1],u=c.nodeType==3?Ev(c,xx(c)-(l?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return ZP($b(u,1),!1)}if(o==null&&a=0)}function ZP(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 ege(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 gQe(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 EDt(t,s,r){let n=s.selection,a=r=="up"?n.$from:n.$to;return gQe(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=xQe(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=Ev(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 PDt=/[\u0590-\u08ac]/;function IDt(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?!PDt.test(n.parent.textContent)||!i.modify?r=="left"||r=="backward"?o:l:gQe(t,s,()=>{let{focusNode:c,focusOffset:u,anchorNode:p,anchorOffset:f}=t.domSelectionRange(),g=i.caretBidiLevel;i.modify("move",r,"character");let b=n.depth?t.docView.domAfterPos(n.before()):t.dom,{focusNode:_,focusOffset:j}=t.domSelectionRange(),w=_&&!b.contains(_.nodeType==1?_:_.parentNode)||c==_&&u==j;try{i.collapse(p,f),c&&(c!=p||u!=f)&&i.extend&&i.extend(c,u)}catch{}return g!=null&&(i.caretBidiLevel=g),w}):n.pos==n.start()||n.pos==n.end()}let qIe=null,UIe=null,VIe=!1;function LDt(t,s,r){return qIe==s&&UIe==r?VIe:(qIe=s,UIe=r,VIe=r=="up"||r=="down"?EDt(t,s,r):IDt(t,s,r))}const Ex=0,HIe=1,v4=2,M0=3;class qO{constructor(s,r,n,a){this.parent=s,this.children=r,this.dom=n,this.contentDOM=a,this.dirty=Ex,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;ryh(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 vQe){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 yQe&&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?yh(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=yh(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 b=document.createRange();b.setEnd(c.node,c.offset),b.setStart(i.node,i.offset),u.removeAllRanges(),u.addRange(b)}}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?v4:HIe,s==i&&r==c&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=M0:o.markDirty(s-i,r-i);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?v4:M0}n=l}this.dirty=v4}markParentsDirty(){let s=1;for(let r=this.parent;r;r=r.parent,s++){let n=s==1?v4:HIe;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==Ex&&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 DDt extends qO{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 VS extends qO{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=pC.renderSpec(document,r.type.spec.toDOM(r,n),null,r.attrs)),new VS(s,r,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&M0||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(s){return this.dirty!=M0&&this.mark.eq(s)}markDirty(s,r){if(super.markDirty(s,r),this.dirty!=Ex){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(o=C1e(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}=pC.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=wQe(p,n,r),u?c=new ODt(s,r,n,a,p,f||null,g,u,o,l+1):r.isText?new Mue(s,r,n,a,p,g,o):new Q_(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=()=>Lr.empty)}return s}matchesNode(s,r,n){return this.dirty==Ex&&s.eq(this.node)&&Qoe(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 FDt(this,l&&l.node,s);$Dt(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?El.none:this.node.child(p).marks,n,s),c.placeWidget(u,s,a)},(u,p,f,g)=>{c.syncToMarks(u.marks,n,s);let b;c.findNodeMatch(u,p,f,g)||i&&s.state.selection.from>a&&s.state.selection.to-1&&c.updateNodeAt(u,p,f,b,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==v4)&&(l&&this.protectLocalComposition(s,l),bQe(this.contentDOM,this.children,s),HT&&qDt(this.dom))}localCompositionInfo(s,r){let{from:n,to:a}=s.state.selection;if(!(s.state.selection instanceof Qa)||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=UDt(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 DDt(this,o,r,a);s.input.compositionNodes.push(l),this.children=C1e(this.children,n,n+a.length,s,l)}update(s,r,n,a){return this.dirty==M0||!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=Ex}updateOuterDeco(s){if(Qoe(s,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=_Qe(this.dom,this.nodeDOM,S1e(this.outerDeco,this.node,r),S1e(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 WIe(t,s,r,n,a){wQe(n,s,t);let o=new Q_(void 0,t,s,r,n,n,n,a,0);return o.contentDOM&&o.updateChildren(a,0),o}class Mue extends Q_{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==M0||this.dirty!=Ex&&!this.inParent()||!s.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=Ex||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=Ex,!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 Mue(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=M0)}get domAtom(){return!1}isText(s){return this.node.text==s}}class vQe extends qO{parseRule(){return{ignore:!0}}matchesHack(s){return this.dirty==Ex&&this.dom.nodeName==s}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ODt extends Q_{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==M0)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 bQe(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=VS.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 VS)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 BDt(t,s){return t.type.side-s.type.side}function $Dt(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 w=_;l!w.inline):i.slice();n(g,j,s.forChild(o,g),b),o=_}}function qDt(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 UDt(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 C1e(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 ENe(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(Cue(r)){for(c=l;a&&!a.node;)a=a.parent;let f=a.node;if(a&&f.isAtom&&Ha.isSelectable(f)&&a.parent&&!(f.isInline&&xDt(r.focusNode,r.focusOffset,a.dom))){let g=a.posBefore;u=new Ha(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 b=0;b{(r.anchorNode!=n||r.anchorOffset!=a)&&(s.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!jQe(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function HDt(t){let s=t.domSelection();if(!s)return;let r=t.cursorWrapper.dom,n=r.nodeName=="IMG";n?s.collapse(r.parentNode,yh(r)+1):s.collapse(r,0),!n&&!t.state.selection.visible&&Tp&&X_<=11&&(r.disabled=!0,r.disabled=!1)}function NQe(t,s){if(s instanceof Ha){let r=t.docView.descAt(s.from);r!=t.lastSelectedViewDesc&&(XIe(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else XIe(t)}function XIe(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function PNe(t,s,r,n){return t.someProp("createSelectionBetween",a=>a(t,s,r))||Qa.between(s,r,n)}function QIe(t){return t.editable&&!t.hasFocus()?!1:kQe(t)}function kQe(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 WDt(t){let s=t.docView.domFromPos(t.state.selection.anchor,0),r=t.domSelectionRange();return US(s.node,s.offset,r.anchorNode,r.anchorOffset)}function M1e(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&&pi.findFrom(o,s)}function Gb(t,s){return t.dispatch(t.state.tr.setSelection(s).scrollIntoView()),!0}function JIe(t,s,r){let n=t.state.selection;if(n instanceof Qa)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 Gb(t,new Qa(n.$anchor,l))}else if(n.empty){if(t.endOfTextblock(s>0?"forward":"backward")){let a=M1e(t.state,s);return a&&a instanceof Ha?Gb(t,a):!1}else if(!(cx&&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?Ha.isSelectable(o)?Gb(t,new Ha(s<0?t.state.doc.resolve(a.pos-o.nodeSize):a)):$O?Gb(t,new Qa(t.state.doc.resolve(s<0?i:i+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof Ha&&n.node.isInline)return Gb(t,new Qa(s>0?n.$to:n.$from));{let a=M1e(t.state,s);return a?Gb(t,a):!1}}}function Joe(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function e8(t,s){let r=t.pmViewDesc;return r&&r.size==0&&(s<0||t.nextSibling||t.nodeName!="BR")}function v5(t,s){return s<0?GDt(t):KDt(t)}function GDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a,o,l=!1;for(Ax&&r.nodeType==1&&n0){if(r.nodeType!=1)break;{let i=r.childNodes[n-1];if(e8(i,-1))a=r,o=--n;else if(i.nodeType==3)r=i,n=r.nodeValue.length;else break}}else{if(SQe(r))break;{let i=r.previousSibling;for(;i&&e8(i,-1);)a=r.parentNode,o=yh(i),i=i.previousSibling;if(i)r=i,n=Joe(r);else{if(r=r.parentNode,r==t.dom)break;n=0}}}l?T1e(t,r,n):a&&T1e(t,a,o)}function KDt(t){let s=t.domSelectionRange(),r=s.focusNode,n=s.focusOffset;if(!r)return;let a=Joe(r),o,l;for(;;)if(n{t.state==a&&f1(t)},50)}function eLe(t,s){let r=t.state.doc.resolve(s);if(!(Yu||uQe)&&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 tLe(t,s,r){let n=t.state.selection;if(n instanceof Qa&&!n.empty||r.indexOf("s")>-1||cx&&r.indexOf("m")>-1)return!1;let{$from:a,$to:o}=n;if(!a.parent.inlineContent||t.endOfTextblock(s<0?"up":"down")){let l=M1e(t.state,s);if(l&&l instanceof Ha)return Gb(t,l)}if(!a.parent.inlineContent){let l=s<0?a:o,i=n instanceof bf?pi.near(l,s):pi.findFrom(l,s);return i?Gb(t,i):!1}return!1}function sLe(t,s){if(!(t.state.selection instanceof Qa))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 rLe(t,s,r){t.domObserver.stop(),s.contentEditable=r,t.domObserver.start()}function XDt(t){if(!Xh||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;rLe(t,n,"true"),setTimeout(()=>rLe(t,n,"false"),20)}return!1}function QDt(t){let s="";return t.ctrlKey&&(s+="c"),t.metaKey&&(s+="m"),t.altKey&&(s+="a"),t.shiftKey&&(s+="s"),s}function JDt(t,s){let r=s.keyCode,n=QDt(s);if(r==8||cx&&r==72&&n=="c")return sLe(t,-1)||v5(t,-1);if(r==46&&!s.shiftKey||cx&&r==68&&n=="c")return sLe(t,1)||v5(t,1);if(r==13||r==27)return!0;if(r==37||cx&&r==66&&n=="c"){let a=r==37?eLe(t,t.state.selection.from)=="ltr"?-1:1:-1;return JIe(t,a,n)||v5(t,a)}else if(r==39||cx&&r==70&&n=="c"){let a=r==39?eLe(t,t.state.selection.from)=="ltr"?1:-1:1;return JIe(t,a,n)||v5(t,a)}else{if(r==38||cx&&r==80&&n=="c")return tLe(t,-1,n)||v5(t,-1);if(r==40||cx&&r==78&&n=="c")return XDt(t)||tLe(t,1,n)||v5(t,1);if(n==(cx?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function INe(t,s){t.someProp("transformCopied",b=>{s=b(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 b=n.firstChild;r.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),n=b.content}let l=t.someProp("clipboardSerializer")||pC.fromSchema(t.state.schema),i=PQe(),c=i.createElement("div");c.appendChild(l.serializeFragment(n,{document:i}));let u=c.firstChild,p,f=0;for(;u&&u.nodeType==1&&(p=EQe[u.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let _=i.createElement(p[b]);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",b=>b(s,t))||s.content.textBetween(0,s.content.size,` `);return{dom:c,text:g,slice:s}}function CQe(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 bn(Lr.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:b}=t.state,_=pC.fromSchema(b);l=document.createElement("div"),s.split(/(?:\r\n?|\n)+/).forEach(j=>{let w=l.appendChild(document.createElement("p"));j&&w.appendChild(_.serializeNode(b.text(j,g)))})}}else t.someProp("transformPastedHTML",f=>{r=f(r,t)}),l=rOt(r),$O&&nOt(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")||XL.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(c||p),context:a,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!eOt.test(g.parentNode.nodeName)?{ignore:!0}:null}})),p)i=aOt(nLe(i,+p[1],+p[2]),p[4]);else if(i=bn.maxOpen(tOt(i.content,a),!0),i.openStart||i.openEnd){let f=0,g=0;for(let b=i.content.firstChild;f{i=f(i,t,c)}),i}const eOt=/^(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&&TQe(c,o,i,l[l.length-1],0))l[l.length-1]=u;else{l.length&&(l[l.length-1]=AQe(l[l.length-1],o.length));let p=MQe(i,c);l.push(p),a=a.matchType(p.type),o=c}}),l)return Lr.from(l)}return t}function MQe(t,s,r=0){for(let n=s.length-1;n>=r;n--)t=s[n].create(null,Lr.from(t));return t}function TQe(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(Lr.empty,!0))),t.replaceChild(s<0?0:t.childCount-1,l.copy(i))}function nLe(t,s,r){return sr})),sge.createHTML(t)):t}function rOt(t){let s=/^(\s*]*>)*/.exec(t);s&&(t=t.slice(s[0].length));let r=PQe().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(t),a;if((a=n&&EQe[n[1].toLowerCase()])&&(t=a.map(o=>"<"+o+">").join("")+t+a.map(o=>"").reverse().join("")),r.innerHTML=sOt(t),a)for(let o=0;o=0;i-=2){let c=r.nodes[n[i]];if(!c||c.hasRequiredAttrs())break;a=Lr.from(c.create(n[i+1],a)),o++,l++}return new bn(a,o,l)}const $m={},qm={},iOt={touchstart:!0,touchmove:!0};class oOt{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 lOt(t){for(let s in $m){let r=$m[s];t.dom.addEventListener(s,t.input.eventHandlers[s]=n=>{dOt(t,n)&&!LNe(t,n)&&(t.editable||!(n.type in qm))&&r(t,n)},iOt[s]?{passive:!0}:void 0)}Xh&&t.dom.addEventListener("input",()=>null),E1e(t)}function k_(t,s){t.input.lastSelectionOrigin=s,t.input.lastSelectionTime=Date.now()}function cOt(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 E1e(t){t.someProp("handleDOMEvents",s=>{for(let r in s)t.input.eventHandlers[r]||t.dom.addEventListener(r,t.input.eventHandlers[r]=n=>LNe(t,n))})}function LNe(t,s){return t.someProp("handleDOMEvents",r=>{let n=r[s.type];return n?n(t,s)||s.defaultPrevented:!1})}function dOt(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 uOt(t,s){!LNe(t,s)&&$m[s.type]&&(t.editable||!(s.type in qm))&&$m[s.type](t,s)}qm.keydown=(t,s)=>{let r=s;if(t.input.shiftKey=r.keyCode==16||r.shiftKey,!LQe(t,r)&&(t.input.lastKeyCode=r.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Kv&&Yu&&r.keyCode==13)))if(r.keyCode!=229&&t.domObserver.forceFlush(),HT&&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,o4(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",n=>n(t,r))||JDt(t,r)?r.preventDefault():k_(t,"key")};qm.keyup=(t,s)=>{s.keyCode==16&&(t.input.shiftKey=!1)};qm.keypress=(t,s)=>{let r=s;if(LQe(t,r)||!r.charCode||r.ctrlKey&&!r.altKey||cx&&r.metaKey)return;if(t.someProp("handleKeyPress",a=>a(t,r))){r.preventDefault();return}let n=t.state.selection;if(!(n instanceof Qa)||!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 Tue(t){return{left:t.clientX,top:t.clientY}}function hOt(t,s){let r=s.x-t.clientX,n=s.y-t.clientY;return r*r+n*n<100}function DNe(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 eT(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 mOt(t,s){if(s==-1)return!1;let r=t.state.doc.resolve(s),n=r.nodeAfter;return n&&n.isAtom&&Ha.isSelectable(n)?(eT(t,new Ha(r)),!0):!1}function pOt(t,s){if(s==-1)return!1;let r=t.state.selection,n,a;r instanceof Ha&&(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(Ha.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?(eT(t,Ha.create(t.state.doc,a)),!0):!1}function fOt(t,s,r,n,a){return DNe(t,"handleClickOn",s,r,n)||t.someProp("handleClick",o=>o(t,s,n))||(a?pOt(t,r):mOt(t,r))}function xOt(t,s,r,n){return DNe(t,"handleDoubleClickOn",s,r,n)||t.someProp("handleDoubleClick",a=>a(t,s,n))}function gOt(t,s,r,n){return DNe(t,"handleTripleClickOn",s,r,n)||t.someProp("handleTripleClick",a=>a(t,s,n))||yOt(t,r,n)}function yOt(t,s,r){if(r.button!=0)return!1;let n=t.state.doc;if(s==-1)return n.inlineContent?(eT(t,Qa.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)eT(t,Qa.create(n,i+1,i+1+l.content.size));else if(Ha.isSelectable(l))eT(t,Ha.create(n,i));else continue;return!0}}function ONe(t){return ele(t)}const IQe=cx?"metaKey":"ctrlKey";$m.mousedown=(t,s)=>{let r=s;t.input.shiftKey=r.shiftKey;let n=ONe(t),a=Date.now(),o="singleClick";a-t.input.lastClick.time<500&&hOt(r,t.input.lastClick)&&!r[IQe]&&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(Tue(r));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new vOt(t,l,r,!!n)):(o=="doubleClick"?xOt:gOt)(t,l.pos,l.inside,r)?r.preventDefault():k_(t,"pointer"))};class vOt{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[IQe],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 Ha&&u.from<=l&&u.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ax&&!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)),k_(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(()=>f1(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(Tue(s))),this.updateAllowDefault(s),this.allowDefault||!r?k_(this.view,"pointer"):fOt(this.view,r.pos,r.inside,s,this.selectNode)?s.preventDefault():s.button==0&&(this.flushed||Xh&&this.mightDrag&&!this.mightDrag.node.isAtom||Yu&&!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)?(eT(this.view,pi.near(this.view.state.doc.resolve(r.pos))),s.preventDefault()):k_(this.view,"pointer")}move(s){this.updateAllowDefault(s),k_(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)}}$m.touchstart=t=>{t.input.lastTouch=Date.now(),ONe(t),k_(t,"pointer")};$m.touchmove=t=>{t.input.lastTouch=Date.now(),k_(t,"pointer")};$m.contextmenu=t=>ONe(t);function LQe(t,s){return t.composing?!0:Xh&&Math.abs(s.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const bOt=Kv?5e3:-1;qm.compositionstart=qm.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:s}=t,r=s.selection.$to;if(s.selection instanceof Qa&&(s.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||Yu&&uQe&&_Ot(t)))t.markCursor=t.state.storedMarks||r.marks(),ele(t,!0),t.markCursor=null;else if(ele(t,!s.selection.empty),Ax&&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}DQe(t,bOt)};function _Ot(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"}qm.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++,DQe(t,20))};function DQe(t,s){clearTimeout(t.input.composingTimeout),s>-1&&(t.input.composingTimeout=setTimeout(()=>ele(t),s))}function OQe(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=jOt());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function wOt(t){let s=t.domSelectionRange();if(!s.focusNode)return null;let r=pDt(s.focusNode,s.focusOffset),n=fDt(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 jOt(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ele(t,s=!1){if(!(Kv&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),OQe(t),s||t.docView&&t.docView.dirty){let r=ENe(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 NOt(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 lD=Tp&&X_<15||HT&&vDt<604;$m.copy=qm.cut=(t,s)=>{let r=s,n=t.state.selection,a=r.type=="cut";if(n.empty)return;let o=lD?null:r.clipboardData,l=n.content(),{dom:i,text:c}=INe(t,l);o?(r.preventDefault(),o.clearData(),o.setData("text/html",i.innerHTML),o.setData("text/plain",c)):NOt(t,i),a&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function kOt(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function SOt(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?cD(t,n.value,null,a,s):cD(t,n.textContent,n.innerHTML,a,s)},50)}function cD(t,s,r,n,a){let o=CQe(t,s,r,n,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,a,o||bn.empty)))return!0;if(!o)return!1;let l=kOt(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 RQe(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," "):""}qm.paste=(t,s)=>{let r=s;if(t.composing&&!Kv)return;let n=lD?null:r.clipboardData,a=t.input.shiftKey&&t.input.lastKeyCode!=45;n&&cD(t,RQe(n),n.getData("text/html"),a,r)?r.preventDefault():SOt(t,r)};class FQe{constructor(s,r,n){this.slice=s,this.move=r,this.node=n}}const COt=cx?"altKey":"ctrlKey";function zQe(t,s){let r=t.someProp("dragCopies",n=>!n(s));return r??!s[COt]}$m.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(Tue(r)),l;if(!(o&&o.pos>=a.from&&o.pos<=(a instanceof Ha?a.to-1:a.to))){if(n&&n.mightDrag)l=Ha.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=Ha.create(t.state.doc,f.posBefore))}}let i=(l||t.state.selection).content(),{dom:c,text:u,slice:p}=INe(t,i);(!r.dataTransfer.files.length||!Yu||dQe>120)&&r.dataTransfer.clearData(),r.dataTransfer.setData(lD?"Text":"text/html",c.innerHTML),r.dataTransfer.effectAllowed="copyMove",lD||r.dataTransfer.setData("text/plain",u),t.dragging=new FQe(p,zQe(t,r),l)};$m.dragend=t=>{let s=t.dragging;window.setTimeout(()=>{t.dragging==s&&(t.dragging=null)},50)};qm.dragover=qm.dragenter=(t,s)=>s.preventDefault();qm.drop=(t,s)=>{try{MOt(t,s,t.dragging)}finally{t.dragging=null}};function MOt(t,s,r){if(!s.dataTransfer)return;let n=t.posAtCoords(Tue(s));if(!n)return;let a=t.state.doc.resolve(n.pos),o=r&&r.slice;o?t.someProp("transformPasted",b=>{o=b(o,t,!1)}):o=CQe(t,RQe(s.dataTransfer),lD?null:s.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&zQe(t,s));if(t.someProp("handleDrop",b=>b(t,s,o||bn.empty,l))){s.preventDefault();return}if(!o)return;s.preventDefault();let i=o?tQe(t.state.doc,a.pos,o):a.pos;i==null&&(i=a.pos);let c=t.state.tr;if(l){let{node:b}=r;b?b.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&&Ha.isSelectable(o.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new Ha(g));else{let b=c.mapping.map(i);c.mapping.maps[c.mapping.maps.length-1].forEach((_,j,w,N)=>b=N),c.setSelection(PNe(t,g,c.doc.resolve(b)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))}$m.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())&&f1(t)},20))};$m.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)};$m.beforeinput=(t,s)=>{if(Yu&&Kv&&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,o4(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 qm)$m[t]=qm[t];function dD(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 tle{constructor(s,r){this.toDOM=s,this.spec=r||xS,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 Cm(o-n,o-n,this)}valid(){return!0}eq(s){return this==s||s instanceof tle&&(this.spec.key&&this.spec.key==s.spec.key||this.toDOM==s.toDOM&&dD(this.spec,s.spec))}destroy(s){this.spec.destroy&&this.spec.destroy(s)}}class J_{constructor(s,r){this.attrs=s,this.spec=r||xS}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 Cm(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==zh||s.maps.length==0?this:this.mapInner(s,r,0,0,n||xS)}mapInner(s,r,n,a,o){let l;for(let i=0;i{let u=c+n,p;if(p=$Qe(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 J_){let u=Math.max(o,c.from)-o,p=Math.min(l,c.to)-o;ua.map(s,r,xS));return r_.from(n)}forChild(s,r){if(r.isLeaf)return pd.empty;let n=[];for(let a=0;ar instanceof pd)?s:s.reduce((r,n)=>r.concat(n instanceof pd?n:n.members),[]))}}forEachSet(s){for(let r=0;r{let w=j-_-(b-g);for(let N=0;NC+p-f)continue;let M=i[N]+p-f;b>=M?i[N+1]=g<=M?-2:-1:g>=p&&w&&(i[N]+=w,i[N+1]+=w)}f+=w}),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),b=g-a,{index:_,offset:j}=n.content.findIndex(f),w=n.maybeChild(_);if(w&&j==f&&j+w.nodeSize==b){let N=i[u+2].mapInner(r,w,p+1,t[u]+o+1,l);N!=zh?(i[u]=f,i[u+1]=b,i[u+2]=N):(i[u+1]=-2,c=!0)}else c=!0}if(c){let u=AOt(i,t,s,r,a,o,l),p=sle(u,n,0,l);s=p.local;for(let f=0;fr&&l.to{let u=$Qe(t,i,c+r);if(u){o=!0;let p=sle(u,i,r+c+1,n);p!=zh&&a.push(c,c+i.nodeSize,p)}});let l=BQe(o?qQe(t):t,-r).sort(gS);for(let i=0;i0;)s++;t.splice(s,0,r)}function rge(t){let s=[];return t.someProp("decorations",r=>{let n=r(t.state);n&&n!=zh&&s.push(n)}),t.cursorWrapper&&s.push(pd.create(t.state.doc,[t.cursorWrapper.deco])),r_.from(s)}const EOt={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},POt=Tp&&X_<=11;class IOt{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 LOt{constructor(s,r){this.view=s,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new IOt,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()}),POt&&(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,EOt)),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(QIe(this.view)){if(this.suppressingSelectionUpdates)return f1(this.view);if(Tp&&X_<=11&&!this.view.state.selection.empty){let s=this.view.domSelectionRange();if(s.focusNode&&US(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=VT(o))r.add(o);for(let o=s.anchorNode;o;o=VT(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)&&QIe(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 b=g.parentNode;b&&b.nodeName=="LI"&&(!f||ROt(s,f)!=b)&&g.remove()}}}else if((Yu||Xh)&&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),DOt(s)),this.handleDOMChange(o,l,i,c),s.docView&&s.docView.dirty?s.updateState(s.state):this.currentSelection.eq(n)||f1(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;w--){let N=n.childNodes[w-1],C=N.pmViewDesc;if(N.nodeName=="BR"&&!C){o=w;break}if(!C||C.size)break}let f=t.state.doc,g=t.someProp("domParser")||XL.fromSchema(t.state.schema),b=f.resolve(l),_=null,j=g.parse(n,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:a,to:o,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:zOt,context:b});if(u&&u[0].pos!=null){let w=u[0].pos,N=u[1]&&u[1].pos;N==null&&(N=w),_={anchor:w+l,head:N+l}}return{doc:j,sel:_,from:l,to:i}}function zOt(t){let s=t.pmViewDesc;if(s)return s.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Xh&&/^(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||Xh&&/^(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 BOt=/^(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 $Ot(t,s,r,n,a){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,s<0){let q=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,U=ENe(t,q);if(U&&!t.state.selection.eq(U)){if(Yu&&Kv&&t.input.lastKeyCode===13&&Date.now()-100V(t,o4(13,"Enter"))))return;let B=t.state.tr.setSelection(U);q=="pointer"?B.setMeta("pointer",!0):q=="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=FOt(t,s,r),p=t.state.doc,f=p.slice(u.from,u.to),g,b;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||Kv)&&a.some(q=>q.nodeType==1&&!BOt.test(q.nodeName))&&(!_||_.endA>=_.endB)&&t.someProp("handleKeyDown",q=>q(t,o4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!_)if(n&&c instanceof Qa&&!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 q=dLe(t,t.state.doc,u.sel);if(q&&!q.eq(t.state.selection)){let U=t.state.tr.setSelection(q);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&&X_<=11&&_.endB==_.start+1&&_.endA==_.start&&_.start>u.from&&u.doc.textBetween(_.start-u.from-1,_.start-u.from+1)=="  "&&(_.start--,_.endA--,_.endB--);let j=u.doc.resolveNoCache(_.start-u.from),w=u.doc.resolveNoCache(_.endB-u.from),N=p.resolve(_.start),C=j.sameParent(w)&&j.parent.inlineContent&&N.end()>=_.endA;if((HT&&t.input.lastIOSEnter>Date.now()-225&&(!C||a.some(q=>q.nodeName=="DIV"||q.nodeName=="P"))||!C&&j.posq(t,o4(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>_.start&&UOt(p,_.start,_.endA,j,w)&&t.someProp("handleKeyDown",q=>q(t,o4(8,"Backspace")))){Kv&&Yu&&t.domObserver.suppressSelectionUpdates();return}Yu&&_.endB==_.start&&(t.input.lastChromeDelete=Date.now()),Kv&&!C&&j.start()!=w.start()&&w.parentOffset==0&&j.depth==w.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==_.endA&&(_.endB-=2,w=u.doc.resolveNoCache(_.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(q){return q(t,o4(13,"Enter"))})},20));let M=_.start,I=_.endA,L=q=>{let U=q||t.state.tr.replace(M,I,u.doc.slice(_.start-u.from,_.endB-u.from));if(u.sel){let B=dLe(t,U.doc,u.sel);B&&!(Yu&&t.composing&&B.empty&&(_.start!=_.endB||t.input.lastChromeDeletef1(t),20));let q=L(t.state.tr.delete(M,I)),U=p.resolve(_.start).marksAcross(p.resolve(_.endA));U&&q.ensureMarks(U),t.dispatch(q)}else if(_.endA==_.endB&&(R=qOt(j.parent.content.cut(j.parentOffset,w.parentOffset),N.parent.content.cut(N.parentOffset,_.endA-N.start())))){let q=L(t.state.tr);R.type=="add"?q.addMark(M,I,R.mark):q.removeMark(M,I,R.mark),t.dispatch(q)}else if(j.parent.child(j.index()).isText&&j.index()==w.index()-(w.textOffset?0:1)){let q=j.parent.textBetween(j.parentOffset,w.parentOffset),U=()=>L(t.state.tr.insertText(q,M,I));t.someProp("handleTextInput",B=>B(t,M,I,q,U))||t.dispatch(U())}else t.dispatch(L());else t.dispatch(L())}function dLe(t,s,r){return Math.max(r.anchor,r.head)>s.content.size?null:PNe(t,s.resolve(r.anchor),s.resolve(r.head))}function qOt(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||nge(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 VOt(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 UQe{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 oOt,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=r,this.state=r.state,this.directPlugins=r.plugins||[],this.directPlugins.forEach(xLe),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=pLe(this),mLe(this),this.nodeViews=fLe(this),this.docView=WIe(this.state.doc,hLe(this),rge(this),this.dom,this),this.domObserver=new LOt(this,(n,a,o,l)=>$Ot(this,n,a,o,l)),this.domObserver.start(),lOt(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&&E1e(this);let r=this._props;this._props=s,s.plugins&&(s.plugins.forEach(xLe),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&&(OQe(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 b=fLe(this);WOt(b,this.nodeViews)&&(this.nodeViews=b,o=!0)}(i||r.handleDOMEvents!=this._props.handleDOMEvents)&&E1e(this),this.editable=pLe(this),mLe(this);let c=rge(this),u=hLe(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&&wDt(this);if(l){this.domObserver.stop();let b=f&&(Tp||Yu)&&!this.composing&&!a.selection.empty&&!s.selection.empty&&HOt(a.selection,s.selection);if(f){let _=Yu?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=wOt(this)),(o||!this.docView.update(s.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=WIe(s.doc,u,c,this.dom,this)),_&&!this.trackWrites&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&WDt(this))?f1(this,b):(NQe(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&&jDt(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 Ha){let r=this.docView.domAfterPos(this.state.selection.from);r.nodeType==1&&BIe(this,r.getBoundingClientRect(),s)}else BIe(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 FQe(s.slice,s.move,a<0?void 0:Ha.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 TDt(this,s)}coordsAtPos(s,r=1){return xQe(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 LDt(this,r||this.state,s)}pasteHTML(s,r){return cD(this,"",s,!1,r||new ClipboardEvent("paste"))}pasteText(s,r){return cD(this,s,null,!0,r||new ClipboardEvent("paste"))}serializeForClipboard(s){return INe(this,s)}destroy(){this.docView&&(cOt(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rge(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,hDt())}get isDestroyed(){return this.docView==null}dispatchEvent(s){return uOt(this,s)}domSelectionRange(){let s=this.domSelection();return s?Xh&&this.root.nodeType===11&&gDt(this.dom.ownerDocument)==this.dom&&OOt(this,s)||s:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}UQe.prototype.dispatch=function(t){let s=this._props.dispatchTransaction;s?s.call(this,t):this.updateState(this.state.apply(t))};function hLe(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"),[Cm.node(0,t.state.doc.content.size,s)]}function mLe(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:Cm.widget(t.state.selection.from,s,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function pLe(t){return!t.someProp("editable",s=>s(t.state)===!1)}function HOt(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 fLe(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 WOt(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 xLe(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 fw={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:"'"},rle={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},GOt=typeof navigator<"u"&&/Mac/.test(navigator.platform),KOt=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var vh=0;vh<10;vh++)fw[48+vh]=fw[96+vh]=String(vh);for(var vh=1;vh<=24;vh++)fw[vh+111]="F"+vh;for(var vh=65;vh<=90;vh++)fw[vh]=String.fromCharCode(vh+32),rle[vh]=String.fromCharCode(vh);for(var age in fw)rle.hasOwnProperty(age)||(rle[age]=fw[age]);function ZOt(t){var s=GOt&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||KOt&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",r=!s&&t.key||(t.shiftKey?rle:fw)[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 YOt=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),XOt=typeof navigator<"u"&&/Win/.test(navigator.platform);function QOt(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 VQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("backward",t):r.parentOffset>0)?null:r}const HQe=(t,s,r)=>{let n=VQe(t,r);if(!n)return!1;let a=$Ne(n);if(!a){let l=n.blockRange(),i=l&&sE(l);return i==null?!1:(s&&s(t.tr.lift(l,i).scrollIntoView()),!0)}let o=a.nodeBefore;if(eJe(t,a,s,-1))return!0;if(n.parent.content.size==0&&(WT(o,"end")||Ha.isSelectable(o)))for(let l=n.depth;;l--){let i=kue(t.doc,n.before(l),n.after(l),bn.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=VQe(t,r);if(!n)return!1;let a=$Ne(n);return a?WQe(t,a,s):!1},sRt=(t,s,r)=>{let n=KQe(t,r);if(!n)return!1;let a=qNe(n);return a?WQe(t,a,s):!1};function WQe(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=kue(t.doc,o,c,bn.empty);if(!u||u.from!=o||u instanceof Ku&&u.slice.size>=c-o)return!1;if(r){let p=t.tr.step(u);p.setSelection(Qa.create(p.doc,o)),r(p.scrollIntoView())}return!0}function WT(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 GQe=(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=$Ne(n)}let l=o&&o.nodeBefore;return!l||!Ha.isSelectable(l)?!1:(s&&s(t.tr.setSelection(Ha.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function $Ne(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 KQe(t,s){let{$cursor:r}=t.selection;return!r||(s?!s.endOfTextblock("forward",t):r.parentOffset{let n=KQe(t,r);if(!n)return!1;let a=qNe(n);if(!a)return!1;let o=a.nodeAfter;if(eJe(t,a,s,1))return!0;if(n.parent.content.size==0&&(WT(o,"start")||Ha.isSelectable(o))){let l=kue(t.doc,n.before(),n.after(),bn.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 Ha,a;if(n){if(r.node.isTextblock||!Pw(t.doc,r.from))return!1;a=r.from}else if(a=Nue(t.doc,r.from,-1),a==null)return!1;if(s){let o=t.tr.join(a);n&&o.setSelection(Ha.create(o.doc,a-t.doc.resolve(a).nodeBefore.nodeSize)),s(o.scrollIntoView())}return!0},nRt=(t,s)=>{let r=t.selection,n;if(r instanceof Ha){if(r.node.isTextblock||!Pw(t.doc,r.to))return!1;n=r.to}else if(n=Nue(t.doc,r.to,1),n==null)return!1;return s&&s(t.tr.join(n).scrollIntoView()),!0},aRt=(t,s)=>{let{$from:r,$to:n}=t.selection,a=r.blockRange(n),o=a&&sE(a);return o==null?!1:(s&&s(t.tr.lift(a,o).scrollIntoView()),!0)},XQe=(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 UNe(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=UNe(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(pi.near(c.doc.resolve(i),1)),s(c.scrollIntoView())}return!0},QQe=(t,s)=>{let r=t.selection,{$from:n,$to:a}=r;if(r instanceof bf||n.parent.inlineContent||a.parent.inlineContent)return!1;let o=UNe(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(p1(t.doc,o))return s&&s(t.tr.split(o).scrollIntoView()),!0}let n=r.blockRange(),a=n&&sE(n);return a==null?!1:(s&&s(t.tr.lift(n,a).scrollIntoView()),!0)};function oRt(t){return(s,r)=>{let{$from:n,$to:a}=s.selection;if(s.selection instanceof Ha&&s.selection.node.isBlock)return!n.parentOffset||!p1(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 b=n.depth;;b--)if(n.node(b).isBlock){c=n.end(b)==n.pos+(n.depth-b),u=n.start(b)==n.pos-(n.depth-b),i=UNe(n.node(b-1).contentMatchAt(n.indexAfter(b-1))),o.unshift(c&&i?{type:i}:null),l=b;break}else{if(b==1)return!1;o.unshift(null)}let p=s.tr;(s.selection instanceof Qa||s.selection instanceof bf)&&p.deleteSelection();let f=p.mapping.map(n.pos),g=p1(p.doc,f,o.length,o);if(g||(o[0]=i?{type:i}:null,g=p1(p.doc,f,o.length,o)),!g)return!1;if(p.split(f,o.length,o),!c&&u&&n.node(l).type!=i){let b=p.mapping.map(n.before(l)),_=p.doc.resolve(b);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 lRt=oRt(),cRt=(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(Ha.create(t.doc,a))),!0)};function dRt(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||Pw(t.doc,s.pos))?!1:(r&&r(t.tr.join(s.pos).scrollIntoView()),!0)}function eJe(t,s,r,n){let a=s.nodeBefore,o=s.nodeAfter,l,i,c=a.type.spec.isolating||o.type.spec.isolating;if(!c&&dRt(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 b=s.pos+o.nodeSize,_=Lr.empty;for(let N=l.length-1;N>=0;N--)_=Lr.from(l[N].create(null,_));_=Lr.from(a.copy(_));let j=t.tr.step(new th(s.pos-1,b,s.pos,b,new bn(_,1,0),l.length,!0)),w=j.doc.resolve(b+2*l.length);w.nodeAfter&&w.nodeAfter.type==a.type&&Pw(j.doc,w.pos)&&j.join(w.pos),r(j.scrollIntoView())}return!0}let p=o.type.spec.isolating||n>0&&c?null:pi.findFrom(s,1),f=p&&p.$from.blockRange(p.$to),g=f&&sE(f);if(g!=null&&g>=s.depth)return r&&r(t.tr.lift(f,g).scrollIntoView()),!0;if(u&&WT(o,"start",!0)&&WT(a,"end")){let b=a,_=[];for(;_.push(b),!b.isTextblock;)b=b.lastChild;let j=o,w=1;for(;!j.isTextblock;j=j.firstChild)w++;if(b.canReplace(b.childCount,b.childCount,j.content)){if(r){let N=Lr.empty;for(let M=_.length-1;M>=0;M--)N=Lr.from(_[M].copy(N));let C=t.tr.step(new th(s.pos-_.length,s.pos+o.nodeSize,s.pos+w,s.pos+o.nodeSize-w,new bn(N,_.length,0),0,!0));r(C.scrollIntoView())}return!0}}return!1}function tJe(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(Qa.create(s.doc,t<0?a.start(o):a.end(o)))),!0):!1}}const uRt=tJe(-1),hRt=tJe(1);function mRt(t,s=null){return function(r,n){let{$from:a,$to:o}=r.selection,l=a.blockRange(o),i=l&&CNe(l,t,s);return i?(n&&n(r.tr.wrap(l,i).scrollIntoView()),!0):!1}}function gLe(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 Yoe(c,c,s.depth),s.endIndex=0;p--)o=Lr.from(r[p].type.create(r[p].attrs,o));t.step(new th(s.start-(n?2:0),s.end,s.start,s.end,new bn(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?yRt(s,r,t,o):vRt(s,r,o):!0:!1}}function yRt(t,s,r,n){let a=t.tr,o=n.end,l=n.$to.end(n.depth);oj;_--)b-=a.child(_).nodeSize,n.delete(b-1,b+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?Lr.empty:Lr.from(a))))return!1;let f=o.pos,g=f+l.nodeSize;return n.step(new th(f-(i?1:0),g+(c?1:0),f+1,g-1,new bn((i?Lr.empty:Lr.from(a.copy(Lr.empty))).append(c?Lr.empty:Lr.from(a.copy(Lr.empty))),i?0:1,c?0:1),i?0:1)),s(n.scrollIntoView()),!0}function bRt(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=Lr.from(u?t.create():null),f=new bn(Lr.from(t.create(null,Lr.from(i.type.create(null,p)))),u?3:1,0),g=o.start,b=o.end;r(s.tr.step(new th(g-(u?3:1),b,g,b,f,1,!0)).scrollIntoView())}return!0}}function Aue(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 Eue{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,b])=>[g,(...j)=>{const w=this.buildProps(u,r),N=b(...j)(w);return i.push(N),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:Aue({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 _Rt=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 aa(t,s,r){return t.config[s]===void 0&&t.parent?aa(t.parent,s,r):typeof t.config[s]=="function"?t.config[s].bind({...r,parent:t.parent?aa(t.parent,s,r):null}):t.config[s]}function Pue(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 sJe(t){const s=[],{nodeExtensions:r,markExtensions:n}=Pue(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=aa(l,"addGlobalAttributes",i);if(!c)return;c().forEach(p=>{p.types.forEach(f=>{Object.entries(p.attributes).forEach(([g,b])=>{s.push({type:f,name:g,attribute:{...o,...b}})})})})}),a.forEach(l=>{const i={name:l.name,options:l.options,storage:l.storage},c=aa(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 nh(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 $c(...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(b=>b.trim());u.set(f,g)}),i.forEach(p=>{const[f,g]=p.split(":").map(b=>b.trim());u.set(f,g)}),n[a]=Array.from(u.entries()).map(([p,f])=>`${p}: ${f}`).join("; ")}else n[a]=o}),n},{})}function P1e(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)=>$c(r,n),{})}function rJe(t){return typeof t=="function"}function eo(t,s=void 0,...r){return rJe(t)?s?t.bind(s)(...r):t(...r):t}function wRt(t={}){return Object.keys(t).length===0&&t.constructor===Object}function jRt(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function yLe(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):jRt(r.getAttribute(l.name));return i==null?o:{...o,[l.name]:i}},{});return{...n,...a}}}}function vLe(t){return Object.fromEntries(Object.entries(t).filter(([s,r])=>s==="attrs"&&wRt(r)?!1:r!=null))}function NRt(t,s){var r;const n=sJe(t),{nodeExtensions:a,markExtensions:o}=Pue(t),l=(r=a.find(u=>aa(u,"topNode")))===null||r===void 0?void 0:r.name,i=Object.fromEntries(a.map(u=>{const p=n.filter(N=>N.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((N,C)=>{const M=aa(C,"extendNodeSchema",f);return{...N,...M?M(u):{}}},{}),b=vLe({...g,content:eo(aa(u,"content",f)),marks:eo(aa(u,"marks",f)),group:eo(aa(u,"group",f)),inline:eo(aa(u,"inline",f)),atom:eo(aa(u,"atom",f)),selectable:eo(aa(u,"selectable",f)),draggable:eo(aa(u,"draggable",f)),code:eo(aa(u,"code",f)),whitespace:eo(aa(u,"whitespace",f)),linebreakReplacement:eo(aa(u,"linebreakReplacement",f)),defining:eo(aa(u,"defining",f)),isolating:eo(aa(u,"isolating",f)),attrs:Object.fromEntries(p.map(N=>{var C;return[N.name,{default:(C=N==null?void 0:N.attribute)===null||C===void 0?void 0:C.default}]}))}),_=eo(aa(u,"parseHTML",f));_&&(b.parseDOM=_.map(N=>yLe(N,p)));const j=aa(u,"renderHTML",f);j&&(b.toDOM=N=>j({node:N,HTMLAttributes:P1e(N,p)}));const w=aa(u,"renderText",f);return w&&(b.toText=w),[u.name,b]})),c=Object.fromEntries(o.map(u=>{const p=n.filter(w=>w.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:s},g=t.reduce((w,N)=>{const C=aa(N,"extendMarkSchema",f);return{...w,...C?C(u):{}}},{}),b=vLe({...g,inclusive:eo(aa(u,"inclusive",f)),excludes:eo(aa(u,"excludes",f)),group:eo(aa(u,"group",f)),spanning:eo(aa(u,"spanning",f)),code:eo(aa(u,"code",f)),attrs:Object.fromEntries(p.map(w=>{var N;return[w.name,{default:(N=w==null?void 0:w.attribute)===null||N===void 0?void 0:N.default}]}))}),_=eo(aa(u,"parseHTML",f));_&&(b.parseDOM=_.map(w=>yLe(w,p)));const j=aa(u,"renderHTML",f);return j&&(b.toDOM=w=>j({mark:w,HTMLAttributes:P1e(w,p)})),[u.name,b]}));return new VXe({topNode:l,nodes:i,marks:c})}function oge(t,s){return s.nodes[t]||s.marks[t]||null}function bLe(t,s){return Array.isArray(s)?s.some(r=>(typeof r=="string"?r:r.name)===t.name):s}function HNe(t,s){const r=pC.fromSchema(s).serializeFragment(t),a=document.implementation.createHTMLDocument().createElement("div");return a.appendChild(r),a.innerHTML}const kRt=(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 WNe(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class Iue{constructor(s){this.find=s.find,this.handler=s.handler}}const SRt=(t,s)=>{if(WNe(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 lz(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=kRt(u)+o;return l.forEach(g=>{if(p)return;const b=SRt(f,g.find);if(!b)return;const _=c.state.tr,j=Aue({state:c.state,transaction:_}),w={from:n-(b[0].length-o.length),to:a},{commands:N,chain:C,can:M}=new Eue({editor:r,state:j});g.handler({state:j,range:w,match:b,commands:N,chain:C,can:M})===null||!_.steps.length||(_.setMeta(i,{transform:_,from:n,to:a,text:o}),c.dispatch(_),p=!0)}),p}function CRt(t){const{editor:s,rules:r}=t,n=new Pu({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=HNe(Lr.from(p),l.schema);const{from:f}=c,g=f+p.length;lz({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 lz({editor:s,from:o,to:l,text:i,rules:r,plugin:n})},handleDOMEvents:{compositionend:a=>(setTimeout(()=>{const{$cursor:o}=a.state.selection;o&&lz({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?lz({editor:s,from:l.pos,to:l.pos,text:` `,rules:r,plugin:n}):!1}},isInputRules:!0});return n}function MRt(t){return Object.prototype.toString.call(t).slice(8,-1)}function cz(t){return MRt(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Lue(t,s){const r={...t};return cz(t)&&cz(s)&&Object.keys(s).forEach(n=>{cz(s[n])&&cz(t[n])?r[n]=Lue(t[n],s[n]):r[n]=s[n]}),r}class oy{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=eo(aa(this,"addOptions",{name:this.name}))),this.storage=eo(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new oy(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Lue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new oy(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=eo(aa(r,"addOptions",{name:r.name})),r.storage=eo(aa(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 TRt(t){return typeof t=="number"}class ARt{constructor(s){this.find=s.find,this.handler=s.handler}}const ERt=(t,s,r)=>{if(WNe(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 PRt(t){const{editor:s,state:r,from:n,to:a,rule:o,pasteEvent:l,dropEvent:i}=t,{commands:c,chain:u,can:p}=new Eue({editor:s,state:r}),f=[];return r.doc.nodesBetween(n,a,(b,_)=>{if(!b.isTextblock||b.type.spec.code)return;const j=Math.max(n,_),w=Math.min(a,_+b.content.size),N=b.textBetween(j-_,w-_,void 0,"");ERt(N,o.find,l).forEach(M=>{if(M.index===void 0)return;const I=j+M.index+1,L=I+M[0].length,R={from:r.tr.mapping.map(I),to:r.tr.mapping.map(L)},q=o.handler({state:r,range:R,match:M,commands:c,chain:u,can:p,pasteEvent:l,dropEvent:i});f.push(q)})}),f.every(b=>b!==null)}let dz=null;const IRt=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 LRt(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:b,pasteEvt:_})=>{const j=p.tr,w=Aue({state:p,transaction:j});if(!(!PRt({editor:s,state:w,from:Math.max(f-1,0),to:g.b-1,rule:b,pasteEvent:_,dropEvent:i})||!j.steps.length)){try{i=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{i=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,j}};return r.map(p=>new Pu({view(f){const g=_=>{var j;n=!((j=f.dom.parentElement)===null||j===void 0)&&j.contains(_.target)?f.dom.parentElement:null,n&&(dz=s)},b=()=>{dz&&(dz=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(f,g)=>{if(o=n===f.dom.parentElement,i=g,!o){const b=dz;b!=null&&b.isEditable&&setTimeout(()=>{const _=b.state.selection;_&&b.commands.deleteRange({from:_.from,to:_.to})},10)}return!1},paste:(f,g)=>{var b;const _=(b=g.clipboardData)===null||b===void 0?void 0:b.getData("text/html");return l=g,a=!!(_!=null&&_.includes("data-pm-slice")),!1}}},appendTransaction:(f,g,b)=>{const _=f[0],j=_.getMeta("uiEvent")==="paste"&&!a,w=_.getMeta("uiEvent")==="drop"&&!o,N=_.getMeta("applyPasteRules"),C=!!N;if(!j&&!w&&!C)return;if(C){let{text:L}=N;typeof L=="string"?L=L:L=HNe(Lr.from(L),b.schema);const{from:R}=N,q=R+L.length,U=IRt(L);return c({rule:p,state:b,from:R,to:{b:q},pasteEvt:U})}const M=g.doc.content.findDiffStart(b.doc.content),I=g.doc.content.findDiffEnd(b.doc.content);if(!(!TRt(M)||!I||M===I.b))return c({rule:p,state:b,from:M,to:I,pasteEvt:l})}}))}function DRt(t){const s=t.filter((r,n)=>t.indexOf(r)!==n);return Array.from(new Set(s))}class aM{constructor(s,r){this.splittableMarks=[],this.editor=r,this.extensions=aM.resolve(s),this.schema=NRt(this.extensions,r),this.setupExtensions()}static resolve(s){const r=aM.sort(aM.flatten(s)),n=DRt(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=aa(r,"addExtensions",n);return a?[r,...this.flatten(a())]:r}).flat(10)}static sort(s){return s.sort((n,a)=>{const o=aa(n,"priority")||100,l=aa(a,"priority")||100;return o>l?-1:o{const n={name:r.name,options:r.options,storage:r.storage,editor:this.editor,type:oge(r.name,this.schema)},a=aa(r,"addCommands",n);return a?{...s,...a()}:s},{})}get plugins(){const{editor:s}=this,r=aM.sort([...this.extensions].reverse()),n=[],a=[],o=r.map(l=>{const i={name:l.name,options:l.options,storage:l.storage,editor:s,type:oge(l.name,this.schema)},c=[],u=aa(l,"addKeyboardShortcuts",i);let p={};if(l.type==="mark"&&aa(l,"exitable",i)&&(p.ArrowRight=()=>oy.handleExit({editor:s,mark:l})),u){const j=Object.fromEntries(Object.entries(u()).map(([w,N])=>[w,()=>N({editor:s})]));p={...p,...j}}const f=eRt(p);c.push(f);const g=aa(l,"addInputRules",i);bLe(l,s.options.enableInputRules)&&g&&n.push(...g());const b=aa(l,"addPasteRules",i);bLe(l,s.options.enablePasteRules)&&b&&a.push(...b());const _=aa(l,"addProseMirrorPlugins",i);if(_){const j=_();c.push(...j)}return c}).flat();return[CRt({editor:s,rules:n}),...LRt({editor:s,rules:a}),...o]}get attributes(){return sJe(this.extensions)}get nodeViews(){const{editor:s}=this,{nodeExtensions:r}=Pue(this.extensions);return Object.fromEntries(r.filter(n=>!!aa(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:nh(n.name,this.schema)},l=aa(n,"addNodeView",o);if(!l)return[];const i=(c,u,p,f,g)=>{const b=P1e(c,a);return l()({node:c,view:u,getPos:p,decorations:f,innerDecorations:g,editor:s,extension:n,HTMLAttributes:b})};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:oge(s.name,this.schema)};s.type==="mark"&&(!((r=eo(aa(s,"keepOnSplit",n)))!==null&&r!==void 0)||r)&&this.splittableMarks.push(s.name);const a=aa(s,"onBeforeCreate",n),o=aa(s,"onCreate",n),l=aa(s,"onUpdate",n),i=aa(s,"onSelectionUpdate",n),c=aa(s,"onTransaction",n),u=aa(s,"onFocus",n),p=aa(s,"onBlur",n),f=aa(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 Ph{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=eo(aa(this,"addOptions",{name:this.name}))),this.storage=eo(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new Ph(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Lue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new Ph({...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=eo(aa(r,"addOptions",{name:r.name})),r.storage=eo(aa(r,"addStorage",{name:r.name,options:r.options})),r}}function nJe(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 b=l==null?void 0:l[c.type.name];if(b)return p&&(i+=b({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 aJe(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,s])=>s.spec.toText).map(([s,r])=>[s,r.spec.toText]))}const ORt=Ph.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Pu({key:new em("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=aJe(r);return nJe(n,{from:l,to:i},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),RRt=()=>({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),FRt=(t=!1)=>({commands:s})=>s.setContent("",t),zRt=()=>({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)),b=f.blockRange(g);if(!b)return;const _=sE(b);if(i.type.isTextblock){const{defaultType:j}=f.parent.contentMatchAt(f.index());s.setNodeMarkup(b.start,j)}(_||_===0)&&s.lift(b,_)})}),!0},BRt=t=>s=>t(s),$Rt=()=>({state:t,dispatch:s})=>QQe(t,s),qRt=(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 Qa(n.doc.resolve(Math.max(l-1,0)))),!0},URt=()=>({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},VRt=t=>({tr:s,state:r,dispatch:n})=>{const a=nh(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},HRt=t=>({tr:s,dispatch:r})=>{const{from:n,to:a}=t;return r&&s.delete(n,a),!0},WRt=()=>({state:t,dispatch:s})=>BNe(t,s),GRt=()=>({commands:t})=>t.keyboardShortcut("Enter"),KRt=()=>({state:t,dispatch:s})=>iRt(t,s);function nle(t,s,r={strict:!0}){const n=Object.keys(s);return n.length?n.every(a=>r.strict?s[a]===t[a]:WNe(s[a])?s[a].test(t[a]):s[a]===t[a]):!0}function iJe(t,s,r={}){return t.find(n=>n.type===s&&nle(Object.fromEntries(Object.keys(r).map(a=>[a,n.attrs[a]])),r))}function _Le(t,s,r={}){return!!iJe(t,s,r)}function GNe(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),!iJe([...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&&_Le([...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=Lw(t,n.schema),{doc:l,selection:i}=r,{$from:c,from:u,to:p}=i;if(a){const f=GNe(c,o,s);if(f&&f.from<=u&&f.to>=p){const g=Qa.create(l,f.from,f.to);r.setSelection(g)}}return!0},YRt=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=()=>{(KNe()||XRt())&&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&&!oJe(r.state.selection))return l(),!0;const i=lJe(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},JRt=(t,s)=>r=>t.every((n,a)=>s(n,{...r,index:a})),eFt=(t,s)=>({tr:r,commands:n})=>n.insertContentAt({from:r.selection.from,to:r.selection.to},t,s),cJe=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&&cJe(n)}return t};function uz(t){const s=`${t}`,r=new window.DOMParser().parseFromString(s,"text/html").body;return cJe(r)}function uD(t,s,r){if(t instanceof Y_||t instanceof Lr)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 Lr.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),uD("",s,r)}if(a){if(r.errorOnInvalidContent){let l=!1,i="";const c=new VXe({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?XL.fromSchema(c).parseSlice(uz(t),r.parseOptions):XL.fromSchema(c).parse(uz(t),r.parseOptions),r.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${i}`)})}const o=XL.fromSchema(s);return r.slice?o.parseSlice(uz(t),r.parseOptions).content:o.parse(uz(t),r.parseOptions)}return uD("",s,r)}function tFt(t,s,r){const n=t.steps.length-1;if(n{l===0&&(l=p)}),t.setSelection(pi.near(t.doc.resolve(l),r))}const sFt=t=>!("type"in t),rFt=(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=w=>{o.emit("contentError",{editor:o,error:w,disableCollaboration:()=>{o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...r.parseOptions};if(!r.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{uD(s,o.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(w){c(w)}try{i=uD(s,o.schema,{parseOptions:u,errorOnInvalidContent:(l=r.errorOnInvalidContent)!==null&&l!==void 0?l:o.options.enableContentCheck})}catch(w){return c(w),!1}let{from:p,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,b=!0;if((sFt(i)?i:[i]).forEach(w=>{w.check(),g=g?w.isText&&w.marks.length===0:!1,b=b?w.isBlock:!1}),p===f&&b){const{parent:w}=n.doc.resolve(p);w.isTextblock&&!w.type.spec.code&&!w.childCount&&(p-=1,f+=1)}let j;if(g){if(Array.isArray(s))j=s.map(w=>w.text||"").join("");else if(s instanceof Lr){let w="";s.forEach(N=>{N.text&&(w+=N.text)}),j=w}else typeof s=="object"&&s&&s.text?j=s.text:j=s;n.insertText(j,p,f)}else j=i,n.replaceWith(p,f,j);r.updateSelection&&tFt(n,n.steps.length-1,-1),r.applyInputRules&&n.setMeta("applyInputRules",{from:p,text:j}),r.applyPasteRules&&n.setMeta("applyPasteRules",{from:p,text:j})}return!0},nFt=()=>({state:t,dispatch:s})=>rRt(t,s),aFt=()=>({state:t,dispatch:s})=>nRt(t,s),iFt=()=>({state:t,dispatch:s})=>HQe(t,s),oFt=()=>({state:t,dispatch:s})=>ZQe(t,s),lFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Nue(t.doc,t.selection.$from.pos,-1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},cFt=()=>({state:t,dispatch:s,tr:r})=>{try{const n=Nue(t.doc,t.selection.$from.pos,1);return n==null?!1:(r.join(n,2),s&&s(r),!0)}catch{return!1}},dFt=()=>({state:t,dispatch:s})=>tRt(t,s),uFt=()=>({state:t,dispatch:s})=>sRt(t,s);function dJe(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function hFt(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=hFt(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 hD(t,s,r={}){const{from:n,to:a,empty:o}=t.selection,l=s?nh(s,t.schema):null,i=[];t.doc.nodesBetween(n,a,(f,g)=>{if(f.isText)return;const b=Math.max(n,g),_=Math.min(a,g+f.nodeSize);i.push({node:f,from:b,to:_})});const c=a-n,u=i.filter(f=>l?l.name===f.node.type.name:!0).filter(f=>nle(f.node.attrs,r,{strict:!1}));return o?!!u.length:u.reduce((f,g)=>f+g.to-g.from,0)>=c}const pFt=(t,s={})=>({state:r,dispatch:n})=>{const a=nh(t,r.schema);return hD(r,a,s)?aRt(r,n):!1},fFt=()=>({state:t,dispatch:s})=>JQe(t,s),xFt=t=>({state:s,dispatch:r})=>{const n=nh(t,s.schema);return gRt(n)(s,r)},gFt=()=>({state:t,dispatch:s})=>XQe(t,s);function Due(t,s){return s.nodes[t]?"node":s.marks[t]?"mark":null}function wLe(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 yFt=(t,s)=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Due(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=nh(t,n.schema)),i==="mark"&&(l=Lw(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,wLe(u.attrs,s)),l&&u.marks.length&&u.marks.forEach(f=>{l===f.type&&r.addMark(p,p+u.nodeSize,l.create(wLe(f.attrs,s)))})})}),!0):!1},vFt=()=>({tr:t,dispatch:s})=>(s&&t.scrollIntoView(),!0),bFt=()=>({tr:t,dispatch:s})=>{if(s){const r=new bf(t.doc);t.setSelection(r)}return!0},_Ft=()=>({state:t,dispatch:s})=>GQe(t,s),wFt=()=>({state:t,dispatch:s})=>YQe(t,s),jFt=()=>({state:t,dispatch:s})=>cRt(t,s),NFt=()=>({state:t,dispatch:s})=>hRt(t,s),kFt=()=>({state:t,dispatch:s})=>uRt(t,s);function I1e(t,s,r={},n={}){return uD(t,s,{slice:!1,parseOptions:r,errorOnInvalidContent:n.errorOnInvalidContent})}const SFt=(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=I1e(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 uJe(t,s){const r=Lw(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 CFt(t,s){const r=new MNe(t);return s.forEach(n=>{n.steps.forEach(a=>{r.step(a)})}),r}function MFt(t){for(let s=0;s{r(a)&&n.push({node:a,pos:o})}),n}function hJe(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 ZNe(t){return s=>hJe(s.$from,t)}function AFt(t,s){const r={from:0,to:t.content.size};return nJe(t,r,s)}function EFt(t,s){const r=nh(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 mJe(t,s){const r=Due(typeof s=="string"?s:s.name,t.schema);return r==="node"?EFt(t,s):r==="mark"?uJe(t,s):{}}function PFt(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 IFt(t){const s=PFt(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 LFt(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}})})}),IFt(n)}function YNe(t,s,r){const n=[];return t===s?r.resolve(t).marks().forEach(a=>{const o=r.resolve(t),l=GNe(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 jie(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 L1e(t,s,r={}){const{empty:n,ranges:a}=t.selection,o=s?Lw(s,t.schema):null;if(n)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>o?o.name===f.type.name:!0).find(f=>nle(f.attrs,r,{strict:!1}));let l=0;const i=[];if(a.forEach(({$from:f,$to:g})=>{const b=f.pos,_=g.pos;t.doc.nodesBetween(b,_,(j,w)=>{if(!j.isText&&!j.marks.length)return;const N=Math.max(b,w),C=Math.min(_,w+j.nodeSize),M=C-N;l+=M,i.push(...j.marks.map(I=>({mark:I,from:N,to:C})))})}),l===0)return!1;const c=i.filter(f=>o?o.name===f.mark.type.name:!0).filter(f=>nle(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 DFt(t,s,r={}){if(!s)return hD(t,null,r)||L1e(t,null,r);const n=Due(s,t.schema);return n==="node"?hD(t,s,r):n==="mark"?L1e(t,s,r):!1}function jLe(t,s){const{nodeExtensions:r}=Pue(s),n=r.find(l=>l.name===t);if(!n)return!1;const a={name:n.name,options:n.options,storage:n.storage},o=eo(aa(n,"group",a));return typeof o!="string"?!1:o.split(" ").includes("list")}function XNe(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&&(XNe(o,{ignoreWhitespace:r,checkChildren:s})||(a=!1))}),a}return!1}function OFt(t){return t instanceof Ha}function RFt(t,s,r){var n;const{selection:a}=s;let o=null;if(oJe(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 b=!g||g.type.allowsMarkType(r),_=!!r.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(r));u=b&&_}return!u}),u})}const FFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{const{selection:o}=r,{empty:l,ranges:i}=o,c=Lw(t,n.schema);if(a)if(l){const u=uJe(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,b)=>{const _=Math.max(b,p),j=Math.min(b+g.nodeSize,f);g.marks.find(N=>N.type===c)?g.marks.forEach(N=>{c===N.type&&r.addMark(_,j,c.create({...N.attrs,...s}))}):r.addMark(_,j,c.create(s))})});return RFt(n,r,c)},zFt=(t,s)=>({tr:r})=>(r.setMeta(t,s),!0),BFt=(t,s={})=>({state:r,dispatch:n,chain:a})=>{const o=nh(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})=>gLe(o,{...l,...s})(r)?!0:i.clearNodes()).command(({state:i})=>gLe(o,{...l,...s})(i,n)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},$Ft=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,a=_4(t,0,n.content.size),o=Ha.create(n,a);s.setSelection(o)}return!0},qFt=t=>({tr:s,dispatch:r})=>{if(r){const{doc:n}=s,{from:a,to:o}=typeof t=="number"?{from:t,to:t}:t,l=Qa.atStart(n).from,i=Qa.atEnd(n).to,c=_4(a,l,i),u=_4(o,l,i),p=Qa.create(n,c,u);s.setSelection(p)}return!0},UFt=t=>({state:s,dispatch:r})=>{const n=nh(t,s.schema);return bRt(n)(s,r)};function NLe(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 VFt=({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=jie(u,i.node().type.name,i.node().attrs);if(o instanceof Ha&&o.node.isBlock)return!i.parentOffset||!p1(l,i.pos)?!1:(n&&(t&&NLe(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:MFt(i.node(-1).contentMatchAt(i.indexAfter(-1)));let b=f&&g?[{type:g,attrs:p}]:void 0,_=p1(s.doc,s.mapping.map(i.pos),1,b);if(!b&&!_&&p1(s.doc,s.mapping.map(i.pos),1,g?[{type:g}]:void 0)&&(_=!0,b=g?[{type:g,attrs:p}]:void 0),n){if(_&&(o instanceof Qa&&s.deleteSelection(),s.split(s.mapping.map(i.pos),1,b),g&&!f&&!i.parentOffset&&i.parent.type!==g)){const j=s.mapping.map(i.before()),w=s.doc.resolve(j);i.node(-1).canReplaceWith(w.index(),w.index()+1,g)&&s.setNodeMarkup(s.mapping.map(i.before()),g)}t&&NLe(r,a.extensionManager.splittableMarks),s.scrollIntoView()}return _},HFt=(t,s={})=>({tr:r,state:n,dispatch:a,editor:o})=>{var l;const i=nh(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 N=Lr.empty;const C=c.index(-1)?1:c.index(-2)?2:3;for(let U=c.depth-C;U>=c.depth-3;U-=1)N=Lr.from(c.node(U).copy(N));const M=c.indexAfter(-1){if(q>-1)return!1;U.isTextblock&&U.content.size===0&&(q=B+1)}),q>-1&&r.setSelection(Qa.near(r.doc.resolve(q))),r.scrollIntoView()}return!0}const b=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,_={...jie(g,f.type.name,f.attrs),...s},j={...jie(g,c.node().type.name,c.node().attrs),...s};r.delete(c.pos,u.pos);const w=b?[{type:i,attrs:_},{type:b,attrs:j}]:[{type:i,attrs:_}];if(!p1(r.doc,c.pos,2))return!1;if(a){const{selection:N,storedMarks:C}=n,{splittableMarks:M}=o.extensionManager,I=C||N.$to.parentOffset&&N.$from.marks();if(r.split(c.pos,2,w).scrollIntoView(),!I||!a)return!0;const L=I.filter(R=>M.includes(R.type.name));r.ensureMarks(L)}return!0},lge=(t,s)=>{const r=ZNe(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)&&Pw(t.doc,r.pos)&&t.join(r.pos),!0},cge=(t,s)=>{const r=ZNe(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)&&Pw(t.doc,n)&&t.join(n),!0},WFt=(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,b=nh(t,l.schema),_=nh(s,l.schema),{selection:j,storedMarks:w}=l,{$from:N,$to:C}=j,M=N.blockRange(C),I=w||j.$to.parentOffset&&j.$from.marks();if(!M)return!1;const L=ZNe(R=>jLe(R.type.name,f))(j);if(M.depth>=1&&L&&M.depth-L.depth<=1){if(L.node.type===b)return u.liftListItem(_);if(jLe(L.node.type.name,f)&&b.validContent(L.node.content)&&i)return c().command(()=>(o.setNodeMarkup(L.pos,b),!0)).command(()=>lge(o,b)).command(()=>cge(o,b)).run()}return!r||!I||!i?c().command(()=>p().wrapInList(b,n)?!0:u.clearNodes()).wrapInList(b,n).command(()=>lge(o,b)).command(()=>cge(o,b)).run():c().command(()=>{const R=p().wrapInList(b,n),q=I.filter(U=>g.includes(U.type.name));return o.ensureMarks(q),R?!0:u.clearNodes()}).wrapInList(b,n).command(()=>lge(o,b)).command(()=>cge(o,b)).run()},GFt=(t,s={},r={})=>({state:n,commands:a})=>{const{extendEmptyMarkRange:o=!1}=r,l=Lw(t,n.schema);return L1e(n,l,s)?a.unsetMark(l,{extendEmptyMarkRange:o}):a.setMark(l,s)},KFt=(t,s,r={})=>({state:n,commands:a})=>{const o=nh(t,n.schema),l=nh(s,n.schema),i=hD(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})},ZFt=(t,s={})=>({state:r,commands:n})=>{const a=nh(t,r.schema);return hD(r,a,s)?n.lift(a):n.wrapIn(a,s)},YFt=()=>({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},XFt=()=>({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},QFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{var o;const{extendEmptyMarkRange:l=!1}=s,{selection:i}=r,c=Lw(t,n.schema),{$from:u,empty:p,ranges:f}=i;if(!a)return!0;if(p&&l){let{from:g,to:b}=i;const _=(o=u.marks().find(w=>w.type===c))===null||o===void 0?void 0:o.attrs,j=GNe(u,c,_);j&&(g=j.from,b=j.to),r.removeMark(g,b,c)}else f.forEach(g=>{r.removeMark(g.$from.pos,g.$to.pos,c)});return r.removeStoredMark(c),!0},JFt=(t,s={})=>({tr:r,state:n,dispatch:a})=>{let o=null,l=null;const i=Due(typeof t=="string"?t:t.name,n.schema);return i?(i==="node"&&(o=nh(t,n.schema)),i==="mark"&&(l=Lw(t,n.schema)),a&&r.selection.ranges.forEach(c=>{const u=c.$from.pos,p=c.$to.pos;let f,g,b,_;r.selection.empty?n.doc.nodesBetween(u,p,(j,w)=>{o&&o===j.type&&(b=Math.max(w,u),_=Math.min(w+j.nodeSize,p),f=w,g=j)}):n.doc.nodesBetween(u,p,(j,w)=>{w=u&&w<=p&&(o&&o===j.type&&r.setNodeMarkup(w,void 0,{...j.attrs,...s}),l&&j.marks.length&&j.marks.forEach(N=>{if(l===N.type){const C=Math.max(w,u),M=Math.min(w+j.nodeSize,p);r.addMark(C,M,l.create({...N.attrs,...s}))}}))}),g&&(f!==void 0&&r.setNodeMarkup(f,void 0,{...g.attrs,...s}),l&&g.marks.length&&g.marks.forEach(j=>{l===j.type&&r.addMark(b,_,l.create({...j.attrs,...s}))}))}),!0):!1},e7t=(t,s={})=>({state:r,dispatch:n})=>{const a=nh(t,r.schema);return mRt(a,s)(r,n)},t7t=(t,s={})=>({state:r,dispatch:n})=>{const a=nh(t,r.schema);return pRt(a,s)(r,n)};var s7t=Object.freeze({__proto__:null,blur:RRt,clearContent:FRt,clearNodes:zRt,command:BRt,createParagraphNear:$Rt,cut:qRt,deleteCurrentNode:URt,deleteNode:VRt,deleteRange:HRt,deleteSelection:WRt,enter:GRt,exitCode:KRt,extendMarkRange:ZRt,first:YRt,focus:QRt,forEach:JRt,insertContent:eFt,insertContentAt:rFt,joinBackward:iFt,joinDown:aFt,joinForward:oFt,joinItemBackward:lFt,joinItemForward:cFt,joinTextblockBackward:dFt,joinTextblockForward:uFt,joinUp:nFt,keyboardShortcut:mFt,lift:pFt,liftEmptyBlock:fFt,liftListItem:xFt,newlineInCode:gFt,resetAttributes:yFt,scrollIntoView:vFt,selectAll:bFt,selectNodeBackward:_Ft,selectNodeForward:wFt,selectParentNode:jFt,selectTextblockEnd:NFt,selectTextblockStart:kFt,setContent:SFt,setMark:FFt,setMeta:zFt,setNode:BFt,setNodeSelection:$Ft,setTextSelection:qFt,sinkListItem:UFt,splitBlock:VFt,splitListItem:HFt,toggleList:WFt,toggleMark:GFt,toggleNode:KFt,toggleWrap:ZFt,undoInputRule:YFt,unsetAllMarks:XFt,unsetMark:QFt,updateAttributes:JFt,wrapIn:e7t,wrapInList:t7t});const r7t=Ph.create({name:"commands",addCommands(){return{...s7t}}}),n7t=Ph.create({name:"drop",addProseMirrorPlugins(){return[new Pu({key:new em("tiptapDrop"),props:{handleDrop:(t,s,r,n)=>{this.editor.emit("drop",{editor:this.editor,event:s,slice:r,moved:n})}}})]}}),a7t=Ph.create({name:"editable",addProseMirrorPlugins(){return[new Pu({key:new em("editable"),props:{editable:()=>this.editor.options.editable}})]}}),i7t=new em("focusEvents"),o7t=Ph.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Pu({key:i7t,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}}}})]}}),l7t=Ph.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:b}=f,_=f.parent.isTextblock&&g>0?i.doc.resolve(g-1):f,j=_.parent.type.spec.isolating,w=f.pos-f.parentOffset,N=j&&_.parent.childCount===1?w===f.pos:pi.atStart(u).from===g;return!p||!b.type.isTextblock||b.textContent.length||!N||N&&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 KNe()||dJe()?o:a},addProseMirrorPlugins(){return[new Pu({key:new em("clearDocument"),appendTransaction:(t,s,r)=>{if(t.some(j=>j.getMeta("composition")))return;const n=t.some(j=>j.docChanged)&&!s.doc.eq(r.doc),a=t.some(j=>j.getMeta("preventClearDocument"));if(!n||a)return;const{empty:o,from:l,to:i}=s.selection,c=pi.atStart(s.doc).from,u=pi.atEnd(s.doc).to;if(o||!(l===c&&i===u)||!XNe(r.doc))return;const g=r.tr,b=Aue({state:r,transaction:g}),{commands:_}=new Eue({editor:this.editor,state:b});if(_.clearNodes(),!!g.steps.length)return g}})]}}),c7t=Ph.create({name:"paste",addProseMirrorPlugins(){return[new Pu({key:new em("tiptapPaste"),props:{handlePaste:(t,s,r)=>{this.editor.emit("paste",{editor:this.editor,event:s,slice:r})}}})]}}),d7t=Ph.create({name:"tabindex",addProseMirrorPlugins(){return[new Pu({key:new em("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class l4{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 l4(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 l4(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 l4(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 l4(i,this.editor,a,a?r:null);a&&(c.actualDepth=this.depth+1),s.push(new l4(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 u7t=`.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 h7t(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 m7t extends _Rt{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=h7t(u7t,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=rJe(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?[a7t,ORt.configure({blockSeparator:(r=(s=this.options.coreExtensionOptions)===null||s===void 0?void 0:s.clipboardTextSerializer)===null||r===void 0?void 0:r.blockSeparator}),r7t,o7t,l7t,d7t,n7t,c7t].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 aM(a,this)}createCommandManager(){this.commandManager=new Eue({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var s;let r;try{r=I1e(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=I1e(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const n=lJe(r,this.options.autofocus);this.view=new UQe(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:nM.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 mJe(this.state,s)}isActive(s,r){const n=typeof s=="string"?s:null,a=typeof s=="string"?r:s;return DFt(this.state,n,a)}getJSON(){return this.state.doc.toJSON()}getHTML(){return HNe(this.state.doc.content,this.schema)}getText(s){const{blockSeparator:r=` `,textSerializers:n={}}=s||{};return AFt(this.state.doc,{blockSeparator:r,textSerializers:{...aJe(this.schema),...n}})}get isEmpty(){return XNe(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 l4(r,this)}get $doc(){return this.$pos(0)}}function GT(t){return new Iue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(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(YNe(r.from,r.to,s.doc).filter(b=>b.mark.type.excluded.find(j=>j===t.type&&j!==b.mark.type)).filter(b=>b.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 pJe(t){return new Iue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=eo(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 D1e(t){return new Iue({find:t.find,handler:({state:s,range:r,match:n})=>{const a=s.doc.resolve(r.from),o=eo(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 Iue({find:t.find,handler:({state:s,range:r,match:n,chain:a})=>{const o=eo(t.getAttributes,void 0,n)||{},l=s.tr.delete(r.from,r.to),c=l.doc.resolve(r.from).blockRange(),u=c&&CNe(c,t.type,o);if(!u)return null;if(l.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:g}=s,{splittableMarks:b}=t.editor.extensionManager,_=g||f.$to.parentOffset&&f.$from.marks();if(_){const j=_.filter(w=>b.includes(w.type.name));l.ensureMarks(j)}}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&&Pw(l.doc,r.from-1)&&(!t.joinPredicate||t.joinPredicate(n,p))&&l.join(r.from-1)}})}let tm=class O1e{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=eo(aa(this,"addOptions",{name:this.name}))),this.storage=eo(aa(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(s={}){return new O1e(s)}configure(s={}){const r=this.extend({...this.config,addOptions:()=>Lue(this.options,s)});return r.name=this.name,r.parent=this.parent,r}extend(s={}){const r=new O1e(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=eo(aa(r,"addOptions",{name:r.name})),r.storage=eo(aa(r,"addStorage",{name:r.name,options:r.options})),r}};function HS(t){return new ARt({find:t.find,handler:({state:s,range:r,match:n,pasteEvent:a})=>{const o=eo(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(YNe(r.from,r.to,s.doc).filter(_=>_.mark.type.excluded.find(w=>w===t.type&&w!==_.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 p7t(t,s){const{selection:r}=t,{$from:n}=r;if(r instanceof Ha){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 f7t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var fJe={exports:{}},dge={};/** * @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 kLe;function x7t(){if(kLe)return dge;kLe=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 b=g(),_=n({inst:{value:b,getSnapshot:g}}),j=_[0].inst,w=_[1];return o(function(){j.value=b,j.getSnapshot=g,c(j)&&w({inst:j})},[f,b,g]),a(function(){return c(j)&&w({inst:j}),f(function(){c(j)&&w({inst:j})})},[f]),l(b),b}function c(f){var g=f.getSnapshot;f=f.value;try{var b=g();return!r(f,b)}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 dge.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,dge}fJe.exports=x7t();var QNe=fJe.exports;const g7t=(...t)=>s=>{t.forEach(r=>{typeof r=="function"?r(s):r&&(r.current=s)})},y7t=({contentComponent:t})=>{const s=QNe.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return ht.createElement(ht.Fragment,null,Object.values(s))};function v7t(){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]:i2e.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 b7t 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=v7t(),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:g7t(r,this.editorContentRef),...n}),(s==null?void 0:s.contentComponent)&&ht.createElement(y7t,{contentComponent:s.contentComponent}))}}const _7t=k.forwardRef((t,s)=>{const r=ht.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ht.createElement(b7t,{key:r,innerRef:s,...t})}),JNe=ht.memo(_7t);var w7t=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},j7t=f7t(w7t),xJe={exports:{}},uge={};/** * @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 SLe;function N7t(){if(SLe)return uge;SLe=1;var t=ht,s=QNe;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 uge.useSyncExternalStoreWithSelector=function(u,p,f,g,b){var _=o(null);if(_.current===null){var j={hasValue:!1,value:null};_.current=j}else j=_.current;_=i(function(){function N(R){if(!C){if(C=!0,M=R,R=g(R),b!==void 0&&j.hasValue){var q=j.value;if(b(q,R))return I=q}return I=R}if(q=I,n(M,R))return q;var U=g(R);return b!==void 0&&b(q,U)?q:(M=R,I=U)}var C=!1,M,I,L=f===void 0?null:f;return[function(){return N(p())},L===null?void 0:function(){return N(L())}]},[p,f,g,b]);var w=a(u,_[0],_[1]);return l(function(){j.hasValue=!0,j.value=w},[w]),c(w),w},uge}xJe.exports=N7t();var k7t=xJe.exports;const S7t=typeof window<"u"?k.useLayoutEffect:k.useEffect;class C7t{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 M7t(t){var s;const[r]=k.useState(()=>new C7t(t.editor)),n=k7t.useSyncExternalStoreWithSelector(r.subscribe,r.getSnapshot,r.getServerSnapshot,t.selector,(s=t.equalityFn)!==null&&s!==void 0?s:j7t);return S7t(()=>r.watch(t.editor),[t.editor,r]),k.useDebugValue(n),n}const T7t=!1,R1e=typeof window>"u",A7t=R1e||!!(typeof window<"u"&&window.next);class eke{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?R1e||A7t?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 m7t(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?eke.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 tke(t={},s=[]){const r=k.useRef(t);r.current=t;const[n]=k.useState(()=>new eke(r)),a=QNe.useSyncExternalStore(n.subscribe,n.getEditor,n.getServerSnapshot);return k.useDebugValue(a),k.useEffect(n.onRender(s)),M7t({editor:a,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1?null:t.immediatelyRender&&o===0?0:o+1}),a}const E7t=k.createContext({editor:null});E7t.Consumer;const P7t=k.createContext({onDragStart:void 0}),I7t=()=>k.useContext(P7t);ht.forwardRef((t,s)=>{const{onDragStart:r}=I7t(),n=t.as||"div";return ht.createElement(n,{...t,ref:s,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...t.style}})});const L7t=/^\s*>\s$/,D7t=tm.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",$c(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:L7t,type:this.type})]}}),O7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,R7t=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,F7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,z7t=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,B7t=oy.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",$c(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[GT({find:O7t,type:this.type}),GT({find:F7t,type:this.type})]},addPasteRules(){return[HS({find:R7t,type:this.type}),HS({find:z7t,type:this.type})]}}),$7t="listItem",CLe="textStyle",MLe=/^\s*([-+*])\s$/,q7t=tm.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",$c(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($7t,this.editor.getAttributes(CLe)).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:MLe,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=mD({find:MLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(CLe),editor:this.editor})),[t]}}),U7t=/(^|[^`])`([^`]+)`(?!`)/,V7t=/(^|[^`])`([^`]+)`(?!`)/g,H7t=oy.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",$c(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[GT({find:U7t,type:this.type})]},addPasteRules(){return[HS({find:V7t,type:this.type})]}}),W7t=/^```([a-z]+)?[\s\n]$/,G7t=/^~~~([a-z]+)?[\s\n]$/,K7t=tm.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",$c(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(pi.near(n.resolve(i))),!0)):t.commands.exitCode()}}},addInputRules(){return[D1e({find:W7t,type:this.type,getAttributes:t=>({language:t[1]})}),D1e({find:G7t,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Pu({key:new em("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(Qa.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),Z7t=tm.create({name:"doc",topNode:!0,content:"block+"});function Y7t(t={}){return new Pu({view(s){return new X7t(s,t)}})}class X7t{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 b=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(b){let _=b.getBoundingClientRect(),j=f?_.bottom:_.top;f&&g&&(j=(j+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let w=this.width/2*i;n={left:_.left,right:_.right,top:j-w,bottom:j+w}}}}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,b=f.height/c.offsetHeight;u=f.left-c.scrollLeft*g,p=f.top-c.scrollTop*b}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=tQe(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 Q7t=Ph.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Y7t(this.options)]}});class fd extends pi{constructor(s){super(s,s)}map(s,r){let n=s.resolve(r.map(this.head));return fd.valid(n)?new fd(n):pi.near(n)}content(){return bn.empty}eq(s){return s instanceof fd&&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 fd(s.resolve(r.pos))}getBookmark(){return new ske(this.anchor)}static valid(s){let r=s.parent;if(r.isTextblock||!J7t(s)||!ezt(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&&fd.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(fd.valid(c))return c}for(;;){let l=r>0?o.firstChild:o.lastChild;if(!l){if(o.isAtom&&!o.isText&&!Ha.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(fd.valid(i))return i}return null}}}fd.prototype.visible=!1;fd.findFrom=fd.findGapCursorFrom;pi.jsonID("gapcursor",fd);class ske{constructor(s){this.pos=s}map(s){return new ske(s.map(this.pos))}resolve(s){let r=s.resolve(this.pos);return fd.valid(r)?new fd(r):pi.near(r)}}function gJe(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function J7t(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||gJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function ezt(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||gJe(a.type))return!0;if(a.inlineContent)return!1}}return!0}function tzt(){return new Pu({props:{decorations:azt,createSelectionBetween(t,s,r){return s.pos==r.pos&&fd.valid(r)?new fd(r):null},handleClick:rzt,handleKeyDown:szt,handleDOMEvents:{beforeinput:nzt}}})}const szt=zNe({ArrowLeft:hz("horiz",-1),ArrowRight:hz("horiz",1),ArrowUp:hz("vert",-1),ArrowDown:hz("vert",1)});function hz(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 Qa){if(!o.endOfTextblock(r)||i.depth==0)return!1;c=!1,i=n.doc.resolve(s>0?i.after():i.before())}let u=fd.findGapCursorFrom(i,s,c);return u?(a&&a(n.tr.setSelection(new fd(u))),!0):!1}}function rzt(t,s,r){if(!t||!t.editable)return!1;let n=t.state.doc.resolve(s);if(!fd.valid(n))return!1;let a=t.posAtCoords({left:r.clientX,top:r.clientY});return a&&a.inside>-1&&Ha.isSelectable(t.state.doc.nodeAt(a.inside))?!1:(t.dispatch(t.state.tr.setSelection(new fd(n))),!0)}function nzt(t,s){if(s.inputType!="insertCompositionText"||!(t.state.selection instanceof fd))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=Lr.empty;for(let l=n.length-1;l>=0;l--)a=Lr.from(n[l].createAndFill(null,a));let o=t.state.tr.replace(r.pos,r.pos,new bn(a,0,0));return o.setSelection(Qa.near(o.doc.resolve(r.pos+1))),t.dispatch(o),!1}function azt(t){if(!(t.selection instanceof fd))return null;let s=document.createElement("div");return s.className="ProseMirror-gapcursor",pd.create(t.doc,[Cm.widget(t.selection.head,s,{key:"gapcursor"})])}const izt=Ph.create({name:"gapCursor",addProseMirrorPlugins(){return[tzt()]},extendNodeSchema(t){var s;const r={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(s=eo(aa(t,"allowGapCursor",r)))!==null&&s!==void 0?s:null}}}),ozt=tm.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",$c(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()}}}),lzt=tm.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]}`,$c(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=>D1e({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var ale=200,sh=function(){};sh.prototype.append=function(s){return s.length?(s=sh.from(s),!this.length&&s||s.length=r?sh.empty:this.sliceInner(Math.max(0,s),Math.min(this.length,r))};sh.prototype.get=function(s){if(!(s<0||s>=this.length))return this.getInner(s)};sh.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)};sh.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};sh.from=function(s){return s instanceof sh?s:s&&s.length?new yJe(s):sh.empty};var yJe=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<=ale)return new s(this.values.concat(a.flatten()))},s.prototype.leafPrepend=function(a){if(this.length+a.length<=ale)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}(sh);sh.empty=new yJe([]);var czt=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}(sh);const dzt=500;class qg{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 Hy(f.map));let b=f.step.map(a.slice(o)),_;b&&l.maybeStep(b).doc&&(_=l.mapping.maps[l.mapping.maps.length-1],u.push(new Hy(_,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 qg(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;phzt&&(i=uzt(i,u),l-=u),new qg(i.append(o),l)}remapping(s,r){let n=new iD;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 qg(this.items.append(s.map(r=>new Hy(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 b=o.getMirror(--c);if(b==null)return;l=Math.min(l,b);let _=o.maps[b];if(g.step){let j=s.steps[b].invert(s.docs[b]),w=g.selection&&g.selection.map(o.slice(c+1,b));w&&i++,n.push(new Hy(_,j,w))}else n.push(new Hy(_))},a);let u=[];for(let g=r;gdzt&&(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 Hy(u.invert(),c,p),g,b=a.length-1;(g=a.length&&a[b].merge(f))?a[b]=g:a.push(f)}}else l.map&&n--},this.items.length,0),new qg(sh.from(a.reverse()),o)}}qg.empty=new qg(sh.empty,0);function uzt(t,s){let r;return t.forEach((n,a)=>{if(n.selection&&s--==0)return r=a,!1}),t.slice(r)}class Hy{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 Hy(r.getMap().invert(),r,this.selection)}}}class Kb{constructor(s,r,n,a,o){this.done=s,this.undone=r,this.prevRanges=n,this.prevTime=a,this.prevComposition=o}}const hzt=20;function mzt(t,s,r,n){let a=r.getMeta(yS),o;if(a)return a.historyState;r.getMeta(xzt)&&(t=new Kb(t.done,t.undone,null,0,-1));let l=r.getMeta("appendedTransaction");if(r.steps.length==0)return t;if(l&&l.getMeta(yS))return l.getMeta(yS).redo?new Kb(t.done.addTransform(r,void 0,n,Nie(s)),t.undone,TLe(r.mapping.maps),t.prevTime,t.prevComposition):new Kb(t.done,t.undone.addTransform(r,void 0,n,Nie(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||!pzt(r,t.prevRanges)),u=l?hge(t.prevRanges,r.mapping):TLe(r.mapping.maps);return new Kb(t.done.addTransform(r,c?s.selection.getBookmark():void 0,n,Nie(s)),qg.empty,u,r.time,i??t.prevComposition)}else return(o=r.getMeta("rebased"))?new Kb(t.done.rebased(r,o),t.undone.rebased(r,o),hge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition):new Kb(t.done.addMaps(r.mapping.maps),t.undone.addMaps(r.mapping.maps),hge(t.prevRanges,r.mapping),t.prevTime,t.prevComposition)}function pzt(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 TLe(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 hge(t,s){if(!t)return null;let r=[];for(let n=0;n{let a=yS.getState(r);if(!a||(t?a.undone:a.done).eventCount==0)return!1;if(n){let o=fzt(a,r,t);o&&n(s?o.scrollIntoView():o)}return!0}}const bJe=vJe(!1,!0),_Je=vJe(!0,!0),yzt=Ph.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:s})=>bJe(t,s),redo:()=>({state:t,dispatch:s})=>_Je(t,s)}},addProseMirrorPlugins(){return[gzt(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()}}}),vzt=tm.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",$c(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:s})=>{if(!p7t(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}):OFt(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(Qa.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(Ha.create(l.doc,u.pos)):l.setSelection(Qa.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(Qa.create(l.doc,p+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[pJe({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),bzt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,_zt=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,wzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,jzt=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Nzt=oy.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",$c(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[GT({find:bzt,type:this.type}),GT({find:wzt,type:this.type})]},addPasteRules(){return[HS({find:_zt,type:this.type}),HS({find:jzt,type:this.type})]}}),kzt=tm.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",$c(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)}}}),Szt="listItem",ELe="textStyle",PLe=/^(\d+)\.\s$/,Czt=tm.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",$c(this.options.HTMLAttributes,r),0]:["ol",$c(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(Szt,this.editor.getAttributes(ELe)).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:PLe,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:PLe,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:s=>({start:+s[1],...this.editor.getAttributes(ELe)}),joinPredicate:(s,r)=>r.childCount+r.attrs.start===+s[1],editor:this.editor})),[t]}}),Mzt=tm.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",$c(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Tzt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Azt=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ezt=oy.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",$c(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[GT({find:Tzt,type:this.type})]},addPasteRules(){return[HS({find:Azt,type:this.type})]}}),Pzt=tm.create({name:"text",group:"inline"}),rke=Ph.create({name:"starterKit",addExtensions(){const t=[];return this.options.bold!==!1&&t.push(B7t.configure(this.options.bold)),this.options.blockquote!==!1&&t.push(D7t.configure(this.options.blockquote)),this.options.bulletList!==!1&&t.push(q7t.configure(this.options.bulletList)),this.options.code!==!1&&t.push(H7t.configure(this.options.code)),this.options.codeBlock!==!1&&t.push(K7t.configure(this.options.codeBlock)),this.options.document!==!1&&t.push(Z7t.configure(this.options.document)),this.options.dropcursor!==!1&&t.push(Q7t.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&t.push(izt.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&t.push(ozt.configure(this.options.hardBreak)),this.options.heading!==!1&&t.push(lzt.configure(this.options.heading)),this.options.history!==!1&&t.push(yzt.configure(this.options.history)),this.options.horizontalRule!==!1&&t.push(vzt.configure(this.options.horizontalRule)),this.options.italic!==!1&&t.push(Nzt.configure(this.options.italic)),this.options.listItem!==!1&&t.push(kzt.configure(this.options.listItem)),this.options.orderedList!==!1&&t.push(Czt.configure(this.options.orderedList)),this.options.paragraph!==!1&&t.push(Mzt.configure(this.options.paragraph)),this.options.strike!==!1&&t.push(Ezt.configure(this.options.strike)),this.options.text!==!1&&t.push(Pzt.configure(this.options.text)),t}}),Izt="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Lzt="ελ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",F1e="numeric",z1e="ascii",B1e="alpha",t8="asciinumeric",kI="alphanumeric",$1e="domain",wJe="emoji",Dzt="scheme",Ozt="slashscheme",pge="whitespace";function Rzt(t,s){return t in s||(s[t]=[]),s[t]}function w4(t,s,r){s[F1e]&&(s[t8]=!0,s[kI]=!0),s[z1e]&&(s[t8]=!0,s[B1e]=!0),s[t8]&&(s[kI]=!0),s[B1e]&&(s[kI]=!0),s[kI]&&(s[$1e]=!0),s[wJe]&&(s[$1e]=!0);for(const n in s){const a=Rzt(n,r);a.indexOf(t)<0&&a.push(t)}}function Fzt(t,s){const r={};for(const n in s)s[n].indexOf(t)>=0&&(r[n]=!0);return r}function fp(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}fp.groups={};fp.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),id=(t,s,r,n,a)=>t.tr(s,r,n,a),ILe=(t,s,r,n,a)=>t.ts(s,r,n,a),Yr=(t,s,r,n,a)=>t.tt(s,r,n,a),Cv="WORD",q1e="UWORD",jJe="ASCIINUMERICAL",NJe="ALPHANUMERICAL",pD="LOCALHOST",U1e="TLD",V1e="UTLD",kie="SCHEME",z5="SLASH_SCHEME",nke="NUM",H1e="WS",ake="NL",s8="OPENBRACE",r8="CLOSEBRACE",ile="OPENBRACKET",ole="CLOSEBRACKET",lle="OPENPAREN",cle="CLOSEPAREN",dle="OPENANGLEBRACKET",ule="CLOSEANGLEBRACKET",hle="FULLWIDTHLEFTPAREN",mle="FULLWIDTHRIGHTPAREN",ple="LEFTCORNERBRACKET",fle="RIGHTCORNERBRACKET",xle="LEFTWHITECORNERBRACKET",gle="RIGHTWHITECORNERBRACKET",yle="FULLWIDTHLESSTHAN",vle="FULLWIDTHGREATERTHAN",ble="AMPERSAND",_le="APOSTROPHE",wle="ASTERISK",Zb="AT",jle="BACKSLASH",Nle="BACKTICK",kle="CARET",n_="COLON",ike="COMMA",Sle="DOLLAR",Wy="DOT",Cle="EQUALS",oke="EXCLAMATION",rx="HYPHEN",n8="PERCENT",Mle="PIPE",Tle="PLUS",Ale="POUND",a8="QUERY",lke="QUOTE",kJe="FULLWIDTHMIDDLEDOT",cke="SEMI",Gy="SLASH",i8="TILDE",Ele="UNDERSCORE",SJe="EMOJI",Ple="SYM";var CJe=Object.freeze({__proto__:null,ALPHANUMERICAL:NJe,AMPERSAND:ble,APOSTROPHE:_le,ASCIINUMERICAL:jJe,ASTERISK:wle,AT:Zb,BACKSLASH:jle,BACKTICK:Nle,CARET:kle,CLOSEANGLEBRACKET:ule,CLOSEBRACE:r8,CLOSEBRACKET:ole,CLOSEPAREN:cle,COLON:n_,COMMA:ike,DOLLAR:Sle,DOT:Wy,EMOJI:SJe,EQUALS:Cle,EXCLAMATION:oke,FULLWIDTHGREATERTHAN:vle,FULLWIDTHLEFTPAREN:hle,FULLWIDTHLESSTHAN:yle,FULLWIDTHMIDDLEDOT:kJe,FULLWIDTHRIGHTPAREN:mle,HYPHEN:rx,LEFTCORNERBRACKET:ple,LEFTWHITECORNERBRACKET:xle,LOCALHOST:pD,NL:ake,NUM:nke,OPENANGLEBRACKET:dle,OPENBRACE:s8,OPENBRACKET:ile,OPENPAREN:lle,PERCENT:n8,PIPE:Mle,PLUS:Tle,POUND:Ale,QUERY:a8,QUOTE:lke,RIGHTCORNERBRACKET:fle,RIGHTWHITECORNERBRACKET:gle,SCHEME:kie,SEMI:cke,SLASH:Gy,SLASH_SCHEME:z5,SYM:Ple,TILDE:i8,TLD:U1e,UNDERSCORE:Ele,UTLD:V1e,UWORD:q1e,WORD:Cv,WS:H1e});const _v=/[a-z]/,YP=new RegExp("\\p{L}","u"),fge=new RegExp("\\p{Emoji}","u"),wv=/\d/,xge=/\s/,LLe="\r",gge=` `,zzt="️",Bzt="‍",yge="";let mz=null,pz=null;function $zt(t=[]){const s={};fp.groups=s;const r=new fp;mz==null&&(mz=DLe(Izt)),pz==null&&(pz=DLe(Lzt)),Yr(r,"'",_le),Yr(r,"{",s8),Yr(r,"}",r8),Yr(r,"[",ile),Yr(r,"]",ole),Yr(r,"(",lle),Yr(r,")",cle),Yr(r,"<",dle),Yr(r,">",ule),Yr(r,"(",hle),Yr(r,")",mle),Yr(r,"「",ple),Yr(r,"」",fle),Yr(r,"『",xle),Yr(r,"』",gle),Yr(r,"<",yle),Yr(r,">",vle),Yr(r,"&",ble),Yr(r,"*",wle),Yr(r,"@",Zb),Yr(r,"`",Nle),Yr(r,"^",kle),Yr(r,":",n_),Yr(r,",",ike),Yr(r,"$",Sle),Yr(r,".",Wy),Yr(r,"=",Cle),Yr(r,"!",oke),Yr(r,"-",rx),Yr(r,"%",n8),Yr(r,"|",Mle),Yr(r,"+",Tle),Yr(r,"#",Ale),Yr(r,"?",a8),Yr(r,'"',lke),Yr(r,"/",Gy),Yr(r,";",cke),Yr(r,"~",i8),Yr(r,"_",Ele),Yr(r,"\\",jle),Yr(r,"・",kJe);const n=id(r,wv,nke,{[F1e]:!0});id(n,wv,n);const a=id(n,_v,jJe,{[t8]:!0}),o=id(n,YP,NJe,{[kI]:!0}),l=id(r,_v,Cv,{[z1e]:!0});id(l,wv,a),id(l,_v,l),id(a,wv,a),id(a,_v,a);const i=id(r,YP,q1e,{[B1e]:!0});id(i,_v),id(i,wv,o),id(i,YP,i),id(o,wv,o),id(o,_v),id(o,YP,o);const c=Yr(r,gge,ake,{[pge]:!0}),u=Yr(r,LLe,H1e,{[pge]:!0}),p=id(r,xge,H1e,{[pge]:!0});Yr(r,yge,p),Yr(u,gge,c),Yr(u,yge,p),id(u,xge,p),Yr(p,LLe),Yr(p,gge),id(p,xge,p),Yr(p,yge,p);const f=id(r,fge,SJe,{[wJe]:!0});Yr(f,"#"),id(f,fge,f),Yr(f,zzt,f);const g=Yr(f,Bzt);Yr(g,"#"),id(g,fge,f);const b=[[_v,l],[wv,a]],_=[[_v,null],[YP,i],[wv,o]];for(let j=0;jj[0]>w[0]?1:-1);for(let j=0;j=0?C[$1e]=!0:_v.test(w)?wv.test(w)?C[t8]=!0:C[z1e]=!0:C[F1e]=!0,ILe(r,w,w,C)}return ILe(r,"localhost",pD,{ascii:!0}),r.jd=new fp(Ple),{start:r,tokens:Object.assign({groups:s},CJe)}}function MJe(t,s){const r=qzt(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 qzt(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 Ib(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 fD={defaultProtocol:"http",events:null,format:OLe,formatHref:OLe,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function dke(t,s=null){let r=Object.assign({},fD);t&&(r=Object.assign(r,t instanceof dke?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=fD.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 Oue(t,s){class r extends TJe{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 RLe=Oue("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),FLe=Oue("text"),Uzt=Oue("nl"),fz=Oue("url",{isLink:!0,toHref(t=fD.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==pD&&t[1].t===n_}}),Yf=t=>new fp(t);function Vzt({groups:t}){const s=t.domain.concat([ble,wle,Zb,jle,Nle,kle,Sle,Cle,rx,nke,n8,Mle,Tle,Ale,Gy,Ple,i8,Ele]),r=[_le,n_,ike,Wy,oke,n8,a8,lke,cke,dle,ule,s8,r8,ole,ile,lle,cle,hle,mle,ple,fle,xle,gle,yle,vle],n=[ble,_le,wle,jle,Nle,kle,Sle,Cle,rx,s8,r8,n8,Mle,Tle,Ale,a8,Gy,Ple,i8,Ele],a=Yf(),o=Yr(a,i8);Ji(o,n,o),Ji(o,t.domain,o);const l=Yf(),i=Yf(),c=Yf();Ji(a,t.domain,l),Ji(a,t.scheme,i),Ji(a,t.slashscheme,c),Ji(l,n,o),Ji(l,t.domain,l);const u=Yr(l,Zb);Yr(o,Zb,u),Yr(i,Zb,u),Yr(c,Zb,u);const p=Yr(o,Wy);Ji(p,n,o),Ji(p,t.domain,o);const f=Yf();Ji(u,t.domain,f),Ji(f,t.domain,f);const g=Yr(f,Wy);Ji(g,t.domain,f);const b=Yf(RLe);Ji(g,t.tld,b),Ji(g,t.utld,b),Yr(u,pD,b);const _=Yr(f,rx);Yr(_,rx,_),Ji(_,t.domain,f),Ji(b,t.domain,f),Yr(b,Wy,g),Yr(b,rx,_);const j=Yr(b,n_);Ji(j,t.numeric,RLe);const w=Yr(l,rx),N=Yr(l,Wy);Yr(w,rx,w),Ji(w,t.domain,l),Ji(N,n,o),Ji(N,t.domain,l);const C=Yf(fz);Ji(N,t.tld,C),Ji(N,t.utld,C),Ji(C,t.domain,l),Ji(C,n,o),Yr(C,Wy,N),Yr(C,rx,w),Yr(C,Zb,u);const M=Yr(C,n_),I=Yf(fz);Ji(M,t.numeric,I);const L=Yf(fz),R=Yf();Ji(L,s,L),Ji(L,r,R),Ji(R,s,L),Ji(R,r,R),Yr(C,Gy,L),Yr(I,Gy,L);const q=Yr(i,n_),U=Yr(c,n_),B=Yr(U,Gy),V=Yr(B,Gy);Ji(i,t.domain,l),Yr(i,Wy,N),Yr(i,rx,w),Ji(c,t.domain,l),Yr(c,Wy,N),Yr(c,rx,w),Ji(q,t.domain,L),Yr(q,Gy,L),Yr(q,a8,L),Ji(V,t.domain,L),Ji(V,s,L),Yr(V,Gy,L);const Y=[[s8,r8],[ile,ole],[lle,cle],[dle,ule],[hle,mle],[ple,fle],[xle,gle],[yle,vle]];for(let J=0;J=0&&g++,a++,p++;if(g<0)a-=p,a0&&(o.push(vge(FLe,s,l)),l=[]),a-=g,p-=g;const b=f.t,_=r.slice(a-p,a);o.push(vge(b,s,_))}}return l.length>0&&o.push(vge(FLe,s,l)),o}function vge(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 Wzt=typeof console<"u"&&console&&console.warn||(()=>{}),Gzt="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",mc={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Kzt(){return fp.groups={},mc.scanner=null,mc.parser=null,mc.tokenQueue=[],mc.pluginQueue=[],mc.customSchemes=[],mc.initialized=!1,mc}function zLe(t,s=!1){if(mc.initialized&&Wzt(`linkifyjs: already initialized - will not register custom scheme "${t}" ${Gzt}`),!/^[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`);mc.customSchemes.push([t,s])}function Zzt(){mc.scanner=$zt(mc.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=CFt(r.doc,[...s]);if(LFt(i).forEach(({newRange:u})=>{const p=TFt(n.doc,u,b=>b.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 b=n.doc.textBetween(u.from,u.to," "," ");if(!Xzt.test(b))return;f=p[0],g=n.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&g){const b=g.split(Yzt).filter(Boolean);if(b.length<=0)return!1;const _=b[b.length-1],j=f.pos+g.lastIndexOf(_);if(!_)return!1;const w=uke(_).map(N=>N.toObject(t.defaultProtocol));if(!Jzt(w))return!1;w.filter(N=>N.isLink).map(N=>({...N,from:j+N.start+1,to:j+N.end+1})).filter(N=>n.schema.marks.code?!n.doc.rangeHasMark(N.from,N.to,n.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{YNe(N.from,N.to,n.doc).some(C=>C.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function t9t(t){return new Pu({key:new em("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=mJe(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 s9t(t){return new Pu({key:new em("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=AJe(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 O2(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(Qzt,"").match(new RegExp(`^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}const mke=oy.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"){zLe(t);return}zLe(t.scheme,t.optionalSlashes)})},onDestroy(){Kzt()},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)=>!!O2(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=>!!O2(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=>!!O2(s,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",$c(this.options.HTMLAttributes,t),0]:["a",$c(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:s})=>{const{href:r}=t;return this.options.isAllowedUri(r,{defaultValidate:n=>!!O2(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=>!!O2(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[HS({find:t=>{const s=[];if(t){const{protocols:r,defaultProtocol:n}=this.options,a=AJe(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!O2(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(e9t({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:n=>this.options.isAllowedUri(n,{defaultValidate:a=>!!O2(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(s9t({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),pke=Ph.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")}}}),r9t=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}`)})},fke=oy.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&r9t(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",$c(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}}}}),n9t=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,a9t=tm.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",$c(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:s})=>s.insertContent({type:this.name,attrs:t})}},addInputRules(){return[pJe({find:n9t,type:this.type,getAttributes:t=>{const[,,s,r,n]=t;return{src:r,alt:s,title:n}}})]}});let W1e,G1e;if(typeof WeakMap<"u"){let t=new WeakMap;W1e=s=>t.get(s),G1e=(s,r)=>(t.set(s,r),r)}else{const t=[];let r=0;W1e=n=>{for(let a=0;a(r==10&&(r=0),t[r++]=n,t[r++]=a)}var xd=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:N-M});break}const I=a+M*s;for(let L=0;Ln&&(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 l9t(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 d9t(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 uy(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 Rue(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=rE(s.$head)||u9t(s.$head);if(r)return r;throw new RangeError(`No cell found around position ${s.head}`)}function u9t(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 K1e(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function h9t(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function xke(t,s){return t.depth==s.depth&&t.pos>=s.start(-1)&&t.pos<=s.end(-1)}function EJe(t,s,r){const n=t.node(-1),a=xd.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 WS(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 PJe(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 iQe(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(K1e(n)&&K1e(a)&&xke(n,a)){const o=this.$anchorCell.node(-1)!=n.node(-1);return o&&this.isRowSelection()?Mv.rowSelection(n,a):o&&this.isColSelection()?Mv.colSelection(n,a):new Mv(n,a)}return Qa.between(n,a)}content(){const s=this.$anchorCell.node(-1),r=xd.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||w>0){let N=_.attrs;if(j>0&&(N=WS(N,0,j)),w>0&&(N=WS(N,N.colspan-w,w)),b.lefta.bottom){const N={..._.attrs,rowspan:Math.min(b.bottom,a.bottom)-Math.max(b.top,a.top)};b.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=xd.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 Mv&&s.$anchorCell.pos==this.$anchorCell.pos&&s.$headCell.pos==this.$headCell.pos}static rowSelection(s,r=s){const n=s.node(-1),a=xd.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(Cm.node(n,n+r.nodeSize,{class:"selectedCell"}))}),pd.create(t.doc,s)}function x9t({$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 g9t({$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 y9t(t,s,r){const n=(s||t).selection,a=(s||t).doc;let o,l;if(n instanceof Ha&&(l=n.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")o=nc.create(a,n.from);else if(l=="row"){const i=a.resolve(n.from+1);o=nc.rowSelection(i,i)}else if(!r){const i=xd.get(n.node),c=n.from+1,u=c+i.map[i.width*i.height-1];o=nc.create(a,c+1,u)}}else n instanceof Qa&&x9t(n)?o=Qa.create(a,n.from):n instanceof Qa&&g9t(n)&&(o=Qa.create(a,n.$from.start(),n.$from.end()));return o&&(s||(s=t.tr)).setSelection(o),s}const v9t=new em("fix-tables");function LJe(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=b9t(t,a,o,r))};return s?s.doc!=t.doc&&LJe(s.doc,t.doc,0,n):t.doc.descendants(n),r}function b9t(t,s,r,n){const a=xd.get(s);if(!a.problems)return n;n||(n=t.tr);const o=[];for(let c=0;c0){let b="cell";p.firstChild&&(b=p.firstChild.type.spec.tableRole);const _=[];for(let w=0;w0?-1:0;m9t(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;k9t(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=BLe(u)?c+1:p;o.replaceWith(f+n.tableStart,p+n.tableStart,i)}o.setSelection(new nc(o.doc.resolve(c+n.tableStart))),s(o)}return!0}function qLe(t,s){const r=Qh(t.schema);return E9t(({node:n})=>r[n.type.spec.tableRole])(t,s)}function E9t(t){return(s,r)=>{const n=s.selection;let a,o;if(n instanceof nc){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;a=n.$anchorCell.nodeAfter,o=n.$anchorCell.pos}else{var l;if(a=d9t(n.$from),!a)return!1;o=(l=rE(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=R0(s),f=s.tr;for(let b=0;b{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 I9t(t){return function(s,r){if(!uy(s))return!1;if(r){const n=Qh(s.schema),a=R0(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 b=g+o.tableStart,_=l.doc.nodeAt(b);_&&l.setNodeMarkup(b,f,_.attrs)}),n(l)}return!0}}xD("row",{useDeprecatedLogic:!0});xD("column",{useDeprecatedLogic:!0});const L9t=xD("cell",{useDeprecatedLogic:!0});function D9t(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 xz(t,s){const r=t.selection;if(!(r instanceof nc))return!1;if(s){const n=t.tr,a=Qh(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 bn(a,0,0))}),n.docChanged&&s(n)}return!0}function R9t(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(Lr.empty),r[a]n&&(g=g.type.createChecked(WS(g.attrs,g.attrs.colspan,p+g.attrs.colspan-n),g.content)),u.push(g),p+=g.attrs.colspan;for(let b=1;ba&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,a-f.attrs.rowspan)},f.content)),c.push(f)}o.push(Lr.from(c))}r=o,s=a}return{width:t,height:s,rows:r}}function B9t(t,s,r,n,a,o,l){const i=t.doc.type.schema,c=Qh(i);let u,p;if(a>s.width)for(let f=0,g=0;fs.height){const f=[];for(let _=0,j=(s.height-1)*s.width;_=s.width?!1:r.nodeAt(s.map[j+_]).type==c.header_cell;f.push(w?p||(p=c.header_cell.createAndFill()):u||(u=c.cell.createAndFill()))}const g=c.row.create(null,Lr.from(f)),b=[];for(let _=s.height;_{if(!a)return!1;const o=r.selection;if(o instanceof nc)return Sie(r,n,pi.near(o.$headCell,s));if(t!="horiz"&&!o.empty)return!1;const l=FJe(a,t,s);if(l==null)return!1;if(t=="horiz")return Sie(r,n,pi.near(r.doc.resolve(o.head+s),s));{const i=r.doc.resolve(l),c=EJe(i,t,s);let u;return c?u=pi.near(c,1):s<0?u=pi.near(r.doc.resolve(i.before(-1)),-1):u=pi.near(r.doc.resolve(i.after(-1)),1),Sie(r,n,u)}}}function yz(t,s){return(r,n,a)=>{if(!a)return!1;const o=r.selection;let l;if(o instanceof nc)l=o;else{const c=FJe(a,t,s);if(c==null)return!1;l=new nc(r.doc.resolve(c))}const i=EJe(l.$headCell,t,s);return i?Sie(r,n,new nc(l.$anchorCell,i)):!1}}function q9t(t,s){const r=t.state.doc,n=rE(r.resolve(s));return n?(t.dispatch(t.state.tr.setSelection(new nc(n))),!0):!1}function U9t(t,s,r){if(!uy(t.state))return!1;let n=R9t(r);const a=t.state.selection;if(a instanceof nc){n||(n={width:1,height:1,rows:[Lr.from(Z1e(Qh(t.state.schema).cell,r))]});const o=a.$anchorCell.node(-1),l=a.$anchorCell.start(-1),i=xd.get(o).rectBetween(a.$anchorCell.pos-l,a.$headCell.pos-l);return n=z9t(n,i.right-i.left,i.bottom-i.top),GLe(t.state,t.dispatch,l,i,n),!0}else if(n){const o=Rue(t.state),l=o.start(-1);return GLe(t.state,t.dispatch,l,xd.get(o.node(-1)).findCell(o.pos-l),n),!0}else return!1}function V9t(t,s){var r;if(s.ctrlKey||s.metaKey)return;const n=KLe(t,s.target);let a;if(s.shiftKey&&t.state.selection instanceof nc)o(t.state.selection.$anchorCell,s),s.preventDefault();else if(s.shiftKey&&n&&(a=rE(t.state.selection.$anchor))!=null&&((r=bge(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=bge(t,u);const f=a_.getState(t.state)==null;if(!p||!xke(c,p))if(f)p=c;else return;const g=new nc(c,p);if(f||!t.state.selection.eq(g)){const b=t.state.tr.setSelection(g);f&&b.setMeta(a_,c.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",i),a_.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(a_,-1))}function i(c){const u=c,p=a_.getState(t.state);let f;if(p!=null)f=t.state.doc.resolve(p);else if(KLe(t,u.target)!=n&&(f=bge(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 FJe(t,s,r){if(!(t.state.selection instanceof Qa))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 KLe(t,s){for(;s&&s!=t.dom;s=s.parentNode)if(s.nodeName=="TD"||s.nodeName=="TH")return s;return null}function bge(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 rE(t.state.doc.resolve(n))}var H9t=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")),Y1e(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,Y1e(s,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(s){return s.type=="attributes"&&(s.target==this.table||this.colgroup.contains(s.target))}};function Y1e(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 G9t(-1,!1)},apply(l,i){return i.apply(l)}},props:{attributes:l=>{const i=cf.getState(l);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,i)=>{K9t(l,i,t,a)},mouseleave:l=>{Z9t(l)},mousedown:(l,i)=>{Y9t(l,i,s,r)}},decorations:l=>{const i=cf.getState(l);if(i&&i.activeHandle>-1)return tBt(l,i.activeHandle)},nodeViews:{}}});return o}var G9t=class Cie{constructor(s,r){this.activeHandle=s,this.dragging=r}apply(s){const r=this,n=s.getMeta(cf);if(n&&n.setHandle!=null)return new Cie(n.setHandle,!1);if(n&&n.setDragging!==void 0)return new Cie(r.activeHandle,n.setDragging);if(r.activeHandle>-1&&s.docChanged){let a=s.mapping.map(r.activeHandle,-1);return K1e(s.doc.resolve(a))||(a=-1),new Cie(a,r.dragging)}return r}};function K9t(t,s,r,n){if(!t.editable)return;const a=cf.getState(t.state);if(a&&!a.dragging){const o=Q9t(s.target);let l=-1;if(o){const{left:i,right:c}=o.getBoundingClientRect();s.clientX-i<=r?l=ZLe(t,s,"left",r):c-s.clientX<=r&&(l=ZLe(t,s,"right",r))}if(l!=a.activeHandle){if(!n&&l!==-1){const i=t.state.doc.resolve(l),c=i.node(-1),u=xd.get(c),p=i.start(-1);if(u.colCount(i.pos-p)+i.nodeAfter.attrs.colspan-1==u.width-1)return}zJe(t,l)}}}function Z9t(t){if(!t.editable)return;const s=cf.getState(t.state);s&&s.activeHandle>-1&&!s.dragging&&zJe(t,-1)}function Y9t(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=cf.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const i=t.state.doc.nodeAt(l.activeHandle),c=X9t(t,l.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(cf,{setDragging:{startX:s.clientX,startWidth:c}}));function u(f){o.removeEventListener("mouseup",u),o.removeEventListener("mousemove",p);const g=cf.getState(t.state);g!=null&&g.dragging&&(J9t(t,g.activeHandle,YLe(g.dragging,f,r)),t.dispatch(t.state.tr.setMeta(cf,{setDragging:null})))}function p(f){if(!f.which)return u(f);const g=cf.getState(t.state);if(g&&g.dragging){const b=YLe(g.dragging,f,r);XLe(t,g.activeHandle,b,n)}}return XLe(t,l.activeHandle,c,n),o.addEventListener("mouseup",u),o.addEventListener("mousemove",p),s.preventDefault(),!0}function X9t(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 iBt(t,s,r,n,a){const o=aBt(t),l=[],i=[];for(let u=0;u{const{selection:s}=t.state;if(!oBt(s))return!1;let r=0;const n=hJe(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},lBt=tm.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:rBt,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}=nBt(t,this.options.cellMinWidth),o=["table",$c(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=iBt(o.schema,t,s,r);if(a){const i=n.selection.from+1;n.replaceSelectionWith(l).scrollIntoView().setSelection(Qa.near(n.doc.resolve(i)))}return!0},addColumnBefore:()=>({state:t,dispatch:s})=>_9t(t,s),addColumnAfter:()=>({state:t,dispatch:s})=>w9t(t,s),deleteColumn:()=>({state:t,dispatch:s})=>N9t(t,s),addRowBefore:()=>({state:t,dispatch:s})=>S9t(t,s),addRowAfter:()=>({state:t,dispatch:s})=>C9t(t,s),deleteRow:()=>({state:t,dispatch:s})=>T9t(t,s),deleteTable:()=>({state:t,dispatch:s})=>O9t(t,s),mergeCells:()=>({state:t,dispatch:s})=>$Le(t,s),splitCell:()=>({state:t,dispatch:s})=>qLe(t,s),toggleHeaderColumn:()=>({state:t,dispatch:s})=>xD("column")(t,s),toggleHeaderRow:()=>({state:t,dispatch:s})=>xD("row")(t,s),toggleHeaderCell:()=>({state:t,dispatch:s})=>L9t(t,s),mergeOrSplit:()=>({state:t,dispatch:s})=>$Le(t,s)?!0:qLe(t,s),setCellAttribute:(t,s)=>({state:r,dispatch:n})=>P9t(t,s)(r,n),goToNextCell:()=>({state:t,dispatch:s})=>VLe(1)(t,s),goToPreviousCell:()=>({state:t,dispatch:s})=>VLe(-1)(t,s),fixTables:()=>({state:t,dispatch:s})=>(s&&DJe(t),!0),setCellSelection:t=>({tr:s,dispatch:r})=>{if(r){const n=nc.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:vz,"Mod-Backspace":vz,Delete:vz,"Mod-Delete":vz}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[W9t({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],sBt({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const s={name:t.name,options:t.options,storage:t.storage};return{tableRole:eo(aa(t,"tableRole",s))}}}),cBt=tm.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",$c(this.options.HTMLAttributes,t),0]}}),dBt=tm.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",$c(this.options.HTMLAttributes,t),0]}}),uBt=tm.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",$c(this.options.HTMLAttributes,t),0]}});function hy({content:t,onChange:s,placeholder:r="Enter content...",minHeight:n="150px",compact:a=!1}){const[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState(!0),f=tke({extensions:[rke,mke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),pke.configure({types:["heading","paragraph"]}),fke,a9t.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),width:{default:null},height:{default:null},style:{default:null}}}}).configure({inline:!0,allowBase64:!0}),lBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},cellpadding:{default:null},cellspacing:{default:null},border:{default:null}}}}).configure({resizable:!1}),cBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null}}}}),dBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1},valign:{default:null}}}}),uBt.extend({addAttributes(){var j;return{...(j=this.parent)==null?void 0:j.call(this),style:{default:null},width:{default:null},colspan:{default:1},rowspan:{default:1}}}})],content:t,onUpdate:({editor:j})=>{s(j.getHTML())},editorProps:{attributes:{class:"outline-none","data-placeholder":r},handlePaste:(j,w)=>{var C;const N=(C=w.clipboardData)==null?void 0:C.items;if(!N)return!1;for(const M of Array.from(N))if(M.type.startsWith("image/")){w.preventDefault();const I=M.getAsFile();if(!I)continue;const L=new FileReader;return L.onload=R=>{var U;const q=(U=R.target)==null?void 0:U.result;j.dispatch(j.state.tr.replaceSelectionWith(j.state.schema.nodes.image.create({src:q})))},L.readAsDataURL(I),!0}return!1}}});k.useEffect(()=>{f&&t!==f.getHTML()&&f.commands.setContent(t)},[t,f]);const g=()=>{if(!f)return;const j=f.getAttributes("link").href||"",w=f.getAttributes("link").target;c(j),p(w==="_blank"),l(!0)},b=()=>{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(kM,{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(SM,{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(W4,{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(Q4,{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(Ch,{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(h0,{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(U4,{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(V4,{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(zo,{className:"h-4 w-4"})}),f.isActive("link")&&e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:_,title:"Remove Link",children:e.jsx(zo,{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(dS,{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(oS,{className:"h-4 w-4"})})]}),e.jsx(JNe,{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(_s,{children:e.jsx(bs,{children:"Insert Link"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"link-url",children:"URL"}),e.jsx(ze,{id:"link-url",value:i,onChange:j=>c(j.target.value),placeholder:"https://example.com"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx($r,{id:"link-new-tab",checked:u,onCheckedChange:p}),e.jsx(ye,{htmlFor:"link-new-tab",children:"Open in new tab"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{type:"button",onClick:b,children:i?"Apply Link":"Remove Link"})]})]})})]}):null}var hBt=Object.defineProperty,mBt=(t,s,r)=>s in t?hBt(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,Tc=(t,s,r)=>mBt(t,typeof s!="symbol"?s+"":s,r);const Ile={x:0,y:0,width:0,height:0,unit:"px"},b5=(t,s,r)=>Math.min(Math.max(t,s),r),pBt=(...t)=>t.filter(s=>s&&typeof s=="string").join(" "),e8e=(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 fBt(t,s,r,n){const a=Ky(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==="%"?Yb(a,r,n):a}function xBt(t,s,r){const n=Ky(t,s,r);return n.x=(s-n.width)/2,n.y=(r-n.height)/2,t.unit==="%"?Yb(n,s,r):n}function Yb(t,s,r){return t.unit==="%"?{...Ile,...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 Ky(t,s,r){return t.unit?t.unit==="px"?{...Ile,...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}:{...Ile,...t,unit:"px"}}function t8e(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),b=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,b=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 j=a-(u.y+u.height);if(j<0&&(u.y=Math.min(u.y,a-f),u.height+=j),u.widthg&&((r==="sw"||r=="nw")&&(u.x-=g-u.width),u.width=g),u.height>b&&((r==="nw"||r=="ne")&&(u.y-=b-u.height),u.height=b),s){const w=u.width/u.height;if(ws){const N=Math.max(u.height*s,p);(r==="sw"||r=="nw")&&(u.x-=N-u.width),u.width=N}}return u}function gBt(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 _5={capture:!0,passive:!1};let yBt=0;const qb=class Cg extends k.PureComponent{constructor(){super(...arguments),Tc(this,"docMoveBound",!1),Tc(this,"mouseDownOnCrop",!1),Tc(this,"dragStarted",!1),Tc(this,"evData",{startClientX:0,startClientY:0,startCropX:0,startCropY:0,clientX:0,clientY:0,isResize:!0}),Tc(this,"componentRef",k.createRef()),Tc(this,"mediaRef",k.createRef()),Tc(this,"resizeObserver"),Tc(this,"initChangeCalled",!1),Tc(this,"instanceId",`rc-${yBt++}`),Tc(this,"state",{cropIsActive:!1,newCropIsBeingDrawn:!1}),Tc(this,"onCropPointerDown",s=>{const{crop:r,disabled:n}=this.props,a=this.getBox();if(!r)return;const o=Ky(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,b=s.clientY-a.y;let _=0,j=0;l==="ne"||l=="e"?(_=g-(o.x+o.width),j=b-o.y,p=o.x,f=o.y+o.height):l==="se"||l==="s"?(_=g-(o.x+o.width),j=b-(o.y+o.height),p=o.x,f=o.y):l==="sw"||l=="w"?(_=g-o.x,j=b-(o.y+o.height),p=o.x+o.width,f=o.y):(l==="nw"||l=="n")&&(_=g-o.x,j=b-o.y,p=o.x+o.width,f=o.y+o.height),c=p+a.x+_,u=f+a.y+j}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})}),Tc(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(Ky(p,i.width,i.height),Yb(p,i.width,i.height)),this.setState({cropIsActive:!0,newCropIsBeingDrawn:!0})}),Tc(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(),e8e(r,c)||a(Ky(c,l.width,l.height),Yb(c,l.width,l.height))}),Tc(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)?Cg.nudgeStepLarge:s.shiftKey?Cg.nudgeStepMedium:Cg.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=b5(u.x,0,c.width-u.width),u.y=b5(u.y,0,c.height-u.height);const f=Ky(u,c.width,c.height),g=Yb(u,c.width,c.height);a(f,g),o&&o(f,g)}}),Tc(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 b=(navigator.platform.match("Mac")?s.metaKey:s.ctrlKey)?Cg.nudgeStepLarge:s.shiftKey?Cg.nudgeStepMedium:Cg.nudgeStep,_=Ky(a,g.width,g.height),j=gBt(_,s.key,b,r),w=t8e(j,n,r,g.width,g.height,l,i,c,u);if(!e8e(a,w)){const N=Yb(w,g.width,g.height);p(w,N),f&&f(w,N)}}),Tc(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(Ky(r,l.width,l.height),Yb(r,l.width,l.height)),this.setState({cropIsActive:!1,newCropIsBeingDrawn:!1}))}),Tc(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(Ky(r,a,o),Yb(r,a,o))}}componentWillUnmount(){this.resizeObserver&&this.resizeObserver.disconnect(),this.unbindDocMove()}bindDocMove(){this.docMoveBound||(this.document.addEventListener("pointermove",this.onDocPointerMove,_5),this.document.addEventListener("pointerup",this.onDocPointerDone,_5),this.document.addEventListener("pointercancel",this.onDocPointerDone,_5),this.docMoveBound=!0)}unbindDocMove(){this.docMoveBound&&(this.document.removeEventListener("pointermove",this.onDocPointerMove,_5),this.document.removeEventListener("pointerup",this.onDocPointerDone,_5),this.document.removeEventListener("pointercancel",this.onDocPointerDone,_5),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=b5(s.startCropX+a,0,r.width-n.width),n.y=b5(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 b={unit:"px",x:0,y:0,width:0,height:0};u==="ne"?(b.x=s.startCropX,b.width=f,r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY-b.height)):u==="se"?(b.x=s.startCropX,b.y=s.startCropY,b.width=f,r?b.height=b.width/r:b.height=g):u==="sw"?(b.x=s.startCropX+f,b.y=s.startCropY,b.width=Math.abs(f),r?b.height=b.width/r:b.height=g):u==="nw"&&(b.x=s.startCropX+f,b.width=Math.abs(f),r?(b.height=b.width/r,b.y=s.startCropY-b.height):(b.height=Math.abs(g),b.y=s.startCropY+g));const _=t8e(b,r,u,o.width,o.height,l,i,n,a);return r||Cg.xyOrds.indexOf(p)>-1?c=_:Cg.xOrds.indexOf(p)>-1?(c.x=_.x,c.width=_.width):Cg.yOrds.indexOf(p)>-1&&(c.y=_.y,c.height=_.height),c.x=b5(c.x,0,o.width-c.width),c.y=b5(c.y,0,o.height-c.height),c}renderCropSelection(){const{ariaLabels:s=Cg.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={...Ile,...this.props.crop||{}};return Ky(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,b=pBt("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:b,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)}};Tc(qb,"xOrds",["e","w"]),Tc(qb,"yOrds",["n","s"]),Tc(qb,"xyOrds",["nw","ne","se","sw"]),Tc(qb,"nudgeStep",1),Tc(qb,"nudgeStepMedium",10),Tc(qb,"nudgeStepLarge",100),Tc(qb,"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 vBt=qb;var BJe=["PageUp","PageDown"],$Je=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],qJe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},nE="Slider",[Q1e,bBt,_Bt]=pO(nE),[UJe]=nd(nE,[_Bt]),[wBt,Fue]=UJe(nE),VJe=k.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:b=!1,form:_,...j}=t,w=k.useRef(new Set),N=k.useRef(0),M=l==="horizontal"?jBt:NBt,[I=[],L]=rh({prop:p,defaultProp:u,onChange:Y=>{var te;(te=[...w.current][N.current])==null||te.focus(),f(Y)}}),R=k.useRef(I);function q(Y){const J=TBt(I,Y);V(Y,J)}function U(Y){V(Y,N.current)}function B(){const Y=R.current[N.current];I[N.current]!==Y&&g(I)}function V(Y,J,{commit:te}={commit:!1}){const X=IBt(o),ce=LBt(Math.round((Y-n)/o)*o+n,X),ne=Y8(ce,[n,a]);L((re=[])=>{const le=CBt(re,ne,J);if(PBt(le,c*o)){N.current=le.indexOf(ne);const pe=String(le)!==String(re);return pe&&te&&g(le),pe?le:re}else return re})}return e.jsx(wBt,{scope:t.__scopeSlider,name:r,disabled:i,min:n,max:a,valueIndexToChangeRef:N,thumbs:w.current,values:I,orientation:l,form:_,children:e.jsx(Q1e.Provider,{scope:t.__scopeSlider,children:e.jsx(Q1e.Slot,{scope:t.__scopeSlider,children:e.jsx(M,{"aria-disabled":i,"data-disabled":i?"":void 0,...j,ref:s,onPointerDown:Ir(j.onPointerDown,()=>{i||(R.current=I)}),min:n,max:a,inverted:b,onSlideStart:i?void 0:q,onSlideMove:i?void 0:U,onSlideEnd:i?void 0:B,onHomeKeyDown:()=>!i&&V(n,0,{commit:!0}),onEndKeyDown:()=>!i&&V(a,I.length-1,{commit:!0}),onStepKeyDown:({event:Y,direction:J})=>{if(!i){const ce=BJe.includes(Y.key)||Y.shiftKey&&$Je.includes(Y.key)?10:1,ne=N.current,re=I[ne],le=o*ce*J;V(re+le,ne,{commit:!0})}}})})})})});VJe.displayName=nE;var[HJe,WJe]=UJe(nE,{startEdge:"left",endEdge:"right",size:"width",direction:1}),jBt=k.forwardRef((t,s)=>{const{min:r,max:n,dir:a,inverted:o,onSlideStart:l,onSlideMove:i,onSlideEnd:c,onStepKeyDown:u,...p}=t,[f,g]=k.useState(null),b=$a(s,M=>g(M)),_=k.useRef(void 0),j=Sw(a),w=j==="ltr",N=w&&!o||!w&&o;function C(M){const I=_.current||f.getBoundingClientRect(),L=[0,I.width],q=gke(L,N?[r,n]:[n,r]);return _.current=I,q(M-I.left)}return e.jsx(HJe,{scope:t.__scopeSlider,startEdge:N?"left":"right",endEdge:N?"right":"left",direction:N?1:-1,size:"width",children:e.jsx(GJe,{dir:j,"data-orientation":"horizontal",...p,ref:b,style:{...p.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const I=C(M.clientX);l==null||l(I)},onSlideMove:M=>{const I=C(M.clientX);i==null||i(I)},onSlideEnd:()=>{_.current=void 0,c==null||c()},onStepKeyDown:M=>{const L=qJe[N?"from-left":"from-right"].includes(M.key);u==null||u({event:M,direction:L?-1:1})}})})}),NBt=k.forwardRef((t,s)=>{const{min:r,max:n,inverted:a,onSlideStart:o,onSlideMove:l,onSlideEnd:i,onStepKeyDown:c,...u}=t,p=k.useRef(null),f=$a(s,p),g=k.useRef(void 0),b=!a;function _(j){const w=g.current||p.current.getBoundingClientRect(),N=[0,w.height],M=gke(N,b?[n,r]:[r,n]);return g.current=w,M(j-w.top)}return e.jsx(HJe,{scope:t.__scopeSlider,startEdge:b?"bottom":"top",endEdge:b?"top":"bottom",size:"height",direction:b?1:-1,children:e.jsx(GJe,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:j=>{const w=_(j.clientY);o==null||o(w)},onSlideMove:j=>{const w=_(j.clientY);l==null||l(w)},onSlideEnd:()=>{g.current=void 0,i==null||i()},onStepKeyDown:j=>{const N=qJe[b?"from-bottom":"from-top"].includes(j.key);c==null||c({event:j,direction:N?-1:1})}})})}),GJe=k.forwardRef((t,s)=>{const{__scopeSlider:r,onSlideStart:n,onSlideMove:a,onSlideEnd:o,onHomeKeyDown:l,onEndKeyDown:i,onStepKeyDown:c,...u}=t,p=Fue(nE,r);return e.jsx(sn.span,{...u,ref:s,onKeyDown:Ir(t.onKeyDown,f=>{f.key==="Home"?(l(f),f.preventDefault()):f.key==="End"?(i(f),f.preventDefault()):BJe.concat($Je).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:Ir(t.onPointerDown,f=>{const g=f.target;g.setPointerCapture(f.pointerId),f.preventDefault(),p.thumbs.has(g)?g.focus():n(f)}),onPointerMove:Ir(t.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&a(f)}),onPointerUp:Ir(t.onPointerUp,f=>{const g=f.target;g.hasPointerCapture(f.pointerId)&&(g.releasePointerCapture(f.pointerId),o(f))})})}),KJe="SliderTrack",ZJe=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Fue(KJe,r);return e.jsx(sn.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...n,ref:s})});ZJe.displayName=KJe;var J1e="SliderRange",YJe=k.forwardRef((t,s)=>{const{__scopeSlider:r,...n}=t,a=Fue(J1e,r),o=WJe(J1e,r),l=k.useRef(null),i=$a(s,l),c=a.values.length,u=a.values.map(g=>JJe(g,a.min,a.max)),p=c>1?Math.min(...u):0,f=100-Math.max(...u);return e.jsx(sn.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...n,ref:i,style:{...t.style,[o.startEdge]:p+"%",[o.endEdge]:f+"%"}})});YJe.displayName=J1e;var ebe="SliderThumb",XJe=k.forwardRef((t,s)=>{const r=bBt(t.__scopeSlider),[n,a]=k.useState(null),o=$a(s,i=>a(i)),l=k.useMemo(()=>n?r().findIndex(i=>i.ref.current===n):-1,[r,n]);return e.jsx(kBt,{...t,ref:o,index:l})}),kBt=k.forwardRef((t,s)=>{const{__scopeSlider:r,index:n,name:a,...o}=t,l=Fue(ebe,r),i=WJe(ebe,r),[c,u]=k.useState(null),p=$a(s,C=>u(C)),f=c?l.form||!!c.closest("form"):!0,g=gO(c),b=l.values[n],_=b===void 0?0:JJe(b,l.min,l.max),j=MBt(n,l.values.length),w=g==null?void 0:g[i.size],N=w?ABt(w,_,i.direction):0;return k.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(${_}% + ${N}px)`},children:[e.jsx(Q1e.ItemSlot,{scope:t.__scopeSlider,children:e.jsx(sn.span,{role:"slider","aria-label":t["aria-label"]||j,"aria-valuemin":l.min,"aria-valuenow":b,"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:b===void 0?{display:"none"}:t.style,onFocus:Ir(t.onFocus,()=>{l.valueIndexToChangeRef.current=n})})}),f&&e.jsx(QJe,{name:a??(l.name?l.name+(l.values.length>1?"[]":""):void 0),form:l.form,value:b},n)]})});XJe.displayName=ebe;var SBt="RadioBubbleInput",QJe=k.forwardRef(({__scopeSlider:t,value:s,...r},n)=>{const a=k.useRef(null),o=$a(a,n),l=AO(s);return k.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(sn.input,{style:{display:"none"},...r,ref:o,defaultValue:s})});QJe.displayName=SBt;function CBt(t=[],s,r){const n=[...t];return n[r]=s,n.sort((a,o)=>a-o)}function JJe(t,s,r){const o=100/(r-s)*(t-s);return Y8(o,[0,100])}function MBt(t,s){return s>2?`Value ${t+1} of ${s}`:s===2?["Minimum","Maximum"][t]:void 0}function TBt(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 ABt(t,s,r){const n=t/2,o=gke([0,50],[0,n]);return(n-o(s)*r)*r}function EBt(t){return t.slice(0,-1).map((s,r)=>t[r+1]-s)}function PBt(t,s){if(s>0){const r=EBt(t);return Math.min(...r)>=s}return!0}function gke(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 IBt(t){return(String(t).split(".")[1]||"").length}function LBt(t,s){const r=Math.pow(10,s);return Math.round(t*r)/r}var eet=VJe,DBt=ZJe,OBt=YJe,RBt=XJe;const Wg=k.forwardRef(({className:t,...s},r)=>e.jsxs(eet,{ref:r,className:Pt("relative flex w-full touch-none select-none items-center",t),...s,children:[e.jsx(DBt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:e.jsx(OBt,{className:"absolute h-full bg-primary"})}),e.jsx(RBt,{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"})]}));Wg.displayName=eet.displayName;function FBt(t,s,r){return xBt(fBt({unit:"%",width:90},r,t,s),t,s)}const yke=({open:t,onClose:s,imageSrc:r,onCropComplete:n,aspectRatio:a=1})=>{const o=k.useRef(null),[l,i]=k.useState(),[c,u]=k.useState(),[p,f]=k.useState(1),[g,b]=k.useState(0),_=k.useCallback(N=>{const{width:C,height:M}=N.currentTarget;i(FBt(C,M,a))},[a]),j=k.useCallback(async()=>{const N=o.current;if(!N||!c)return;const C=document.createElement("canvas"),M=C.getContext("2d");if(!M)return;const I=N.naturalWidth/N.width,L=N.naturalHeight/N.height,R=400;C.width=R,C.height=R,M.imageSmoothingQuality="high";const q=c.x*I,U=c.y*L,B=c.width*I,V=c.height*L,Y=g*Math.PI/180,J=C.width/2,te=C.height/2;return M.save(),M.translate(J,te),M.rotate(Y),M.scale(p,p),M.translate(-J,-te),M.drawImage(N,q,U,B,V,0,0,R,R),M.restore(),new Promise((X,ce)=>{C.toBlob(ne=>{ne?X(ne):ce(new Error("Canvas is empty"))},"image/jpeg",.95)})},[c,p,g]),w=async()=>{try{const N=await j();N&&(n(N),s())}catch(N){console.error("Error cropping image:",N)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(bs,{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(vBt,{crop:l,onChange:(N,C)=>i(C),onComplete:N=>u(N),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(UM,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Wg,{value:[p],min:.5,max:3,step:.1,onValueChange:([N])=>f(N),className:"flex-1"}),e.jsx(H_,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_L,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(Wg,{value:[g],min:-180,max:180,step:1,onValueChange:([N])=>b(N),className:"flex-1"}),e.jsxs("span",{className:"text-sm text-muted-foreground w-12",children:[g,"°"]})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"}),e.jsx(K,{onClick:w,children:"Save Photo"})]})]})})},zBt=()=>{const{user:t}=Rs(),{toast:s}=qa(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(null);k.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:b}=await H.functions.invoke("customer-portal",{headers:{Authorization:`Bearer ${f.access_token}`}});if(b)throw b;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(tt,{className:"bg-amber-500",children:"Grandfathered"});switch(l==null?void 0:l.status){case"active":return e.jsx(tt,{className:"bg-green-500",children:"Active"});case"trialing":return e.jsx(tt,{className:"bg-blue-500",children:"Trial"});case"past_due":return e.jsx(tt,{variant:"destructive",children:"Past Due"});case"canceled":return e.jsx(tt,{variant:"secondary",children:"Canceled"});default:return e.jsx(tt,{variant:"outline",children:"No Subscription"})}};return r?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-5 w-5"}),"Subscription"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Cx,{className:"h-5 w-5"}),"Subscription"]}),e.jsx(xr,{children:"Manage your subscription and billing"})]}),e.jsxs(Re,{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(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(an,{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."})]})]})},BBt=()=>{const{user:t}=Rs(),s=pr(),{toast:r}=qa(),[n]=qc(),a=n.get("setup")==="true",o=n.get("reset")==="true",{isSupported:l,isSubscribed:i,isLoading:c,subscribe:u,unsubscribe:p}=IYe(),[f,g]=k.useState(!1),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!1),[M,I]=k.useState(""),[L,R]=k.useState({name:"",email:"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}),[q,U]=k.useState(!1),[B,V]=k.useState(!1),[Y,J]=k.useState({newPassword:"",confirmPassword:""});k.useEffect(()=>{t&&te()},[t]),k.useEffect(()=>{o&&t&&setTimeout(()=>{var le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},500)},[o,t]);const te=async()=>{var le,pe,xe;if(!(t!=null&&t.id)){console.log("No user ID available yet");return}try{console.log("Loading profile for user:",t.id);const{data:_e,error:fe}=await H.from("profiles").select("name, email, 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(fe)throw console.error("Profile query error:",fe),fe;_e?(console.log("Profile loaded successfully:",_e),R({name:_e.name||"",email:_e.email||"",title:_e.title||"",bio:_e.bio||"",areas_served:_e.areas_served||"",years_experience:((le=_e.years_experience)==null?void 0:le.toString())||"",instagram_url:_e.instagram_url||"",facebook_url:_e.facebook_url||"",linkedin_url:_e.linkedin_url||"",email_signature:_e.email_signature||"",use_email_signature:_e.use_email_signature||!1}),U(_e.digest_opt_out||!1)):(console.warn("No profile found for user"),R({name:((pe=t.user_metadata)==null?void 0:pe.name)||((xe=t.email)==null?void 0:xe.split("@")[0])||"",email:t.email||"",title:"",bio:"",areas_served:"",years_experience:"",instagram_url:"",facebook_url:"",linkedin_url:"",email_signature:"",use_email_signature:!1}));const{data:we}=await H.storage.from("avatars").list(`${t.id}`);if(we&&we.length>0){const{data:Ie}=H.storage.from("avatars").getPublicUrl(`${t.id}/${we[0].name}`);_(Ie.publicUrl)}}catch(_e){console.error("Error loading profile:",_e),r({title:"Error",description:_e.message||"Failed to load profile",variant:"destructive"})}},X=le=>{var _e;const pe=(_e=le.target.files)==null?void 0:_e[0];if(!pe)return;const xe=new FileReader;xe.onloadend=()=>{I(xe.result),C(!0)},xe.readAsDataURL(pe),le.target.value=""},ce=async le=>{if(t){w(!0);try{const{data:pe}=await H.storage.from("avatars").list(`${t.id}`);pe&&pe.length>0&&await H.storage.from("avatars").remove(pe.map(Ne=>`${t.id}/${Ne.name}`));const _e=`${t.id}/avatar.jpg`,{error:fe}=await H.storage.from("avatars").upload(_e,le,{upsert:!0,contentType:"image/jpeg"});if(fe)throw fe;const{data:we}=H.storage.from("avatars").getPublicUrl(_e),Ie=we.publicUrl;_(`${Ie}?t=${Date.now()}`),await H.from("profiles").update({avatar_url:Ie}).eq("id",t.id),r({title:"Success",description:"Profile photo updated successfully"})}catch(pe){console.error("Error uploading avatar:",pe),r({title:"Error",description:pe.message||"Failed to upload photo",variant:"destructive"})}finally{w(!1)}}},ne=async()=>{if(!L.name.trim()||!L.email.trim()){r({title:"Error",description:"Name and email are required",variant:"destructive"});return}g(!0);try{const{error:le}=await H.from("profiles").update({name:L.name.trim(),email:L.email.trim(),title:L.title.trim()||null,bio:L.bio.trim()||null,areas_served:L.areas_served.trim()||null,years_experience:L.years_experience?parseInt(L.years_experience):null,instagram_url:L.instagram_url.trim()||null,facebook_url:L.facebook_url.trim()||null,linkedin_url:L.linkedin_url.trim()||null,email_signature:L.email_signature||"",use_email_signature:L.use_email_signature}).eq("id",t==null?void 0:t.id);if(le)throw le;r({title:"Success",description:"Profile updated successfully"})}catch(le){console.error("Error updating profile:",le),r({title:"Error",description:le.message||"Failed to update profile",variant:"destructive"})}finally{g(!1)}},re=async()=>{if(!Y.newPassword){r({title:"Error",description:"Please enter a new password",variant:"destructive"});return}if(Y.newPassword.length<6){r({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}if(Y.newPassword!==Y.confirmPassword){r({title:"Error",description:"Passwords do not match",variant:"destructive"});return}g(!0);try{const{error:le}=await H.auth.updateUser({password:Y.newPassword});if(le)throw le;r({title:"Success",description:"Password updated successfully"}),J({newPassword:"",confirmPassword:""}),a&&setTimeout(()=>s("/dashboard"),1e3)}catch(le){console.error("Error updating password:",le),r({title:"Error",description:le.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 le;(le=document.getElementById("change-password-section"))==null||le.scrollIntoView({behavior:"smooth",block:"center"})},className:"gap-2",children:[e.jsx(J4,{className:"h-4 w-4"}),"Change Password"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Profile Photo"}),e.jsx(xr,{children:"Upload a professional photo for your profile"})]}),e.jsxs(Re,{className:"flex items-center gap-6",children:[e.jsxs(_n,{className:"h-24 w-24",children:[e.jsx(za,{src:b}),e.jsx(wn,{className:"text-2xl",children:L.name.split(" ").map(le=>le[0]).join("").toUpperCase()||"U"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",id:"avatar-upload",accept:"image/*",className:"hidden",onChange:X,disabled:j}),e.jsxs(K,{variant:"outline",onClick:()=>{var le;return(le=document.getElementById("avatar-upload"))==null?void 0:le.click()},disabled:j,children:[e.jsx(oi,{className:"mr-2 h-4 w-4"}),j?"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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Personal Information"}),e.jsx(xr,{children:"Update your profile details"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:L.name,onChange:le=>R({...L,name:le.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:L.email,onChange:le=>R({...L,email:le.target.value}),maxLength:255})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Job Title"}),e.jsx(ze,{id:"title",value:L.title,onChange:le=>R({...L,title:le.target.value}),placeholder:"e.g., Broker Associate, Team Lead",maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"bio",children:"Bio"}),e.jsx(Er,{id:"bio",value:L.bio,onChange:le=>R({...L,bio:le.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(ye,{htmlFor:"areas_served",children:"Areas Served"}),e.jsx(ze,{id:"areas_served",value:L.areas_served,onChange:le=>R({...L,areas_served:le.target.value}),placeholder:"e.g., Downtown, Suburbs"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"years_experience",children:"Years Experience"}),e.jsx(ze,{id:"years_experience",type:"number",min:"0",value:L.years_experience,onChange:le=>R({...L,years_experience:le.target.value}),placeholder:"e.g., 5"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Social Links"}),e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsx(ze,{value:L.linkedin_url,onChange:le=>R({...L,linkedin_url:le.target.value}),placeholder:"LinkedIn URL"}),e.jsx(ze,{value:L.instagram_url,onChange:le=>R({...L,instagram_url:le.target.value}),placeholder:"Instagram URL"}),e.jsx(ze,{value:L.facebook_url,onChange:le=>R({...L,facebook_url:le.target.value}),placeholder:"Facebook URL"})]})]}),e.jsxs(K,{onClick:ne,disabled:f,children:[e.jsx(ed,{className:"mr-2 h-4 w-4"}),"Save Changes"]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Rv,{className:"h-5 w-5"}),"Email Signature"]}),e.jsx(xr,{children:"Add a signature that will be appended to emails sent via Gmail"})]}),e.jsxs(Re,{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:L.use_email_signature?"Your signature will be added to every email sent via Gmail":"Signature is currently disabled"})]}),e.jsx($r,{checked:L.use_email_signature,onCheckedChange:le=>R({...L,use_email_signature:le})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Signature"}),e.jsx(hy,{content:L.email_signature,onChange:le=>R({...L,email_signature:le}),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(ed,{className:"mr-2 h-4 w-4"}),"Save Signature"]})]})]}),e.jsxs(Pe,{id:"change-password-section",children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:a?"Set Your Password":"Change Password"}),e.jsx(xr,{children:a?"Create a secure password for your account":"Update your password to keep your account secure"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"newPassword",children:"New Password"}),e.jsx(ze,{id:"newPassword",type:"password",value:Y.newPassword,onChange:le=>J({...Y,newPassword:le.target.value}),placeholder:"Min 6 characters"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"confirmPassword",children:"Confirm Password"}),e.jsx(ze,{id:"confirmPassword",type:"password",value:Y.confirmPassword,onChange:le=>J({...Y,confirmPassword:le.target.value}),placeholder:"Re-enter your new password"})]}),e.jsxs(K,{onClick:re,disabled:f,children:[e.jsx(ed,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[i?e.jsx(Pm,{className:"h-5 w-5"}):e.jsx(e1,{className:"h-5 w-5"}),"Push Notifications"]}),e.jsx(xr,{children:"Receive browser notifications when new content is added"})]}),e.jsx(Re,{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($r,{checked:i,onCheckedChange:le=>{le?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 supported in this browser."}),e.jsxs("p",{className:"text-xs",children:[e.jsx("strong",{children:"Desktop:"})," Use Chrome, Firefox, or Edge.",e.jsx("br",{}),e.jsx("strong",{children:"iPhone/iPad:"}),' Open this site in Safari, tap the Share button, then "Add to Home Screen". Push notifications will work from the installed app.']})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[q?e.jsx(dL,{className:"h-5 w-5"}):e.jsx(dr,{className:"h-5 w-5"}),"Email Preferences"]}),e.jsx(xr,{children:"Manage your email subscription settings"})]}),e.jsx(Re,{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:q?"You won't receive weekly digest emails":"Receive a weekly summary of new content, events, and your progress"})]}),e.jsx($r,{checked:!q,onCheckedChange:async le=>{V(!0);try{const{error:pe}=await H.from("profiles").update({digest_opt_out:!le}).eq("id",t==null?void 0:t.id);if(pe)throw pe;U(!le),r({title:le?"Subscribed":"Unsubscribed",description:le?"You will now receive weekly digest emails":"You will no longer receive weekly digest emails"})}catch(pe){r({title:"Error",description:pe.message||"Failed to update preference",variant:"destructive"})}finally{V(!1)}},disabled:B})]})})]}),e.jsx(g8t,{}),e.jsx(zBt,{})]}),e.jsx(yke,{open:N,onClose:()=>C(!1),imageSrc:M,onCropComplete:ce,aspectRatio:1})]})})};var $Bt="AspectRatio",tet=k.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(sn.div,{...a,ref:s,style:{...n,position:"absolute",top:0,right:0,bottom:0,left:0}})})});tet.displayName=$Bt;var qBt=tet;const UBt=qBt;function VBt(){const{user:t}=Rs(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),{data:l,isLoading:i}=mt({queryKey:["calendar-token",t==null?void 0:t.id],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select("calendar_token").eq("id",t==null?void 0:t.id).single();if(j)throw j;return _},enabled:!!t&&a}),c=Lt({mutationFn:async()=>{const _=new Uint8Array(12);crypto.getRandomValues(_);const j=btoa(String.fromCharCode(..._)).replace(/\+/g,"x").replace(/\//g,"y").replace(/=/g,"").substring(0,16),{error:w}=await H.from("profiles").update({calendar_token:j}).eq("id",t==null?void 0:t.id);if(w)throw w;return j},onSuccess:()=>{s.invalidateQueries({queryKey:["calendar-token",t==null?void 0:t.id]}),he.success("Calendar subscription URL generated!")},onError:_=>{he.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),he.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://"),j=`https://calendar.google.com/calendar/r?cid=${encodeURIComponent(_)}`;window.open(j,"_blank")}},b=()=>{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(cn,{className:"h-4 w-4"}),"Subscribe to Calendar"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cn,{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(ws,{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(fa,{className:"h-4 w-4 text-green-500"}):e.jsx(gi,{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(an,{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(an,{className:"h-3 w-3 ml-auto opacity-50"})]}),e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-2",onClick:b,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(an,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(cn,{className:"h-4 w-4 mr-2"}),"Generate Calendar URL"]})})]})})]})]})}var zue="Tabs",[HBt]=nd(zue,[Cw]),set=Cw(),[WBt,vke]=HBt(zue),ret=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,onValueChange:a,defaultValue:o,orientation:l="horizontal",dir:i,activationMode:c="automatic",...u}=t,p=Sw(i),[f,g]=rh({prop:n,onChange:a,defaultProp:o??"",caller:zue});return e.jsx(WBt,{scope:r,baseId:Mu(),value:f,onValueChange:g,orientation:l,dir:p,activationMode:c,children:e.jsx(sn.div,{dir:p,"data-orientation":l,...u,ref:s})})});ret.displayName=zue;var net="TabsList",aet=k.forwardRef((t,s)=>{const{__scopeTabs:r,loop:n=!0,...a}=t,o=vke(net,r),l=set(r);return e.jsx(Ede,{asChild:!0,...l,orientation:o.orientation,dir:o.dir,loop:n,children:e.jsx(sn.div,{role:"tablist","aria-orientation":o.orientation,...a,ref:s})})});aet.displayName=net;var iet="TabsTrigger",oet=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,disabled:a=!1,...o}=t,l=vke(iet,r),i=set(r),c=uet(l.baseId,n),u=het(l.baseId,n),p=n===l.value;return e.jsx(Pde,{asChild:!0,...i,focusable:!a,active:p,children:e.jsx(sn.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:Ir(t.onMouseDown,f=>{!a&&f.button===0&&f.ctrlKey===!1?l.onValueChange(n):f.preventDefault()}),onKeyDown:Ir(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&l.onValueChange(n)}),onFocus:Ir(t.onFocus,()=>{const f=l.activationMode!=="manual";!p&&!a&&f&&l.onValueChange(n)})})})});oet.displayName=iet;var cet="TabsContent",det=k.forwardRef((t,s)=>{const{__scopeTabs:r,value:n,forceMount:a,children:o,...l}=t,i=vke(cet,r),c=uet(i.baseId,n),u=het(i.baseId,n),p=n===i.value,f=k.useRef(p);return k.useEffect(()=>{const g=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(g)},[]),e.jsx(Fd,{present:a||p,children:({present:g})=>e.jsx(sn.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})})});det.displayName=cet;function uet(t,s){return`${t}-trigger-${s}`}function het(t,s){return`${t}-content-${s}`}var GBt=ret,met=aet,pet=oet,fet=det;const ja=GBt,ga=k.forwardRef(({className:t,...s},r)=>e.jsx(met,{ref:r,className:Pt("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...s}));ga.displayName=met.displayName;const us=k.forwardRef(({className:t,...s},r)=>e.jsx(pet,{ref:r,className:Pt("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}));us.displayName=pet.displayName;const ks=k.forwardRef(({className:t,...s},r)=>e.jsx(fet,{ref:r,className:Pt("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...s}));ks.displayName=fet.displayName;const KBt={first_timer:Jn,regular:a1,dedicated:bc,veteran:xo,streak_master:Qu,century:xo},ZBt={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 s8e(t){return t===1?e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}):t===2?e.jsx(a1,{className:"h-5 w-5 text-gray-400"}):t===3?e.jsx(bc,{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 xet({showUserStats:t=!0,compact:s=!1,brokerageId:r,title:n="Event Leaderboard"}){const{user:a}=Rs(),{data:o,isLoading:l}=sXe(s?5:10,r),{data:i}=rXe(a==null?void 0:a.id),{data:c}=aXe(a==null?void 0:a.id),{data:u}=nXe(a==null?void 0:a.id);return l?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsx(Re,{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(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-yellow-500"}),n]})}),e.jsxs(Re,{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(tt,{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(Qu,{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=KBt[p.badge_type]||Jn;return e.jsxs(tt,{variant:"outline",className:`text-xs ${ZBt[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(tt,{variant:"outline",className:"text-xs",children:["+",u.length-4," more"]})]})]}),e.jsxs(ja,{defaultValue:"points",className:"w-full",children:[e.jsxs(ga,{className:"w-full mb-3",children:[e.jsx(us,{value:"points",className:"flex-1",children:"By Points"}),e.jsx(us,{value:"events",className:"flex-1",children:"By Events"})]}),e.jsx(ks,{value:"points",className:"mt-0",children:e.jsxs("div",{className:"space-y-2",children:[o==null?void 0:o.map((p,f)=>{var g,b,_;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:s8e(f+1)}),e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.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(ks,{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,b,_;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:s8e(f+1)}),e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{className:"text-xs",children:((b=(g=p.profile)==null?void 0:g.name)==null?void 0:b.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 YBt(){const t=pr(),{user:s,isAdmin:r}=Rs(),n=es(),{data:a,isLoading:o}=mt({queryKey:["public-events"],queryFn:async()=>{const{data:j,error:w}=await H.from("events").select("*").order("event_date",{ascending:!0});if(w)throw w;return j}}),{data:l}=mt({queryKey:["my-registrations"],queryFn:async()=>{if(!s)return[];const{data:j,error:w}=await H.from("event_registrations").select("event_id, zoom_join_url").eq("user_id",s.id);if(w)throw w;return j},enabled:!!s}),{data:i}=mt({queryKey:["event-registration-counts"],queryFn:async()=>{let j=[],w=0;const N=1e3;for(;;){const{data:M,error:I}=await H.from("event_registrations").select("event_id").range(w,w+N-1);if(I)throw I;if(!M||M.length===0||(j=j.concat(M),M.length{C[M.event_id]=(C[M.event_id]||0)+1}),C}}),c=Lt({mutationFn:async j=>{await H.auth.refreshSession();const{data:w,error:N}=await H.functions.invoke("zoom-register",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:j=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),j!=null&&j.join_url?he.success("Successfully registered! You'll receive a Zoom confirmation email."):he.success("Successfully registered for the event!")},onError:j=>{he.error("Failed to register: "+j.message)}}),u=Lt({mutationFn:async j=>{const{data:w,error:N}=await H.functions.invoke("zoom-unregister",{body:{event_id:j}});if(N)throw N;if(w!=null&&w.error)throw new Error(w.error);return w},onSuccess:()=>{n.invalidateQueries({queryKey:["my-registrations"]}),n.invalidateQueries({queryKey:["event-registration-counts"]}),he.success("Registration cancelled and removed from Zoom")},onError:j=>{he.error("Failed to cancel: "+j.message)}}),p=j=>l==null?void 0:l.some(w=>w.event_id===j),f=j=>{const w=l==null?void 0:l.find(N=>N.event_id===j);return w==null?void 0:w.zoom_join_url},g=j=>j.capacity?((i==null?void 0:i[j.id])||0)>=j.capacity:!1,b=(a==null?void 0:a.filter(j=>XM(j.event_date)!=="ended"))||[],_=(a==null?void 0:a.filter(j=>XM(j.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(VBt,{}),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..."}):b.length===0?e.jsx(Pe,{className:"text-center py-12",children:e.jsx(Re,{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:b.map(j=>{const w=XM(j.event_date),N=fNe(j.event_date),C=w==="live",M=w==="starting_soon";return e.jsxs(Pe,{className:`flex flex-col overflow-hidden cursor-pointer hover:shadow-lg transition-all ${C?"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/${j.id}`),children:[N&&e.jsxs("div",{className:`${C?"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"})]}),C?e.jsxs(e.Fragment,{children:[e.jsx(l1,{className:"h-3.5 w-3.5"}),"LIVE NOW"]}):e.jsxs(e.Fragment,{children:[e.jsx(mn,{className:"h-3.5 w-3.5"}),"STARTING SOON"]})]}),j.image_url&&e.jsx(UBt,{ratio:3/2,className:"overflow-hidden",children:e.jsx("img",{src:j.image_url,alt:j.title,className:"w-full h-full object-cover group-hover:scale-105 transition-transform"})}),e.jsxs(Dt,{children:[e.jsx(zt,{className:"line-clamp-2",children:j.title}),j.description&&e.jsx(xr,{className:"line-clamp-2",children:j.description.replace(/<[^>]*>/g,"")})]}),e.jsxs(Re,{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(cn,{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(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mn,{className:"h-4 w-4"}),rD(new Date(j.event_date))]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mr,{className:"h-4 w-4"}),(i==null?void 0:i[j.id])||0," registered",j.capacity&&` / ${j.capacity} spots`]})]}),e.jsx(BL,{className:"flex gap-2",onClick:I=>I.stopPropagation(),children:p(j.id)?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>u.mutate(j.id),disabled:u.isPending,children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),"Cancel"]}),e.jsxs(K,{className:"flex-1",onClick:()=>window.open(f(j.id)||j.zoom_link,"_blank"),children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Join Zoom"]})]}):e.jsx(K,{className:"w-full",onClick:()=>c.mutate(j.id),disabled:c.isPending||g(j),children:g(j)?"Event Full":e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-4 w-4 mr-2"}),"Register"]})})})]},j.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(j=>e.jsx(Pe,{className:"opacity-60 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>t(`/events/${j.id}`),children:e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-base line-clamp-1",children:j.title}),e.jsx(xr,{children:new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",timeZone:"America/New_York"}).format(new Date(j.event_date))})]})},j.id))})]})]}),r&&e.jsx("div",{className:"lg:col-span-1",children:e.jsx(xet,{showUserStats:!0})})]})]})})}const _ge=[{value:"all",label:"All Roles",icon:mr},{value:"newest",label:"Newest Members",icon:mn},{value:"brokerage_manager",label:"Brokerage Managers",icon:IL},{value:"admin",label:"Admins",icon:Th}];function XBt({open:t,onOpenChange:s,resourceType:r,resourceId:n,resourceTitle:a}){var $e,ct;const{user:o,isAdmin:l,isBrokerageManager:i}=Rs(),[c,u]=k.useState([]),[p,f]=k.useState([]),[g,b]=k.useState([]),[_,j]=k.useState([]),[w,N]=k.useState(""),[C,M]=k.useState(""),[I,L]=k.useState(""),[R,q]=k.useState(!1),[U,B]=k.useState(!1),[V,Y]=k.useState("agents"),[J,te]=k.useState("all"),[X,ce]=k.useState({}),ne=l||i;k.useEffect(()=>{t&&o&&(l?re():le())},[t,o,l]),k.useEffect(()=>{t||(b([]),j([]),N(""),M(""),L(""),Y("agents"),te("all"))},[t]);const re=async()=>{if(o){q(!0);try{const{data:Te,error:ft}=await H.from("brokerages").select("id, name").order("name");if(ft)throw ft;const me=1e3,Ve={};let nt=0,et=!0;for(;et;){const{data:Ge,error:lt}=await H.from("profiles").select("brokerage_id").range(nt*me,(nt+1)*me-1);if(lt)throw lt;Ge==null||Ge.forEach(qe=>{qe.brokerage_id&&(Ve[qe.brokerage_id]=(Ve[qe.brokerage_id]||0)+1)}),et=(Ge==null?void 0:Ge.length)===me,nt++}f((Te==null?void 0:Te.map(Ge=>({...Ge,agent_count:Ve[Ge.id]||0})))||[]);const Se=[];for(nt=0,et=!0;et;){const{data:Ge,error:lt}=await H.from("profiles").select("id, name, email, brokerage_id, created_at, brokerages(name)").neq("id",o.id).order("name").range(nt*me,(nt+1)*me-1);if(lt)throw lt;Ge&&Se.push(...Ge),et=(Ge==null?void 0:Ge.length)===me,nt++}const rt={};for(nt=0,et=!0;et;){const{data:Ge,error:lt}=await H.from("user_roles").select("user_id, role").range(nt*me,(nt+1)*me-1);if(lt)throw lt;Ge==null||Ge.forEach(qe=>{rt[qe.user_id]||(rt[qe.user_id]=[]),rt[qe.user_id].push(qe.role)}),et=(Ge==null?void 0:Ge.length)===me,nt++}ce(rt),u(Se.map(Ge=>{var lt;return{id:Ge.id,name:Ge.name,email:Ge.email,brokerage_name:((lt=Ge.brokerages)==null?void 0:lt.name)||"No Brokerage",roles:rt[Ge.id]||[],created_at:Ge.created_at}}))}catch(Te){console.error("Error loading data:",Te),he.error("Failed to load agents and brokerages")}finally{q(!1)}}},le=async()=>{if(o){q(!0);try{const{data:Te}=await H.from("profiles").select("brokerage_id").eq("id",o.id).single();if(!(Te!=null&&Te.brokerage_id)){he.error("You must be part of a brokerage to share resources"),s(!1);return}const{data:ft,error:me}=await H.from("profiles").select("id, name, email").eq("brokerage_id",Te.brokerage_id).neq("id",o.id).order("name");if(me)throw me;u(ft||[])}catch(Te){console.error("Error loading agents:",Te),he.error("Failed to load agents")}finally{q(!1)}}},pe=c.filter(Te=>{var me;const ft=Te.name.toLowerCase().includes(w.toLowerCase())||Te.email.toLowerCase().includes(w.toLowerCase())||((me=Te.brokerage_name)==null?void 0:me.toLowerCase().includes(w.toLowerCase()));if(l&&J!=="all"&&J!=="newest"){const Ve=X[Te.id]||[];return ft&&Ve.includes(J)}return ft}).sort((Te,ft)=>J==="newest"?(ft.created_at||"").localeCompare(Te.created_at||""):0),xe=p.filter(Te=>Te.name.toLowerCase().includes(C.toLowerCase())),_e=()=>{g.length===pe.length?b([]):b(pe.map(Te=>Te.id))},fe=()=>{_.length===xe.length?j([]):j(xe.map(Te=>Te.id))},we=Te=>{if(!ne){b([Te]);return}b(ft=>ft.includes(Te)?ft.filter(me=>me!==Te):[...ft,Te])},Ie=Te=>{j(ft=>ft.includes(Te)?ft.filter(me=>me!==Te):[...ft,Te])},Ne=async()=>{if(!(g.length>0||_.length>0)){he.error("Please select at least one agent or brokerage to share with");return}B(!0);try{const{data:ft,error:me}=await H.functions.invoke("send-share-notification",{body:{recipientIds:g,brokerageIds:_,resourceType:r,resourceId:n,resourceTitle:a,message:I.trim()||void 0}});if(me)throw me;const Ve=(ft==null?void 0:ft.sharesCreated)||g.length;he.success(`Shared with ${Ve} agent${Ve!==1?"s":""}`),s(!1)}catch(ft){console.error("Error sharing resource:",ft),he.error("Failed to share resource")}finally{B(!1)}},Ae=Te=>Te.split(" ").map(ft=>ft[0]).join("").toUpperCase().slice(0,2),Fe=Te=>{const ft=X[Te]||[];return ft.includes("admin")?e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"Admin"}):ft.includes("brokerage_manager")?e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"Manager"}):null},Ce=g.length+_.length,Me=J!=="all"&&J!=="newest"?pe.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(_s,{className:"flex-shrink-0",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Rn,{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(ja,{value:V,onValueChange:Y,className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2 flex-shrink-0",children:[e.jsxs(us,{value:"agents",className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{children:"Agents"}),g.length>0&&e.jsx(tt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:g.length})]}),e.jsxs(us,{value:"brokerages",className:"flex items-center gap-2",children:[e.jsx(wa,{className:"h-4 w-4"}),e.jsx("span",{children:"Brokerages"}),_.length>0&&e.jsx(tt,{variant:"default",className:"h-5 min-w-5 px-1.5 text-xs",children:_.length})]})]}),e.jsxs(ks,{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(hn,{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:w,onChange:Te=>N(Te.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:J,onValueChange:te,children:[e.jsxs(Gs,{className:"w-[180px]",children:[e.jsx(Yg,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Qs,{placeholder:"Filter by role"})]}),e.jsx(Ks,{children:_ge.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:_e,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[Me!==null&&e.jsxs("span",{className:"text-primary font-medium",children:[Me," ",($e=_ge.find(Te=>Te.value===J))==null?void 0:$e.label]}),e.jsxs("span",{className:"font-medium",children:[g.length," selected"]})]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(mr,{className:"h-8 w-8 mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:J!=="all"?`No ${(ct=_ge.find(Te=>Te.value===J))==null?void 0:ct.label.toLowerCase()} found`:"No agents found"})]}):e.jsx("div",{className:"p-2 space-y-1",children:pe.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:()=>we(Te.id),children:[e.jsx(Lo,{checked:g.includes(Te.id),onCheckedChange:()=>we(Te.id),className:"flex-shrink-0"}),e.jsx(_n,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(wn,{className:"text-xs bg-primary/10 text-primary",children:Ae(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}),Fe(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(ks,{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(hn,{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:C,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:fe,className:"text-xs h-8",disabled:xe.length===0,children:[e.jsx(wa,{className:"h-3.5 w-3.5 mr-1.5"}),_.length===xe.length&&xe.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(Gi,{className:"h-[250px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[180px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):xe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[180px] text-muted-foreground",children:[e.jsx(wa,{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:xe.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:()=>Ie(Te.id),children:[e.jsx(Lo,{checked:_.includes(Te.id),onCheckedChange:()=>Ie(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(wa,{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(hn,{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:w,onChange:Te=>N(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:_e,className:"text-xs h-8",disabled:pe.length===0,children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1.5"}),g.length===pe.length&&pe.length>0?"Deselect All":"Select All"]}),e.jsxs("span",{className:"text-xs text-muted-foreground font-medium",children:[g.length," selected"]})]}),e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:R?e.jsx("div",{className:"flex items-center justify-center h-[200px]",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):pe.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-[200px] text-muted-foreground",children:[e.jsx(mr,{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:pe.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:()=>we(Te.id),children:[e.jsx(Lo,{checked:g.includes(Te.id),onCheckedChange:()=>we(Te.id),className:"flex-shrink-0"}),e.jsx(_n,{className:"h-9 w-9 flex-shrink-0",children:e.jsx(wn,{className:"text-xs bg-primary/10 text-primary",children:Ae(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(ye,{htmlFor:"message",className:"text-sm font-medium",children:"Add a message (optional)"}),e.jsx(Er,{id:"message",placeholder:"I thought you might find this useful...",value:I,onChange:Te=>L(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:Ne,disabled:Ce===0||U,children:U?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sharing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Share"]})})]})]})]})})}function aE({resourceType:t,resourceId:s,resourceTitle:r,variant:n="outline",size:a="sm",className:o=""}){const[l,i]=k.useState(!1),{user:c}=Rs();return c?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:n,size:a,onClick:()=>i(!0),className:o,children:[e.jsx(bd,{className:"h-4 w-4 mr-2"}),"Share"]}),e.jsx(XBt,{open:l,onOpenChange:i,resourceType:t,resourceId:s,resourceTitle:r})]}):null}function QBt(){const{eventId:t}=yo(),s=pr(),{user:r}=Rs(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(0),[u,p]=k.useState(!0),[f,g]=k.useState(!1);k.useEffect(()=>{t&&b()},[t,r]);const b=async()=>{try{const{data:M,error:I}=await H.from("events").select("*").eq("id",t).single();if(I)throw I;a(M);const{count:L}=await H.from("event_registrations").select("*",{count:"exact",head:!0}).eq("event_id",t);if(c(L||0),r){const{data:R}=await H.from("event_registrations").select("id, zoom_join_url").eq("event_id",t).eq("user_id",r.id).maybeSingle();l(R)}}catch(M){console.error("Error loading event:",M),he.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),he.error("Your session has expired. Please log in again.");return}if(o){const{error:I}=await H.functions.invoke("zoom-unregister",{body:{event_id:n.id}});if(I)throw I;he.success("Successfully cancelled registration"),l(null),c(L=>L-1)}else{const{data:I,error:L}=await H.functions.invoke("zoom-register",{body:{event_id:n.id}});if(L)throw L;he.success("Successfully registered for event!"),l({id:I.registration_id,zoom_join_url:I.zoom_join_url}),c(R=>R+1)}}catch(M){console.error("Registration error:",M),he.error(o?"Failed to cancel registration":"Failed to register for event")}finally{g(!1)}}},j=M=>{var I,L,R;if(M.includes("iframe.mediadelivery.net")||M.includes("video.bunnycdn.com")){const q=M.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(q)return`https://iframe.mediadelivery.net/embed/${q[1]}/${q[2]}?autoplay=false&preload=true`}if(M.includes("youtube.com")||M.includes("youtu.be")){const q=M.includes("youtu.be")?(I=M.split("youtu.be/")[1])==null?void 0:I.split("?")[0]:(L=M.split("v=")[1])==null?void 0:L.split("&")[0];if(q)return`https://www.youtube.com/embed/${q}`}if(M.includes("vimeo.com")){const q=(R=M.split("vimeo.com/")[1])==null?void 0:R.split("?")[0];if(q)return`https://player.vimeo.com/video/${q}`}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 w=y0(new Date(n.event_date)),N=n.capacity&&i>=n.capacity,C=(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(ri,{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"}),w&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(tt,{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(aE,{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(mp,{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:j(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(Pe,{children:e.jsxs(Re,{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(cn,{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:rD(new Date(n.event_date))})]})]}),n.capacity&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(mr,{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(xi,{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:[!w&&e.jsx(e.Fragment,{children:o?e.jsxs(e.Fragment,{children:[e.jsxs(K,{className:"w-full gap-2",onClick:()=>window.open(C,"_blank"),children:[e.jsx(an,{className:"h-4 w-4"}),"Join Event"]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:_,disabled:f,children:[f?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Cancel Registration"]})]}):e.jsx(K,{className:"w-full gap-2",onClick:_,disabled:f||(N??!1),children:f?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):N?"Event Full":"Register Now"})}),w&&o&&e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:()=>window.open(n.zoom_link,"_blank"),children:[e.jsx(an,{className:"h-4 w-4"}),"View Recording"]})]})]})})})]})]})})}const JBt=[{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(Cx,{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(Qg,{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(En,{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(kh,{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(un,{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(dr,{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(xu,{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(Rn,{className:"h-6 w-6"}),path:"/admin/email-campaigns",category:"Marketing",beta:!0,color:"bg-teal-500/15 text-teal-600"}],e$t=()=>{const{user:t,isAdmin:s}=Rs(),r=pr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,p]=k.useState("all"),[f,g]=k.useState(new Set),[b,_]=k.useState(new Set);k.useEffect(()=>{j()},[t]);const j=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(pe=>pe.tag))||[],{data:Y,error:J}=await H.from("app_tiles").select("*").order("name");if(J)throw J;const[{data:te},{data:X}]=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((te==null?void 0:te.map(pe=>pe.app_id))||[]);g(ce);const ne=new Set((X||[]).map(pe=>pe.tool_id));_(ne);const le=((Y==null?void 0:Y.filter(pe=>!pe.required_tags||pe.required_tags.length===0?!0:pe.required_tags.some(xe=>V.includes(xe))))||[]).sort((pe,xe)=>pe.name==="LevelUp Members Portal"?-1:xe.name==="LevelUp Members Portal"?1:0);a(le)}catch(B){console.error("Error loading apps:",B),he.error("Failed to load apps")}finally{l(!1)}},w=async B=>{var Y;const V=window.open("about:blank","_blank");try{const{data:J,error:te}=await H.auth.getSession();if(te||!J.session){V==null||V.close(),he.error("Session expired. Please refresh the page and try again.");return}const X=J.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 ${X}`}});if(ne)throw ne;ce!=null&&ce.redirect_url?V&&!V.closed?(V.location.href=ce.redirect_url,(Y=V.focus)==null||Y.call(V)):window.location.assign(ce.redirect_url):(V==null||V.close(),he.error("Launch link unavailable"))}catch(J){V==null||V.close(),console.error("Error launching app:",J),he.error("Failed to launch app. Please try again.")}},N=async(B,V)=>{B.stopPropagation();const Y=f.has(V);try{if(Y){const{error:J}=await H.from("user_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("app_id",V);if(J)throw J;g(te=>{const X=new Set(te);return X.delete(V),X}),he.success("Removed from favorites")}else{const{error:J}=await H.from("user_favorites").insert({user_id:t==null?void 0:t.id,app_id:V});if(J)throw J;g(te=>new Set(te).add(V)),he.success("Added to favorites")}}catch(J){console.error("Error toggling favorite:",J),he.error("Failed to update favorites")}},C=async(B,V)=>{B.stopPropagation();const Y=b.has(V);try{if(Y){const{error:J}=await H.from("user_tool_favorites").delete().eq("user_id",t==null?void 0:t.id).eq("tool_id",V);if(J)throw J;_(te=>{const X=new Set(te);return X.delete(V),X}),he.success("Removed from favorites")}else{const{error:J}=await H.from("user_tool_favorites").insert({user_id:t==null?void 0:t.id,tool_id:V});if(J)throw J;_(te=>new Set(te).add(V)),he.success("Added to favorites")}}catch(J){console.error("Error toggling tool favorite:",J),he.error("Failed to update favorites")}},M=n.filter(B=>{var Y;const V=B.name.toLowerCase().includes(i.toLowerCase())||((Y=B.description)==null?void 0:Y.toLowerCase().includes(i.toLowerCase()));return u==="favorites"?V&&f.has(B.id):V}),I=JBt.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&&b.has(B.id):V}),L=I.reduce((B,V)=>(B[V.category]||(B[V.category]=[]),B[V.category].push(V),B),{}),R=[{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 q=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(hn,{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:R.map(B=>e.jsxs("button",{onClick:()=>p(B.id),className:Pt("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))}),q&&Object.keys(L).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(Jg,{className:"h-5 w-5 text-primary"}),e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Built-in Tools"})]}),Object.entries(L).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(Y=>{const J=b.has(Y.id);return e.jsxs("div",{onClick:()=>r(Y.path),className:Pt("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",Y.isNew?"border-primary/40 ring-1 ring-primary/20 hover:border-primary/60":"border-border hover:border-primary/30"),children:[Y.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:Pt("flex-shrink-0 w-14 h-14 rounded-xl flex items-center justify-center transition-transform group-hover:scale-105",Y.color||"bg-primary/10 text-primary"),children:Y.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:[Y.name,Y.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:Y.description})]}),e.jsx("button",{className:Pt("flex-shrink-0 p-1 transition-colors",J?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:te=>C(te,Y.id),children:e.jsx(Nx,{className:Pt("h-5 w-5",J&&"fill-current")})})]},Y.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(an,{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"&&I.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(Nx,{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(Mh,{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),Y=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:()=>w(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:Pt("flex-shrink-0 p-1 transition-colors",V?"text-primary":"text-muted-foreground/50 hover:text-primary"),onClick:J=>N(J,B.id),children:e.jsx(Nx,{className:Pt("h-5 w-5",V&&"fill-current")})})]}),Y&&e.jsx("a",{href:"https://forms.gle/vXnrzgSnPbw7CKPV6",target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),className:"mt-3 text-sm text-primary hover:underline flex items-center gap-1",children:"Create your account with this link →"})]},B.id)})})]}),q&&U&&M.length===0&&I.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(hn,{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=pr(),[s,r]=k.useState(""),[n,a]=k.useState("all"),[o,l]=k.useState("all"),[i,c]=k.useState("grid"),{data:u=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:N,error:C}=await H.from("template_categories").select("*").order("name");if(C)throw C;return N}}),{data:p=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:N,error:C}=await H.from("template_types").select("*").order("name");if(C)throw C;return N}}),{data:f=[],isLoading:g}=mt({queryKey:["canva-templates"],queryFn:async()=>{const{data:N,error:C}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(C)throw C;const{data:M,error:I}=await H.from("template_links").select("*").order("sort_order");if(I)throw I;const{data:L}=await H.from("template_likes").select("template_id"),{data:R}=await H.from("template_comments").select("template_id"),q=new Map;L==null||L.forEach(V=>{q.set(V.template_id,(q.get(V.template_id)||0)+1)});const U=new Map;return R==null||R.forEach(V=>{U.set(V.template_id,(U.get(V.template_id)||0)+1)}),(N||[]).map(V=>({...V,links:(M||[]).filter(Y=>Y.template_id===V.id)||[],likesCount:q.get(V.id)||0,commentsCount:U.get(V.id)||0}))}}),b=f.filter(N=>{var L;const C=N.name.toLowerCase().includes(s.toLowerCase())||((L=N.description)==null?void 0:L.toLowerCase().includes(s.toLowerCase())),M=n==="all"||N.category_id===n,I=o==="all"||N.type_id===o;return C&&M&&I}),_=()=>{r(""),a("all"),l("all")},j=s||n!=="all"||o!=="all",w=N=>{t(`/templates/${N}`)};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(hn,{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:N=>r(N.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:n,onValueChange:a,children:[e.jsx(Gs,{className:"w-full sm:w-48",children:e.jsx(Qs,{placeholder:"All Categories"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Categories"}),u.map(N=>e.jsx(Mt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs(Ys,{value:o,onValueChange:l,children:[e.jsx(Gs,{className:"w-full sm:w-48",children:e.jsx(Qs,{placeholder:"All Types"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),p.map(N=>e.jsx(Mt,{value:N.id,children:N.name},N.id))]})]}),e.jsxs("div",{className:"flex gap-2",children:[j&&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(Ch,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[b.length," template",b.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((N,C)=>e.jsx(Pe,{children:e.jsxs(Re,{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"})]})]})},C))}),!g&&b.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-muted-foreground mb-4",children:j?"No templates match your filters":"No templates available yet"}),j&&e.jsx(K,{variant:"outline",onClick:_,children:"Clear Filters"})]}),!g&&b.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:b.map(N=>e.jsxs(Pe,{className:`group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer ${i==="list"?"flex flex-row":""}`,onClick:()=>w(N.id),children:[e.jsxs("div",{className:`relative overflow-hidden bg-muted ${i==="list"?"w-48 shrink-0":"aspect-[3/2]"}`,children:[N.preview_image_url?e.jsx("img",{src:N.preview_image_url,alt:N.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"}),N.links.length>1&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm !text-secondary",children:[e.jsx(zo,{className:"h-3 w-3"}),N.links.length]})})]}),e.jsxs(Re,{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:N.name}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3 flex-1",children:bde(N.description)}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-3",children:[N.category&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:N.category.name}),N.type&&e.jsx(tt,{variant:"outline",className:"text-xs",children:N.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(eh,{className:"h-3.5 w-3.5"}),N.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{className:"h-3.5 w-3.5"}),N.commentsCount]})]}),e.jsxs(K,{size:"sm",className:"w-full gap-2",onClick:C=>{C.stopPropagation(),w(N.id)},children:[e.jsx(an,{className:"h-4 w-4"}),"View Template"]})]})]},N.id))})]})})};var s$t="Separator",r8e="horizontal",r$t=["horizontal","vertical"],get=k.forwardRef((t,s)=>{const{decorative:r,orientation:n=r8e,...a}=t,o=n$t(n)?n:r8e,i=r?{role:"none"}:{"aria-orientation":o==="vertical"?o:void 0,role:"separator"};return e.jsx(sn.div,{"data-orientation":o,...i,...a,ref:s})});get.displayName=s$t;function n$t(t){return r$t.includes(t)}var yet=get;const sl=k.forwardRef(({className:t,orientation:s="horizontal",decorative:r=!0,...n},a)=>e.jsx(yet,{ref:a,decorative:r,orientation:s,className:Pt("shrink-0 bg-border",s==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",t),...n}));sl.displayName=yet.displayName;const UO=()=>({trackEngagement:k.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)}},[])}),a$t=()=>{const{templateId:t}=yo(),s=pr(),{user:r,isAdmin:n}=Rs(),{toast:a}=qa(),o=es(),{trackEngagement:l}=UO(),[i,c]=k.useState(""),{data:u,isLoading:p}=mt({queryKey:["template-detail",t],queryFn:async()=>{const{data:I,error:L}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).eq("id",t).single();if(L)throw L;const{data:R}=await H.from("template_links").select("*").eq("template_id",t).order("sort_order"),{data:q}=await H.from("template_guides").select("*").eq("template_id",t).order("sort_order");return{...I,links:R||[],guides:q||[]}},enabled:!!t}),{data:f=[]}=mt({queryKey:["template-linked-toolkits",t],queryFn:async()=>{const{data:I,error:L}=await H.from("resource_kit_templates").select("kit_id, resource_kits:kit_id(id, name, featured_image_url)").eq("template_id",t);if(L)throw L;return(I||[]).map(R=>R.resource_kits).filter(Boolean)},enabled:!!t});k.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:I,error:L}=await H.from("template_likes").select("*").eq("template_id",t);if(L)throw L;return I},enabled:!!t}),{data:b=[]}=mt({queryKey:["template-comments",t],queryFn:async()=>{const{data:I,error:L}=await H.from("template_comments").select("*").eq("template_id",t).order("created_at",{ascending:!1});if(L)throw L;const R=[...new Set(I.map(B=>B.user_id))],{data:q}=await H.from("profiles").select("id, name").in("id",R),U=new Map((q==null?void 0:q.map(B=>[B.id,B.name]))||[]);return I.map(B=>({...B,user_name:U.get(B.user_id)||"Unknown User"}))},enabled:!!t}),_=Lt({mutationFn:async I=>{const{error:L}=await H.from("template_comments").insert({template_id:t,user_id:r.id,content:I});if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),c(""),a({title:"Comment added!"})},onError:I=>{a({title:"Error adding comment",description:I.message,variant:"destructive"})}}),j=Lt({mutationFn:async I=>{const{error:L}=await H.from("template_comments").delete().eq("id",I);if(L)throw L},onSuccess:()=>{o.invalidateQueries({queryKey:["template-comments",t]}),a({title:"Comment deleted"})}}),w=Lt({mutationFn:async()=>{const I=g.find(L=>L.user_id===(r==null?void 0:r.id));if(I){const{error:L}=await H.from("template_likes").delete().eq("id",I.id);if(L)throw L}else{const{error:L}=await H.from("template_likes").insert({template_id:t,user_id:r.id});if(L)throw L}},onSuccess:()=>{o.invalidateQueries({queryKey:["template-likes",t]})}}),N=g.some(I=>I.user_id===(r==null?void 0:r.id)),C=I=>I.split(" ").map(L=>L[0]).join("").toUpperCase().slice(0,2),M=I=>{I.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(Ei,{to:"/templates",children:[e.jsx(ri,{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(tt,{variant:"secondary",children:u.category.name}),u.type&&e.jsx(tt,{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(Ei,{to:`/admin/templates?edit=${u.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(aE,{resourceType:"template",resourceId:u.id,resourceTitle:u.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:N?"default":"outline",className:"gap-2 rounded-full",onClick:()=>w.mutate(),disabled:!r||w.isPending,children:[e.jsx(eh,{className:`h-4 w-4 ${N?"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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(zo,{className:"h-4 w-4"}),u.links.length===1?"Template Link":"Template Links"]}),e.jsx("div",{className:"grid gap-2",children:u.links.map(I=>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(I.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:I.title}),e.jsx(an,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),u.video_url&&e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{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"}),"Guide Files"]}),e.jsx("div",{className:"grid gap-2",children:u.guides.map(I=>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(I.file_url,"_blank")},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:I.name}),I.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",(I.file_size/1024).toFixed(0)," KB)"]})]}),e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground"})]},I.id))})]})}),f.length>0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(Cl,{className:"h-4 w-4"}),"Related Toolkits"]}),e.jsx("div",{className:"grid gap-2",children:f.map(I=>e.jsxs(K,{variant:"outline",className:"w-full justify-start gap-3 h-auto py-3",onClick:()=>s(`/toolbox/${I.id}`),children:[I.featured_image_url?e.jsx("img",{src:I.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(Cl,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"font-medium",children:I.name})]},I.id))})]})}),e.jsx(sl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(zc,{className:"h-5 w-5"}),"Comments (",b.length,")"]}),r?e.jsxs("form",{onSubmit:M,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:i,onChange:I=>c(I.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(Rn,{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:b.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center",children:e.jsx("p",{className:"text-muted-foreground",children:"No comments yet. Be the first to share your thoughts!"})})}):b.map(I=>e.jsx(Pe,{children:e.jsx(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_n,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(wn,{className:"text-sm",children:C(I.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:I.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_d(new Date(I.created_at),{addSuffix:!0})}),I.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 ml-auto",onClick:()=>j.mutate(I.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:I.content})]})]})})},I.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(zo,{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(Ei,{to:"/templates",children:"Back to Templates"})})]})})},i$t=()=>{const{user:t}=Rs(),[s,r]=k.useState(""),[n,a]=k.useState("all"),{data:o=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(b)throw b;return g}}),{data:l=[],isLoading:i}=mt({queryKey:["academy-videos"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("is_published",!0).order("publish_date",{ascending:!1});if(b)throw b;const{data:_,error:j}=await H.from("academy_resources").select("*").order("sort_order");if(j)throw j;return g.map(N=>({...N,resources:(_==null?void 0:_.filter(C=>C.video_id===N.id))||[]}))}}),{data:c=[]}=mt({queryKey:["academy-video-likes"],queryFn:async()=>{const{data:g,error:b}=await H.from("academy_video_likes").select("video_id, user_id");if(b)throw b;return g}}),u=l.filter(g=>{var j;const b=s===""||g.title.toLowerCase().includes(s.toLowerCase())||((j=g.description)==null?void 0:j.toLowerCase().includes(s.toLowerCase())),_=n==="all"||g.category_id===n;return b&&_}),p=g=>c.filter(b=>b.video_id===g).length,f=g=>c.some(b=>b.video_id===g&&b.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(hn,{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(ja,{value:n,onValueChange:a,children:e.jsxs(ga,{className:"w-full justify-start flex-wrap h-auto gap-2 bg-transparent p-0",children:[e.jsx(us,{value:"all",className:"data-[state=active]:bg-primary data-[state=active]:text-primary-foreground",children:"All Videos"}),o.map(g=>e.jsx(us,{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(Pe,{children:e.jsxs(Re,{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(Ei,{to:`/academy/${g.id}`,children:e.jsxs(Pe,{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(rl,{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(mn,{className:"h-3 w-3"}),g.duration]})]}),e.jsxs(Dt,{className:"pb-2",children:[e.jsx("div",{className:"flex items-start justify-between gap-2",children:e.jsx(zt,{className:"text-lg line-clamp-2",children:g.title})}),g.category&&e.jsx(tt,{variant:"secondary",className:"w-fit",children:g.category.name})]}),e.jsxs(Re,{className:"pt-0",children:[g.description&&e.jsx(xr,{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(eh,{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(En,{className:"h-4 w-4"}),g.resources.length]})]})]})]})},g.id))})]})})};function vet({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(sc,{className:"h-4 w-4"}),"Related Templates"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(n=>e.jsx(Ei,{to:`/templates/${n.id}`,children:e.jsxs(tt,{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(sc,{className:"h-3 w-3"}),n.name]})},n.id))})]})}const o$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},l$t=()=>{const{videoId:t}=yo();pr();const{user:s,isAdmin:r}=Rs(),{toast:n}=qa(),a=es(),{trackEngagement:o}=UO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["academy-video",t],queryFn:async()=>{const{data:M,error:I}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await H.from("academy_resources").select("*").eq("video_id",t).order("sort_order");return{...M,resources:L||[]}},enabled:!!t});k.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:I}=await H.from("academy_video_likes").select("*").eq("video_id",t);if(I)throw I;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["academy-video-comments",t],queryFn:async()=>{const{data:M,error:I}=await H.from("academy_video_comments").select("*").eq("video_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(M.map(U=>U.user_id))],{data:R}=await H.from("profiles").select("id, name").in("id",L),q=new Map((R==null?void 0:R.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:I}=await H.from("academy_video_comments").insert({video_id:t,user_id:s.id,content:M});if(I)throw I},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"})}}),b=Lt({mutationFn:async M=>{const{error:I}=await H.from("academy_video_comments").delete().eq("id",M);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(I=>I.user_id===(s==null?void 0:s.id));if(M){const{error:I}=await H.from("academy_video_likes").delete().eq("id",M.id);if(I)throw I}else{const{error:I}=await H.from("academy_video_likes").insert({video_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-video-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=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"📁"}},N=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),C=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(Ei,{to:"/academy",children:[e.jsx(ri,{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:o$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(an,{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(tt,{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(Ei,{to:`/admin/academy?edit=${c.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(aE,{resourceType:"academy_video",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 w-fit",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(eh,{className:`h-4 w-4 ${j?"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(Pe,{children:e.jsxs(Re,{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"}),"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:w(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(Ci,{className:"h-4 w-4 text-muted-foreground"})]},M.id))})]})}),e.jsx(vet,{resourceType:"academy_video",resourceId:c.id}),e.jsx(sl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(zc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Er,{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(Rn,{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(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsx(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_n,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(wn,{className:"text-sm",children:N(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:_d(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:()=>b.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(Ei,{to:"/academy",children:"Back to Academy"})})]})})};function c$t(){const t=pr(),[s,r]=k.useState(""),{data:n,isLoading:a}=mt({queryKey:["resource-kits-published"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kits").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(_)throw _;return b}}),{data:o}=mt({queryKey:["resource-kit-files-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(_)throw _;return b}}),{data:l}=mt({queryKey:["resource-kit-likes-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_likes").select("kit_id");if(_)throw _;return b}}),{data:i}=mt({queryKey:["resource-kit-comments-all"],queryFn:async()=>{const{data:b,error:_}=await H.from("resource_kit_comments").select("kit_id");if(_)throw _;return b}}),c=n==null?void 0:n.filter(b=>{var _;return b.name.toLowerCase().includes(s.toLowerCase())||((_=b.description)==null?void 0:_.toLowerCase().includes(s.toLowerCase()))}),u=b=>(o==null?void 0:o.filter(_=>_.kit_id===b))||[],p=b=>(l==null?void 0:l.filter(_=>_.kit_id===b).length)||0,f=b=>(i==null?void 0:i.filter(_=>_.kit_id===b).length)||0,g=b=>{t(`/toolbox/${b}`)};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(hn,{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:b=>r(b.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((b,_)=>e.jsx(Pe,{children:e.jsxs(Re,{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(Pe,{className:"p-12 text-center",children:[e.jsx(Cl,{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(b=>{const _=u(b.id).length,j=p(b.id),w=f(b.id);return e.jsxs(Pe,{className:"group overflow-hidden cursor-pointer hover:shadow-lg transition-all duration-200",onClick:()=>g(b.id),children:[e.jsx("div",{className:"relative overflow-hidden bg-muted aspect-[3/2]",children:b.featured_image_url?e.jsx("img",{src:b.featured_image_url,alt:b.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(Cl,{className:"h-16 w-16 text-muted-foreground"})})}),e.jsxs(Re,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold text-foreground line-clamp-1 mb-1",children:b.name}),b.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:bde(b.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(En,{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(eh,{className:"h-3.5 w-3.5"}),j]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{className:"h-3.5 w-3.5"}),w]})]})]})]})]},b.id)})})]})})}const d$t=()=>{const{kitId:t}=yo(),{user:s,isAdmin:r}=Rs(),{toast:n}=qa(),a=es(),{trackEngagement:o}=UO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["resource-kit-detail",t],queryFn:async()=>{const{data:M,error:I}=await H.from("resource_kits").select("*").eq("id",t).eq("is_published",!0).single();if(I)throw I;const{data:L}=await H.from("resource_kit_files").select("*").eq("kit_id",t).order("sort_order"),{data:R}=await H.from("resource_kit_links").select("*").eq("kit_id",t).order("sort_order");return{...M,files:L||[],links:R||[]}},enabled:!!t});k.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:I}=await H.from("resource_kit_likes").select("*").eq("kit_id",t);if(I)throw I;return M},enabled:!!t}),{data:f=[]}=mt({queryKey:["resource-kit-comments",t],queryFn:async()=>{const{data:M,error:I}=await H.from("resource_kit_comments").select("*").eq("kit_id",t).order("created_at",{ascending:!1});if(I)throw I;const L=[...new Set(M.map(U=>U.user_id))],{data:R}=await H.from("profiles").select("id, name").in("id",L),q=new Map((R==null?void 0:R.map(U=>[U.id,U.name]))||[]);return M.map(U=>({...U,user_name:q.get(U.user_id)||"Unknown User"}))},enabled:!!t}),g=Lt({mutationFn:async M=>{const{error:I}=await H.from("resource_kit_comments").insert({kit_id:t,user_id:s.id,content:M});if(I)throw I},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"})}}),b=Lt({mutationFn:async M=>{const{error:I}=await H.from("resource_kit_comments").delete().eq("id",M);if(I)throw I},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-comments",t]}),n({title:"Comment deleted"})}}),_=Lt({mutationFn:async()=>{const M=p.find(I=>I.user_id===(s==null?void 0:s.id));if(M){const{error:I}=await H.from("resource_kit_likes").delete().eq("id",M.id);if(I)throw I}else{const{error:I}=await H.from("resource_kit_likes").insert({kit_id:t,user_id:s.id});if(I)throw I}},onSuccess:()=>{a.invalidateQueries({queryKey:["resource-kit-likes",t]})}}),j=p.some(M=>M.user_id===(s==null?void 0:s.id)),w=M=>M.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),N=M=>M?M<1024?M+" B":M<1024*1024?(M/1024).toFixed(1)+" KB":(M/(1024*1024)).toFixed(1)+" MB":"",C=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(Ei,{to:"/toolbox",children:[e.jsx(ri,{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(Ei,{to:`/admin/toolbox?edit=${c.id}`,children:[e.jsx(Da,{className:"h-4 w-4"}),e.jsx("span",{children:"Edit"})]})}),e.jsx(aE,{resourceType:"resource_kit",resourceId:c.id,resourceTitle:c.name,size:"default",className:"rounded-full"}),e.jsxs(K,{variant:j?"default":"outline",className:"gap-2 rounded-full",onClick:()=>_.mutate(),disabled:!s||_.isPending,children:[e.jsx(eh,{className:`h-4 w-4 ${j?"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(Pe,{children:e.jsxs(Re,{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"}),"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(En,{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:N(M.file_size)})]})]}),e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},M.id))})]})}),c.links&&c.links.length>0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(an,{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(an,{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(vet,{resourceType:"resource_kit",resourceId:c.id}),e.jsx(sl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(zc,{className:"h-5 w-5"}),"Comments (",f.length,")"]}),s?e.jsxs("form",{onSubmit:C,className:"flex gap-2",children:[e.jsx(Er,{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(Rn,{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(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsx(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_n,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(wn,{className:"text-sm",children:w(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:_d(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:()=>b.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(Cl,{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(Ei,{to:"/toolbox",children:"Back to Toolbox"})})]})})},u$t=()=>{const t=pr(),[s,r]=k.useState(""),[n,a]=k.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:b}=await H.from("social_swag_likes").select("swag_id"),{data:_}=await H.from("social_swag_comments").select("swag_id"),j=new Map;b==null||b.forEach(C=>{j.set(C.swag_id,(j.get(C.swag_id)||0)+1)});const w=new Map;return _==null||_.forEach(C=>{w.set(C.swag_id,(w.get(C.swag_id)||0)+1)}),(u||[]).map(C=>({...C,links:(f||[]).filter(M=>M.swag_id===C.id)||[],likesCount:j.get(C.id)||0,commentsCount:w.get(C.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(hn,{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(Ch,{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(Pe,{children:e.jsxs(Re,{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(Pe,{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(tt,{variant:"secondary",className:"gap-1 bg-background/90 backdrop-blur-sm",children:[e.jsx(zo,{className:"h-3 w-3"}),u.links.length]})})]}),e.jsxs(Re,{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(eh,{className:"h-3.5 w-3.5"}),u.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{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(an,{className:"h-4 w-4"}),"View Details"]})]})]},u.id))})]})})};var ji=function(){return ji=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)},b=function(){a&&o(a)};return e.jsx(V$t,{displayMonth:t.displayMonth,hideNext:p,hidePrevious:f,nextMonth:a,previousMonth:n,onPreviousClick:g,onNextClick:b})}function H$t(t){var s,r=ac(),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:wet,u;return a?u=e.jsx(c,{id:t.id,displayMonth:t.displayMonth}):l==="dropdown"?u=e.jsx(n8e,{displayMonth:t.displayMonth,id:t.id}):l==="dropdown-buttons"?u=e.jsxs(e.Fragment,{children:[e.jsx(n8e,{displayMonth:t.displayMonth,displayIndex:t.displayIndex,id:t.id}),e.jsx(a8e,{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(a8e,{displayMonth:t.displayMonth,id:t.id})]}),e.jsx("div",{className:n.caption,style:o.caption,children:u})}function W$t(t){var s=ac(),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 G$t(t,s,r){for(var n=r?M1(new Date):Yh(new Date,{locale:t,weekStartsOn:s}),a=[],o=0;o<7;o++){var l=Tl(n,o);a.push(l)}return a}function K$t(){var t=ac(),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=G$t(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 Z$t(){var t,s=ac(),r=s.classNames,n=s.styles,a=s.components,o=(t=a==null?void 0:a.HeadRow)!==null&&t!==void 0?t:K$t;return e.jsx("thead",{style:n.head,className:r.head,children:e.jsx(o,{})})}function Y$t(t){var s=ac(),r=s.locale,n=s.formatters.formatDay;return e.jsx(e.Fragment,{children:n(t.date,{locale:r})})}var bke=k.createContext(void 0);function X$t(t){if(!VO(t.initialProps)){var s={selected:void 0,modifiers:{disabled:[]}};return e.jsx(bke.Provider,{value:s,children:t.children})}return e.jsx(Q$t,{initialProps:t.initialProps,children:t.children})}function Q$t(t){var s=t.initialProps,r=t.children,n=s.selected,a=s.min,o=s.max,l=function(u,p,f){var g,b;(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 j=!!(!p.selected&&o&&(n==null?void 0:n.length)===o);if(!j){var w=n?bet([],n):[];if(p.selected){var N=w.findIndex(function(C){return Sl(u,C)});w.splice(N,1)}else w.push(u);(b=s.onSelect)===null||b===void 0||b.call(s,w,u,p,f)}}},i={disabled:[]};n&&i.disabled.push(function(u){var p=o&&n.length>o-1,f=n.some(function(g){return Sl(g,u)});return!!(p&&!f)});var c={selected:n,onDayClick:l,modifiers:i};return e.jsx(bke.Provider,{value:c,children:r})}function _ke(){var t=k.useContext(bke);if(!t)throw new Error("useSelectMultiple must be used within a SelectMultipleProvider");return t}function J$t(t,s){var r=s||{},n=r.from,a=r.to;return n&&a?Sl(a,t)&&Sl(n,t)?void 0:Sl(a,t)?{from:a,to:void 0}:Sl(n,t)?void 0:RS(n,t)?{from:t,to:a}:{from:n,to:t}:a?RS(t,a)?{from:a,to:t}:{from:t,to:a}:n?FS(t,n)?{from:t,to:n}:{from:n,to:t}:{from:t,to:void 0}}var wke=k.createContext(void 0);function eqt(t){if(!HO(t.initialProps)){var s={selected:void 0,modifiers:{range_start:[],range_end:[],range_middle:[],disabled:[]}};return e.jsx(wke.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(b,_,j){var w,N;(w=s.onDayClick)===null||w===void 0||w.call(s,b,_,j);var C=J$t(b,n);(N=s.onSelect)===null||N===void 0||N.call(s,C,b,_,j)},p={range_start:[],range_end:[],range_middle:[],disabled:[]};if(o?(p.range_start=[o],l?(p.range_end=[l],Sl(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:die(o,i-1),before:Tl(o,i-1)}),o&&l&&p.disabled.push({after:o,before:Tl(o,i-1)}),!o&&l&&p.disabled.push({after:die(l,i-1),before:Tl(l,i-1)})),c){if(o&&!l&&(p.disabled.push({before:Tl(o,-c+1)}),p.disabled.push({after:Tl(o,c-1)})),o&&l){var f=hf(l,o)+1,g=c-f;p.disabled.push({before:die(o,g)}),p.disabled.push({after:Tl(l,g)})}!o&&l&&(p.disabled.push({before:Tl(l,-c+1)}),p.disabled.push({after:Tl(l,c-1)}))}return e.jsx(wke.Provider,{value:{selected:n,onDayClick:u,modifiers:p},children:r})}function jke(){var t=k.useContext(wke);if(!t)throw new Error("useSelectRange must be used within a SelectRangeProvider");return t}function Mie(t){return Array.isArray(t)?bet([],t):t!==void 0?[t]:[]}function sqt(t){var s={};return Object.entries(t).forEach(function(r){var n=r[0],a=r[1];s[n]=Mie(a)}),s}var ly;(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"})(ly||(ly={}));var rqt=ly.Selected,jv=ly.Disabled,nqt=ly.Hidden,aqt=ly.Today,wge=ly.RangeEnd,jge=ly.RangeMiddle,Nge=ly.RangeStart,iqt=ly.Outside;function oqt(t,s,r){var n,a=(n={},n[rqt]=Mie(t.selected),n[jv]=Mie(t.disabled),n[nqt]=Mie(t.hidden),n[aqt]=[t.today],n[wge]=[],n[jge]=[],n[Nge]=[],n[iqt]=[],n);return t.fromDate&&a[jv].push({before:t.fromDate}),t.toDate&&a[jv].push({after:t.toDate}),VO(t)?a[jv]=a[jv].concat(s.modifiers[jv]):HO(t)&&(a[jv]=a[jv].concat(r.modifiers[jv]),a[Nge]=r.modifiers[Nge],a[jge]=r.modifiers[jge],a[wge]=r.modifiers[wge]),a}var ket=k.createContext(void 0);function lqt(t){var s=ac(),r=_ke(),n=jke(),a=oqt(s,r,n),o=sqt(s.modifiers),l=ji(ji({},a),o);return e.jsx(ket.Provider,{value:l,children:t.children})}function Cet(){var t=k.useContext(ket);if(!t)throw new Error("useModifiers must be used within a ModifiersProvider");return t}function cqt(t){return!!(t&&typeof t=="object"&&"before"in t&&"after"in t)}function dqt(t){return!!(t&&typeof t=="object"&&"from"in t)}function uqt(t){return!!(t&&typeof t=="object"&&"after"in t)}function hqt(t){return!!(t&&typeof t=="object"&&"before"in t)}function mqt(t){return!!(t&&typeof t=="object"&&"dayOfWeek"in t)}function pqt(t,s){var r,n=s.from,a=s.to;if(n&&a){var o=hf(a,n)<0;o&&(r=[a,n],n=r[0],a=r[1]);var l=hf(t,n)>=0&&hf(a,t)>=0;return l}return a?Sl(a,t):n?Sl(n,t):!1}function fqt(t){return dje(t)}function xqt(t){return Array.isArray(t)&&t.every(dje)}function gqt(t,s){return s.some(function(r){if(typeof r=="boolean")return r;if(fqt(r))return Sl(t,r);if(xqt(r))return r.includes(t);if(dqt(r))return pqt(t,r);if(mqt(r))return r.dayOfWeek.includes(t.getDay());if(cqt(r)){var n=hf(r.before,t),a=hf(r.after,t),o=n>0,l=a<0,i=RS(r.before,r.after);return i?l&&o:o||l}return uqt(r)?hf(t,r.after)>0:hqt(r)?hf(r.before,t)>0:typeof r=="function"?r(t):!1})}function Nke(t,s,r){var n=Object.keys(s).reduce(function(o,l){var i=s[l];return gqt(t,i)&&o.push(l),o},[]),a={};return n.forEach(function(o){return a[o]=!0}),r&&!Qde(t,r)&&(a.outside=!0),a}function yqt(t,s){for(var r=Lc(t[0]),n=lx(t[t.length-1]),a,o,l=r;l<=n;){var i=Nke(l,s),c=!i.disabled&&!i.hidden;if(!c){l=Tl(l,1);continue}if(i.selected)return l;i.today&&!o&&(o=l),a||(a=l),l=Tl(l,1)}return o||a}var vqt=365;function Met(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:Tl,week:p4,month:zm,year:r4t,startOfWeek:function(w){return a.ISOWeek?M1(w):Yh(w,{locale:f,weekStartsOn:c})},endOfWeek:function(w){return a.ISOWeek?yGe(w):Yde(w,{locale:f,weekStartsOn:c})}},b=g[r](t,n==="after"?1:-1);n==="before"&&u?b=n4t([u,b]):n==="after"&&p&&(b=a4t([p,b]));var _=!0;if(o){var j=Nke(b,o);_=!j.disabled&&!j.hidden}return _?b:i.count>vqt?i.lastFocused:Met(b,{moveBy:r,direction:n,context:a,modifiers:o,retry:ji(ji({},i),{count:i.count+1})})}var Tet=k.createContext(void 0);function bqt(t){var s=WO(),r=Cet(),n=k.useState(),a=n[0],o=n[1],l=k.useState(),i=l[0],c=l[1],u=yqt(s.displayMonths,r),p=a??(i&&s.isDateDisplayed(i))?i:u,f=function(){c(a),o(void 0)},g=function(w){o(w)},b=ac(),_=function(w,N){if(a){var C=Met(a,{moveBy:w,direction:N,context:b,modifiers:r});Sl(a,C)||(s.goToDate(C,a),g(C))}},j={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(Tet.Provider,{value:j,children:t.children})}function kke(){var t=k.useContext(Tet);if(!t)throw new Error("useFocusContext must be used within a FocusProvider");return t}function _qt(t,s){var r=Cet(),n=Nke(t,r,s);return n}var Ske=k.createContext(void 0);function wqt(t){if(!Bue(t.initialProps)){var s={selected:void 0};return e.jsx(Ske.Provider,{value:s,children:t.children})}return e.jsx(jqt,{initialProps:t.initialProps,children:t.children})}function jqt(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(Ske.Provider,{value:a,children:r})}function Aet(){var t=k.useContext(Ske);if(!t)throw new Error("useSelectSingle must be used within a SelectSingleProvider");return t}function Nqt(t,s){var r=ac(),n=Aet(),a=_ke(),o=jke(),l=kke(),i=l.focusDayAfter,c=l.focusDayBefore,u=l.focusWeekAfter,p=l.focusWeekBefore,f=l.blur,g=l.focus,b=l.focusMonthBefore,_=l.focusMonthAfter,j=l.focusYearBefore,w=l.focusYearAfter,N=l.focusStartOfWeek,C=l.focusEndOfWeek,M=function(re){var le,pe,xe,_e;Bue(r)?(le=n.onDayClick)===null||le===void 0||le.call(n,t,s,re):VO(r)?(pe=a.onDayClick)===null||pe===void 0||pe.call(a,t,s,re):HO(r)?(xe=o.onDayClick)===null||xe===void 0||xe.call(o,t,s,re):(_e=r.onDayClick)===null||_e===void 0||_e.call(r,t,s,re)},I=function(re){var le;g(t),(le=r.onDayFocus)===null||le===void 0||le.call(r,t,s,re)},L=function(re){var le;f(),(le=r.onDayBlur)===null||le===void 0||le.call(r,t,s,re)},R=function(re){var le;(le=r.onDayMouseEnter)===null||le===void 0||le.call(r,t,s,re)},q=function(re){var le;(le=r.onDayMouseLeave)===null||le===void 0||le.call(r,t,s,re)},U=function(re){var le;(le=r.onDayPointerEnter)===null||le===void 0||le.call(r,t,s,re)},B=function(re){var le;(le=r.onDayPointerLeave)===null||le===void 0||le.call(r,t,s,re)},V=function(re){var le;(le=r.onDayTouchCancel)===null||le===void 0||le.call(r,t,s,re)},Y=function(re){var le;(le=r.onDayTouchEnd)===null||le===void 0||le.call(r,t,s,re)},J=function(re){var le;(le=r.onDayTouchMove)===null||le===void 0||le.call(r,t,s,re)},te=function(re){var le;(le=r.onDayTouchStart)===null||le===void 0||le.call(r,t,s,re)},X=function(re){var le;(le=r.onDayKeyUp)===null||le===void 0||le.call(r,t,s,re)},ce=function(re){var le;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?j():b();break;case"PageDown":re.preventDefault(),re.stopPropagation(),re.shiftKey?w():_();break;case"Home":re.preventDefault(),re.stopPropagation(),N();break;case"End":re.preventDefault(),re.stopPropagation(),C();break}(le=r.onDayKeyDown)===null||le===void 0||le.call(r,t,s,re)},ne={onClick:M,onFocus:I,onBlur:L,onKeyDown:ce,onKeyUp:X,onMouseEnter:R,onMouseLeave:q,onPointerEnter:U,onPointerLeave:B,onTouchCancel:V,onTouchEnd:Y,onTouchMove:J,onTouchStart:te};return ne}function kqt(){var t=ac(),s=Aet(),r=_ke(),n=jke(),a=Bue(t)?s.selected:VO(t)?r.selected:HO(t)?n.selected:void 0;return a}function Sqt(t){return Object.values(ly).includes(t)}function Cqt(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(Sqt(n)){var o=t.classNames["day_".concat(n)];o&&r.push(o)}}),r}function Mqt(t,s){var r=ji({},t.styles.day);return Object.keys(s).forEach(function(n){var a;r=ji(ji({},r),(a=t.modifiersStyles)===null||a===void 0?void 0:a[n])}),r}function Tqt(t,s,r){var n,a,o,l=ac(),i=kke(),c=_qt(t,s),u=Nqt(t,c),p=kqt(),f=!!(l.onDayClick||l.mode!=="default");k.useEffect(function(){var R;c.outside||i.focusedDay&&f&&Sl(i.focusedDay,t)&&((R=r.current)===null||R===void 0||R.focus())},[i.focusedDay,t,r,f,c.outside]);var g=Cqt(l,c).join(" "),b=Mqt(l,c),_=!!(c.outside&&!l.showOutsideDays||c.hidden),j=(o=(a=l.components)===null||a===void 0?void 0:a.DayContent)!==null&&o!==void 0?o:Y$t,w=e.jsx(j,{date:t,displayMonth:s,activeModifiers:c}),N={style:b,className:g,children:w,role:"gridcell"},C=i.focusTarget&&Sl(i.focusTarget,t)&&!c.outside,M=i.focusedDay&&Sl(i.focusedDay,t),I=ji(ji(ji({},N),(n={disabled:c.disabled,role:"gridcell"},n["aria-selected"]=c.selected,n.tabIndex=M||C?0:-1,n)),u),L={isButton:f,isHidden:_,activeModifiers:c,selectedDays:p,buttonProps:I,divProps:N};return L}function Aqt(t){var s=k.useRef(null),r=Tqt(t.date,t.displayMonth,s);return r.isHidden?e.jsx("div",{role:"gridcell"}):r.isButton?e.jsx(Lle,ji({name:"day",ref:s},r.buttonProps)):e.jsx("div",ji({},r.divProps))}function Eqt(t){var s=t.number,r=t.dates,n=ac(),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(b){a(s,r,b)};return e.jsx(Lle,{name:"week-number","aria-label":f,className:l.weeknumber,style:o.weeknumber,onClick:g,children:p})}function Pqt(t){var s,r,n=ac(),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:Aqt,u=(r=i==null?void 0:i.WeekNumber)!==null&&r!==void 0?r:Eqt,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})},lSt(f))})]})}function i8e(t,s,r){for(var n=r!=null&&r.ISOWeek?yGe(s):Yde(s,r),a=r!=null&&r.ISOWeek?M1(t):Yh(t,r),o=hf(n,a),l=[],i=0;i<=o;i++)l.push(Tl(a,i));var c=l.reduce(function(u,p){var f=r!=null&&r.ISOWeek?uje(p):mje(p,r),g=u.find(function(b){return b.weekNumber===f});return g?(g.dates.push(p),u):(u.push({weekNumber:f,dates:[p]}),u)},[]);return c}function Iqt(t,s){var r=i8e(Lc(t),lx(t),s);if(s!=null&&s.useFixedWeeks){var n=dSt(t,s);if(n<6){var a=r[r.length-1],o=a.dates[a.dates.length-1],l=p4(o,6-n),i=i8e(p4(o,1),l,s);r.push.apply(r,i)}}return r}function Lqt(t){var s,r,n,a=ac(),o=a.locale,l=a.classNames,i=a.styles,c=a.hideHead,u=a.fixedWeeks,p=a.components,f=a.weekStartsOn,g=a.firstWeekContainsDate,b=a.ISOWeek,_=Iqt(t.displayMonth,{useFixedWeeks:!!u,ISOWeek:b,locale:o,weekStartsOn:f,firstWeekContainsDate:g}),j=(s=p==null?void 0:p.Head)!==null&&s!==void 0?s:Z$t,w=(r=p==null?void 0:p.Row)!==null&&r!==void 0?r:Pqt,N=(n=p==null?void 0:p.Footer)!==null&&n!==void 0?n:W$t;return e.jsxs("table",{id:t.id,className:l.table,style:i.table,role:"grid","aria-labelledby":t["aria-labelledby"],children:[!c&&e.jsx(j,{}),e.jsx("tbody",{className:l.tbody,style:i.tbody,children:_.map(function(C){return e.jsx(w,{displayMonth:t.displayMonth,dates:C.dates,weekNumber:C.weekNumber},C.weekNumber)})}),e.jsx(N,{displayMonth:t.displayMonth})]})}function Dqt(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Oqt=Dqt()?k.useLayoutEffect:k.useEffect,kge=!1,Rqt=0;function o8e(){return"react-day-picker-".concat(++Rqt)}function Fqt(t){var s,r=t??(kge?o8e():null),n=k.useState(r),a=n[0],o=n[1];return Oqt(function(){a===null&&o(o8e())},[]),k.useEffect(function(){kge===!1&&(kge=!0)},[]),(s=t??a)!==null&&s!==void 0?s:void 0}function zqt(t){var s,r,n=ac(),a=n.dir,o=n.classNames,l=n.styles,i=n.components,c=WO().displayMonths,u=Fqt(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,b=t.displayIndex===0,_=t.displayIndex===c.length-1,j=!b&&!_;a==="rtl"&&(s=[b,_],_=s[0],b=s[1]),b&&(f.push(o.caption_start),g=ji(ji({},g),l.caption_start)),_&&(f.push(o.caption_end),g=ji(ji({},g),l.caption_end)),j&&(f.push(o.caption_between),g=ji(ji({},g),l.caption_between));var w=(r=i==null?void 0:i.Caption)!==null&&r!==void 0?r:H$t;return e.jsxs("div",{className:f.join(" "),style:g,children:[e.jsx(w,{id:u,displayMonth:t.displayMonth,displayIndex:t.displayIndex}),e.jsx(Lqt,{id:p,"aria-labelledby":u,displayMonth:t.displayMonth})]},t.displayIndex)}function Bqt(t){var s=ac(),r=s.classNames,n=s.styles;return e.jsx("div",{className:r.months,style:n.months,children:t.children})}function $qt(t){var s,r,n=t.initialProps,a=ac(),o=kke(),l=WO(),i=k.useState(!1),c=i[0],u=i[1];k.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=ji(ji({},a.styles.root),a.style),g=Object.keys(n).filter(function(_){return _.startsWith("data-")}).reduce(function(_,j){var w;return ji(ji({},_),(w={},w[j]=n[j],w))},{}),b=(r=(s=n.components)===null||s===void 0?void 0:s.Months)!==null&&r!==void 0?r:Bqt;return e.jsx("div",ji({className:p.join(" "),style:f,dir:a.dir,id:a.id,nonce:n.nonce,title:n.title,lang:n.lang},g,{children:e.jsx(b,{children:l.displayMonths.map(function(_,j){return e.jsx(zqt,{displayIndex:j,displayMonth:_},j)})})}))}function qqt(t){var s=t.children,r=h$t(t,["children"]);return e.jsx(E$t,{initialProps:r,children:e.jsx($$t,{children:e.jsx(wqt,{initialProps:r,children:e.jsx(X$t,{initialProps:r,children:e.jsx(eqt,{initialProps:r,children:e.jsx(lqt,{children:e.jsx(bqt,{children:s})})})})})})})}function Uqt(t){return e.jsx(qqt,ji({},t,{children:e.jsx($qt,{initialProps:t})}))}function _f({className:t,classNames:s,showOutsideDays:r=!0,...n}){return e.jsx(Uqt,{showOutsideDays:r,className:Pt("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:Pt(G8({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:Pt(G8({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(ll,{className:"h-4 w-4"}),IconRight:({...a})=>e.jsx(xa,{className:"h-4 w-4"})},...n})}_f.displayName="Calendar";var $ue="Popover",[Eet]=nd($ue,[L0]),GO=L0(),[Vqt,Dw]=Eet($ue),Pet=t=>{const{__scopePopover:s,children:r,open:n,defaultOpen:a,onOpenChange:o,modal:l=!1}=t,i=GO(s),c=k.useRef(null),[u,p]=k.useState(!1),[f,g]=rh({prop:n,defaultProp:a??!1,onChange:o,caller:$ue});return e.jsx(yO,{...i,children:e.jsx(Vqt,{scope:s,contentId:Mu(),triggerRef:c,open:f,onOpenChange:g,onOpenToggle:k.useCallback(()=>g(b=>!b),[g]),hasCustomAnchor:u,onCustomAnchorAdd:k.useCallback(()=>p(!0),[]),onCustomAnchorRemove:k.useCallback(()=>p(!1),[]),modal:l,children:r})})};Pet.displayName=$ue;var Iet="PopoverAnchor",Hqt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Dw(Iet,r),o=GO(r),{onCustomAnchorAdd:l,onCustomAnchorRemove:i}=a;return k.useEffect(()=>(l(),()=>i()),[l,i]),e.jsx(BA,{...o,...n,ref:s})});Hqt.displayName=Iet;var Let="PopoverTrigger",Det=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Dw(Let,r),o=GO(r),l=$a(s,a.triggerRef),i=e.jsx(sn.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":Bet(a.open),...n,ref:l,onClick:Ir(t.onClick,a.onOpenToggle)});return a.hasCustomAnchor?i:e.jsx(BA,{asChild:!0,...o,children:i})});Det.displayName=Let;var Cke="PopoverPortal",[Wqt,Gqt]=Eet(Cke,{forceMount:void 0}),Oet=t=>{const{__scopePopover:s,forceMount:r,children:n,container:a}=t,o=Dw(Cke,s);return e.jsx(Wqt,{scope:s,forceMount:r,children:e.jsx(Fd,{present:r||o.open,children:e.jsx(OA,{asChild:!0,container:a,children:n})})})};Oet.displayName=Cke;var KT="PopoverContent",Ret=k.forwardRef((t,s)=>{const r=Gqt(KT,t.__scopePopover),{forceMount:n=r.forceMount,...a}=t,o=Dw(KT,t.__scopePopover);return e.jsx(Fd,{present:n||o.open,children:o.modal?e.jsx(Zqt,{...a,ref:s}):e.jsx(Yqt,{...a,ref:s})})});Ret.displayName=KT;var Kqt=aw("PopoverContent.RemoveScroll"),Zqt=k.forwardRef((t,s)=>{const r=Dw(KT,t.__scopePopover),n=k.useRef(null),a=$a(s,n),o=k.useRef(!1);return k.useEffect(()=>{const l=n.current;if(l)return Ide(l)},[]),e.jsx(NO,{as:Kqt,allowPinchZoom:!0,children:e.jsx(Fet,{...t,ref:a,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ir(t.onCloseAutoFocus,l=>{var i;l.preventDefault(),o.current||(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:Ir(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:Ir(t.onFocusOutside,l=>l.preventDefault(),{checkForDefaultPrevented:!1})})})}),Yqt=k.forwardRef((t,s)=>{const r=Dw(KT,t.__scopePopover),n=k.useRef(!1),a=k.useRef(!1);return e.jsx(Fet,{...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()}})}),Fet=k.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=Dw(KT,r),b=GO(r);return Ade(),e.jsx(wO,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:o,children:e.jsx(ww,{asChild:!0,disableOutsidePointerEvents:l,onInteractOutside:p,onEscapeKeyDown:i,onPointerDownOutside:c,onFocusOutside:u,onDismiss:()=>g.onOpenChange(!1),children:e.jsx(vO,{"data-state":Bet(g.open),role:"dialog",id:g.contentId,...b,...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)"}})})})}),zet="PopoverClose",Xqt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=Dw(zet,r);return e.jsx(sn.button,{type:"button",...n,ref:s,onClick:Ir(t.onClick,()=>a.onOpenChange(!1))})});Xqt.displayName=zet;var Qqt="PopoverArrow",Jqt=k.forwardRef((t,s)=>{const{__scopePopover:r,...n}=t,a=GO(r);return e.jsx(bO,{...a,...n,ref:s})});Jqt.displayName=Qqt;function Bet(t){return t?"open":"closed"}var eUt=Pet,tUt=Det,sUt=Oet,$et=Ret;const Bo=eUt,$o=tUt,Do=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(sUt,{children:e.jsx($et,{ref:a,align:s,sideOffset:r,className:Pt("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})}));Do.displayName=$et.displayName;const rUt=lC("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"}}),Mke=k.forwardRef(({className:t,variant:s,...r},n)=>e.jsx("div",{ref:n,role:"alert",className:Pt(rUt({variant:s}),t),...r}));Mke.displayName="Alert";const nUt=k.forwardRef(({className:t,...s},r)=>e.jsx("h5",{ref:r,className:Pt("mb-1 font-medium leading-none tracking-tight",t),...s}));nUt.displayName="AlertTitle";const Tke=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{ref:r,className:Pt("text-sm [&_p]:leading-relaxed",t),...s}));Tke.displayName="AlertDescription";function aUt({open:t,onOpenChange:s,imageUrl:r,imageId:n,defaultCaption:a="",swagItemId:o,reelId:l}){const i=es(),[c,u]=k.useState(a),[p,f]=k.useState([]),[g,b]=k.useState(null),[_,j]=k.useState("now"),[w,N]=k.useState(r6e(c6e(new Date),1)),[C,M]=k.useState("12"),[I,L]=k.useState("00"),[R,q]=k.useState("PM");k.useEffect(()=>{if(t){u(a),j("now"),f([]);const we=r6e(c6e(new Date),1);N(we);const Ie=we.getHours();M(String(Ie>12?Ie-12:Ie===0?12:Ie)),L("00"),q(Ie>=12?"PM":"AM")}},[t,a]);const U=()=>{if(!w)return null;let we=parseInt(C);const Ie=parseInt(I);return R==="PM"&&we!==12&&(we+=12),R==="AM"&&we===12&&(we=0),qL($L(w,we),Ie)},{data:B,isLoading:V}=mt({queryKey:["social-accounts-for-post"],queryFn:async()=>{const{data:{user:we}}=await H.auth.getUser();if(!we)return[];const{data:Ie,error:Ne}=await H.from("social_accounts").select("*").eq("user_id",we.id).eq("is_active",!0).order("platform",{ascending:!0});if(Ne)throw Ne;return console.log("Fetched social accounts for posting:",Ie),Ie},enabled:t,staleTime:0}),Y=Lt({mutationFn:async({accountId:we,platform:Ie})=>{b(we);const{data:Ne,error:Ae}=await H.functions.invoke("social-post",{body:{platform:Ie,accountId:we,imageUrl:r,caption:c}});if(Ae)throw Ae;if(Ne!=null&&Ne.error)throw new Error(Ne.error);return Ne},onSuccess:we=>{const Ie=we.platform==="facebook"?"Facebook":we.platform==="instagram"?"Instagram":we.platform==="linkedin"?"LinkedIn":"Google Business";he.success(`Posted to ${Ie}!`)},onError:we=>{he.error(`Failed to post: ${we.message}`)},onSettled:()=>{b(null)}}),J=Lt({mutationFn:async({accountId:we,platform:Ie,scheduledFor:Ne})=>{const{data:{user:Ae}}=await H.auth.getUser();if(!Ae)throw new Error("Not authenticated");const{error:Fe}=await H.from("scheduled_posts").insert({user_id:Ae.id,social_account_id:we,platform:Ie,image_url:r,caption:c,swag_item_id:o||null,reel_id:l||null,scheduled_for:Ne.toISOString(),status:"scheduled"});if(Fe)throw Fe;return{platform:Ie}},onSuccess:we=>{const Ie=we.platform==="facebook"?"Facebook":we.platform==="instagram"?"Instagram":"LinkedIn";he.success(`Post scheduled for ${Ie}!`)},onError:we=>{he.error(`Failed to schedule: ${we.message}`)}}),te=async()=>{if(p.length===0){he.error("Please select at least one account");return}if(_==="schedule"){const we=U();if(!we||we<=new Date){he.error("Please select a future date and time");return}for(const Ie of p){const Ne=B==null?void 0:B.find(Ae=>Ae.id===Ie);Ne&&await J.mutateAsync({accountId:Ie,platform:Ne.platform,scheduledFor:we})}i.invalidateQueries({queryKey:["scheduled-posts"]}),he.success(`${p.length} post(s) scheduled for ${ps(we,"PPp")}`)}else for(const we of p){const Ie=B==null?void 0:B.find(Ne=>Ne.id===we);Ie&&await Y.mutateAsync({accountId:we,platform:Ie.platform})}i.invalidateQueries({queryKey:["scheduled-posts"]}),u(""),f([]),s(!1)},X=we=>{f(Ie=>Ie.includes(we)?Ie.filter(Ne=>Ne!==we):[...Ie,we])},ce=(B==null?void 0:B.filter(we=>we.platform==="facebook"))||[],ne=(B==null?void 0:B.filter(we=>we.platform==="instagram"))||[],re=(B==null?void 0:B.filter(we=>we.platform==="linkedin"))||[],le=(B==null?void 0:B.filter(we=>we.platform==="google_business"))||[],pe=((B==null?void 0:B.length)||0)>0,xe=Y.isPending||J.isPending,_e=Array.from({length:12},(we,Ie)=>String(Ie+1)),fe=["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(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"caption",children:"Caption"}),e.jsx(Er,{id:"caption",placeholder:"Write a caption for your post...",value:c,onChange:we=>u(we.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(ye,{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:()=>j("now"),className:Pt("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:()=>j("schedule"),className:Pt("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(mn,{className:"h-4 w-4"}),"Schedule for"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!w&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),w?ps(w,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:w,onSelect:N,disabled:we=>wee.jsx(Mt,{value:we,children:we},we))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ys,{value:I,onValueChange:L,children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:fe.map(we=>e.jsx(Mt,{value:we,children:we},we))})]}),e.jsxs(Ys,{value:R,onValueChange:we=>q(we),children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]}),w&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Post will be published on ",ps(U()||new Date,"PPP 'at' p")]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{children:"Post to"}),V&&e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-6 w-6 animate-spin"})}),!V&&!pe&&e.jsxs(Mke,{children:[e.jsx(Nl,{className:"h-4 w-4"}),e.jsxs(Tke,{className:"flex flex-col gap-2",children:[e.jsx("span",{children:"No social accounts connected yet."}),e.jsxs(Ei,{to:"/social-connections",className:"inline-flex items-center gap-1.5 text-primary hover:underline font-medium",children:[e.jsx(Yo,{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(ku,{className:"h-4 w-4 text-blue-600"})," Facebook"]}),ce.map(we=>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(Lo,{checked:p.includes(we.id),onCheckedChange:()=>X(we.id),disabled:g===we.id}),e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:we.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(ku,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:we.page_name||we.platform_username}),g===we.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},we.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(Cu,{className:"h-4 w-4 text-pink-600"})," Instagram"]}),ne.map(we=>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(Lo,{checked:p.includes(we.id),onCheckedChange:()=>X(we.id),disabled:g===we.id}),e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:we.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Cu,{className:"h-4 w-4"})})]}),e.jsxs("span",{className:"flex-1 text-sm font-medium",children:["@",we.platform_username]}),g===we.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},we.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(we=>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(Lo,{checked:p.includes(we.id),onCheckedChange:()=>X(we.id),disabled:g===we.id}),e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:we.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:we.platform_username}),g===we.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},we.id))]}),le.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(Ba,{className:"h-4 w-4 text-red-600"})," Google Business"]}),le.map(we=>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(Lo,{checked:p.includes(we.id),onCheckedChange:()=>X(we.id),disabled:g===we.id}),e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:we.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Ba,{className:"h-4 w-4"})})]}),e.jsx("span",{className:"flex-1 text-sm font-medium",children:we.page_name||we.platform_username}),g===we.id&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]},we.id))]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:te,disabled:p.length===0||xe,className:"gap-2",children:[xe?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):_==="schedule"?e.jsx(cn,{className:"h-4 w-4"}):e.jsx(Rn,{className:"h-4 w-4"}),_==="schedule"?`Schedule ${p.length} post${p.length!==1?"s":""}`:`Post to ${p.length} account${p.length!==1?"s":""}`]})]})]})})}function iUt(){const t=es(),[s,r]=k.useState(void 0),[n,a]=k.useState("all"),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(void 0),[f,g]=k.useState("12"),[b,_]=k.useState("00"),[j,w]=k.useState("PM"),{data:N=[],isLoading:C}=mt({queryKey:["scheduled-posts"],queryFn:async()=>{const{data:le,error:pe}=await H.from("scheduled_posts").select(` *, social_accounts ( page_name, platform_username, profile_picture_url ) `).order("scheduled_for",{ascending:!1});if(pe)throw pe;return le}}),M=N.filter(le=>{if(n!=="all"&&le.status!==n)return!1;if(s&&le.scheduled_for){const pe=new Date(le.scheduled_for);if(!Sl(pe,s))return!1}return!0}),I=N.filter(le=>le.scheduled_for).map(le=>Bm(new Date(le.scheduled_for))),L=Lt({mutationFn:async le=>{const{error:pe}=await H.from("scheduled_posts").update({caption:le.caption,scheduled_for:le.scheduled_for}).eq("id",le.id);if(pe)throw pe},onSuccess:()=>{he.success("Post updated!"),t.invalidateQueries({queryKey:["scheduled-posts"]}),l(null)},onError:le=>{he.error(`Failed to update: ${le.message}`)}}),R=Lt({mutationFn:async le=>{const{error:pe}=await H.from("scheduled_posts").update({status:"cancelled"}).eq("id",le);if(pe)throw pe},onSuccess:()=>{he.success("Post cancelled"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{he.error(`Failed to cancel: ${le.message}`)}}),q=Lt({mutationFn:async le=>{const{error:pe}=await H.from("scheduled_posts").delete().eq("id",le);if(pe)throw pe},onSuccess:()=>{he.success("Post deleted"),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{he.error(`Failed to delete: ${le.message}`)}}),U=Lt({mutationFn:async le=>{const{data:pe,error:xe}=await H.functions.invoke("social-post",{body:{platform:le.platform,accountId:le.social_account_id,imageUrl:le.image_url,caption:le.caption}});if(xe)throw xe;if(pe!=null&&pe.error)throw new Error(pe.error);return await H.from("scheduled_posts").update({status:"posted",posted_at:new Date().toISOString(),post_id:pe.postId}).eq("id",le.id),pe},onSuccess:le=>{const pe=le.platform==="facebook"?"Facebook":le.platform==="instagram"?"Instagram":"LinkedIn";he.success(`Posted to ${pe}!`),t.invalidateQueries({queryKey:["scheduled-posts"]})},onError:le=>{he.error(`Failed to post: ${le.message}`)}}),B=le=>{if(l(le),c(le.caption||""),le.scheduled_for){const pe=new Date(le.scheduled_for);p(pe);const xe=pe.getHours();g(String(xe>12?xe-12:xe===0?12:xe)),_(String(pe.getMinutes()).padStart(2,"0")),w(xe>=12?"PM":"AM")}},V=()=>{if(!o||!u)return;let le=parseInt(f);const pe=parseInt(b);j==="PM"&&le!==12&&(le+=12),j==="AM"&&le===12&&(le=0);const xe=qL($L(u,le),pe);L.mutate({id:o.id,caption:i,scheduled_for:xe.toISOString()})},Y=le=>{switch(le){case"facebook":return e.jsx(ku,{className:"h-4 w-4 text-blue-600"});case"instagram":return e.jsx(Cu,{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}},J=le=>{switch(le){case"scheduled":return e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),"Scheduled"]});case"posted":return e.jsxs(tt,{variant:"default",className:"gap-1 bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3"}),"Posted"]});case"failed":return e.jsxs(tt,{variant:"destructive",className:"gap-1",children:[e.jsx(xc,{className:"h-3 w-3"}),"Failed"]});case"cancelled":return e.jsxs(tt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(Nl,{className:"h-3 w-3"}),"Cancelled"]});default:return e.jsx(tt,{variant:"outline",children:le})}},te=Array.from({length:12},(le,pe)=>String(pe+1)),X=["00","15","30","45"],ce=N.filter(le=>le.status==="scheduled").length,ne=N.filter(le=>le.status==="posted").length,re=N.filter(le=>le.status==="scheduled"&&le.scheduled_for&&uSt(new Date(le.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(Pe,{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(Pe,{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(Pe,{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(Pe,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:N.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(Pe,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Dd,{className:"h-5 w-5"}),e.jsx("h3",{className:"font-semibold",children:"Calendar"})]}),e.jsx(_f,{mode:"single",selected:s,onSelect:r,className:Pt("pointer-events-auto"),modifiers:{hasPost:I},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(Yg,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:["all","scheduled","posted","failed","cancelled"].map(le=>e.jsx(K,{variant:n===le?"default":"outline",size:"sm",onClick:()=>a(le),className:"capitalize",children:le},le))})]}),C&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),!C&&M.length===0&&e.jsxs(Pe,{className:"p-8 text-center",children:[e.jsx(cn,{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 ${ps(s,"PPP")}`:"Schedule a post from Social Swag to get started!"})]}),e.jsx("div",{className:"space-y-4",children:M.map(le=>{var pe,xe;return e.jsx(Pe,{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:le.image_url,alt:"Post preview",className:"w-full h-full object-cover"})}),e.jsxs(Re,{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:[Y(le.platform),e.jsx("span",{className:"font-medium",children:((pe=le.social_accounts)==null?void 0:pe.page_name)||((xe=le.social_accounts)==null?void 0:xe.platform_username)||"Unknown"}),J(le.status)]}),e.jsxs("div",{className:"flex items-center gap-1",children:[le.status==="scheduled"&&e.jsxs(F1,{children:[e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>B(le),children:e.jsx(Da,{className:"h-4 w-4"})})}),e.jsx(gc,{children:"Edit post"})]}),e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>U.mutate(le),disabled:U.isPending,children:U.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"})})}),e.jsx(gc,{children:"Post now"})]}),e.jsxs(_c,{children:[e.jsx(Sm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Cancel this scheduled post?"}),e.jsx(Jl,{children:"This will cancel the post. You can delete it entirely or keep it in your history."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Keep"}),e.jsx(Ll,{onClick:()=>R.mutate(le.id),className:"bg-amber-600 hover:bg-amber-700",children:"Cancel Post"}),e.jsx(Ll,{onClick:()=>q.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]}),(le.status==="posted"||le.status==="cancelled"||le.status==="failed")&&e.jsxs(_c,{children:[e.jsx(Sm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})}),e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete this post?"}),e.jsx(Jl,{children:"This will permanently remove this post from your history."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>q.mutate(le.id),className:"bg-destructive hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),le.caption&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-2",children:le.caption}),e.jsxs("div",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),le.status==="posted"&&le.posted_at?`Posted ${ps(new Date(le.posted_at),"PPp")}`:le.scheduled_for?`Scheduled for ${ps(new Date(le.scheduled_for),"PPp")}`:"Not scheduled"]}),le.status==="failed"&&le.error_message&&e.jsxs("p",{className:"text-xs text-destructive mt-2",children:["Error: ",le.error_message]})]})]})},le.id)})})]})]}),e.jsx(xs,{open:!!o,onOpenChange:le=>!le&&l(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Caption"}),e.jsx(Er,{value:i,onChange:le=>c(le.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-3 p-4 border rounded-lg",children:[e.jsx(ye,{children:"Schedule for"}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("justify-start text-left font-normal flex-1",!u&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),u?ps(u,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:u,onSelect:p,disabled:le=>lee.jsx(Mt,{value:le,children:le},le))})]}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsxs(Ys,{value:b,onValueChange:_,children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:X.map(le=>e.jsx(Mt,{value:le,children:le},le))})]}),e.jsxs(Ys,{value:j,onValueChange:le=>w(le),children:[e.jsx(Gs,{className:"w-[70px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"AM",children:"AM"}),e.jsx(Mt,{value:"PM",children:"PM"})]})]})]})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(null),children:"Cancel"}),e.jsxs(K,{onClick:V,disabled:L.isPending,children:[L.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Save Changes"]})]})]})})]})}function bz(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 qet={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 bz=="function"&&bz;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 b=a[u]={exports:{}};n[u][0].call(b.exports,function(_){var j=n[u][1][_];return l(j||_)},b,b.exports,r,n,a,o)}return a[u].exports}for(var i=typeof bz=="function"&&bz,c=0;c>2,b=(3&u)<<4|p>>4,_=1>6:64,j=2>4,p=(15&g)<<4|(b=i.indexOf(c.charAt(j++)))>>2,f=(3&b)<<6|(_=i.indexOf(c.charAt(j++))),C[w++]=u,b!==64&&(C[w++]=p),_!==64&&(C[w++]=f);return C}},{"./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,b,_){this.compressedSize=p,this.uncompressedSize=f,this.crc32=g,this.compression=b,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 b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p[j])];return-1^u}(0|c,i,i.length,0):function(u,p,f,g){var b=l,_=g+f;u^=-1;for(var j=g;j<_;j++)u=u>>>8^b[255&(u^p.charCodeAt(j))];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(b,_){var j,w="";for(j=0;j<_;j++)w+=String.fromCharCode(255&b),b>>>=8;return w}function l(b,_,j,w,N,C){var M,I,L=b.file,R=b.compression,q=C!==u.utf8encode,U=i.transformTo("string",C(L.name)),B=i.transformTo("string",u.utf8encode(L.name)),V=L.comment,Y=i.transformTo("string",C(V)),J=i.transformTo("string",u.utf8encode(V)),te=B.length!==L.name.length,X=J.length!==V.length,ce="",ne="",re="",le=L.dir,pe=L.date,xe={crc32:0,compressedSize:0,uncompressedSize:0};_&&!j||(xe.crc32=b.crc32,xe.compressedSize=b.compressedSize,xe.uncompressedSize=b.uncompressedSize);var _e=0;_&&(_e|=8),q||!te&&!X||(_e|=2048);var fe=0,we=0;le&&(fe|=16),N==="UNIX"?(we=798,fe|=function(Ne,Ae){var Fe=Ne;return Ne||(Fe=Ae?16893:33204),(65535&Fe)<<16}(L.unixPermissions,le)):(we=20,fe|=function(Ne){return 63&(Ne||0)}(L.dosPermissions)),M=pe.getUTCHours(),M<<=6,M|=pe.getUTCMinutes(),M<<=5,M|=pe.getUTCSeconds()/2,I=pe.getUTCFullYear()-1980,I<<=4,I|=pe.getUTCMonth()+1,I<<=5,I|=pe.getUTCDate(),te&&(ne=o(1,1)+o(p(U),4)+B,ce+="up"+o(ne.length,2)+ne),X&&(re=o(1,1)+o(p(Y),4)+J,ce+="uc"+o(re.length,2)+re);var Ie="";return Ie+=` \0`,Ie+=o(_e,2),Ie+=R.magic,Ie+=o(M,2),Ie+=o(I,2),Ie+=o(xe.crc32,4),Ie+=o(xe.compressedSize,4),Ie+=o(xe.uncompressedSize,4),Ie+=o(U.length,2),Ie+=o(ce.length,2),{fileRecord:f.LOCAL_FILE_HEADER+Ie+U+ce,dirRecord:f.CENTRAL_FILE_HEADER+o(we,2)+Ie+o(Y.length,2)+"\0\0\0\0"+o(fe,4)+o(w,4)+U+ce+Y}}var i=r("../utils"),c=r("../stream/GenericWorker"),u=r("../utf8"),p=r("../crc32"),f=r("../signature");function g(b,_,j,w){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=j,this.encodeFileName=w,this.streamFiles=b,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(b){var _=b.meta.percent||0,j=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(b):(this.bytesWritten+=b.data.length,c.prototype.push.call(this,{data:b.data,meta:{currentFile:this.currentFile,percent:j?(_+100*(j-w-1))/j:100}}))},g.prototype.openedSource=function(b){this.currentSourceOffset=this.bytesWritten,this.currentFile=b.file.name;var _=this.streamFiles&&!b.file.dir;if(_){var j=l(b,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:j.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(b){this.accumulate=!1;var _=this.streamFiles&&!b.file.dir,j=l(b,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(j.dirRecord),_)this.push({data:function(w){return f.DATA_DESCRIPTOR+o(w.crc32,4)+o(w.compressedSize,4)+o(w.uncompressedSize,4)}(b),meta:{percent:100}});else for(this.push({data:j.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},g.prototype.flush=function(){for(var b=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(_,j){return new p.Promise(function(w,N){var C=[],M=_._internalType,I=_._outputType,L=_._mimeType;_.on("data",function(R,q){C.push(R),j&&j(q)}).on("error",function(R){C=[],N(R)}).on("end",function(){try{var R=function(q,U,B){switch(q){case"blob":return o.newBlob(o.transformTo("arraybuffer",U),B);case"base64":return c.encode(U);default:return o.transformTo(q,U)}}(I,function(q,U){var B,V=0,Y=null,J=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(b){return l.nodebuffer?i.newBufferFrom(b,"utf-8"):function(_){var j,w,N,C,M,I=_.length,L=0;for(C=0;C>>6:(w<65536?j[M++]=224|w>>>12:(j[M++]=240|w>>>18,j[M++]=128|w>>>12&63),j[M++]=128|w>>>6&63),j[M++]=128|63&w);return j}(b)},a.utf8decode=function(b){return l.nodebuffer?o.transformTo("nodebuffer",b).toString("utf-8"):function(_){var j,w,N,C,M=_.length,I=new Array(2*M);for(j=w=0;j>10&1023,I[w++]=56320|1023&N)}return I.length!==w&&(I.subarray?I=I.subarray(0,w):I.length=w),o.applyFromCharCode(I)}(b=o.transformTo(l.uint8array?"uint8array":"array",b))},o.inherits(f,c),f.prototype.processChunk=function(b){var _=o.transformTo(l.uint8array?"uint8array":"array",b.data);if(this.leftOver&&this.leftOver.length){if(l.uint8array){var j=_;(_=new Uint8Array(j.length+this.leftOver.length)).set(this.leftOver,0),_.set(j,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var w=function(C,M){var I;for((M=M||C.length)>C.length&&(M=C.length),I=M-1;0<=I&&(192&C[I])==128;)I--;return I<0||I===0?M:I+u[C[I]]>M?I:M}(_),N=_;w!==_.length&&(l.uint8array?(N=_.subarray(0,w),this.leftOver=_.subarray(w,_.length)):(N=_.slice(0,w),this.leftOver=_.slice(w,_.length))),this.push({data:a.utf8decode(N),meta:b.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(b){this.push({data:a.utf8encode(b.data),meta:b.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(j){return j}function p(j,w){for(var N=0;N>8;this.dir=!!(16&this.externalFileAttributes),b==0&&(this.dosPermissions=63&this.externalFileAttributes),b==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var b=o(this.extraFields[1].value);this.uncompressedSize===l.MAX_VALUE_32BITS&&(this.uncompressedSize=b.readInt(8)),this.compressedSize===l.MAX_VALUE_32BITS&&(this.compressedSize=b.readInt(8)),this.localHeaderOffset===l.MAX_VALUE_32BITS&&(this.localHeaderOffset=b.readInt(8)),this.diskNumberStart===l.MAX_VALUE_32BITS&&(this.diskNumberStart=b.readInt(4))}},readExtraFields:function(b){var _,j,w,N=b.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});b.index+4>>6:(b<65536?g[w++]=224|b>>>12:(g[w++]=240|b>>>18,g[w++]=128|b>>>12&63),g[w++]=128|b>>>6&63),g[w++]=128|63&b);return g},a.buf2binstring=function(f){return p(f,f.length)},a.binstring2buf=function(f){for(var g=new o.Buf8(f.length),b=0,_=g.length;b<_;b++)g[b]=f.charCodeAt(b);return g},a.buf2string=function(f,g){var b,_,j,w,N=g||f.length,C=new Array(2*N);for(b=_=0;b>10&1023,C[_++]=56320|1023&j)}return p(C,_)},a.utf8border=function(f,g){var b;for((g=g||f.length)>f.length&&(g=f.length),b=g-1;0<=b&&(192&f[b])==128;)b--;return b<0||b===0?g:b+c[f[b]]>g?b: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,b=0,_=-2,j=-1,w=4,N=2,C=8,M=9,I=286,L=30,R=19,q=2*I+1,U=15,B=3,V=258,Y=V+B+1,J=42,te=113,X=1,ce=2,ne=3,re=4;function le(me,Ve){return me.msg=p[Ve],Ve}function pe(me){return(me<<1)-(4me.avail_out&&(nt=me.avail_out),nt!==0&&(l.arraySet(me.output,Ve.pending_buf,Ve.pending_out,nt,me.next_out),me.next_out+=nt,Ve.pending_out+=nt,me.total_out+=nt,me.avail_out-=nt,Ve.pending-=nt,Ve.pending===0&&(Ve.pending_out=0))}function fe(me,Ve){i._tr_flush_block(me,0<=me.block_start?me.block_start:-1,me.strstart-me.block_start,Ve),me.block_start=me.strstart,_e(me.strm)}function we(me,Ve){me.pending_buf[me.pending++]=Ve}function Ie(me,Ve){me.pending_buf[me.pending++]=Ve>>>8&255,me.pending_buf[me.pending++]=255&Ve}function Ne(me,Ve){var nt,et,Se=me.max_chain_length,rt=me.strstart,Ge=me.prev_length,lt=me.nice_match,qe=me.strstart>me.w_size-Y?me.strstart-(me.w_size-Y):0,Ze=me.window,Je=me.w_mask,He=me.prev,Qe=me.strstart+V,at=Ze[rt+Ge-1],It=Ze[rt+Ge];me.prev_length>=me.good_match&&(Se>>=2),lt>me.lookahead&&(lt=me.lookahead);do if(Ze[(nt=Ve)+Ge]===It&&Ze[nt+Ge-1]===at&&Ze[nt]===Ze[rt]&&Ze[++nt]===Ze[rt+1]){rt+=2,nt++;do;while(Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&Ze[++rt]===Ze[++nt]&&rtqe&&--Se!=0);return Ge<=me.lookahead?Ge:me.lookahead}function Ae(me){var Ve,nt,et,Se,rt,Ge,lt,qe,Ze,Je,He=me.w_size;do{if(Se=me.window_size-me.lookahead-me.strstart,me.strstart>=He+(He-Y)){for(l.arraySet(me.window,me.window,He,He,0),me.match_start-=He,me.strstart-=He,me.block_start-=He,Ve=nt=me.hash_size;et=me.head[--Ve],me.head[Ve]=He<=et?et-He:0,--nt;);for(Ve=nt=He;et=me.prev[--Ve],me.prev[Ve]=He<=et?et-He:0,--nt;);Se+=He}if(me.strm.avail_in===0)break;if(Ge=me.strm,lt=me.window,qe=me.strstart+me.lookahead,Ze=Se,Je=void 0,Je=Ge.avail_in,Ze=B)for(rt=me.strstart-me.insert,me.ins_h=me.window[rt],me.ins_h=(me.ins_h<=B&&(me.ins_h=(me.ins_h<=B)if(et=i._tr_tally(me,me.strstart-me.match_start,me.match_length-B),me.lookahead-=me.match_length,me.match_length<=me.max_lazy_match&&me.lookahead>=B){for(me.match_length--;me.strstart++,me.ins_h=(me.ins_h<=B&&(me.ins_h=(me.ins_h<=B&&me.match_length<=me.prev_length){for(Se=me.strstart+me.lookahead-B,et=i._tr_tally(me,me.strstart-1-me.prev_match,me.prev_length-B),me.lookahead-=me.prev_length-1,me.prev_length-=2;++me.strstart<=Se&&(me.ins_h=(me.ins_h<me.pending_buf_size-5&&(nt=me.pending_buf_size-5);;){if(me.lookahead<=1){if(Ae(me),me.lookahead===0&&Ve===f)return X;if(me.lookahead===0)break}me.strstart+=me.lookahead,me.lookahead=0;var et=me.block_start+nt;if((me.strstart===0||me.strstart>=et)&&(me.lookahead=me.strstart-et,me.strstart=et,fe(me,!1),me.strm.avail_out===0)||me.strstart-me.block_start>=me.w_size-Y&&(fe(me,!1),me.strm.avail_out===0))return X}return me.insert=0,Ve===g?(fe(me,!0),me.strm.avail_out===0?ne:re):(me.strstart>me.block_start&&(fe(me,!1),me.strm.avail_out),X)}),new Me(4,4,8,4,Fe),new Me(4,5,16,8,Fe),new Me(4,6,32,32,Fe),new Me(4,4,16,16,Ce),new Me(8,16,32,32,Ce),new Me(8,16,128,128,Ce),new Me(8,32,128,256,Ce),new Me(32,128,258,1024,Ce),new Me(32,258,258,4096,Ce)],a.deflateInit=function(me,Ve){return ft(me,Ve,C,15,8,0)},a.deflateInit2=ft,a.deflateReset=Te,a.deflateResetKeep=ct,a.deflateSetHeader=function(me,Ve){return me&&me.state?me.state.wrap!==2?_:(me.state.gzhead=Ve,b):_},a.deflate=function(me,Ve){var nt,et,Se,rt;if(!me||!me.state||5>8&255),we(et,et.gzhead.time>>16&255),we(et,et.gzhead.time>>24&255),we(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),we(et,255&et.gzhead.os),et.gzhead.extra&&et.gzhead.extra.length&&(we(et,255&et.gzhead.extra.length),we(et,et.gzhead.extra.length>>8&255)),et.gzhead.hcrc&&(me.adler=u(me.adler,et.pending_buf,et.pending,0)),et.gzindex=0,et.status=69):(we(et,0),we(et,0),we(et,0),we(et,0),we(et,0),we(et,et.level===9?2:2<=et.strategy||et.level<2?4:0),we(et,3),et.status=te);else{var Ge=C+(et.w_bits-8<<4)<<8;Ge|=(2<=et.strategy||et.level<2?0:et.level<6?1:et.level===6?2:3)<<6,et.strstart!==0&&(Ge|=32),Ge+=31-Ge%31,et.status=te,Ie(et,Ge),et.strstart!==0&&(Ie(et,me.adler>>>16),Ie(et,65535&me.adler)),me.adler=1}if(et.status===69)if(et.gzhead.extra){for(Se=et.pending;et.gzindex<(65535&et.gzhead.extra.length)&&(et.pending!==et.pending_buf_size||(et.gzhead.hcrc&&et.pending>Se&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),_e(me),Se=et.pending,et.pending!==et.pending_buf_size));)we(et,255&et.gzhead.extra[et.gzindex]),et.gzindex++;et.gzhead.hcrc&&et.pending>Se&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),et.gzindex===et.gzhead.extra.length&&(et.gzindex=0,et.status=73)}else et.status=73;if(et.status===73)if(et.gzhead.name){Se=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Se&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),_e(me),Se=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexSe&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),rt===0&&(et.gzindex=0,et.status=91)}else et.status=91;if(et.status===91)if(et.gzhead.comment){Se=et.pending;do{if(et.pending===et.pending_buf_size&&(et.gzhead.hcrc&&et.pending>Se&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),_e(me),Se=et.pending,et.pending===et.pending_buf_size)){rt=1;break}rt=et.gzindexSe&&(me.adler=u(me.adler,et.pending_buf,et.pending-Se,Se)),rt===0&&(et.status=103)}else et.status=103;if(et.status===103&&(et.gzhead.hcrc?(et.pending+2>et.pending_buf_size&&_e(me),et.pending+2<=et.pending_buf_size&&(we(et,255&me.adler),we(et,me.adler>>8&255),me.adler=0,et.status=te)):et.status=te),et.pending!==0){if(_e(me),me.avail_out===0)return et.last_flush=-1,b}else if(me.avail_in===0&&pe(Ve)<=pe(nt)&&Ve!==g)return le(me,-5);if(et.status===666&&me.avail_in!==0)return le(me,-5);if(me.avail_in!==0||et.lookahead!==0||Ve!==f&&et.status!==666){var lt=et.strategy===2?function(qe,Ze){for(var Je;;){if(qe.lookahead===0&&(Ae(qe),qe.lookahead===0)){if(Ze===f)return X;break}if(qe.match_length=0,Je=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++,Je&&(fe(qe,!1),qe.strm.avail_out===0))return X}return qe.insert=0,Ze===g?(fe(qe,!0),qe.strm.avail_out===0?ne:re):qe.last_lit&&(fe(qe,!1),qe.strm.avail_out===0)?X:ce}(et,Ve):et.strategy===3?function(qe,Ze){for(var Je,He,Qe,at,It=qe.window;;){if(qe.lookahead<=V){if(Ae(qe),qe.lookahead<=V&&Ze===f)return X;if(qe.lookahead===0)break}if(qe.match_length=0,qe.lookahead>=B&&0qe.lookahead&&(qe.match_length=qe.lookahead)}if(qe.match_length>=B?(Je=i._tr_tally(qe,1,qe.match_length-B),qe.lookahead-=qe.match_length,qe.strstart+=qe.match_length,qe.match_length=0):(Je=i._tr_tally(qe,0,qe.window[qe.strstart]),qe.lookahead--,qe.strstart++),Je&&(fe(qe,!1),qe.strm.avail_out===0))return X}return qe.insert=0,Ze===g?(fe(qe,!0),qe.strm.avail_out===0?ne:re):qe.last_lit&&(fe(qe,!1),qe.strm.avail_out===0)?X:ce}(et,Ve):o[et.level].func(et,Ve);if(lt!==ne&<!==re||(et.status=666),lt===X||lt===ne)return me.avail_out===0&&(et.last_flush=-1),b;if(lt===ce&&(Ve===1?i._tr_align(et):Ve!==5&&(i._tr_stored_block(et,0,0,!1),Ve===3&&(xe(et.head),et.lookahead===0&&(et.strstart=0,et.block_start=0,et.insert=0))),_e(me),me.avail_out===0))return et.last_flush=-1,b}return Ve!==g?b:et.wrap<=0?1:(et.wrap===2?(we(et,255&me.adler),we(et,me.adler>>8&255),we(et,me.adler>>16&255),we(et,me.adler>>24&255),we(et,255&me.total_in),we(et,me.total_in>>8&255),we(et,me.total_in>>16&255),we(et,me.total_in>>24&255)):(Ie(et,me.adler>>>16),Ie(et,65535&me.adler)),_e(me),0=nt.w_size&&(rt===0&&(xe(nt.head),nt.strstart=0,nt.block_start=0,nt.insert=0),Ze=new l.Buf8(nt.w_size),l.arraySet(Ze,Ve,Je-nt.w_size,nt.w_size,0),Ve=Ze,Je=nt.w_size),Ge=me.avail_in,lt=me.next_in,qe=me.input,me.avail_in=Je,me.next_in=0,me.input=Ve,Ae(nt);nt.lookahead>=B;){for(et=nt.strstart,Se=nt.lookahead-(B-1);nt.ins_h=(nt.ins_h<>>=B=U>>>24,M-=B,(B=U>>>16&255)===0)ce[p++]=65535&U;else{if(!(16&B)){if(!(64&B)){U=I[(65535&U)+(C&(1<>>=B,M-=B),M<15&&(C+=X[c++]<>>=B=U>>>24,M-=B,!(16&(B=U>>>16&255))){if(!(64&B)){U=L[(65535&U)+(C&(1<>>=B,M-=B,(B=p-f)>3,C&=(1<<(M-=V<<3))-1,o.next_in=c,o.next_out=p,o.avail_in=c>>24&255)+(J>>>8&65280)+((65280&J)<<8)+((255&J)<<24)}function C(){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(J){var te;return J&&J.state?(te=J.state,J.total_in=J.total_out=te.total=0,J.msg="",te.wrap&&(J.adler=1&te.wrap),te.mode=_,te.last=0,te.havedict=0,te.dmax=32768,te.head=null,te.hold=0,te.bits=0,te.lencode=te.lendyn=new o.Buf32(j),te.distcode=te.distdyn=new o.Buf32(w),te.sane=1,te.back=-1,g):b}function I(J){var te;return J&&J.state?((te=J.state).wsize=0,te.whave=0,te.wnext=0,M(J)):b}function L(J,te){var X,ce;return J&&J.state?(ce=J.state,te<0?(X=0,te=-te):(X=1+(te>>4),te<48&&(te&=15)),te&&(te<8||15=re.wsize?(o.arraySet(re.window,te,X-re.wsize,re.wsize,0),re.wnext=0,re.whave=re.wsize):(ce<(ne=re.wsize-re.wnext)&&(ne=ce),o.arraySet(re.window,te,X-ce,ne,re.wnext),(ce-=ne)?(o.arraySet(re.window,te,X-ce,ce,0),re.wnext=ce,re.whave=re.wsize):(re.wnext+=ne,re.wnext===re.wsize&&(re.wnext=0),re.whave>>8&255,X.check=i(X.check,rt,2,0),fe=_e=0,X.mode=2;break}if(X.flags=0,X.head&&(X.head.done=!1),!(1&X.wrap)||(((255&_e)<<8)+(_e>>8))%31){J.msg="incorrect header check",X.mode=30;break}if((15&_e)!=8){J.msg="unknown compression method",X.mode=30;break}if(fe-=4,me=8+(15&(_e>>>=4)),X.wbits===0)X.wbits=me;else if(me>X.wbits){J.msg="invalid window size",X.mode=30;break}X.dmax=1<>8&1),512&X.flags&&(rt[0]=255&_e,rt[1]=_e>>>8&255,X.check=i(X.check,rt,2,0)),fe=_e=0,X.mode=3;case 3:for(;fe<32;){if(pe===0)break e;pe--,_e+=ce[re++]<>>8&255,rt[2]=_e>>>16&255,rt[3]=_e>>>24&255,X.check=i(X.check,rt,4,0)),fe=_e=0,X.mode=4;case 4:for(;fe<16;){if(pe===0)break e;pe--,_e+=ce[re++]<>8),512&X.flags&&(rt[0]=255&_e,rt[1]=_e>>>8&255,X.check=i(X.check,rt,2,0)),fe=_e=0,X.mode=5;case 5:if(1024&X.flags){for(;fe<16;){if(pe===0)break e;pe--,_e+=ce[re++]<>>8&255,X.check=i(X.check,rt,2,0)),fe=_e=0}else X.head&&(X.head.extra=null);X.mode=6;case 6:if(1024&X.flags&&(pe<(Ne=X.length)&&(Ne=pe),Ne&&(X.head&&(me=X.head.extra_len-X.length,X.head.extra||(X.head.extra=new Array(X.head.extra_len)),o.arraySet(X.head.extra,ce,re,Ne,me)),512&X.flags&&(X.check=i(X.check,ce,Ne,re)),pe-=Ne,re+=Ne,X.length-=Ne),X.length))break e;X.length=0,X.mode=7;case 7:if(2048&X.flags){if(pe===0)break e;for(Ne=0;me=ce[re+Ne++],X.head&&me&&X.length<65536&&(X.head.name+=String.fromCharCode(me)),me&&Ne>9&1,X.head.done=!0),J.adler=X.check=0,X.mode=12;break;case 10:for(;fe<32;){if(pe===0)break e;pe--,_e+=ce[re++]<>>=7&fe,fe-=7&fe,X.mode=27;break}for(;fe<3;){if(pe===0)break e;pe--,_e+=ce[re++]<>>=1)){case 0:X.mode=14;break;case 1:if(V(X),X.mode=20,te!==6)break;_e>>>=2,fe-=2;break e;case 2:X.mode=17;break;case 3:J.msg="invalid block type",X.mode=30}_e>>>=2,fe-=2;break;case 14:for(_e>>>=7&fe,fe-=7&fe;fe<32;){if(pe===0)break e;pe--,_e+=ce[re++]<>>16^65535)){J.msg="invalid stored block lengths",X.mode=30;break}if(X.length=65535&_e,fe=_e=0,X.mode=15,te===6)break e;case 15:X.mode=16;case 16:if(Ne=X.length){if(pe>>=5,fe-=5,X.ndist=1+(31&_e),_e>>>=5,fe-=5,X.ncode=4+(15&_e),_e>>>=4,fe-=4,286>>=3,fe-=3}for(;X.have<19;)X.lens[Ge[X.have++]]=0;if(X.lencode=X.lendyn,X.lenbits=7,nt={bits:X.lenbits},Ve=u(0,X.lens,0,19,X.lencode,0,X.work,nt),X.lenbits=nt.bits,Ve){J.msg="invalid code lengths set",X.mode=30;break}X.have=0,X.mode=19;case 19:for(;X.have>>16&255,$e=65535&Se,!((Ce=Se>>>24)<=fe);){if(pe===0)break e;pe--,_e+=ce[re++]<>>=Ce,fe-=Ce,X.lens[X.have++]=$e;else{if($e===16){for(et=Ce+2;fe>>=Ce,fe-=Ce,X.have===0){J.msg="invalid bit length repeat",X.mode=30;break}me=X.lens[X.have-1],Ne=3+(3&_e),_e>>>=2,fe-=2}else if($e===17){for(et=Ce+3;fe>>=Ce)),_e>>>=3,fe-=3}else{for(et=Ce+7;fe>>=Ce)),_e>>>=7,fe-=7}if(X.have+Ne>X.nlen+X.ndist){J.msg="invalid bit length repeat",X.mode=30;break}for(;Ne--;)X.lens[X.have++]=me}}if(X.mode===30)break;if(X.lens[256]===0){J.msg="invalid code -- missing end-of-block",X.mode=30;break}if(X.lenbits=9,nt={bits:X.lenbits},Ve=u(p,X.lens,0,X.nlen,X.lencode,0,X.work,nt),X.lenbits=nt.bits,Ve){J.msg="invalid literal/lengths set",X.mode=30;break}if(X.distbits=6,X.distcode=X.distdyn,nt={bits:X.distbits},Ve=u(f,X.lens,X.nlen,X.ndist,X.distcode,0,X.work,nt),X.distbits=nt.bits,Ve){J.msg="invalid distances set",X.mode=30;break}if(X.mode=20,te===6)break e;case 20:X.mode=21;case 21:if(6<=pe&&258<=xe){J.next_out=le,J.avail_out=xe,J.next_in=re,J.avail_in=pe,X.hold=_e,X.bits=fe,c(J,Ie),le=J.next_out,ne=J.output,xe=J.avail_out,re=J.next_in,ce=J.input,pe=J.avail_in,_e=X.hold,fe=X.bits,X.mode===12&&(X.back=-1);break}for(X.back=0;Me=(Se=X.lencode[_e&(1<>>16&255,$e=65535&Se,!((Ce=Se>>>24)<=fe);){if(pe===0)break e;pe--,_e+=ce[re++]<>ct)])>>>16&255,$e=65535&Se,!(ct+(Ce=Se>>>24)<=fe);){if(pe===0)break e;pe--,_e+=ce[re++]<>>=ct,fe-=ct,X.back+=ct}if(_e>>>=Ce,fe-=Ce,X.back+=Ce,X.length=$e,Me===0){X.mode=26;break}if(32&Me){X.back=-1,X.mode=12;break}if(64&Me){J.msg="invalid literal/length code",X.mode=30;break}X.extra=15&Me,X.mode=22;case 22:if(X.extra){for(et=X.extra;fe>>=X.extra,fe-=X.extra,X.back+=X.extra}X.was=X.length,X.mode=23;case 23:for(;Me=(Se=X.distcode[_e&(1<>>16&255,$e=65535&Se,!((Ce=Se>>>24)<=fe);){if(pe===0)break e;pe--,_e+=ce[re++]<>ct)])>>>16&255,$e=65535&Se,!(ct+(Ce=Se>>>24)<=fe);){if(pe===0)break e;pe--,_e+=ce[re++]<>>=ct,fe-=ct,X.back+=ct}if(_e>>>=Ce,fe-=Ce,X.back+=Ce,64&Me){J.msg="invalid distance code",X.mode=30;break}X.offset=$e,X.extra=15&Me,X.mode=24;case 24:if(X.extra){for(et=X.extra;fe>>=X.extra,fe-=X.extra,X.back+=X.extra}if(X.offset>X.dmax){J.msg="invalid distance too far back",X.mode=30;break}X.mode=25;case 25:if(xe===0)break e;if(Ne=Ie-xe,X.offset>Ne){if((Ne=X.offset-Ne)>X.whave&&X.sane){J.msg="invalid distance too far back",X.mode=30;break}Ae=Ne>X.wnext?(Ne-=X.wnext,X.wsize-Ne):X.wnext-Ne,Ne>X.length&&(Ne=X.length),Fe=X.window}else Fe=ne,Ae=le-X.offset,Ne=X.length;for(xeq?(B=Ae[Fe+w[te]],fe[we+w[te]]):(B=96,0),C=1<>le)+(M-=C)]=U<<24|B<<16|V|0,M!==0;);for(C=1<>=1;if(C!==0?(_e&=C-1,_e+=C):_e=0,te++,--Ie[J]==0){if(J===ce)break;J=f[g+w[te]]}if(ne>>7)]}function we(Se,rt){Se.pending_buf[Se.pending++]=255&rt,Se.pending_buf[Se.pending++]=rt>>>8&255}function Ie(Se,rt,Ge){Se.bi_valid>N-Ge?(Se.bi_buf|=rt<>N-Se.bi_valid,Se.bi_valid+=Ge-N):(Se.bi_buf|=rt<>>=1,Ge<<=1,0<--rt;);return Ge>>>1}function Fe(Se,rt,Ge){var lt,qe,Ze=new Array(w+1),Je=0;for(lt=1;lt<=w;lt++)Ze[lt]=Je=Je+Ge[lt-1]<<1;for(qe=0;qe<=rt;qe++){var He=Se[2*qe+1];He!==0&&(Se[2*qe]=Ae(Ze[He]++,He))}}function Ce(Se){var rt;for(rt=0;rt>1;1<=Ge;Ge--)ct(Se,Ze,Ge);for(qe=Qe;Ge=Se.heap[1],Se.heap[1]=Se.heap[Se.heap_len--],ct(Se,Ze,1),lt=Se.heap[1],Se.heap[--Se.heap_max]=Ge,Se.heap[--Se.heap_max]=lt,Ze[2*qe]=Ze[2*Ge]+Ze[2*lt],Se.depth[qe]=(Se.depth[Ge]>=Se.depth[lt]?Se.depth[Ge]:Se.depth[lt])+1,Ze[2*Ge+1]=Ze[2*lt+1]=qe,Se.heap[1]=qe++,ct(Se,Ze,1),2<=Se.heap_len;);Se.heap[--Se.heap_max]=Se.heap[1],function(It,Ut){var hs,Yt,ts,Ds,vr,Ct,As=Ut.dyn_tree,Us=Ut.max_code,kr=Ut.stat_desc.static_tree,ta=Ut.stat_desc.has_stree,ka=Ut.stat_desc.extra_bits,Li=Ut.stat_desc.extra_base,Wa=Ut.stat_desc.max_length,cr=0;for(Ds=0;Ds<=w;Ds++)It.bl_count[Ds]=0;for(As[2*It.heap[It.heap_max]+1]=0,hs=It.heap_max+1;hs>=7;qe>>=1)if(1&at&&He.dyn_ltree[2*Qe]!==0)return l;if(He.dyn_ltree[18]!==0||He.dyn_ltree[20]!==0||He.dyn_ltree[26]!==0)return i;for(Qe=32;Qe>>3,(Ze=Se.static_len+3+7>>>3)<=qe&&(qe=Ze)):qe=Ze=Ge+5,Ge+4<=qe&&rt!==-1?et(Se,rt,Ge,lt):Se.strategy===4||Ze===qe?(Ie(Se,2+(lt?1:0),3),Te(Se,Y,J)):(Ie(Se,4+(lt?1:0),3),function(He,Qe,at,It){var Ut;for(Ie(He,Qe-257,5),Ie(He,at-1,5),Ie(He,It-4,4),Ut=0;Ut>>8&255,Se.pending_buf[Se.d_buf+2*Se.last_lit+1]=255&rt,Se.pending_buf[Se.l_buf+Se.last_lit]=255&Ge,Se.last_lit++,rt===0?Se.dyn_ltree[2*Ge]++:(Se.matches++,rt--,Se.dyn_ltree[2*(X[Ge]+f+1)]++,Se.dyn_dtree[2*fe(rt)]++),Se.last_lit===Se.lit_bufsize-1},a._tr_align=function(Se){Ie(Se,2,3),Ne(Se,M,Y),function(rt){rt.bi_valid===16?(we(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)}(Se)}},{"../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,b={},_=!1,j=l.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(l);w=w&&w.setTimeout?w:l,c={}.toString.call(l.process)==="[object process]"?function(I){process.nextTick(function(){C(I)})}:function(){if(l.postMessage&&!l.importScripts){var I=!0,L=l.onmessage;return l.onmessage=function(){I=!1},l.postMessage("","*"),l.onmessage=L,I}}()?(f="setImmediate$"+Math.random()+"$",l.addEventListener?l.addEventListener("message",M,!1):l.attachEvent("onmessage",M),function(I){l.postMessage(f+I,"*")}):l.MessageChannel?((p=new MessageChannel).port1.onmessage=function(I){C(I.data)},function(I){p.port2.postMessage(I)}):j&&"onreadystatechange"in j.createElement("script")?(u=j.documentElement,function(I){var L=j.createElement("script");L.onreadystatechange=function(){C(I),L.onreadystatechange=null,u.removeChild(L),L=null},u.appendChild(L)}):function(I){setTimeout(C,0,I)},w.setImmediate=function(I){typeof I!="function"&&(I=new Function(""+I));for(var L=new Array(arguments.length-1),R=0;R"u"?o===void 0?this:o:self)}).call(this,typeof Vv<"u"?Vv:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(qet);var oUt=qet.exports;const lUt=Ao(oUt);function Sge(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 cUt=()=>{const{isAdmin:t}=Rs(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState("all"),[i,c]=k.useState(new Set),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState("images"),[j,w]=k.useState(null),{data:N=[],isLoading:C}=mt({queryKey:["social-swag-2"],queryFn:async()=>{const{data:pe,error:xe}=await H.from("social_swag_2").select("*").order("month",{ascending:!1}).order("sort_order");if(xe)throw xe;return pe}}),{data:M=[]}=mt({queryKey:["social-swag-2-months"],queryFn:async()=>{const{data:pe,error:xe}=await H.from("social_swag_2_months").select("*").order("month",{ascending:!1});if(xe)throw xe;return pe}}),{data:I=[]}=mt({queryKey:["social-swag-2-reels"],queryFn:async()=>{const{data:pe,error:xe}=await H.from("social_swag_2_reels").select("*").order("month",{ascending:!1});if(xe)throw xe;return pe}}),{data:L=[]}=mt({queryKey:["my-social-accounts-count"],queryFn:async()=>{const{data:pe,error:xe}=await H.from("social_accounts").select("id, platform").eq("is_active",!0);if(xe)throw xe;return pe||[]}}),R=L.length>0,q=k.useMemo(()=>o==="all"?null:I.find(pe=>pe.month===o)||null,[o,I]),U=k.useMemo(()=>[...new Set(N.map(xe=>xe.month))].sort((xe,_e)=>_e.localeCompare(xe)),[N]);k.useEffect(()=>{U.length>0&&o==="all"&&l(U[0])},[U,o]);const B=pe=>{try{const xe=xje(pe,"yyyy-MM",new Date);return ps(xe,"MMMM yyyy")}catch{return pe}},V=k.useMemo(()=>o==="all"?N:N.filter(pe=>pe.month===o),[o,N]),Y=k.useMemo(()=>{var pe;return o==="all"?null:((pe=M.find(xe=>xe.month===o))==null?void 0:pe.canva_link)||null},[o,M]),J=async pe=>{try{await navigator.clipboard.writeText(pe),he.success("Caption copied to clipboard!")}catch{he.error("Failed to copy caption")}},te=async(pe,xe)=>{try{const fe=await(await fetch(pe)).blob(),we=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),Ie=navigator.canShare&&navigator.canShare({files:[new File([fe],"test.jpg",{type:"image/jpeg"})]});if(we&&Ie){const Ne=new File([fe],`social-swag-${xe}.jpg`,{type:"image/jpeg"});await navigator.share({files:[Ne],title:"Social Swag Image"}),he.success("Image ready to save!")}else{const Ne=window.URL.createObjectURL(fe),Ae=document.createElement("a");Ae.href=Ne,Ae.download=`social-swag-${xe}.jpg`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),window.URL.revokeObjectURL(Ne),he.success("Image downloaded!")}}catch(_e){_e.name!=="AbortError"&&he.error("Failed to download image")}},X=pe=>{c(xe=>{const _e=new Set(xe);return _e.has(pe)?_e.delete(pe):_e.add(pe),_e})},ce=()=>{c(new Set(V.map(pe=>pe.id)))},ne=()=>{c(new Set),p(!1)},re=async()=>{const pe=V.filter(xe=>i.has(xe.id));if(pe.length===0){he.error("No images selected");return}g(!0),he.info(`Preparing ${pe.length} images for download...`);try{const xe=new lUt,_e=[...pe].sort((Ae,Fe)=>Ae.sort_order-Fe.sort_order);for(let Ae=0;Ae<_e.length;Ae++){const Fe=_e[Ae];try{const Ce=await fetch(Fe.image_url),Me=await Ce.blob(),$e=Ce.headers.get("content-type")||"image/jpeg",ct=$e.includes("png")?"png":$e.includes("webp")?"webp":"jpg",Te=`${Ae+1}.${ct}`;xe.file(Te,Me)}catch{console.error("Failed to fetch image:",Fe.id)}}const fe=o!=="all"?B(o):"Social Swag",we=await xe.generateAsync({type:"blob"}),Ie=window.URL.createObjectURL(we),Ne=document.createElement("a");Ne.href=Ie,Ne.download=`${fe}.zip`,document.body.appendChild(Ne),Ne.click(),document.body.removeChild(Ne),window.URL.revokeObjectURL(Ie),he.success(`Downloaded ${_e.length} images as "${fe}.zip"!`)}catch(xe){console.error("Failed to create ZIP:",xe),he.error("Failed to create download package")}g(!1),ne()},le=pe=>{u?X(pe.id):r(pe)};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(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(un,{className:"h-3 w-3 mr-1"}),"New content monthly"]}),e.jsxs(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(fl,{className:"h-3 w-3 mr-1"}),N.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(ja,{defaultValue:"gallery",className:"space-y-6",children:[e.jsxs(ga,{className:"grid w-full max-w-md grid-cols-2",children:[e.jsxs(us,{value:"gallery",className:"gap-2",children:[e.jsx(fl,{className:"h-4 w-4"}),"Gallery"]}),e.jsxs(us,{value:"scheduled",className:"gap-2",children:[e.jsx(Dd,{className:"h-4 w-4"}),"Scheduled"]})]}),e.jsxs(ks,{value:"gallery",className:"space-y-6",children:[t?R?e.jsx(Pe,{className:"border rounded-xl",children:e.jsx(Re,{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(Ei,{to:"/social-connections",children:"Manage Accounts"})})]})})}):e.jsx(Pe,{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(Re,{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(ku,{className:"h-5 w-5 text-blue-600"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Cu,{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(Ei,{to:"/social-connections",children:[e.jsx(cl,{className:"h-4 w-4"}),"Connect Accounts"]})})]})})}):e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Re,{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(mn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(ku,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Cu,{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(tt,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(pe)},pe))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,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:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(fl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(xu,{className:"h-4 w-4"}),"Reels"]})]}),b==="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(Or,{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(Ci,{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(fa,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&b==="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(pe=>{const xe=i.has(pe.id);return e.jsx(Pe,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:Sge(pe.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"}),pe.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:ps(new Date(pe.post_date+"T00:00:00"),"MMM d")})}),u&&e.jsx("div",{className:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(fa,{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"})})]})},pe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{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."})]})]}),!C&&b==="reels"&&e.jsx(e.Fragment,{children:q?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(Pe,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:Sge(q.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(tt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(xu,{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(xu,{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:Sge(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(cn,{className:"h-4 w-4"}),ps(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(cn,{className:"h-3.5 w-3.5"}),"Post on ",ps(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:()=>{w({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(Rn,{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:()=>J(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Ci,{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(xu,{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:()=>J(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{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(an,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})}),e.jsx(aUt,{open:!!j,onOpenChange:pe=>!pe&&w(null),imageUrl:(j==null?void 0:j.imageUrl)||"",imageId:(j==null?void 0:j.imageId)||"",defaultCaption:(j==null?void 0:j.caption)||"",swagItemId:j==null?void 0:j.imageId})]}),e.jsx(ks,{value:"scheduled",children:e.jsx(iUt,{})})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"border-2 border-dashed border-muted-foreground/20 bg-muted/30 rounded-xl",children:e.jsx(Re,{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(mn,{className:"h-5 w-5 text-muted-foreground"})}),e.jsx("div",{className:"p-2 rounded-full bg-blue-500/10",children:e.jsx(ku,{className:"h-5 w-5 text-blue-400"})}),e.jsx("div",{className:"p-2 rounded-full bg-pink-500/10",children:e.jsx(Cu,{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(tt,{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(pe=>e.jsx("button",{onClick:()=>l(pe),className:Pt("px-4 py-2 rounded-full text-sm font-medium transition-all",o===pe?"bg-primary text-primary-foreground shadow-sm":"bg-muted text-muted-foreground hover:text-foreground"),children:B(pe)},pe))}),o!=="all"&&(Y?e.jsxs("a",{href:Y,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:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="images"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(fl,{className:"h-4 w-4"}),"Images"]}),e.jsxs("button",{onClick:()=>{_("reels"),ne()},className:Pt("flex items-center gap-2 px-4 py-2 rounded-full text-sm font-medium transition-all",b==="reels"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:[e.jsx(xu,{className:"h-4 w-4"}),"Reels"]})]}),b==="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(Or,{className:"h-4 w-4"}),"Cancel"]}),i.size>0&&e.jsxs(K,{size:"sm",onClick:re,disabled:f,className:"gap-2",children:[e.jsx(Ci,{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(fa,{className:"h-4 w-4"}),"Select Images"]})})]}),C&&e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}),!C&&b==="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(pe=>{const xe=i.has(pe.id);return e.jsx(Pe,{className:Pt("group cursor-pointer overflow-hidden border-0 shadow-md hover:shadow-xl transition-all duration-300 rounded-2xl",u&&xe&&"ring-2 ring-primary ring-offset-2"),onClick:()=>le(pe),children:e.jsxs("div",{className:"relative aspect-[4/5] overflow-hidden",children:[e.jsx("img",{src:pe.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:Pt("absolute top-2 right-2 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",xe?"bg-primary border-primary text-primary-foreground":"bg-white/80 border-muted-foreground/50"),children:xe&&e.jsx(fa,{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"})})]})},pe.id)})}),V.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{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."})]})]}),!C&&b==="reels"&&e.jsx(e.Fragment,{children:q?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(Pe,{className:"group overflow-hidden rounded-2xl cursor-pointer transition-all duration-300 hover:shadow-xl hover:scale-[1.02]",onClick:()=>a(q),children:e.jsxs("div",{className:"relative aspect-[9/16] overflow-hidden",children:[e.jsx("img",{src:q.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(tt,{variant:"secondary",className:"bg-black/50 text-white border-0 backdrop-blur-sm text-xs",children:[e.jsx(xu,{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(xu,{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(cn,{className:"h-4 w-4"}),ps(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:()=>J(s.caption),className:"flex-1 gap-2",children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy Caption"]}),e.jsxs(K,{variant:"outline",onClick:()=>te(s.image_url,s.id),className:"flex-1 gap-2",children:[e.jsx(Ci,{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(xu,{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:()=>J(n.caption||""),className:"flex-1 gap-2",children:[e.jsx(gi,{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(an,{className:"h-4 w-4"}),"Open in Canva"]})]})]})]})})})})]})]})})},dUt=()=>{const{swagId:t}=yo(),{user:s}=Rs(),{toast:r}=qa(),n=es(),{trackEngagement:a}=UO(),[o,l]=k.useState(""),{data:i,isLoading:c}=mt({queryKey:["social-swag-detail",t],queryFn:async()=>{const{data:N,error:C}=await H.from("social_swag").select("*").eq("id",t).single();if(C)throw C;const{data:M}=await H.from("social_swag_links").select("*").eq("swag_id",t).order("sort_order");return{...N,links:M||[]}},enabled:!!t});k.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:N,error:C}=await H.from("social_swag_likes").select("*").eq("swag_id",t);if(C)throw C;return N},enabled:!!t}),{data:p=[]}=mt({queryKey:["social-swag-comments",t],queryFn:async()=>{const{data:N,error:C}=await H.from("social_swag_comments").select("*").eq("swag_id",t).order("created_at",{ascending:!1});if(C)throw C;const M=[...new Set(N.map(R=>R.user_id))],{data:I}=await H.from("profiles").select("id, name").in("id",M),L=new Map((I==null?void 0:I.map(R=>[R.id,R.name]))||[]);return N.map(R=>({...R,user_name:L.get(R.user_id)||"Unknown User"}))},enabled:!!t}),f=Lt({mutationFn:async N=>{const{error:C}=await H.from("social_swag_comments").insert({swag_id:t,user_id:s.id,content:N});if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),l(""),r({title:"Comment added!"})},onError:N=>{r({title:"Error adding comment",description:N.message,variant:"destructive"})}}),g=Lt({mutationFn:async N=>{const{error:C}=await H.from("social_swag_comments").delete().eq("id",N);if(C)throw C},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-comments",t]}),r({title:"Comment deleted"})}}),b=Lt({mutationFn:async()=>{const N=u.find(C=>C.user_id===(s==null?void 0:s.id));if(N){const{error:C}=await H.from("social_swag_likes").delete().eq("id",N.id);if(C)throw C}else{const{error:C}=await H.from("social_swag_likes").insert({swag_id:t,user_id:s.id});if(C)throw C}},onSuccess:()=>{n.invalidateQueries({queryKey:["social-swag-likes",t]})}}),_=u.some(N=>N.user_id===(s==null?void 0:s.id)),j=N=>N.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2),w=N=>{N.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(Ei,{to:"/social-swag",children:[e.jsx(ri,{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(aE,{resourceType:"social_swag",resourceId:i.id,resourceTitle:i.title}),e.jsxs(K,{variant:_?"default":"outline",className:"gap-2 w-fit",onClick:()=>b.mutate(),disabled:!s||b.isPending,children:[e.jsx(eh,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(zo,{className:"h-4 w-4"}),i.links.length===1?"Canva Link":"Canva Links"]}),e.jsx("div",{className:"grid gap-2",children:i.links.map(N=>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(N.canva_share_link,"_blank")},children:[e.jsx("span",{className:"font-medium",children:N.title}),e.jsx(an,{className:"h-4 w-4 text-muted-foreground"})]},N.id))})]})}),e.jsx(sl,{}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 text-lg",children:[e.jsx(zc,{className:"h-5 w-5"}),"Comments (",p.length,")"]}),s?e.jsxs("form",{onSubmit:w,className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Add a comment...",value:o,onChange:N=>l(N.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(Rn,{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(Pe,{children:e.jsx(Re,{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(N=>e.jsx(Pe,{children:e.jsx(Re,{className:"pt-4 pb-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_n,{className:"h-10 w-10 flex-shrink-0",children:e.jsx(wn,{className:"text-sm",children:j(N.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:N.user_name}),e.jsx("span",{className:"text-sm text-muted-foreground",children:_d(new Date(N.created_at),{addSuffix:!0})}),N.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(N.id),children:e.jsx(Nr,{className:"h-3 w-3 text-muted-foreground"})})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap",children:N.content})]})]})})},N.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(zo,{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(Ei,{to:"/social-swag",children:"Back to Social Swag"})})]})})},uUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.useState(!0),[i,c]=k.useState(!0),[u,p]=k.useState(!0),f=g=>g.split(" ").map(b=>b[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(z_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsxs(gf,{open:o,onOpenChange:l,children:[e.jsx(yf,{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(To,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(vf,{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(gf,{open:i,onOpenChange:c,children:[e.jsx(yf,{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(Mh,{className:"h-3 w-3"}),"Your Groups"]}),i?e.jsx(To,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(vf,{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(gf,{open:u,onOpenChange:p,children:[e.jsx(yf,{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(mr,{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(To,{className:"h-4 w-4"}):e.jsx(xa,{className:"h-4 w-4"})]})}),e.jsx(vf,{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(_n,{className:"h-7 w-7",children:[e.jsx(za,{src:g.avatarUrl}),e.jsx(wn,{className:"text-xs",children:f(g.name)})]}),e.jsx(vd,{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))})]})]})})})},hUt=({categories:t,privateGroups:s,selectedFilter:r,onFilterChange:n,onlineUsers:a})=>{const[o,l]=k.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(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"flex-1 justify-between",children:[e.jsx("span",{className:"truncate",children:c()}),e.jsx(To,{className:"h-4 w-4 ml-2 shrink-0"})]})}),e.jsxs(zd,{className:"w-56 bg-background border",children:[e.jsxs(Ca,{onClick:()=>n("all"),children:[e.jsx(z_,{className:"h-4 w-4 mr-2"}),"All Posts"]}),e.jsx(lw,{}),e.jsx(_ve,{className:"text-xs text-muted-foreground",children:"Categories"}),t.map(u=>e.jsxs(Ca,{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(lw,{}),e.jsxs(_ve,{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(Mh,{className:"h-3 w-3"}),"Your Groups"]}),s.map(u=>e.jsxs(Ca,{onClick:()=>n(`group:${u.id}`),children:[e.jsx("span",{className:"mr-2",children:u.icon||"🔒"}),u.name]},u.id))]})]})]}),e.jsxs(QA,{open:o,onOpenChange:l,children:[e.jsx(Jje,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"icon",className:"relative",children:[e.jsx(mr,{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(mC,{children:[e.jsx(JA,{children:e.jsxs(eE,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Online Now (",a.length,")"]})}),e.jsx(Gi,{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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:u.avatarUrl}),e.jsx(wn,{children:i(u.name)})]}),e.jsx(vd,{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 Cge,que="HoverCard",[Uet]=nd(que,[L0]),Uue=L0(),[mUt,Ake]=Uet(que),Vet=t=>{const{__scopeHoverCard:s,children:r,open:n,defaultOpen:a,onOpenChange:o,openDelay:l=700,closeDelay:i=300}=t,c=Uue(s),u=k.useRef(0),p=k.useRef(0),f=k.useRef(!1),g=k.useRef(!1),[b,_]=rh({prop:n,defaultProp:a??!1,onChange:o,caller:que}),j=k.useCallback(()=>{clearTimeout(p.current),u.current=window.setTimeout(()=>_(!0),l)},[l,_]),w=k.useCallback(()=>{clearTimeout(u.current),!f.current&&!g.current&&(p.current=window.setTimeout(()=>_(!1),i))},[i,_]),N=k.useCallback(()=>_(!1),[_]);return k.useEffect(()=>()=>{clearTimeout(u.current),clearTimeout(p.current)},[]),e.jsx(mUt,{scope:s,open:b,onOpenChange:_,onOpen:j,onClose:w,onDismiss:N,hasSelectionRef:f,isPointerDownOnContentRef:g,children:e.jsx(yO,{...c,children:r})})};Vet.displayName=que;var Het="HoverCardTrigger",Wet=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Ake(Het,r),o=Uue(r);return e.jsx(BA,{asChild:!0,...o,children:e.jsx(sn.a,{"data-state":a.open?"open":"closed",...n,ref:s,onPointerEnter:Ir(t.onPointerEnter,Ole(a.onOpen)),onPointerLeave:Ir(t.onPointerLeave,Ole(a.onClose)),onFocus:Ir(t.onFocus,a.onOpen),onBlur:Ir(t.onBlur,a.onClose),onTouchStart:Ir(t.onTouchStart,l=>l.preventDefault())})})});Wet.displayName=Het;var pUt="HoverCardPortal",[jMs,fUt]=Uet(pUt,{forceMount:void 0}),Dle="HoverCardContent",Get=k.forwardRef((t,s)=>{const r=fUt(Dle,t.__scopeHoverCard),{forceMount:n=r.forceMount,...a}=t,o=Ake(Dle,t.__scopeHoverCard);return e.jsx(Fd,{present:n||o.open,children:e.jsx(xUt,{"data-state":o.open?"open":"closed",...a,onPointerEnter:Ir(t.onPointerEnter,Ole(o.onOpen)),onPointerLeave:Ir(t.onPointerLeave,Ole(o.onClose)),ref:s})})});Get.displayName=Dle;var xUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:l,...i}=t,c=Ake(Dle,r),u=Uue(r),p=k.useRef(null),f=$a(s,p),[g,b]=k.useState(!1);return k.useEffect(()=>{if(g){const _=document.body;return Cge=_.style.userSelect||_.style.webkitUserSelect,_.style.userSelect="none",_.style.webkitUserSelect="none",()=>{_.style.userSelect=Cge,_.style.webkitUserSelect=Cge}}},[g]),k.useEffect(()=>{if(p.current){const _=()=>{b(!1),c.isPointerDownOnContentRef.current=!1,setTimeout(()=>{var w;((w=document.getSelection())==null?void 0:w.toString())!==""&&(c.hasSelectionRef.current=!0)})};return document.addEventListener("pointerup",_),()=>{document.removeEventListener("pointerup",_),c.hasSelectionRef.current=!1,c.isPointerDownOnContentRef.current=!1}}},[c.isPointerDownOnContentRef,c.hasSelectionRef]),k.useEffect(()=>{p.current&&vUt(p.current).forEach(j=>j.setAttribute("tabindex","-1"))}),e.jsx(ww,{asChild:!0,disableOutsidePointerEvents:!1,onInteractOutside:l,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:Ir(o,_=>{_.preventDefault()}),onDismiss:c.onDismiss,children:e.jsx(vO,{...u,...i,onPointerDown:Ir(i.onPointerDown,_=>{_.currentTarget.contains(_.target)&&b(!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)"}})})}),gUt="HoverCardArrow",yUt=k.forwardRef((t,s)=>{const{__scopeHoverCard:r,...n}=t,a=Uue(r);return e.jsx(bO,{...a,...n,ref:s})});yUt.displayName=gUt;function Ole(t){return s=>s.pointerType==="touch"?void 0:t()}function vUt(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 bUt=Vet,_Ut=Wet,Ket=Get;const wUt=bUt,jUt=_Ut,Zet=k.forwardRef(({className:t,align:s="center",sideOffset:r=4,...n},a)=>e.jsx(Ket,{ref:a,align:s,sideOffset:r,className:Pt("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}));Zet.displayName=Ket.displayName;const NUt=[{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"}],kUt=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2),Yet=({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(wUt,{openDelay:200,closeDelay:100,children:[e.jsx(jUt,{asChild:!0,children:e.jsx("div",{className:"cursor-pointer",children:s})}),e.jsx(Zet,{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=NUt.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(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:l.user_avatar||void 0}),e.jsx(wn,{className:"text-[10px]",children:kUt(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 SUt({images:t,initialIndex:s=0,open:r,onOpenChange:n}){const[a,o]=k.useState(s),[l,i]=k.useState(!1);k.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]);k.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(Or,{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(ll,{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(xa,{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(UM,{className:"h-5 w-5"}):e.jsx(H_,{className:"h-5 w-5"})}),e.jsx("div",{className:Pt("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:Pt("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,b)=>e.jsx("button",{onClick:()=>{o(b),i(!1)},className:Pt("w-12 h-12 rounded overflow-hidden flex-shrink-0 border-2 transition-all",a===b?"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"})},b))})]})})}const _z=[{type:"like",emoji:"👍",label:"Like"},{type:"love",emoji:"❤️",label:"Love"}],CUt=({commentId:t,reactions:s,currentUserId:r})=>{var u,p;const n=es(),[a,o]=k.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(Yet,{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=_z.find(b=>b.type===f))==null?void 0:g.emoji},f)})}),e.jsx("span",{children:s.length})]})}),r&&e.jsxs(Bo,{open:a,onOpenChange:o,children:[e.jsx($o,{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=_z.find(f=>f.type===l.reaction_type))==null?void 0:u.emoji," ",(p=_z.find(f=>f.type===l.reaction_type))==null?void 0:p.label]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ii,{className:"h-3 w-3"}),"Like"]})})}),e.jsx(Do,{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:_z.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 Eke({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(Ei,{to:p?`/templates/${u}`:`/profile?user=${u}`,className:Pt("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(k.Fragment,{children:i},c))})}function Rle({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=k.useRef(null),f=k.useRef(null),[g,b]=k.useState(!1),[_,j]=k.useState("user"),[w,N]=k.useState(""),[C,M]=k.useState(null),[I,L]=k.useState(0),[R,q]=k.useState({top:0,left:0,width:0}),U=k.useRef(new Map),B=k.useRef(new Map),V=fe=>{if(c==="plain"){const Ae=[];return U.current.forEach((Ce,Me)=>{fe.includes(`@${Me}`)&&Ae.push(Ce)}),[...new Set(Ae)]}const we=/@\[([^\]]+)\]\(([^)]+)\)/g,Ie=[];let Ne;for(;(Ne=we.exec(fe))!==null;)Ie.push(Ne[2]);return[...new Set(Ie)]},Y=fe=>{if(c==="plain"){const Ae=[];return B.current.forEach((Ce,Me)=>{fe.includes(`#${Me}`)&&Ae.push(Ce)}),[...new Set(Ae)]}const we=/#\[([^\]]+)\]\(([^)]+)\)/g,Ie=[];let Ne;for(;(Ne=we.exec(fe))!==null;)Ie.push(Ne[2]);return[...new Set(Ie)]};k.useEffect(()=>{if(o){const fe=V(t);o(fe)}if(l){const fe=Y(t);l(fe)}},[t,o,l,c]);const{data:J=[],isLoading:te}=mt({queryKey:["mention-users",w],queryFn:async()=>{const fe=H.from("profiles").select("id, name").limit(8),we=w.length>=1?fe.ilike("name",`%${w}%`):fe.order("name"),{data:Ie,error:Ne}=await we;if(Ne)throw Ne;const Ae=Ie.map(Ce=>Ce.id),Fe=await LZe(Ae);return Ie.map(Ce=>({id:Ce.id,name:Ce.name||"Unknown",avatar_url:Fe.get(Ce.id)}))},enabled:g&&_==="user",staleTime:3e4}),{data:X=[],isLoading:ce}=mt({queryKey:["mention-templates",w],queryFn:async()=>{let fe=H.from("canva_templates").select("id, name, preview_image_url").lte("publish_date",new Date().toISOString()).order("publish_date",{ascending:!1}).limit(8);w.length>=1&&(fe=fe.ilike("name",`%${w}%`));const{data:we,error:Ie}=await fe;if(Ie)throw Ie;return we||[]},enabled:g&&_==="template"&&u,staleTime:3e4}),ne=_==="user"?te:ce,re=_==="user"?J:X,le=fe=>fe.split(" ").map(we=>we[0]).join("").toUpperCase().slice(0,2),pe=fe=>{const we=fe.target.value,Ie=fe.target.selectionStart;s(we);const Ne=we.substring(0,Ie),Ae=Ne.lastIndexOf("@"),Fe=u?Ne.lastIndexOf("#"):-1;let Ce=-1,Me="user";if(Ae>Fe?(Ce=Ae,Me="user"):Fe>Ae&&u&&(Ce=Fe,Me="template"),Ce!==-1){const $e=Ne.substring(Ce+1),ct=$e.includes(" "),Te=$e.includes(` `);if(!ct&&!Te&&$e.length<=30){M(Ce),N($e),j(Me),b(!0),L(0);return}}b(!1),M(null)},xe=fe=>{if(C===null)return;const we=t.substring(0,C),Ie=t.substring(C+w.length+1),Ne=_==="user"?"@":"#",Ae=c==="plain"?`${Ne}${fe.name} `:`${Ne}[${fe.name}](${fe.id}) `;c==="plain"&&(_==="user"?U.current.set(fe.name,fe.id):B.current.set(fe.name,fe.id));const Fe=we+Ae+Ie;s(Fe),b(!1),M(null),N(""),setTimeout(()=>{if(p.current){const Ce=we.length+Ae.length;p.current.focus(),p.current.setSelectionRange(Ce,Ce)}},0)},_e=fe=>{if(!(!g||re.length===0))switch(fe.key){case"ArrowDown":fe.preventDefault(),L(we=>(we+1)%re.length);break;case"ArrowUp":fe.preventDefault(),L(we=>(we-1+re.length)%re.length);break;case"Enter":re[I]&&(fe.preventDefault(),xe(re[I]));break;case"Escape":fe.preventDefault(),b(!1);break;case"Tab":re[I]&&(fe.preventDefault(),xe(re[I]));break}};return k.useEffect(()=>{const fe=we=>{f.current&&!f.current.contains(we.target)&&p.current&&!p.current.contains(we.target)&&b(!1)};return document.addEventListener("mousedown",fe),()=>document.removeEventListener("mousedown",fe)},[]),k.useEffect(()=>{if(!g)return;const fe=()=>{const we=p.current;if(!we)return;const Ie=we.getBoundingClientRect();q({top:Ie.bottom+4,left:Ie.left,width:Ie.width})};return fe(),window.addEventListener("resize",fe),window.addEventListener("scroll",fe,!0),()=>{window.removeEventListener("resize",fe),window.removeEventListener("scroll",fe,!0)}},[g,t]),e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Er,{ref:p,value:t,onChange:pe,onKeyDown:fe=>{_e(fe),fe.defaultPrevented||i==null||i(fe)},placeholder:r,className:Pt("resize-none",n),style:{minHeight:a}}),g&&gp.createPortal(e.jsxs("div",{ref:f,className:"fixed z-[1000] max-h-[220px] overflow-hidden rounded-lg border bg-popover shadow-lg",style:{top:R.top,left:R.left,width:R.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:w.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((fe,we)=>e.jsx("li",{className:Pt("flex items-center gap-2 px-3 py-2 cursor-pointer transition-colors",we===I?"bg-accent":"hover:bg-accent/50"),onClick:()=>xe(fe),onMouseEnter:()=>L(we),children:_==="user"?e.jsxs(e.Fragment,{children:[e.jsxs(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:fe.avatar_url}),e.jsx(wn,{className:"text-xs",children:le(fe.name)})]}),e.jsx("span",{className:"text-sm font-medium truncate",children:fe.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:fe.preview_image_url?e.jsx("img",{src:fe.preview_image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(sc,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:fe.name})]})},fe.id))})]}),document.body)]})}function MUt(t){const s=/#\[([^\]]+)\]\(([^)]+)\)/g,r=[];let n;for(;(n=s.exec(t))!==null;)r.push(n[2]);return[...new Set(r)]}const l8e=t=>t.split(" ").map(s=>s[0]).join("").toUpperCase().slice(0,2);function Xet({comment:t,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l=0}){const i=es(),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState([]),_=Lt({mutationFn:async({content:C,parentCommentId:M})=>{const{data:I,error:L}=await H.from("community_comments").insert({post_id:s,user_id:r,content:C,parent_comment_id:M}).select("id").single();if(L)throw L;const R=g;if(R.length>0&&I){const q=R.filter(U=>U!==r).map(U=>({comment_id:I.id,mentioned_user_id:U,mentioned_by_user_id:r}));q.length>0&&await H.from("community_comment_mentions").insert(q)}},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),f(""),b([]),u(!1)}}),j=Lt({mutationFn:async C=>{const{error:M}=await H.from("community_comments").delete().eq("id",C);if(M)throw M},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),w=()=>{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(_n,{className:"h-8 w-8 shrink-0",children:[e.jsx(za,{src:t.user_avatar||void 0}),e.jsx(wn,{className:"text-xs",children:l8e(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(Eke,{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:_d(new Date(t.created_at),{addSuffix:!0})}),e.jsx(CUt,{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(bL,{className:"h-3 w-3"}),"Reply"]}),(t.user_id===r||o)&&e.jsx("button",{onClick:()=>j.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(_n,{className:"h-6 w-6 shrink-0 mt-1",children:[e.jsx(za,{src:n||void 0}),e.jsx(wn,{className:"text-xs",children:l8e((a==null?void 0:a.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2 items-start",children:[e.jsx(Rle,{placeholder:`Reply to ${t.user_name}...`,value:p,onChange:f,onMentionsChange:b,mentionFormat:"plain",className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:w,disabled:!p.trim()||_.isPending,className:"h-8 px-2 mt-0.5",children:e.jsx(Rn,{className:"h-3 w-3"})})]})]})]})]}),t.replies&&t.replies.length>0&&e.jsx("div",{className:"mt-2 space-y-2",children:t.replies.map(C=>e.jsx(Xet,{comment:C,postId:s,currentUserId:r,currentUserAvatar:n,currentUserEmail:a,canModerate:o,depth:l+1},C.id))})]})}const wz=[{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"}],TUt=()=>{const{user:t,isBrokerageManager:s,managedBrokerages:r,isAdmin:n}=Rs(),{avatarUrl:a}=IZe(t==null?void 0:t.id),{onlineUsers:o}=DYe(),{toast:l}=qa(),i=es(),c=k.useRef(null),[u,p]=k.useState("all"),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(""),[N,C]=k.useState([]),[M,I]=k.useState([]),[L,R]=k.useState(""),[q,U]=k.useState(!1),[B,V]=k.useState(null),[Y,J]=k.useState(""),[te,X]=k.useState(new Set),[ce,ne]=k.useState({}),[re,le]=k.useState({}),[pe,xe]=k.useState([]),[_e,fe]=k.useState([]),[we,Ie]=k.useState({open:!1,images:[],index:0});k.useEffect(()=>{if(u.startsWith("group:")){const at=u.replace("group:","");w(at),_("")}else u!=="all"?(_(u),w("")):(_(""),w(""))},[u]);const{data:Ne=[]}=mt({queryKey:["community-categories"],queryFn:async()=>{const{data:at,error:It}=await H.from("community_categories").select("*").order("sort_order");if(It)throw It;return at}}),{data:Ae=[]}=mt({queryKey:["community-private-groups"],queryFn:async()=>{const{data:at,error:It}=await H.from("community_private_groups").select("id, name, description, icon, brokerage_id, sort_order").order("sort_order");if(It)throw It;return at}}),Fe=20,{data:Ce,isLoading:Me,hasNextPage:$e,fetchNextPage:ct,isFetchingNextPage:Te}=rUe({queryKey:["community-posts",u],initialPageParam:0,queryFn:async({pageParam:at})=>{var Be;const It=at*Fe,Ut=It+Fe;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(It,Ut);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:Yt,error:ts}=await hs;if(ts)throw ts;const Ds=((Yt==null?void 0:Yt.length)||0)>Fe,vr=(Yt||[]).slice(0,Fe);if(vr.length===0)return{posts:[],hasMore:!1,nextPage:at+1};const Ct=vr.map(Ye=>Ye.id),As=[...new Set(vr.filter(Ye=>Ye.category_id).map(Ye=>Ye.category_id))].filter(Boolean),[Us,kr,ta,ka,Li]=await Promise.all([As.length?H.from("community_categories").select("*").in("id",As):Promise.resolve({data:[]}),H.from("community_post_media").select("*").in("post_id",Ct).order("sort_order"),H.from("community_reactions").select("*").in("post_id",Ct),H.from("community_comments").select("*").in("post_id",Ct).order("created_at",{ascending:!0}),H.from("community_post_resources").select("*").in("post_id",Ct)]),Wa=Us==null?void 0:Us.data,cr=kr==null?void 0:kr.data,Qr=ta==null?void 0:ta.data,Hr=ka==null?void 0:ka.data,ln=Li==null?void 0:Li.data,Zr=(Hr||[]).map(Ye=>Ye.id),[yi,pt]=await Promise.all([Zr.length?H.from("community_comment_reactions").select("*").in("comment_id",Zr):Promise.resolve({data:[]}),(()=>{const Ye=(ln||[]).filter(vt=>vt.resource_type==="template").map(vt=>vt.resource_id);return Ye.length===0?Promise.resolve({data:[]}):H.from("canva_templates").select("id, name, preview_image_url").in("id",Ye)})()]),ir=(yi==null?void 0:yi.data)||[],Bn=(pt==null?void 0:pt.data)||[],Cr=new Map(Bn.map(Ye=>[Ye.id,{name:Ye.name,preview_image_url:Ye.preview_image_url}])),jr=Array.from(new Set([...vr.map(Ye=>Ye.user_id),...(Qr||[]).map(Ye=>Ye.user_id),...(Hr||[]).map(Ye=>Ye.user_id),...ir.map(Ye=>Ye.user_id)])),[Xn,Aa]=await Promise.all([jr.length?H.from("profiles").select("id, name").in("id",jr):Promise.resolve({data:[]}),LZe(jr)]),Pi=new Map(((Be=Xn==null?void 0:Xn.data)==null?void 0:Be.map(Ye=>[Ye.id,Ye.name]))||[]),Oo=new Map((Wa||[]).map(Ye=>[Ye.id,Ye])),$t=Ye=>{const vt=new Map,xt=[];return Ye.forEach(Rt=>{vt.set(Rt.id,{...Rt,user_name:Pi.get(Rt.user_id)||"Unknown User",user_avatar:Aa.get(Rt.user_id),reactions:ir.filter(Zt=>Zt.comment_id===Rt.id).map(Zt=>({...Zt,user_name:Pi.get(Zt.user_id)||"Unknown User",user_avatar:Aa.get(Zt.user_id)})),replies:[]})}),Ye.forEach(Rt=>{const Zt=vt.get(Rt.id);if(Rt.parent_comment_id&&vt.has(Rt.parent_comment_id)){const Vt=vt.get(Rt.parent_comment_id);Vt.replies=Vt.replies||[],Vt.replies.push(Zt)}else xt.push(Zt)}),xt};return{posts:vr.map(Ye=>{const vt=(ln||[]).filter(xt=>xt.post_id===Ye.id).map(xt=>{let Rt="",Zt=null;if(xt.resource_type==="template"){const Vt=Cr.get(xt.resource_id);Rt=(Vt==null?void 0:Vt.name)||"Unknown Template",Zt=(Vt==null?void 0:Vt.preview_image_url)||null}return{id:xt.id,resource_type:xt.resource_type,resource_id:xt.resource_id,resource_name:Rt,resource_preview_url:Zt}});return{...Ye,user_name:Pi.get(Ye.user_id)||"Unknown User",user_avatar:Aa.get(Ye.user_id),category:Ye.category_id?Oo.get(Ye.category_id):null,media:(cr||[]).filter(xt=>xt.post_id===Ye.id),reactions:((Qr||[]).filter(xt=>xt.post_id===Ye.id)||[]).map(xt=>({...xt,user_name:Pi.get(xt.user_id)||"Unknown User",user_avatar:Aa.get(xt.user_id)})),comments:$t((Hr||[]).filter(xt=>xt.post_id===Ye.id)),resources:vt}}),hasMore:Ds,nextPage:at+1}},getNextPageParam:at=>at.hasMore?at.nextPage:void 0}),ft=k.useMemo(()=>(Ce==null?void 0:Ce.pages.flatMap(at=>at.posts))??[],[Ce]),me=Lt({mutationFn:async()=>{U(!0);const{data:at,error:It}=await H.from("community_posts").insert({user_id:t.id,category_id:j?null:b||null,private_group_id:j||null,content:f,link_url:L||null}).select().single();if(It)throw It;for(let hs=0;hs0){const hs=pe.filter(Yt=>Yt!==t.id).map(Yt=>({post_id:at.id,mentioned_user_id:Yt,mentioned_by_user_id:t.id}));hs.length>0&&await H.from("community_post_mentions").insert(hs)}const Ut=MUt(f);if(Ut.length>0){const hs=Ut.map(Yt=>({post_id:at.id,resource_type:"template",resource_id:Yt}));await H.from("community_post_resources").insert(hs)}return at},onSuccess:async at=>{var It;i.invalidateQueries({queryKey:["community-posts"]}),g(""),xe([]),fe([]),_(""),w(""),C([]),I([]),R(""),l({title:"Post created!"});try{const Ut=((It=t==null?void 0:t.user_metadata)==null?void 0:It.name)||"Someone",hs=f.replace(/@\[([^\]]+)\]\([^)]+\)/g,"@$1"),Yt=hs.length>50?hs.substring(0,50)+"...":hs;await H.functions.invoke("send-push-notification",{body:{title:"New Community Post",body:`${Ut}: ${Yt}`,url:"/community"}})}catch(Ut){console.error("Failed to send push notification:",Ut)}},onError:at=>{l({title:"Error creating post",description:at.message,variant:"destructive"})},onSettled:()=>U(!1)}),Ve=Lt({mutationFn:async({postId:at,content:It})=>{const{error:Ut}=await H.from("community_posts").update({content:It}).eq("id",at);if(Ut)throw Ut},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),V(null),J(""),l({title:"Post updated!"})}}),nt=Lt({mutationFn:async at=>{const{error:It}=await H.from("community_posts").delete().eq("id",at);if(It)throw It},onSuccess:()=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:"Post deleted"})}}),et=Lt({mutationFn:async({postId:at,isPinned:It})=>{const{error:Ut}=await H.from("community_posts").update({is_pinned:!It,pinned_at:It?null:new Date().toISOString(),pinned_by:It?null:t==null?void 0:t.id}).eq("id",at);if(Ut)throw Ut},onSuccess:(at,{isPinned:It})=>{i.invalidateQueries({queryKey:["community-posts"]}),l({title:It?"Post unpinned":"Post pinned to top"})}}),Se=Lt({mutationFn:async({postId:at,reactionType:It})=>{var hs;const Ut=(hs=ft.find(Yt=>Yt.id===at))==null?void 0:hs.reactions.find(Yt=>Yt.user_id===(t==null?void 0:t.id));Ut?Ut.reaction_type===It?await H.from("community_reactions").delete().eq("id",Ut.id):await H.from("community_reactions").update({reaction_type:It}).eq("id",Ut.id):await H.from("community_reactions").insert({post_id:at,user_id:t.id,reaction_type:It})},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})}),rt=Lt({mutationFn:async({postId:at,content:It})=>{const{data:Ut,error:hs}=await H.from("community_comments").insert({post_id:at,user_id:t.id,content:It}).select("id").single();if(hs)throw hs;const Yt=re[at]||[];if(Yt.length>0&&Ut){const ts=Yt.filter(Ds=>Ds!==t.id).map(Ds=>({comment_id:Ut.id,mentioned_user_id:Ds,mentioned_by_user_id:t.id}));ts.length>0&&await H.from("community_comment_mentions").insert(ts)}},onSuccess:(at,{postId:It})=>{i.invalidateQueries({queryKey:["community-posts"]}),ne(Ut=>({...Ut,[It]:""})),le(Ut=>({...Ut,[It]:[]}))}});Lt({mutationFn:async at=>{const{error:It}=await H.from("community_comments").delete().eq("id",at);if(It)throw It},onSuccess:()=>i.invalidateQueries({queryKey:["community-posts"]})});const Ge=at=>{const It=Array.from(at.target.files||[]);if(It.length+N.length>10){l({title:"Maximum 10 files allowed",variant:"destructive"});return}C(Ut=>[...Ut,...It]),It.forEach(Ut=>{const hs=new FileReader;hs.onloadend=()=>{I(Yt=>[...Yt,hs.result])},hs.readAsDataURL(Ut)})},lt=at=>{C(It=>It.filter((Ut,hs)=>hs!==at)),I(It=>It.filter((Ut,hs)=>hs!==at))},qe=at=>at.split(" ").map(It=>It[0]).join("").toUpperCase().slice(0,2),Ze=at=>{const It={};return at.forEach(Ut=>{It[Ut.reaction_type]=(It[Ut.reaction_type]||0)+1}),It},Je=at=>{var It;return(It=at.find(Ut=>Ut.user_id===(t==null?void 0:t.id)))==null?void 0:It.reaction_type},He=at=>at.reduce((It,Ut)=>It+1+(Ut.replies?He(Ut.replies):0),0),Qe=at=>{if(n)return!0;if(!s||!at.private_group_id)return!1;const It=Ae.find(Ut=>Ut.id===at.private_group_id);return It!=null&&It.brokerage_id?r.some(Ut=>Ut.id===It.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(uUt,{categories:Ne,privateGroups:Ae,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(hUt,{categories:Ne,privateGroups:Ae,selectedFilter:u,onFilterChange:p,onlineUsers:o}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsxs(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:a||void 0}),e.jsx(wn,{children:t!=null&&t.email?qe(t.email.split("@")[0]):"U"})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx(Rle,{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:xe,onTemplatesChange:fe,mentionFormat:"encoded",minHeight:"80px",enableTemplateMentions:n}),M.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:M.map((at,It)=>{var Ut;return e.jsxs("div",{className:"relative aspect-square rounded-lg overflow-hidden bg-muted",children:[(Ut=N[It])!=null&&Ut.type.startsWith("video/")?e.jsx("video",{src:at,className:"w-full h-full object-cover"}):e.jsx("img",{src:at,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:()=>lt(It),children:e.jsx(Or,{className:"h-3 w-3"})})]},It)})}),L&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:L,onChange:at=>R(at.target.value),placeholder:"https://...",className:"flex-1"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>R(""),children:e.jsx(Or,{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:Ge,accept:"image/*,video/*",multiple:!0,className:"hidden"}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var at;return(at=c.current)==null?void 0:at.click()},children:[e.jsx(fl,{className:"h-4 w-4 mr-1"}),"Photo"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>{var at;return(at=c.current)==null?void 0:at.click()},children:[e.jsx(Cn,{className:"h-4 w-4 mr-1"}),"Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>R("https://"),children:[e.jsx(zo,{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:[Ae.length>0?e.jsxs(Ys,{value:j||b||"none",onValueChange:at=>{at==="none"?(_(""),w("")):at.startsWith("group:")?(w(at.replace("group:","")),_("")):(_(at),w(""))},children:[e.jsx(Gs,{className:"w-[130px] sm:w-[160px] h-8 text-xs sm:text-sm",children:e.jsx(Qs,{placeholder:"Select..."})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No category"}),Ne.map(at=>e.jsxs(Mt,{value:at.id,children:[at.icon," ",at.name]},at.id)),Ae.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"}),Ae.map(at=>e.jsxs(Mt,{value:`group:${at.id}`,children:[at.icon||"🔒"," ",at.name]},at.id))]})]})]}):e.jsxs(Ys,{value:b,onValueChange:_,children:[e.jsx(Gs,{className:"w-[110px] sm:w-[140px] h-8 text-xs sm:text-sm",children:e.jsx(Qs,{placeholder:"Category"})}),e.jsx(Ks,{children:Ne.map(at=>e.jsxs(Mt,{value:at.id,children:[at.icon," ",at.name]},at.id))})]}),e.jsxs(K,{size:"sm",onClick:()=>me.mutate(),disabled:!f.trim()||q,children:[e.jsx(Rn,{className:"h-4 w-4 mr-1"}),"Post"]})]})]})]})]})})}),Me?e.jsx("div",{className:"space-y-4",children:[...Array(3)].map((at,It)=>e.jsx(Pe,{children:e.jsx(Re,{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"})]})]})})},It))}):ft.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(zc,{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:[ft.map(at=>{var It,Ut,hs,Yt;return e.jsx(Pe,{children:e.jsxs(Re,{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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:at.user_avatar||void 0}),e.jsx(wn,{children:qe(at.user_name||"U")})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold break-words",children:at.user_name}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{children:_d(new Date(at.created_at),{addSuffix:!0})}),at.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[at.category.icon," ",at.category.name]})]})]})]})]}),(at.user_id===(t==null?void 0:t.id)||Qe(at))&&e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",children:[Qe(at)&&at.private_group_id&&e.jsx(Ca,{onClick:()=>et.mutate({postId:at.id,isPinned:at.is_pinned}),children:at.is_pinned?e.jsxs(e.Fragment,{children:[e.jsx(fL,{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"]})}),at.user_id===(t==null?void 0:t.id)&&e.jsxs(Ca,{onClick:()=>{V(at),J(at.content)},children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ca,{className:"text-destructive",onClick:()=>nt.mutate(at.id),children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),at.user_id!==(t==null?void 0:t.id)?"Remove (Moderate)":"Delete"]})]})]})]}),at.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(Eke,{content:at.content})}),at.media.length>0&&e.jsx("div",{className:`grid gap-2 mb-3 ${at.media.length===1?"grid-cols-1":at.media.length===2?"grid-cols-2":at.media.length===3?"grid-cols-3":"grid-cols-2"}`,children:at.media.slice(0,4).map((ts,Ds)=>{const vr=Ds===3&&at.media.length>4,Ct=at.media.length-4;return e.jsxs("div",{className:`relative rounded-lg overflow-hidden bg-muted cursor-pointer group ${at.media.length===1?"max-h-[500px]":at.media.length===2?"aspect-[4/3]":"aspect-square"}`,onClick:()=>Ie({open:!0,images:at.media.map(As=>({url:As.media_url,type:As.media_type==="video"?"video":"image"})),index:Ds}),children:[ts.media_type==="video"?e.jsx("video",{src:ts.media_url,className:"w-full h-full object-cover transition-transform group-hover:scale-105"}):e.jsx("img",{src:ts.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"})})})}),vr&&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:["+",Ct]})})]},ts.id)})}),at.link_url&&e.jsxs("a",{href:at.link_url,target:"_blank",rel:"noopener noreferrer",className:"block rounded-lg border hover:bg-muted transition-colors mb-3 overflow-hidden",children:[at.link_image&&e.jsx("div",{className:"aspect-video bg-muted",children:e.jsx("img",{src:at.link_image,alt:at.link_title||"Link preview",className:"w-full h-full object-cover",onError:ts=>{ts.currentTarget.style.display="none"}})}),e.jsx("div",{className:"p-3",children:at.link_title?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"font-medium text-foreground line-clamp-2",children:at.link_title}),at.link_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:at.link_description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 truncate",children:new URL(at.link_url).hostname})]}):e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary",children:[e.jsx(zo,{className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:at.link_url})]})})]}),at.reactions.length>0&&e.jsx(Yet,{reactions:at.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(at.reactions)).slice(0,3).map(([ts])=>{var Ds;return e.jsx("span",{className:"text-base",children:(Ds=wz.find(vr=>vr.type===ts))==null?void 0:Ds.emoji},ts)})}),e.jsx("span",{children:at.reactions.length})]})}),e.jsxs("div",{className:"flex items-center gap-1 border-t border-b py-1 my-2",children:[e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",children:[Je(at.reactions)?e.jsx("span",{className:"mr-1",children:(It=wz.find(ts=>ts.type===Je(at.reactions)))==null?void 0:It.emoji}):e.jsx(eh,{className:"h-4 w-4 mr-1"}),Je(at.reactions)?(Ut=wz.find(ts=>ts.type===Je(at.reactions)))==null?void 0:Ut.label:"Like"]})}),e.jsx(Do,{className:"w-auto p-2",side:"top",children:e.jsx("div",{className:"flex gap-1",children:wz.map(ts=>e.jsx("button",{onClick:()=>Se.mutate({postId:at.id,reactionType:ts.type}),className:"text-2xl hover:scale-125 transition-transform p-1",title:ts.label,children:ts.emoji},ts.type))})})]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"flex-1",onClick:()=>X(ts=>{const Ds=new Set(ts);return Ds.has(at.id)?Ds.delete(at.id):Ds.add(at.id),Ds}),children:[e.jsx(zc,{className:"h-4 w-4 mr-1"}),(()=>{const ts=He(at.comments);return ts>0?`Comment (${ts})`:"Comment"})()]})]}),te.has(at.id)&&e.jsxs("div",{className:"space-y-3 mt-3",children:[at.comments.map(ts=>e.jsx(Xet,{comment:ts,postId:at.id,currentUserId:t==null?void 0:t.id,currentUserAvatar:a,currentUserEmail:t==null?void 0:t.email,canModerate:Qe(at)},ts.id)),t&&e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:a||void 0}),e.jsx(wn,{className:"text-xs",children:qe(((hs=t.email)==null?void 0:hs.split("@")[0])||"U")})]}),e.jsxs("div",{className:"flex-1 flex gap-2",children:[e.jsx(Rle,{placeholder:"Write a comment... (use @ to mention)",value:ce[at.id]||"",onChange:ts=>ne(Ds=>({...Ds,[at.id]:ts})),onMentionsChange:ts=>le(Ds=>({...Ds,[at.id]:ts})),mentionFormat:"plain",onKeyDown:ts=>{var Ds;ts.defaultPrevented||ts.key==="Enter"&&!ts.shiftKey&&((Ds=ce[at.id])!=null&&Ds.trim())&&(ts.preventDefault(),rt.mutate({postId:at.id,content:ce[at.id]}))},className:"text-sm min-h-0 py-1.5",minHeight:"32px"}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{var ts;(ts=ce[at.id])!=null&&ts.trim()&&rt.mutate({postId:at.id,content:ce[at.id]})},disabled:!((Yt=ce[at.id])!=null&&Yt.trim()),className:"h-8 px-2 mt-0.5",children:e.jsx(Rn,{className:"h-4 w-4"})})]})]})]})]})},at.id)}),$e&&e.jsx("div",{className:"flex justify-center pt-2",children:e.jsx(K,{variant:"outline",onClick:()=>ct(),disabled:Te,children:Te?"Loading…":"Load more posts"})})]}),e.jsx(xs,{open:!!B,onOpenChange:()=>V(null),children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Edit Post"})}),e.jsx(Er,{value:Y,onChange:at=>J(at.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&&Ve.mutate({postId:B.id,content:Y})},disabled:!Y.trim(),children:"Save Changes"})]})]})}),e.jsx(SUt,{images:we.images,initialIndex:we.index,open:we.open,onOpenChange:at=>Ie(It=>({...It,open:at}))})]})]})})},w5={open:{label:"Open",icon:mn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:zc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:xc,color:"bg-muted-foreground"}},c8e={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function AUt(){const{user:t}=Rs(),s=es(),[r,n]=k.useState(null),[a,o]=k.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(""),he.success("Reply sent!")},onError:()=>{he.error("Failed to send reply")}}),p=()=>{a.trim()&&u.mutate(a)};if(r){const f=w5[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(ri,{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(tt,{variant:"secondary",children:c8e[r.category]}),e.jsxs(tt,{className:w5[r.status].color,children:[e.jsx(f,{className:"h-3 w-3 mr-1"}),w5[r.status].label]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(xr,{children:["Created on ",ps(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(Gi,{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 b;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":((b=g.profiles)==null?void 0:b.name)||"You"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(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(sl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{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(Rn,{className:"h-4 w-4"})})]})]})]})]})]})})}return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{className:"bg-gradient-to-br from-primary/10 via-primary/5 to-background border-primary/20",children:e.jsx(Re,{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(Lv,{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(d1e,{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(Un,{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(d1e,{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(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"text-center py-12",children:[e.jsx(zc,{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=w5[f.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(f),children:e.jsx(Re,{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(tt,{variant:"outline",className:"text-xs",children:c8e[f.category]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(new Date(f.created_at),"MMM d, yyyy")})]})]}),e.jsxs(tt,{className:w5[f.status].color,children:[e.jsx(g,{className:"h-3 w-3 mr-1"}),w5[f.status].label]})]})})},f.id)})})]})})}function EUt({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(_s,{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(cn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{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 PUt({open:t,onOpenChange:s}){const{brokerageId:r}=Rs(),[n,a]=k.useState(""),[o,l]=k.useState([]),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["brokerage-agents-for-onboarding",r],queryFn:async()=>{if(!r)return[];const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name",{ascending:!0});if(w)throw w;return j},enabled:t&&!!r}),f=u==null?void 0:u.filter(j=>j.name.toLowerCase().includes(n.toLowerCase())||j.email.toLowerCase().includes(n.toLowerCase())),g=j=>{l(w=>w.includes(j)?w.filter(N=>N!==j):[...w,j])},b=async()=>{if(o.length===0){he.error("Please select at least one agent");return}c(!0);try{const{data:j,error:w}=await H.functions.invoke("send-onboarding-link",{body:{agentIds:o}});if(w)throw w;he.success(`Onboarding link sent to ${o.length} agent${o.length>1?"s":""}`),l([]),s(!1)}catch(j){console.error("Error sending onboarding link:",j),he.error(j.message||"Failed to send onboarding link")}finally{c(!1)}},_=j=>{j||(l([]),a("")),s(j)};return e.jsx(xs,{open:t,onOpenChange:_,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{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(Rn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{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(hn,{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:j=>a(j.target.value),className:"pl-10"})]}),p?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{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(mr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No agents found"})]}):e.jsx(Gi,{className:"h-[300px] border rounded-lg",children:e.jsx("div",{className:"p-2 space-y-1",children:f==null?void 0:f.map(j=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-muted cursor-pointer",onClick:()=>g(j.id),children:[e.jsx(Lo,{checked:o.includes(j.id),onCheckedChange:()=>g(j.id)}),e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{className:"text-xs",children:j.name.split(" ").map(w=>w[0]).join("").toUpperCase()})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:j.name}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:j.email})]})]},j.id))})}),o.length>0&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:[o.length," agent",o.length>1?"s":""," selected"]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:b,disabled:o.length===0||i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Send Link"]})})]})]})})}function IUt(){const[t,s]=k.useState(!1),[r,n]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Dt,{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(mr,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Agent Onboarding"}),e.jsx(xr,{children:"Schedule onboarding sessions for yourself or your agents"})]})]})}),e.jsx(Re,{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(cn,{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(Rn,{className:"h-4 w-4"}),"Send New Agent Onboarding Link"]})]})})]}),e.jsx(EUt,{open:t,onOpenChange:s}),e.jsx(PUt,{open:r,onOpenChange:n})]})}function LUt({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(_s,{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(p0,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(bs,{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 DUt(){const[t,s]=k.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{className:"mb-8",children:[e.jsx(Dt,{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(p0,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Launch or ReLaunch Meeting"}),e.jsx(xr,{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(Re,{children:e.jsxs(K,{onClick:()=>s(!0),className:"flex items-center gap-2",children:[e.jsx(p0,{className:"h-4 w-4"}),"Schedule Launch Meeting"]})})]}),e.jsx(LUt,{open:t,onOpenChange:s})]})}function OUt(){const t=pr(),[s,r]=k.useState(""),[n,a]=k.useState(null),{data:o,isLoading:l}=mt({queryKey:["brokerage-resources-published"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resources").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(w)throw w;return j}}),{data:i}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(w)throw w;return j}}),{data:c}=mt({queryKey:["brokerage-resource-pdfs-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_pdfs").select("resource_id");if(w)throw w;return j}}),{data:u}=mt({queryKey:["brokerage-resource-videos-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_videos").select("resource_id");if(w)throw w;return j}}),{data:p}=mt({queryKey:["brokerage-resource-links-all"],queryFn:async()=>{const{data:j,error:w}=await H.from("brokerage_resource_links").select("resource_id");if(w)throw w;return j}}),f=o==null?void 0:o.filter(j=>{var C;const w=j.title.toLowerCase().includes(s.toLowerCase())||((C=j.description)==null?void 0:C.toLowerCase().includes(s.toLowerCase())),N=!n||j.category_id===n;return w&&N}),g=i==null?void 0:i.filter(j=>o==null?void 0:o.some(w=>w.category_id===j.id)),b=j=>{const w=(c==null?void 0:c.filter(M=>M.resource_id===j).length)||0,N=(u==null?void 0:u.filter(M=>M.resource_id===j).length)||0,C=(p==null?void 0:p.filter(M=>M.resource_id===j).length)||0;return{pdfCount:w,videoCount:N,linkCount:C}},_=j=>{t(`/brokerage-resources/${j}`)};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(IUt,{}),e.jsx(DUt,{}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(hn,{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:j=>r(j.target.value),className:"pl-10"})]}),g&&g.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(tt,{variant:n===null?"default":"outline",className:"cursor-pointer",onClick:()=>a(null),children:"All"}),g.map(j=>e.jsx(tt,{variant:n===j.id?"default":"outline",className:"cursor-pointer",onClick:()=>a(j.id),children:j.name},j.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((j,w)=>e.jsxs(Pe,{children:[e.jsx(vs,{className:"h-40 w-full"}),e.jsx(Dt,{children:e.jsx(vs,{className:"h-5 w-3/4"})}),e.jsxs(Re,{children:[e.jsx(vs,{className:"h-4 w-full mb-2"}),e.jsx(vs,{className:"h-4 w-2/3"})]})]},w))}):(f==null?void 0:f.length)===0?e.jsxs(Pe,{className:"p-12 text-center",children:[e.jsx(Wh,{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(j=>{const{pdfCount:w,videoCount:N,linkCount:C}=b(j.id),M=i==null?void 0:i.find(I=>I.id===j.category_id);return e.jsxs(Pe,{className:"overflow-hidden cursor-pointer hover:shadow-lg transition-shadow",onClick:()=>_(j.id),children:[j.preview_image_url?e.jsx("img",{src:j.preview_image_url,alt:j.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(Wh,{className:"h-16 w-16 text-muted-foreground"})}),e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(zt,{className:"text-lg line-clamp-1",children:j.title}),M&&e.jsx(tt,{variant:"secondary",className:"shrink-0 text-xs",children:M.name})]})}),e.jsxs(Re,{children:[j.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-3",children:j.description}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[w>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(En,{className:"h-4 w-4"}),w]}),N>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-4 w-4"}),N]}),C>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zo,{className:"h-4 w-4"}),C]})]})]})]},j.id)})})]})})}const RUt=()=>{const{resourceId:t}=yo(),{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(Ei,{to:"/brokerage-resources",children:[e.jsx(ri,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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"}),"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(En,{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(Ci,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors"})]},a.id))})]})}),s.links&&s.links.length>0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("h3",{className:"font-semibold flex items-center gap-2 mb-4",children:[e.jsx(an,{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(an,{className:"h-4 w-4 text-primary"})}),e.jsx("div",{className:"font-medium text-sm",children:a.title})]}),e.jsx(an,{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(Wh,{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(Ei,{to:"/brokerage-resources",children:"Back to Resources"})})]})})};function FUt(){const{onlineUsers:t,totalOnline:s}=DYe();return e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Online Now"]}),e.jsxs(tt,{variant:"secondary",className:"bg-green-100 text-green-700",children:[e.jsx(vd,{className:"h-2 w-2 fill-green-500 text-green-500 mr-1"}),s," online"]})]})}),e.jsx(Re,{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(Gi,{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(_n,{className:"h-9 w-9",children:[e.jsx(za,{src:r.avatarUrl,alt:r.name}),e.jsx(wn,{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 ",_d(new Date(r.onlineSince),{addSuffix:!1})]})]})]},r.id)})})})})]})}const d8e={users:{label:"Users & Access",sections:[{title:"Members",description:"Manage users, roles, and brokerage assignments",icon:mr,path:"/admin/members",color:"bg-blue-500/10 text-blue-600"},{title:"Invite Codes",description:"Create and manage signup invite codes",icon:AL,path:"/admin/invite-codes",color:"bg-amber-500/10 text-amber-600"},{title:"Subscriptions",description:"Track and manage user subscriptions",icon:Cx,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:JI,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:Om,path:"/admin/discounts",color:"bg-red-500/10 text-red-600"},{title:"Referral Program",description:"Track brokerage referrals and discounts",icon:bd,path:"/admin/referrals",color:"bg-teal-500/10 text-teal-600"},{title:"Teams",description:"Manage agent teams across all brokerages",icon:mr,path:"/admin/members?tab=teams",color:"bg-violet-500/10 text-violet-600"},{title:"Prospector",description:"Send free trial invites and track conversions",icon:Rm,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:rc,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:sc,path:"/admin/templates",color:"bg-pink-500/10 text-pink-600"},{title:"Manage Academy",description:"Upload videos and training content",icon:Gh,path:"/admin/academy",color:"bg-indigo-500/10 text-indigo-600"},{title:"Manage Toolbox",description:"Create and manage resource kits",icon:Jg,path:"/admin/toolbox",color:"bg-orange-500/10 text-orange-600"},{title:"Social Swag",description:"Manage social media content and links",icon:un,path:"/admin/social-swag",color:"bg-fuchsia-500/10 text-fuchsia-600"},{title:"Social Swag 2.0",description:"New monthly social media images",icon:un,path:"/admin/social-swag-2",color:"bg-cyan-500/10 text-cyan-600"},{title:"Newsletters",description:"Manage monthly newsletter templates",icon:i1,path:"/admin/newsletters",color:"bg-violet-500/10 text-violet-600"},{title:"Manage Events",description:"Create and publish events with Zoom integration",icon:Dd,path:"/admin/events",color:"bg-green-500/10 text-green-600"},{title:"Additional Services",description:"Manage additional service offerings",icon:Wh,path:"/admin/additional-services",color:"bg-lime-500/10 text-lime-600"},{title:"Brokerage Resources",description:"Manage resources for brokerage managers",icon:Wh,path:"/admin/brokerage-resources",color:"bg-slate-500/10 text-slate-600"},{title:"Agent Email Templates",description:"Manage curated email templates for agents",icon:dr,path:"/admin/agent-email-templates",color:"bg-rose-500/10 text-rose-600"}]},platform:{label:"Platform",sections:[{title:"Dashboard Management",description:"Configure banners and dashboard modules",icon:eS,path:"/admin/dashboard-management",color:"bg-teal-500/10 text-teal-600"},{title:"Manage Apps",description:"Configure app tiles and access requirements",icon:nx,path:"/admin/apps",color:"bg-purple-500/10 text-purple-600"},{title:"Email Templates",description:"Customize system email templates",icon:dr,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:Kh,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:wM,path:"/admin/onboarding-checklist",color:"bg-emerald-500/10 text-emerald-600"},{title:"Marketplace",description:"Manage store categories, products, and orders",icon:f0,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:No,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:xo,path:"/admin/agent-points",color:"bg-amber-500/10 text-amber-600"},{title:"Integrations",description:"Connect Canva, Facebook & Instagram for platform-level features",icon:cl,path:"/admin/integrations",color:"bg-blue-500/10 text-blue-600"},{title:"Agent Cards",description:"Manage digital business cards for agents",icon:mr,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:Kh,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:io,path:"/admin/community",color:"bg-cyan-500/10 text-cyan-600"},{title:"Support Tickets",description:"View and respond to agent support requests",icon:AM,path:"/admin/support-tickets",color:"bg-rose-500/10 text-rose-600"},{title:"Wishlist",description:"Review and manage community feature requests",icon:B_,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:dr,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:Ro,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:kh,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:Gh,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:ii,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:Sn,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:Qg,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:kh,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:fl,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:dr,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:F_,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:Su,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:eL,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:Ol,path:"/admin/lead-site-analytics",color:"bg-gradient-to-br from-amber-500/20 to-orange-500/10 text-amber-600"}]}};function zUt(){const t=pr();return 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(FUt,{})})]}),e.jsxs(ja,{defaultValue:"users",className:"w-full",children:[e.jsx(ga,{className:"w-full justify-start flex-wrap h-auto gap-1 bg-muted/50 p-1 overflow-x-auto",children:Object.entries(d8e).map(([s,r])=>e.jsx(us,{value:s,className:"data-[state=active]:bg-background",children:r.label},s))}),Object.entries(d8e).map(([s,r])=>e.jsx(ks,{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(Pe,{className:"cursor-pointer hover:shadow-md transition-all hover:border-primary/50 group",onClick:()=>t(n.path),children:[e.jsxs(Dt,{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(zt,{className:"text-base",children:n.title})]}),e.jsx(Re,{className:"pt-0",children:e.jsx(xr,{className:"text-sm",children:n.description})})]},n.path))})},s))]})]})})}const Ln=k.forwardRef(({className:t,...s},r)=>e.jsx("div",{className:"relative w-full overflow-auto",children:e.jsx("table",{ref:r,className:Pt("w-full caption-bottom text-sm",t),...s})}));Ln.displayName="Table";const Dn=k.forwardRef(({className:t,...s},r)=>e.jsx("thead",{ref:r,className:Pt("[&_tr]:border-b",t),...s}));Dn.displayName="TableHeader";const On=k.forwardRef(({className:t,...s},r)=>e.jsx("tbody",{ref:r,className:Pt("[&_tr:last-child]:border-0",t),...s}));On.displayName="TableBody";const BUt=k.forwardRef(({className:t,...s},r)=>e.jsx("tfoot",{ref:r,className:Pt("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s}));BUt.displayName="TableFooter";const Ss=k.forwardRef(({className:t,...s},r)=>e.jsx("tr",{ref:r,className:Pt("border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50",t),...s}));Ss.displayName="TableRow";const kt=k.forwardRef(({className:t,...s},r)=>e.jsx("th",{ref:r,className:Pt("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s}));kt.displayName="TableHead";const dt=k.forwardRef(({className:t,...s},r)=>e.jsx("td",{ref:r,className:Pt("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s}));dt.displayName="TableCell";const $Ut=k.forwardRef(({className:t,...s},r)=>e.jsx("caption",{ref:r,className:Pt("mt-4 text-sm text-muted-foreground",t),...s}));$Ut.displayName="TableCaption";const qUt=()=>{const{isAdmin:t}=Rs(),s=pr(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[c,u]=k.useState(null);k.useEffect(()=>{if(!t){s("/dashboard");return}p()},[t]);const p=async()=>{try{const{data:j,error:w}=await H.from("app_tiles").select("*").order("name");if(w)throw w;n(j||[])}catch(j){console.error("Error loading apps:",j),he.error("Failed to load apps")}finally{o(!1)}},f=async j=>{j.preventDefault();const w=new FormData(j.currentTarget),N={name:w.get("name"),description:w.get("description"),icon:w.get("icon"),app_id:w.get("app_id"),target_url:w.get("target_url"),required_tags:w.get("required_tags").split(",").map(C=>C.trim()).filter(Boolean)};try{if(c){const{error:C}=await H.from("app_tiles").update(N).eq("id",c.id);if(C)throw C;he.success("App updated successfully")}else{const{error:C}=await H.from("app_tiles").insert([N]);if(C)throw C;he.success("App created successfully")}i(!1),u(null),p()}catch(C){console.error("Error saving app:",C),he.error("Failed to save app")}},g=async j=>{if(confirm("Are you sure you want to delete this app?"))try{const{error:w}=await H.from("app_tiles").delete().eq("id",j);if(w)throw w;he.success("App deleted successfully"),p()}catch(w){console.error("Error deleting app:",w),he.error("Failed to delete app")}},b=j=>{u(j),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(ri,{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(_s,{children:[e.jsx(bs,{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(ye,{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(ye,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{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(ye,{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(ye,{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(ye,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Application Tiles"}),e.jsx(xr,{children:"Manage the apps that appear on the member dashboard"})]}),e.jsx(Re,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"App ID"}),e.jsx(kt,{children:"Target URL"}),e.jsx(kt,{children:"Tags"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:r.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-2xl",children:j.icon}),e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"font-mono text-sm",children:j.app_id}),e.jsx(dt,{className:"text-sm text-muted-foreground max-w-xs truncate",children:j.target_url}),e.jsx(dt,{children:e.jsx("div",{className:"flex flex-wrap gap-1",children:j.required_tags.map(w=>e.jsx("span",{className:"text-xs bg-secondary text-secondary-foreground px-2 py-1 rounded",children:w},w))})}),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:()=>b(j),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>g(j.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},j.id))})]})})]})})]})};function ah({title:t,description:s,children:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ei,{to:"/admin",children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",children:[e.jsx(ri,{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 u8e=({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(tt,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(Gu,{className:"h-3 w-3"}),"Trial Expired"]}):a<=1?e.jsxs(tt,{variant:"destructive",className:Pt("gap-1",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: <1 day left"]}):a<=3?e.jsxs(tt,{className:Pt("gap-1 bg-amber-500 hover:bg-amber-600",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: ",a," days left"]}):e.jsxs(tt,{variant:"secondary",className:Pt("gap-1",s),children:[e.jsx(mn,{className:"h-3 w-3"}),"Trial: ",a," days left"]})},Qet=({open:t,onOpenChange:s,brokerages:r,fixedBrokerageId:n,onSuccess:a})=>{const{toast:o}=qa(),l=k.useRef(null),[i,c]=k.useState([]),[u,p]=k.useState(""),[f,g]=k.useState(!1),[b,_]=k.useState("upload"),[j,w]=k.useState(null),N=()=>{c([]),p(""),_("upload"),w(null),l.current&&(l.current.value="")},C=()=>{N(),s(!1)},M=U=>{const B=U.split(` `).map(X=>X.trim()).filter(X=>X);if(B.length===0)return[];const V=B[0].toLowerCase(),J=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,te=[];for(const X of J){const ne=(X.includes(" ")?X.split(" "):X.split(",")).map(re=>re.trim().replace(/^["']|["']$/g,""));if(ne.length>=2){let re="",le="",pe="",xe="",_e;if(ne.length===2){const Ie=ne[0].split(" ");re=Ie[0]||"",le=Ie.slice(1).join(" ")||"",pe=ne[1]}else if(ne.length===3)re=ne[0],le=ne[1],pe=ne[2];else if(ne.length===4)re=ne[0],le=ne[1],pe=ne[2],xe=ne[3];else if(ne.length>=5){re=ne[0],le=ne[1],pe=ne[2],xe=ne[3];const Ie=ne[4].toLowerCase();_e=Ie==="true"||Ie==="yes"||Ie==="1"||Ie==="y"}const we=/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(pe);te.push({firstName:re.trim(),lastName:le.trim(),email:pe.trim().toLowerCase(),phone:xe.trim()||void 0,smsConsent:_e,isValid:we&&re.trim().length>0,error:we?re.trim()?void 0:"Missing name":"Invalid email"})}}return te},I=U=>{var Y;const B=(Y=U.target.files)==null?void 0:Y[0];if(!B)return;const V=new FileReader;V.onload=J=>{var ce;const te=(ce=J.target)==null?void 0:ce.result,X=M(te);if(X.length===0){o({title:"No data found",description:"The CSV file appears to be empty or in an unsupported format.",variant:"destructive"});return}c(X),_("preview")},V.readAsText(B)},L=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(),Y=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(te=>({firstName:te.firstName,lastName:te.lastName,email:te.email,phone:te.phone,smsConsent:te.smsConsent})),brokerageId:B})}),J=await Y.json();if(!Y.ok)throw new Error(J.error||"Failed to import users");w(J),_("result"),J.created>0&&a(),o({title:"Import Complete",description:`${J.created} user(s) created successfully.${J.failed>0?` ${J.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)}},R=i.filter(U=>U.isValid).length,q=i.filter(U=>!U.isValid).length;return e.jsx(xs,{open:t,onOpenChange:C,children:e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(s1,{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."})]}),b==="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:I,className:"hidden"}),e.jsx(oi,{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."})]})]}),b==="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(ye,{children:"Assign to Brokerage (optional)"}),e.jsxs(Ys,{value:u||"none",onValueChange:U=>p(U==="none"?"":U),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a brokerage..."})}),e.jsxs(Ks,{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(la,{className:"h-4 w-4 text-green-500"}),e.jsxs("span",{children:[R," valid"]})]}),q>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nl,{className:"h-4 w-4"}),e.jsxs("span",{children:[q," invalid"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-auto border rounded-lg",children:[e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(kt,{children:"First Name"}),e.jsx(kt,{children:"Last Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Phone"}),e.jsx(kt,{children:"SMS"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(On,{children:i.slice(0,100).map((U,B)=>e.jsxs(Ss,{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(tt,{variant:"default",className:"bg-green-500/10 text-green-600",children:"Valid"}):e.jsx(tt,{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"]})]})]}),b==="result"&&j&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(la,{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:[j.created," agent(s) created and invited"]}),j.failed>0&&e.jsxs("p",{className:"text-destructive mt-1",children:[j.failed," failed to create"]})]}),j.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:[j.errors.slice(0,10).map((U,B)=>e.jsxs("li",{children:["• ",U]},B)),j.errors.length>10&&e.jsxs("li",{children:["...and ",j.errors.length-10," more"]})]})]})]}),e.jsxs(zn,{children:[b==="upload"&&e.jsx(K,{variant:"outline",onClick:C,children:"Cancel"}),b==="preview"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:N,children:"Back"}),e.jsx(K,{onClick:L,disabled:f||R===0,children:f?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Importing..."]}):`Import ${R} Agent${R!==1?"s":""}`})]}),b==="result"&&e.jsx(K,{onClick:C,children:"Done"})]})]})})};function gl({sortKey:t,currentSortKey:s,currentDirection:r,onSort:n,children:a,className:o,...l}){const i=s===t;return e.jsx(kt,{className:Pt("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(Nu,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(Hh,{className:"h-3.5 w-3.5 shrink-0"}):e.jsx(yd,{className:"h-3.5 w-3.5 shrink-0 opacity-40"})]})})}function KO(t=null,s=null){const[r,n]=k.useState(t),[a,o]=k.useState(s),l=k.useCallback(c=>{r===c?a==="asc"?o("desc"):a==="desc"?(n(null),o(null)):o("asc"):(n(c),o("asc"))},[r,a]),i=k.useCallback((c,u)=>{if(!r||!a||!u[r])return c;const p=u[r];return[...c].sort((f,g)=>{const b=p(f),_=p(g);if(b==null&&_==null)return 0;if(b==null)return 1;if(_==null)return-1;let j;return typeof b=="string"&&typeof _=="string"?j=b.localeCompare(_,void 0,{sensitivity:"base"}):j=b-_,a==="asc"?j:-j})},[r,a]);return{sortKey:r,sortDirection:a,handleSort:l,sortData:i}}const UUt=[{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:xo},{type:"custom",title:"Congratulations!",message:"You earned this celebration!",icon:tu}];function Jet({open:t,onOpenChange:s,userId:r,userName:n}){const[a,o]=k.useState("custom"),[l,i]=k.useState(""),[c,u]=k.useState(""),p=Qjt(),f=b=>{o(b.type),i(b.title),u(b.message)},g=async b=>{if(b.preventDefault(),!l.trim()){vn({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}),vn({title:"Celebration sent! 🎉",description:`${n} will see confetti on their next visit!`}),s(!1),i(""),u(""),o("custom")}catch{vn({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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(tu,{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(ye,{className:"text-sm text-muted-foreground mb-2 block",children:"Quick presets:"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:UUt.map((b,_)=>e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>f(b),className:"text-xs",children:[e.jsx(b.icon,{className:"h-3 w-3 mr-1"}),b.title]},_))})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"type",children:"Celebration Type"}),e.jsxs(Ys,{value:a,onValueChange:b=>o(b),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(xo,{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(Sn,{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(wc,{className:"h-4 w-4"})," Deal Closed"]})})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l,onChange:b=>i(b.target.value),placeholder:"e.g., Congratulations!",maxLength:100})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"message",children:"Message (optional)"}),e.jsx(Er,{id:"message",value:c,onChange:b=>u(b.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(tu,{className:"h-4 w-4 mr-2"}),p.isPending?"Sending...":"Send Celebration"]})]})]})]})})}const Mge={points_earned:{label:"Points Earned",icon:xo,color:"bg-yellow-500"},listing_created:{label:"Listing Created",icon:Sn,color:"bg-blue-500"},deal_closed:{label:"Deal Closed",icon:wc,color:"bg-green-500"},custom:{label:"Custom",icon:un,color:"bg-purple-500"}};function VUt(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.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(j=>j.user_id),...p.map(j=>j.created_by).filter(Boolean)])],{data:b}=await H.from("profiles").select("id, name, email").in("id",g),_=new Map((b==null?void 0:b.map(j=>[j.id,j]))||[]);return p.map(j=>{var w,N,C;return{...j,user_name:((w=_.get(j.user_id))==null?void 0:w.name)||"Unknown",user_email:((N=_.get(j.user_id))==null?void 0:N.email)||"",creator_name:j.created_by?((C=_.get(j.created_by))==null?void 0:C.name)||"System":"Auto-triggered"}})}}),c=l.filter(p=>{var _,j;const f=((_=p.user_name)==null?void 0:_.toLowerCase().includes(t.toLowerCase()))||((j=p.user_email)==null?void 0:j.toLowerCase().includes(t.toLowerCase()))||p.title.toLowerCase().includes(t.toLowerCase()),g=r==="all"||p.celebration_type===r,b=a==="all"||a==="seen"&&p.seen_at||a==="unseen"&&!p.seen_at;return f&&g&&b}),u={total:l.length,seen:l.filter(p=>p.seen_at).length,unseen:l.filter(p=>!p.seen_at).length,byType:Object.keys(Mge).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(ws,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium",children:"Total Celebrations"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:u.total})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-green-600",children:"Seen"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-green-600",children:u.seen})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-orange-600",children:"Pending"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-orange-600",children:u.unseen})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-purple-600",children:"Custom Sent"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold text-purple-600",children:u.byType.custom||0})})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tu,{className:"h-5 w-5"}),"Celebration History"]}),e.jsx(xr,{children:"View all celebrations awarded to agents"})]}),e.jsxs(Re,{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(hn,{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(Ys,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Filter by type"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),Object.entries(Mge).map(([p,f])=>e.jsx(Mt,{value:p,children:f.label},p))]})]}),e.jsxs(Ys,{value:a,onValueChange:o,children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Qs,{placeholder:"Status"})}),e.jsxs(Ks,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Points"}),e.jsx(kt,{children:"Created By"}),e.jsx(kt,{children:"Created"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(On,{children:c.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No celebrations found"})}):c.map(p=>{const f=Mge[p.celebration_type],g=f.icon;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(tt,{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(tt,{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:ps(new Date(p.created_at),"MMM d, yyyy h:mm a")})}),e.jsx(dt,{children:p.seen_at?e.jsx(tt,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200",children:"Seen"}):e.jsx(tt,{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 HUt=()=>{const{user:t}=Rs(),{toast:s}=qa(),[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(!1),[c,u]=k.useState("all"),[p,f]=k.useState("all"),[g,b]=k.useState("new"),[_,j]=k.useState(new Set),w=k.useCallback(async()=>{try{o(!0);const{data:te,error:X}=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(X)throw X;const{data:ce,error:ne}=await H.from("trial_email_exports").select("user_id");if(ne)throw ne;const re=new Set((ce||[]).map(pe=>pe.user_id)),le=(te||[]).map(pe=>({...pe,converted_from_trial_at:pe.converted_from_trial_at??null,already_exported:re.has(pe.id)}));le.sort((pe,xe)=>new Date(xe.created_at).getTime()-new Date(pe.created_at).getTime()),n(le)}catch(te){console.error("Error loading trial users:",te),s({title:"Error",description:"Failed to load trial users",variant:"destructive"})}finally{o(!1)}},[s]);k.useEffect(()=>{w()},[w]);const N=te=>te.trial_started_at?"ghl":"stripe",C=te=>te.trial_expires_at?te.trial_expires_at:te.subscription_end_date?te.subscription_end_date:null,M=te=>te.converted_from_trial_at!==null,I=te=>{if(M(te))return!1;const X=C(te);return X?new Date(X).getTime()<=Date.now():!1},L=r.filter(te=>!(c!=="all"&&N(te)!==c||p==="active"&&(I(te)||M(te))||p==="expired"&&!I(te)||p==="converted"&&!M(te)||g==="new"&&te.already_exported||g==="exported"&&!te.already_exported)),R=()=>{_.size===L.length?j(new Set):j(new Set(L.map(te=>te.id)))},q=te=>{const X=new Set(_);X.has(te)?X.delete(te):X.add(te),j(X)},U=async()=>{if(_.size===0){s({title:"No users selected",description:"Select users to export",variant:"destructive"});return}i(!0);try{const te=r.filter(_e=>_.has(_e.id)),X="First Name,Last Name,Email,Phone,Trial Type,Status,Signup Date,Expiry Date",ce=te.map(_e=>{const fe=(_e.name||"").split(" "),we=fe[0]||"",Ie=fe.slice(1).join(" ")||"",Ne=N(_e)==="stripe"?"Credit Card Trial":"Free Trial (No CC)",Ae=M(_e)?"Converted":I(_e)?"Expired":"Active",Fe=_e.created_at?new Date(_e.created_at).toLocaleDateString():"",Ce=C(_e)?new Date(C(_e)).toLocaleDateString():"";return`"${we}","${Ie}","${_e.email}","${_e.phone||""}","${Ne}","${Ae}","${Fe}","${Ce}"`}),ne=[X,...ce].join(` `),re=new Blob([ne],{type:"text/csv"}),le=URL.createObjectURL(re),pe=document.createElement("a");pe.href=le,pe.download=`trial-users-${new Date().toISOString().split("T")[0]}.csv`,pe.click(),URL.revokeObjectURL(le);const xe=te.filter(_e=>!_e.already_exported).map(_e=>({user_id:_e.id,exported_by:t.id}));if(xe.length>0){const{error:_e}=await H.from("trial_email_exports").upsert(xe,{onConflict:"user_id"});_e&&console.error("Error marking exports:",_e)}s({title:"Export complete",description:`Downloaded ${te.length} trial user(s). ${xe.length} newly marked as exported.`}),j(new Set),w()}catch(te){console.error("Export error:",te),s({title:"Error",description:"Failed to export",variant:"destructive"})}finally{i(!1)}},B=r.filter(te=>!te.already_exported).length,V=r.filter(te=>te.already_exported).length,Y=r.filter(te=>M(te)).length,J=r.filter(te=>!I(te)&&!M(te)).length;return a?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{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(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Total"}),e.jsx(zt,{className:"text-2xl",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"New (Not Exported)"}),e.jsx(zt,{className:"text-2xl text-green-600",children:B})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Active Trials"}),e.jsx(zt,{className:"text-2xl",children:J})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Converted 🎉"}),e.jsx(zt,{className:"text-2xl text-primary",children:Y})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Already Exported"}),e.jsx(zt,{className:"text-2xl text-muted-foreground",children:V})]})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Ys,{value:g,onValueChange:te=>b(te),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:c,onValueChange:te=>u(te),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:p,onValueChange:te=>f(te),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Export Selected (",_.size,")"]})})]}),e.jsx("div",{className:"border rounded-lg",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Lo,{checked:L.length>0&&_.size===L.length,onCheckedChange:R})}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Trial Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Signup Date"}),e.jsx(kt,{children:"Expires / Renews"}),e.jsx(kt,{children:"Exported"})]})}),e.jsx(On,{children:L.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-8 text-muted-foreground",children:"No trial users match the current filters"})}):L.map(te=>{const X=N(te),ce=M(te),ne=I(te),re=C(te);return e.jsxs(Ss,{className:`hover:bg-muted/30 ${ce?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Lo,{checked:_.has(te.id),onCheckedChange:()=>q(te.id)})}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[te.name,ce&&e.jsx(Ol,{className:"h-3.5 w-3.5 text-primary"})]})}),e.jsx(dt,{className:"text-muted-foreground",children:te.email}),e.jsx(dt,{children:X==="stripe"?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Cx,{className:"h-3 w-3"}),"Credit Card"]}):e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(dr,{className:"h-3 w-3"}),"Free (No CC)"]})}),e.jsx(dt,{children:ce?e.jsxs(tt,{className:"bg-primary/10 text-primary hover:bg-primary/20 gap-1",children:[e.jsx(Ol,{className:"h-3 w-3"}),"Converted"]}):ne?e.jsx(tt,{variant:"destructive",children:"Expired"}):e.jsx(tt,{className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active Trial"})}),e.jsx(dt,{className:"text-sm",children:te.created_at?new Date(te.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:te.already_exported?e.jsx(la,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(tt,{variant:"outline",className:"text-green-600 border-green-300",children:"New"})})]},te.id)})})]})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Showing ",L.length," of ",r.length," trial users · ",Y," converted to paid"]})]})},WUt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0);return k.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(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):t.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"User Deletion History"})}),e.jsx(Re,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"User"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Deleted By"})]})}),e.jsx(On,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"whitespace-nowrap text-sm",children:ps(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(tt,{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))})]})})]})},fC=t=>{const{user:s}=Rs(),r=es(),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:b}=await f;if(b)throw b;return g||[]},enabled:!!s}),a=f=>mt({queryKey:["team-members",f],queryFn:async()=>{const{data:g,error:b}=await H.from("team_members").select("*").eq("team_id",f).order("role",{ascending:!0});if(b)throw b;const _=(g||[]).map(N=>N.user_id),{data:j}=await H.from("profiles").select("id, name, email, avatar_url").in("id",_),w=new Map((j||[]).map(N=>[N.id,N]));return(g||[]).map(N=>({...N,profile:w.get(N.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:b,error:_}=await H.from("teams").insert(g).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),he.success("Team created!")},onError:f=>{he.error("Failed to create team: "+f.message)}}),l=Lt({mutationFn:async({id:f,...g})=>{const{data:b,error:_}=await H.from("teams").update(g).eq("id",f).select().single();if(_)throw _;return b},onSuccess:()=>{r.invalidateQueries({queryKey:["teams"]}),he.success("Team updated")},onError:f=>{he.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"]}),he.success("Team deleted")},onError:f=>{he.error("Failed to delete team: "+f.message)}}),c=Lt({mutationFn:async f=>{const{data:g,error:b}=await H.from("team_members").insert({team_id:f.team_id,user_id:f.user_id,role:f.role||"team_member"}).select().single();if(b)throw b.message.includes("duplicate")||b.message.includes("unique")?new Error("This agent is already on a team. They must be removed from their current team first."):b;return g},onSuccess:(f,g)=>{r.invalidateQueries({queryKey:["team-members",g.team_id]}),he.success("Member added to team")},onError:f=>{he.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]}),he.success("Member removed from team")},onError:f=>{he.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]}),he.success("Member role updated")},onError:f=>{he.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}},GUt=()=>{const{user:t}=Rs();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})},ett=t=>{const{user:s}=Rs(),r=es(),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(N=>N.contact_id),p=[...new Set(i.map(N=>N.added_by))],f=i.filter(N=>N.claimed_by).map(N=>N.claimed_by),g=[...new Set([...p,...f])],[b,_]=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)]),j=new Map((b.data||[]).map(N=>[N.id,N])),w=new Map((_.data||[]).map(N=>[N.id,N]));return i.map(N=>({...N,status:N.claimed_by?"claimed":"available",contact:j.get(N.contact_id)||null,contributor:w.get(N.added_by)||null,claimer:N.claimed_by&&w.get(N.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"]}),he.success("Contact added to Lead Pond")},onError:i=>{he.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"]}),he.success("Lead claimed!")},onError:i=>{he.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"]}),he.success("Lead returned to pond")},onError:i=>{he.error(i.message)}});return{leadPondItems:n.data||[],isLoading:n.isLoading,addToLeadPond:a,claimLead:o,returnLead:l}},KUt=()=>{const t=es();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"]}),he.success("Contact transferred successfully")},onError:s=>{he.error(s.message||"Failed to transfer contact")}})};function ttt({open:t,onOpenChange:s,contactIds:r,contactNames:n=[],onComplete:a}){var L;const{user:o}=Rs(),{data:l}=Bx(),{useTeamMembers:i}=fC(),{data:c=[]}=i((l==null?void 0:l.teamId)||""),u=KUt(),[p,f]=k.useState(null),[g,b]=k.useState(""),[_,j]=k.useState(!1),w=c.filter(R=>R.user_id!==(o==null?void 0:o.id)),N=async()=>{if(p){j(!0);try{for(const R of r)await u.mutateAsync({contactId:R,toUserId:p,notes:g||void 0});s(!1),f(null),b(""),a==null||a()}catch{}finally{j(!1)}}},C=w.find(R=>R.user_id===p),M=r.length>1,I=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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Jv,{className:"h-5 w-5"}),"Transfer ",I]}),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(ye,{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:w.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No other team members available"}):w.map(R=>{var q,U,B;return e.jsxs("button",{onClick:()=>f(R.user_id),className:`w-full flex items-center gap-3 p-3 rounded-lg text-left transition-colors ${p===R.user_id?"bg-primary/10 border border-primary/30":"hover:bg-accent border border-transparent"}`,children:[e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:((q=R.profile)==null?void 0:q.avatar_url)||""}),e.jsx(wn,{className:"text-xs",children:(((U=R.profile)==null?void 0:U.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:((B=R.profile)==null?void 0:B.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:R.role.replace("_"," ")})]})]},R.user_id)})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"transfer-notes",className:"text-sm font-medium",children:"Notes (optional)"}),e.jsx(Er,{id:"transfer-notes",value:g,onChange:R=>b(R.target.value),placeholder:"Reason for transfer...",className:"mt-1",rows:2})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:N,disabled:!p||_,children:[_?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Jv,{className:"h-4 w-4 mr-2"}),"Transfer",C?` to ${(L=C.profile)==null?void 0:L.name}`:""]})]})]})})}const Pke=()=>{const t=pr(),{data:s,isLoading:r}=GUt(),{data:n}=Bx(),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState(null),[p,f]=k.useState(""),g=(n==null?void 0:n.role)==="team_leader",b=k.useMemo(()=>{if(!s)return[];const j=new Map;return s.forEach(w=>{j.has(w.owner_user_id)||j.set(w.owner_user_id,{id:w.owner_user_id,name:w.owner_name||"Unknown",avatar:w.owner_avatar_url})}),Array.from(j.values())},[s]),_=k.useMemo(()=>{if(!s)return[];let j=s;if(l!=="all"&&(j=j.filter(w=>w.owner_user_id===l)),a.trim()){const w=a.toLowerCase();j=j.filter(N=>{var C,M,I;return(N.first_name+" "+(N.last_name||"")).toLowerCase().includes(w)||((C=N.email)==null?void 0:C.toLowerCase().includes(w))||((M=N.phone)==null?void 0:M.includes(w))||((I=N.owner_name)==null?void 0:I.toLowerCase().includes(w))})}return j},[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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{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(Pe,{children:e.jsx(Re,{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(hn,{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:j=>o(j.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Qs,{placeholder:"Filter by agent"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Team Members"}),b.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))]})]})]})})}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[_.length," contact",_.length!==1?"s":""," from ",b.length," teammate",b.length!==1?"s":""]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Contact Info"}),e.jsx(kt,{children:"Address"}),e.jsx(kt,{children:"Lead Source"}),e.jsx(kt,{children:"Date Added"}),g&&e.jsx(kt,{className:"w-[80px]",children:"Actions"})]})}),e.jsx(On,{children:_.length===0?e.jsx(Ss,{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(j=>e.jsxs(Ss,{className:`hover:bg-accent/50 ${g?"cursor-pointer":""}`,onClick:g?()=>t(`/mission-control/contacts/${j.id}`):void 0,children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("span",{className:g?"hover:text-primary hover:underline transition-colors":"",children:[j.first_name," ",j.last_name||""]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:j.owner_avatar_url||""}),e.jsx(wn,{className:"text-[10px]",children:(j.owner_name||"?").charAt(0).toUpperCase()})]}),e.jsx("span",{className:"text-sm text-muted-foreground truncate max-w-[120px]",children:j.owner_name||"Unknown"})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[j.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(dr,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:j.email})]}),j.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:j.phone})]}),!j.email&&!j.phone&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"No contact info"})]})}),e.jsx(dt,{children:j.address?e.jsxs("div",{className:"flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(Ba,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate max-w-[180px]",children:j.address})]}):e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"—"})}),e.jsx(dt,{children:j.lead_source?e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:j.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:ps(new Date(j.created_at),"MMM d, yyyy")})}),g&&e.jsx(dt,{children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 px-2",onClick:w=>{w.stopPropagation(),u(j.id),f(`${j.first_name} ${j.last_name||""}`.trim())},title:"Transfer to team member",children:e.jsx(Jv,{className:"h-4 w-4"})})})]},j.id))})]})})}),e.jsx(ttt,{open:!!c,onOpenChange:j=>{j||u(null)},contactIds:c?[c]:[],contactNames:p?[p]:[],onComplete:()=>u(null)})]})},Ike=({teamId:t})=>{const{user:s}=Rs(),{leadPondItems:r,isLoading:n,claimLead:a,returnLead:o}=ett(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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Zg,{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,b,_,j;return e.jsx(Pe,{children:e.jsxs(Re,{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(dr,{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(Un,{className:"h-3 w-3"})," ",c.contact.phone]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsxs(_n,{className:"h-4 w-4",children:[e.jsx(za,{src:((b=c.contributor)==null?void 0:b.avatar_url)||""}),e.jsx(wn,{className:"text-[8px]",children:(((_=c.contributor)==null?void 0:_.name)||"?").charAt(0)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["from ",((j=c.contributor)==null?void 0:j.name)||"Unknown"]})]})]}),e.jsxs(K,{size:"sm",onClick:()=>a.mutate(c.id),disabled:a.isPending,children:[e.jsx(nL,{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(Pe,{className:"opacity-75",children:e.jsxs(Re,{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(tt,{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(c1,{className:"mr-1 h-3 w-3"}),"Return"]})]})},c.id)})})]})]})},stt=({teamId:t})=>{const{useTeamMembers:s}=fC(),{data:r=[]}=s(t),n=r.map(b=>b.user_id),a=new Map(r.map(b=>[b.user_id,b.profile])),{data:o=[],isLoading:l}=mt({queryKey:["team-shared-presentations",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,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 b||[]},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:b,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 b||[]},enabled:n.length>0}),{data:u=[],isLoading:p}=mt({queryKey:["team-shared-videos",t,n],queryFn:async()=>{if(n.length===0)return[];const{data:b,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 b||[]},enabled:n.length>0});if(l||c||p)return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(b=>e.jsx(vs,{className:"h-20 w-full"},b))});const g=b=>{const _=a.get(b);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(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(Qg,{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(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsx(Sn,{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(Pe,{children:e.jsxs(Re,{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(ja,{defaultValue:"presentations",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"presentations",children:["Presentations (",o.length,")"]}),e.jsxs(us,{value:"guest-books",children:["Guest Books (",i.length,")"]}),e.jsxs(us,{value:"videos",children:["Videos (",u.length,")"]})]}),e.jsx(ks,{value:"presentations",className:"space-y-2",children:o.length===0?e.jsx(Tge,{icon:e.jsx(Qg,{className:"h-10 w-10"}),label:"No presentations yet"}):o.map(b=>{const _=g(b.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(_n,{className:"h-8 w-8 shrink-0",children:[e.jsx(za,{src:_.avatar}),e.jsx(wn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||"Untitled"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ps(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(tt,{variant:b.status==="published"?"default":"secondary",className:"text-xs capitalize",children:b.status}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(qn,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})}),e.jsx(ks,{value:"guest-books",className:"space-y-2",children:i.length===0?e.jsx(Tge,{icon:e.jsx(Sn,{className:"h-10 w-10"}),label:"No guest books yet"}):i.map(b=>{const _=g(b.agent_id);return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(_n,{className:"h-8 w-8 shrink-0",children:[e.jsx(za,{src:_.avatar}),e.jsx(wn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.property_address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ps(new Date(b.event_date),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[b.is_active?e.jsx(tt,{className:"text-xs",children:"Active"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Inactive"}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(mr,{className:"h-3 w-3"}),b.visitor_count||0]})]})]})},b.id)})}),e.jsx(ks,{value:"videos",className:"space-y-2",children:u.length===0?e.jsx(Tge,{icon:e.jsx(Cn,{className:"h-10 w-10"}),label:"No videos yet"}):u.map(b=>{const _=g(b.owner_user_id);return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsxs(_n,{className:"h-8 w-8 shrink-0",children:[e.jsx(za,{src:_.avatar}),e.jsx(wn,{className:"text-xs",children:_.initials})]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:b.title||b.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[_.name," · ",ps(new Date(b.created_at),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsx(tt,{variant:"secondary",className:"text-xs capitalize",children:b.touch_type}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(qn,{className:"h-3 w-3"}),b.view_count||0]})]})]})},b.id)})})]})]})},Tge=({icon:t,label:s})=>e.jsx(Pe,{children:e.jsxs(Re,{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})]})}),rtt=({team:t,brokerageAgents:s,onBack:r,onUpdate:n,onAddMember:a,onRemoveMember:o,onUpdateRole:l,onDeleteTeam:i,isUpdating:c,isAddingMember:u})=>{var q,U;const{useTeamMembers:p}=fC(),{data:f=[],isLoading:g}=p(t.id),[b,_]=k.useState(!1),[j,w]=k.useState(""),[N,C]=k.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(Y=>{var J;V.set(Y.user_id,((J=Y.teams)==null?void 0:J.name)||"another team")}),V}}),I=new Set(f.map(B=>B.user_id)),L=s.filter(B=>!I.has(B.id)),R=async()=>{j&&(await a(j,N),w(""),C("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(ja,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"members",children:"Members"}),e.jsxs(us,{value:"contacts",children:[e.jsx(Y4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),t.lead_pond_enabled&&e.jsxs(us,{value:"lead-pond",children:[e.jsx(Zg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),t.shared_assets_enabled&&e.jsxs(us,{value:"shared-assets",children:[e.jsx(Lm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]}),e.jsx(us,{value:"settings",children:"Settings"})]}),e.jsxs(ks,{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:b,onOpenChange:_,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(rc,{className:"mr-2 h-4 w-4"}),"Add Member"]})}),e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Agent"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox",className:"w-full justify-between font-normal",children:[j&&(((q=L.find(B=>B.id===j))==null?void 0:q.name)||((U=L.find(B=>B.id===j))==null?void 0:U.email))||"Select an agent",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search agents..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No agents found."}),e.jsx(Fx,{children:L.map(B=>{const V=M==null?void 0:M.get(B.id);return e.jsxs(vp,{value:B.name||B.email||B.id,disabled:!!V,onSelect:()=>w(B.id),children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",j===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(ye,{children:"Role"}),e.jsxs(Ys,{value:N,onValueChange:C,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(!1),children:"Cancel"}),e.jsx(K,{onClick:R,disabled:!j||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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(mr,{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,Y,J,te,X;return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex items-center justify-between p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:((V=B.profile)==null?void 0:V.avatar_url)||""}),e.jsx(wn,{children:(((Y=B.profile)==null?void 0:Y.name)||"?").charAt(0).toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((J=B.profile)==null?void 0:J.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(te=B.profile)==null?void 0:te.email})]}),B.role==="team_leader"?e.jsxs(tt,{className:"bg-[hsl(var(--chart-4)/0.1)] text-[hsl(var(--chart-4))] border-[hsl(var(--chart-4))]",children:[e.jsx(Im,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(tt,{variant:"secondary",children:"Member"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(Ys,{value:B.role,onValueChange:ce=>l(B.id,ce),children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"team_leader",children:"Team Leader"}),e.jsx(Mt,{value:"team_member",children:"Team Member"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-destructive",children:e.jsx(LL,{className:"h-4 w-4"})})}),e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Remove Member?"}),e.jsxs(Jl,{children:["Remove ",((X=B.profile)==null?void 0:X.name)||"this member"," from ",t.name,"?"]})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>o(B.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]})]})]})]})},B.id)})})]}),e.jsx(ks,{value:"contacts",className:"space-y-4",children:e.jsx(Pke,{})}),t.lead_pond_enabled&&e.jsx(ks,{value:"lead-pond",className:"space-y-4",children:e.jsx(Ike,{teamId:t.id})}),t.shared_assets_enabled&&e.jsx(ks,{value:"shared-assets",className:"space-y-4",children:e.jsx(stt,{teamId:t.id})}),e.jsxs(ks,{value:"settings",className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-lg",children:"Team Settings"}),e.jsx(xr,{children:"Configure how this team operates."})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{children:"Description"}),e.jsx(Er,{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(ye,{children:"Contact Visibility"}),e.jsxs(Ys,{defaultValue:t.contact_visibility,onValueChange:B=>n({contact_visibility:B}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{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($r,{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(ye,{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($r,{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(ye,{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($r,{checked:t.shared_videos_enabled??!1,onCheckedChange:B=>n({shared_videos_enabled:B})})]})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Team?"}),e.jsxs(Jl,{children:['This will permanently delete "',t.name,'" and remove all team members. This cannot be undone.']})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>{i(),r()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Team"})]})]})]})]})]})]})},ntt=({open:t,onOpenChange:s,onCreateTeam:r,isCreating:n,brokerageAgents:a,isAdmin:o,allBrokerages:l,activeBrokerageId:i})=>{const[c,u]=k.useState(1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),[w,N]=k.useState(""),[C,M]=k.useState([]),I=()=>{u(1),f(""),b(""),j(""),N(""),M([])},L=B=>{B||I(),s(B)},R=async()=>{const B=_&&_!=="none"?_:i||null;await r({name:p.trim(),description:g.trim()||void 0,brokerage_id:B,leaderId:w||void 0,memberIds:C.length>0?C:void 0}),I()},q=B=>{B!==w&&M(V=>V.includes(B)?V.filter(Y=>Y!==B):[...V,B])},U=a.filter(B=>B.id!==w);return e.jsx(xs,{open:t,onOpenChange:L,children:e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(bs,{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:Pt("h-1.5 flex-1 rounded-full transition-colors","bg-primary")}),e.jsx("div",{className:Pt("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(ye,{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(ye,{htmlFor:"team-desc",children:"Description"}),e.jsx(Er,{id:"team-desc",value:g,onChange:B=>b(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(ye,{children:"Brokerage"}),e.jsxs(Ys,{value:_,onValueChange:j,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"No brokerage (independent team)"})}),e.jsxs(Ks,{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(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Im,{className:"h-3.5 w-3.5 text-[hsl(var(--chart-4))]"}),"Team Leader"]}),e.jsxs(Ys,{value:w,onValueChange:B=>{N(B),M(V=>V.filter(Y=>Y!==B))},children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a team leader (optional)"})}),e.jsxs(Ks,{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(ye,{className:"flex items-center gap-1.5",children:[e.jsx(rc,{className:"h-3.5 w-3.5"}),"Initial Members",C.length>0&&e.jsxs(tt,{variant:"secondary",className:"ml-1 text-xs",children:[C.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(mr,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),"No agents available"]}):U.map(B=>{const V=C.includes(B.id);return e.jsxs("button",{type:"button",className:Pt("w-full flex items-center gap-3 p-3 text-left transition-colors hover:bg-accent/50",V&&"bg-primary/5"),onClick:()=>q(B.id),children:[e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:B.avatar_url||""}),e.jsx(wn,{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:Pt("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(fa,{className:"h-3 w-3"})})]},B.id)})})]})]})}),e.jsx(zn,{className:"gap-2 sm:gap-0",children:c===1?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>u(2),disabled:!p.trim(),children:["Next",e.jsx(fi,{className:"ml-2 h-4 w-4"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>u(1),children:[e.jsx(ri,{className:"mr-2 h-4 w-4"}),"Back"]}),e.jsx(K,{onClick:R,disabled:n,children:n?"Creating…":"Create Team"})]})})]})})},ZUt=()=>{const{teams:t,isLoading:s,createTeam:r,updateTeam:n,deleteTeam:a,addMember:o,removeMember:l,updateMemberRole:i}=fC(),[c,u]=k.useState(!1),[p,f]=k.useState(null),[g,b]=k.useState(""),{data:_}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:L,error:R}=await H.from("brokerages").select("id, name").order("name");if(R)throw R;return L||[]}}),{data:j}=mt({queryKey:["admin-team-member-info",t.map(L=>L.id).join(",")],queryFn:async()=>{var B;if(t.length===0)return{};const{data:L}=await H.from("team_members").select("team_id, user_id, role").in("team_id",t.map(V=>V.id));if(!L)return{};const R=L.filter(V=>V.role==="team_leader").map(V=>V.user_id);let q={};if(R.length>0){const{data:V}=await H.from("profiles").select("id, name").in("id",R);V&&(q=Object.fromEntries(V.map(Y=>[Y.id,{name:Y.name}])))}const U={};for(const V of t){const Y=L.filter(te=>te.team_id===V.id),J=Y.find(te=>te.role==="team_leader");U[V.id]={count:Y.length,leaderName:J&&((B=q[J.user_id])==null?void 0:B.name)||null}}return U},enabled:t.length>0}),w=(p==null?void 0:p.brokerage_id)||null,{data:N}=mt({queryKey:["brokerage-agents-for-teams",w],queryFn:async()=>{let L=H.from("profiles").select("id, name, email, avatar_url").order("name");w&&(L=L.eq("brokerage_id",w));const{data:R,error:q}=await L;if(q)throw q;return R||[]},enabled:!!p}),C=Object.fromEntries((_||[]).map(L=>[L.id,L.name])),M=async L=>{const R=await r.mutateAsync({name:L.name,brokerage_id:L.brokerage_id||null,description:L.description});if(L.leaderId&&L.leaderId!=="none"&&await o.mutateAsync({team_id:R.id,user_id:L.leaderId,role:"team_leader"}),L.memberIds)for(const q of L.memberIds)await o.mutateAsync({team_id:R.id,user_id:q,role:"team_member"});u(!1)};if(p)return e.jsx(rtt,{team:p,brokerageAgents:N||[],onBack:()=>f(null),onUpdate:L=>n.mutateAsync({id:p.id,...L}).then(R=>f(R)),onAddMember:(L,R)=>o.mutateAsync({team_id:p.id,user_id:L,role:R}),onRemoveMember:L=>l.mutateAsync({team_id:p.id,member_id:L}),onUpdateRole:(L,R)=>i.mutateAsync({team_id:p.id,member_id:L,role:R}),onDeleteTeam:()=>{a.mutate(p.id),f(null)},isUpdating:n.isPending,isAddingMember:o.isPending});const I=t.filter(L=>L.name.toLowerCase().includes(g.toLowerCase())||(L.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(hn,{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:L=>b(L.target.value),className:"pl-10"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground whitespace-nowrap",children:[I.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(ntt,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Team Name"}),e.jsx(kt,{className:"font-semibold",children:"Brokerage"}),e.jsx(kt,{className:"font-semibold",children:"Leader"}),e.jsx(kt,{className:"font-semibold",children:"Members"}),e.jsx(kt,{className:"font-semibold",children:"Visibility"}),e.jsx(kt,{className:"w-[100px]"})]})}),e.jsx(On,{children:s?e.jsx(e.Fragment,{children:[1,2,3].map(L=>e.jsxs(Ss,{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"})})]},L))}):I.length===0?e.jsx(Ss,{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."})}):I.map(L=>{const R=j==null?void 0:j[L.id];return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsxs(dt,{children:[e.jsx("button",{onClick:()=>f(L),className:"text-primary hover:underline font-medium",children:L.name}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 line-clamp-1",children:L.description})]}),e.jsx(dt,{children:L.brokerage_id?e.jsx("span",{className:"text-sm",children:C[L.brokerage_id]||"—"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"Independent"})}),e.jsx(dt,{children:R!=null&&R.leaderName?e.jsxs("span",{className:"text-sm flex items-center gap-1",children:[e.jsx(Im,{className:"h-3 w-3 text-[hsl(var(--chart-4))]"}),R.leaderName]}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No leader"})}),e.jsx(dt,{children:e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),(R==null?void 0:R.count)??0]})}),e.jsx(dt,{children:e.jsxs("span",{className:"text-xs text-muted-foreground capitalize flex items-center gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),L.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(L),title:"Edit team",children:e.jsx(Da,{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 "${L.name}"? This cannot be undone.`)&&a.mutate(L.id)},title:"Delete team",children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})})]},L.id)})})]})})]})},YUt=()=>{const t=pr(),{user:s,isAdmin:r}=Rs(),{startImpersonation:n,isLoading:a}=V2e(),{toast:o}=qa(),[l,i]=k.useState([]),[c,u]=k.useState([]),[p,f]=k.useState([]),[g,b]=k.useState({}),[_,j]=k.useState(!0),[w,N]=k.useState({}),[C,M]=k.useState(!1),[I,L]=k.useState({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),[R,q]=k.useState(!1),[U,B]=k.useState(""),[V,Y]=k.useState(1),[J,te]=k.useState(50),[X,ce]=k.useState("all"),[ne,re]=k.useState("all"),[le,pe]=k.useState("all"),[xe,_e]=k.useState("all"),[fe,we]=k.useState(!1),[Ie,Ne]=k.useState(!1),[Ae,Fe]=k.useState(null),[Ce,Me]=k.useState(null),[$e,ct]=k.useState(!1),[Te,ft]=k.useState({name:"",email:"",brokerage_id:"",phone:""}),[me,Ve]=k.useState(null),[nt,et]=k.useState(!1),[Se,rt]=k.useState(""),[Ge,lt]=k.useState(!1),[qe,Ze]=k.useState(!1),[Je,He]=k.useState(null),[Qe,at]=k.useState(""),[It,Ut]=k.useState(!1),[hs,Yt]=k.useState(!1),[ts,Ds]=k.useState(null),[vr,Ct]=k.useState(!1),[As,Us]=k.useState(!1),[kr,ta]=k.useState(null),[ka,Li]=k.useState(""),[Wa,cr]=k.useState(!1),[Qr,Hr]=k.useState({email:"",name:"",password:"",phone:""}),[ln,Zr]=k.useState(!1),[yi,pt]=k.useState(!1),[ir,Bn]=k.useState(""),[Cr,jr]=k.useState(!1),[Xn,Aa]=k.useState(!1),[Pi,Oo]=k.useState(""),[$t,je]=k.useState(new Set),[Be,Ye]=k.useState(!1),[vt,xt]=k.useState(!1),[Rt,Zt]=k.useState(null),[Vt,Qt]=k.useState(!1),[Es,ys]=k.useState(null),[yr,Vr]=k.useState([]),[fr,Pn]=k.useState([]),[In,Mn]=k.useState(!1),[ya,vo]=k.useState({});k.useEffect(()=>{!s||!r||(Ja(),dl())},[s,r]);const al=async()=>{try{const{data:wt,error:Ms}=await H.from("brokerage_manager_assignments").select("user_id, brokerage_id");if(Ms)throw Ms;const Js={};for(const pn of wt??[])Js[pn.brokerage_id]||(Js[pn.brokerage_id]=[]),Js[pn.brokerage_id].push(pn.user_id);b(Js)}catch(wt){console.error("Error loading brokerage manager assignments:",wt)}},Ja=async()=>{try{j(!0);const{data:wt,error:Ms}=await H.functions.invoke("get-user-details");if(Ms)throw Ms;const Js=wt.users||[];i(Js),f(wt.brokerages||[]),await al();const pn=Js.filter(fn=>fn.roles.includes("assistant"));if(pn.length>0){const fn=pn.map(qr=>qr.id),{data:oa}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("assistant_id",fn);if(oa&&oa.length>0){const qr=[...new Set(oa.map(Op=>Op.agent_id))],{data:uo}=await H.from("profiles").select("id, name, email").in("id",qr),Xx={};for(const Op of oa){const Kr=uo==null?void 0:uo.find(X0=>X0.id===Op.agent_id);Kr&&(Xx[Op.assistant_id]={agent_name:Kr.name||"",agent_email:Kr.email||""})}vo(Xx)}}}catch(wt){console.error("Error loading members:",wt),o({title:"Error",description:"Failed to load members",variant:"destructive"})}finally{j(!1)}},dl=async()=>{try{const{data:wt,error:Ms}=await H.from("app_tiles").select("id, name, icon, app_id, required_tags").order("name");if(Ms)throw Ms;u(wt||[])}catch(wt){console.error("Error loading apps:",wt),o({title:"Error",description:"Failed to load apps",variant:"destructive"})}},oo=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:Js}=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(Js)throw Js;o({title:"Success",description:"Member details updated successfully"}),Fe(null),Ja()}catch(Js){console.error("Error updating member:",Js),o({title:"Error",description:Js.message||"Failed to update member",variant:"destructive"})}},Ea=async wt=>{try{const{data:{session:Ms}}=await H.auth.getSession(),Js=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ms==null?void 0:Ms.access_token}`},body:JSON.stringify({userId:wt})}),pn=await Js.json();if(!Js.ok)throw new Error(pn.error||"Failed to resend welcome email");o({title:"Success",description:"Welcome email sent successfully"})}catch(Ms){console.error("Error resending welcome email:",Ms),o({title:"Error",description:Ms.message||"Failed to resend welcome email",variant:"destructive"})}},lo=async(wt,Ms)=>{try{const{error:Js}=await H.functions.invoke("send-password-reset",{body:{email:wt,redirectTo:window.location.origin}});if(Js)throw Js;o({title:"Password Reset Sent",description:`Password reset email sent to ${Ms}`})}catch(Js){console.error("Error sending password reset:",Js),o({title:"Error",description:Js.message||"Failed to send password reset email",variant:"destructive"})}},Mi=async(wt,Ms)=>{if(confirm(`Are you sure you want to delete ${Ms}? This action cannot be undone.`))try{const{data:{session:Js}}=await H.auth.getSession(),pn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:wt})}),fn=await pn.json();if(!pn.ok)throw new Error(fn.error||"Failed to delete user");o({title:"Success",description:"User deleted successfully"}),Ja()}catch(Js){console.error("Error deleting user:",Js),o({title:"Error",description:Js.message||"Failed to delete user",variant:"destructive"})}},ca=async()=>{if(!I.email||!I.name||!I.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}if(I.role==="brokerage_manager"&&!I.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(),Ms=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(I)}),Js=await Ms.json();if(!Ms.ok)throw new Error(Js.error||"Failed to create user");if(I.role&&I.role!=="user"&&Js.userId){const pn=I.role==="brokerage_manager"?I.brokerage_id:void 0;await co(Js.userId,I.role,"add",pn)}o({title:"Success",description:`User ${I.email} created successfully`}),L({email:"",name:"",password:"",brokerage_id:"",role:"user",phone:"",trial_days:""}),q(!1),Ja()}catch(wt){console.error("Error creating user:",wt),o({title:"Error",description:wt.message||"Failed to create user",variant:"destructive"})}finally{M(!1)}},co=async(wt,Ms,Js,pn)=>{try{const{data:{session:fn}}=await H.auth.getSession(),oa={userId:wt,role:Ms,action:Js};if(Ms==="brokerage_manager"){if(!pn){o({title:"Error",description:"Please choose a brokerage for this manager assignment",variant:"destructive"});return}oa.brokerageId=pn}const qr=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${fn==null?void 0:fn.access_token}`},body:JSON.stringify(oa)}),uo=await qr.json();if(!qr.ok)throw new Error(uo.error||"Failed to manage user role");o({title:"Success",description:`Role ${Js==="add"?"added":"removed"} successfully`}),Ja()}catch(fn){console.error("Error managing user role:",fn),o({title:"Error",description:fn.message||"Failed to manage user role",variant:"destructive"})}},Nc=(wt,Ms)=>Ms.length===0?!0:Ms.some(Js=>wt.includes(Js)),Uc=async(wt,Ms,Js)=>{const pn=`${wt}-${Ms.id}`;Ve(pn);try{if(Js){const fn=l.find(qr=>qr.id===wt),oa=Ms.required_tags.filter(qr=>fn==null?void 0:fn.tags.includes(qr));for(const qr of oa){const{error:uo}=await H.from("user_tags").delete().eq("user_id",wt).eq("tag",qr);if(uo)throw uo}o({title:"Access Removed",description:`Removed access to ${Ms.name}`})}else if(Ms.required_tags.length>0){const{error:fn}=await H.from("user_tags").insert({user_id:wt,tag:Ms.required_tags[0]});if(fn)throw fn;o({title:"Access Granted",description:`Granted access to ${Ms.name}`})}await Ja()}catch(fn){console.error("Error toggling access:",fn),o({title:"Error",description:fn.message||"Failed to update access",variant:"destructive"})}finally{Ve(null)}},ou=async()=>{const wt=Se.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(Js=>Js.name.toLowerCase()===wt.toLowerCase())){o({title:"Error",description:"A brokerage with this name already exists",variant:"destructive"});return}lt(!0);try{const{error:Js}=await H.from("brokerages").insert({name:wt});if(Js)throw Js;o({title:"Success",description:`Brokerage "${wt}" created successfully`}),rt(""),et(!1),Ja()}catch(Js){console.error("Error creating brokerage:",Js),o({title:"Error",description:Js.message||"Failed to create brokerage",variant:"destructive"})}finally{lt(!1)}},Df=wt=>{He(wt),at(wt.name),Ze(!0)},Rl=()=>{He(null),at(""),Ze(!1)},oh=async()=>{if(!Je)return;const wt=Qe.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}Ut(!0);try{const{error:Ms}=await H.from("brokerages").update({name:wt}).eq("id",Je.id);if(Ms)throw Ms;o({title:"Success",description:"Brokerage updated successfully"}),Rl(),Ja()}catch(Ms){console.error("Error updating brokerage:",Ms),o({title:"Error",description:Ms.message||"Failed to update brokerage",variant:"destructive"})}finally{Ut(!1)}},kd=async(wt,Ms)=>{var Js;if(!Ms||typeof Ms!="string"){o({title:"Error",description:"Please select a brokerage first",variant:"destructive"});return}try{const pn={userId:wt,role:"brokerage_manager",action:"add",brokerageId:Ms};console.debug("[assignManagerToBrokerage] payload",pn);const{data:{session:fn}}=await H.auth.getSession(),oa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/manage-user-roles",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${fn==null?void 0:fn.access_token}`},body:JSON.stringify(pn)}),qr=await oa.json();if(!oa.ok&&!((Js=qr.error)!=null&&Js.includes("duplicate")))throw new Error(qr.error||"Failed to add role");o({title:"Success",description:"Manager assigned to brokerage"}),await Ja()}catch(pn){console.error("Error assigning manager:",pn),o({title:"Error",description:pn.message||"Failed to assign manager",variant:"destructive"})}},Gm=wt=>{Ds(wt),Yt(!0)},Fl=async()=>{if(ts){Ct(!0);try{const wt=l.filter(pn=>pn.brokerage_id===ts.id),{data:{session:Ms}}=await H.auth.getSession();for(const pn of wt){const fn=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ms==null?void 0:Ms.access_token}`},body:JSON.stringify({userId:pn.id})});if(!fn.ok){const oa=await fn.json();console.error(`Failed to delete user ${pn.email}:`,oa.error)}}const{error:Js}=await H.from("brokerages").delete().eq("id",ts.id);if(Js)throw Js;o({title:"Success",description:`Brokerage "${ts.name}" and ${wt.length} member(s) deleted`}),Yt(!1),Ds(null),Ja()}catch(wt){console.error("Error deleting brokerage:",wt),o({title:"Error",description:wt.message||"Failed to delete brokerage",variant:"destructive"})}finally{Ct(!1)}}},Kx=wt=>{ta(wt),Li(""),Us(!0)},gy=()=>{ta(null),Li(""),Us(!1)},U1=async wt=>{try{const{error:Ms}=await H.from("profiles").update({brokerage_id:null}).eq("id",wt);if(Ms)throw Ms;o({title:"Success",description:"User removed from brokerage"}),Ja()}catch(Ms){console.error("Error removing user from brokerage:",Ms),o({title:"Error",description:Ms.message||"Failed to remove user",variant:"destructive"})}},V1=async(wt,Ms)=>{try{const{error:Js}=await H.from("profiles").update({brokerage_id:Ms}).eq("id",wt);if(Js)throw Js;o({title:"Success",description:"User added to brokerage"}),Ja()}catch(Js){console.error("Error adding user to brokerage:",Js),o({title:"Error",description:Js.message||"Failed to add user",variant:"destructive"})}},H1=async()=>{if(!kr||!Qr.email||!Qr.name||!Qr.password){o({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}Zr(!0);try{const{data:{session:wt}}=await H.auth.getSession(),Ms=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({...Qr,brokerage_id:kr.id,role:"user"})}),Js=await Ms.json();if(!Ms.ok)throw new Error(Js.error||"Failed to create agent");o({title:"Success",description:`Agent ${Qr.email} created successfully`}),Hr({email:"",name:"",password:"",phone:""}),cr(!1),Ja()}catch(wt){console.error("Error creating agent:",wt),o({title:"Error",description:wt.message||"Failed to create agent",variant:"destructive"})}finally{Zr(!1)}},Dp=wt=>l.filter(Ms=>Ms.brokerage_id===wt),nm=wt=>{const Ms=Dp(wt);if(!ka)return Ms;const Js=ka.toLowerCase();return Ms.filter(pn=>pn.name.toLowerCase().includes(Js)||pn.email.toLowerCase().includes(Js))},lu=wt=>l.filter(Ms=>Ms.brokerage_id!==wt),am=l.filter(wt=>{var Js;if(U){const pn=U.toLowerCase();if(!(wt.name.toLowerCase().includes(pn)||wt.email.toLowerCase().includes(pn)||((Js=wt.brokerage_name)==null?void 0:Js.toLowerCase().includes(pn))))return!1}if(X==="claimed"&&!wt.claimed||X==="unclaimed"&&wt.claimed||ne!=="all"&&!wt.roles.includes(ne))return!1;const Ms=wt.is_trial||wt.subscription_status==="trialing";return!(le==="trial"&&!Ms||le==="non-trial"&&Ms||xe==="none"&&wt.brokerage_id||xe!=="all"&&xe!=="none"&&wt.brokerage_id!==xe)}),{sortKey:Bd,sortDirection:Sd,handleSort:cu,sortData:Of}=KO("created_at","desc"),Rf=Of(am,{name:wt=>{var Ms;return((Ms=wt.name)==null?void 0:Ms.toLowerCase())||""},brokerage:wt=>{var Ms;return((Ms=wt.brokerage_name)==null?void 0:Ms.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}),Km=Rf.length,Zm=J===0,Cd=Zm?1:Math.ceil(Km/J),G0=Zm?0:(V-1)*J,Zx=Zm?Km:G0+J,Ml=Rf.slice(G0,Zx),W1=wt=>{B(wt),Y(1)},Yx=wt=>{te(wt),Y(1)},Ih=(wt,Ms)=>{wt(Ms),Y(1)},qw=async(wt,Ms)=>{we(!0);try{const Js=l.find(qr=>qr.id===wt);if(!Js)return;const pn=Js.trial_expires_at?new Date(Js.trial_expires_at):new Date,fn=new Date(pn.getTime()+Ms*24*60*60*1e3),{error:oa}=await H.from("profiles").update({trial_expires_at:fn.toISOString()}).eq("id",wt);if(oa)throw oa;o({title:"Trial Extended",description:`Trial extended by ${Ms} days`}),Ja()}catch(Js){console.error("Error extending trial:",Js),o({title:"Error",description:Js.message||"Failed to extend trial",variant:"destructive"})}finally{we(!1)}},kC=async wt=>{Ne(!0);try{const{error:Ms}=await H.from("profiles").update({is_trial:!1,trial_expires_at:null,trial_started_at:null,trial_claimed_at:null}).eq("id",wt);if(Ms)throw Ms;o({title:"Account Converted",description:"User has been converted to a full account"}),Ja(),yy()}catch(Ms){console.error("Error converting trial:",Ms),o({title:"Error",description:Ms.message||"Failed to convert account",variant:"destructive"})}finally{Ne(!1)}},K0=async wt=>{Mn(!0);try{const{data:Ms}=await H.from("agent_assistant_assignments").select("id, assistant_id, permissions").eq("agent_id",wt);if(Ms&&Ms.length>0){const pn=Ms.map(oa=>oa.assistant_id),{data:fn}=await H.from("profiles").select("id, name, email").in("id",pn);Vr(Ms.map(oa=>{const qr=fn==null?void 0:fn.find(uo=>uo.id===oa.assistant_id);return{id:oa.id,assistant_id:oa.assistant_id,assistant_name:(qr==null?void 0:qr.name)||"Unknown",assistant_email:(qr==null?void 0:qr.email)||"",permissions:oa.permissions||{}}}))}else Vr([]);const{data:Js}=await H.from("agent_assistant_assignments").select("id, agent_id, permissions").eq("assistant_id",wt);if(Js&&Js.length>0){const pn=Js.map(oa=>oa.agent_id),{data:fn}=await H.from("profiles").select("id, name, email").in("id",pn);Pn(Js.map(oa=>{const qr=fn==null?void 0:fn.find(uo=>uo.id===oa.agent_id);return{id:oa.id,agent_id:oa.agent_id,agent_name:(qr==null?void 0:qr.name)||"Unknown",agent_email:(qr==null?void 0:qr.email)||"",permissions:oa.permissions||{}}}))}else Pn([])}catch(Ms){console.error("Error loading assistant data:",Ms)}finally{Mn(!1)}},Pa=wt=>{Me(wt),ft({name:wt.name,email:wt.email,brokerage_id:wt.brokerage_id||"",phone:wt.phone||""}),ct(!0),K0(wt.id)},yy=()=>{Me(null),ct(!1),ft({name:"",email:"",brokerage_id:"",phone:""})},Uw=async()=>{Ce&&(await oo(Ce.id),yy())},SC=wt=>{je(Ms=>{const Js=new Set(Ms);return Js.has(wt)?Js.delete(wt):Js.add(wt),Js})},CC=()=>{if($t.size===Ml.length&&Ml.every(wt=>$t.has(wt.id))){const wt=new Set($t);Ml.forEach(Ms=>wt.delete(Ms.id)),je(wt)}else{const wt=new Set($t);Ml.forEach(Ms=>wt.add(Ms.id)),je(wt)}},im=()=>{je(new Set)},Z0=async()=>{if($t.size===0)return;Ye(!0);let wt=0,Ms=0;try{const{data:{session:Js}}=await H.auth.getSession();for(const pn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:pn})})).ok?wt++:Ms++}catch{Ms++}o({title:"Bulk Email Complete",description:`Sent ${wt} emails${Ms>0?`, ${Ms} failed`:""}`}),im()}catch(Js){o({title:"Error",description:Js.message||"Failed to send emails",variant:"destructive"})}finally{Ye(!1)}},Y0=async()=>{if($t.size===0)return;Ye(!0);let wt=0,Ms=0;try{const{data:{session:Js}}=await H.auth.getSession();for(const pn of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-password-reset",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({userId:pn})})).ok?wt++:Ms++}catch{Ms++}o({title:"Bulk Password Reset Complete",description:`Sent ${wt} reset emails${Ms>0?`, ${Ms} failed`:""}`}),im()}catch(Js){o({title:"Error",description:Js.message||"Failed to send password reset emails",variant:"destructive"})}finally{Ye(!1)}},Vw=async()=>{if($t.size===0)return;const wt=l.filter(fn=>$t.has(fn.id)).map(fn=>fn.name).slice(0,5).join(", "),Ms=$t.size>5?` and ${$t.size-5} more`:"";if(!confirm(`Are you sure you want to delete ${$t.size} users (${wt}${Ms})? This action cannot be undone.`))return;Ye(!0);let Js=0,pn=0;try{const{data:{session:fn}}=await H.auth.getSession();for(const oa of $t)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/delete-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${fn==null?void 0:fn.access_token}`},body:JSON.stringify({userId:oa})})).ok?Js++:pn++}catch{pn++}o({title:"Bulk Delete Complete",description:`Deleted ${Js} users${pn>0?`, ${pn} failed`:""}`}),im(),Ja()}catch(fn){o({title:"Error",description:fn.message||"Failed to delete users",variant:"destructive"})}finally{Ye(!1)}},G1=async()=>{xt(!0);try{const{data:{session:wt}}=await H.auth.getSession(),Ms=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(!Ms.ok){const pn=await Ms.json();throw new Error(pn.error||"Failed to sync phones")}const Js=await Ms.json();o({title:"Phone Sync Complete",description:`Pulled ${Js.summary.pulledFromGHL} from GHL, pushed ${Js.summary.pushedToGHL} to GHL, ${Js.summary.alreadySynced} already synced`}),Ja()}catch(wt){o({title:"Error",description:wt.message||"Failed to sync phones with GHL",variant:"destructive"})}finally{xt(!1)}},Ym=async(wt,Ms)=>{Zt(wt);try{const{data:{session:Js}}=await H.auth.getSession(),{data:pn}=await H.from("profiles").select("phone").eq("id",wt).single(),fn=(pn==null?void 0:pn.phone)||"",oa=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ghl-tag-sync",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Js==null?void 0:Js.access_token}`},body:JSON.stringify({email:Ms,action:"update",phone:fn||void 0})});if(!oa.ok){const uo=await oa.json();throw new Error(uo.error||"Failed to sync with GHL")}const qr=await fetch(`https://services.leadconnectorhq.com/contacts/lookup?locationId=&email=${encodeURIComponent(Ms)}`,{method:"GET",headers:{"Content-Type":"application/json"}});o({title:"Phone Synced",description:fn?`Phone ${fn} synced to GHL`:"Sync attempted - run bulk sync to pull phone from GHL"}),Ja()}catch(Js){o({title:"Error",description:Js.message||"Failed to sync phone",variant:"destructive"})}finally{Zt(null)}},vy=async wt=>{await n(wt)},Hw=()=>{if($t.size===0){o({title:"No members selected",description:"Please select members to export",variant:"destructive"});return}const wt=l.filter(uo=>$t.has(uo.id)),Ms=["Name","Email","Phone","Brokerage","Roles","Status","Created At"],Js=wt.map(uo=>[uo.name,uo.email,uo.phone||"",uo.brokerage_name||"",uo.roles.join("; "),uo.claimed?"Claimed":"Unclaimed",new Date(uo.created_at).toLocaleDateString()]),pn=[Ms.join(","),...Js.map(uo=>uo.map(Xx=>`"${(Xx||"").replace(/"/g,'""')}"`).join(","))].join(` `),fn=new Blob([pn],{type:"text/csv"}),oa=URL.createObjectURL(fn),qr=document.createElement("a");qr.href=oa,qr.download=`members-export-${new Date().toISOString().split("T")[0]}.csv`,qr.click(),URL.revokeObjectURL(oa),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(ah,{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:G1,disabled:vt,children:[vt?e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Un,{className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:vt?"Syncing...":"Sync Phones with GHL"}),e.jsx("span",{className:"sm:hidden",children:vt?"Syncing...":"Sync GHL"})]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>pt(!0),children:[e.jsx(s1,{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:R,onOpenChange:q,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(rc,{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(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",placeholder:"John Doe",value:I.name,onChange:wt=>L({...I,name:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",placeholder:"john@example.com",value:I.email,onChange:wt=>L({...I,email:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"password",children:"Password"}),e.jsx(ze,{id:"password",type:"password",placeholder:"Min 6 characters",value:I.password,onChange:wt=>L({...I,password:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",placeholder:"555-123-4567",value:I.phone,onChange:wt=>L({...I,phone:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"brokerage",children:["Brokerage",I.role==="brokerage_manager"?" (required)":""]}),e.jsxs(Ys,{value:I.brokerage_id||"none",onValueChange:wt=>L({...I,brokerage_id:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"brokerage",children:e.jsx(Qs,{placeholder:I.role==="brokerage_manager"?"Select brokerage":"Select brokerage (optional)"})}),e.jsxs(Ks,{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(ye,{htmlFor:"role",children:"Role"}),e.jsxs(Ys,{value:I.role,onValueChange:wt=>L({...I,role:wt}),children:[e.jsx(Gs,{id:"role",children:e.jsx(Qs,{placeholder:"Select role"})}),e.jsxs(Ks,{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(ye,{htmlFor:"trial_days",children:"Trial Period (optional)"}),e.jsxs(Ys,{value:I.trial_days||"none",onValueChange:wt=>L({...I,trial_days:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"trial_days",children:e.jsx(Qs,{placeholder:"No trial (full access)"})}),e.jsxs(Ks,{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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>q(!1),children:"Cancel"}),e.jsx(K,{onClick:ca,disabled:C,children:C?"Creating...":"Create User"})]})]})]})]})]}),e.jsxs(ja,{defaultValue:new URLSearchParams(window.location.search).get("tab")||"members",className:"space-y-6",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"members",children:"Members"}),e.jsx(us,{value:"brokerages",children:"Brokerages"}),e.jsx(us,{value:"teams",children:"Teams"}),e.jsx(us,{value:"trials",children:"Trial Users"}),e.jsx(us,{value:"access",children:"Access Matrix"}),e.jsx(us,{value:"celebrations",children:"Celebrations"}),e.jsx(us,{value:"deletions",children:"Deletion Log"})]}),e.jsxs(ks,{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(hn,{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=>W1(wt.target.value),className:"pl-10 h-9"})]}),e.jsxs(Ys,{value:X,onValueChange:wt=>Ih(ce,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:ne,onValueChange:wt=>Ih(re,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:le,onValueChange:wt=>Ih(pe,wt),children:[e.jsx(Gs,{className:"w-[130px] h-9",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:xe,onValueChange:wt=>Ih(_e,wt),children:[e.jsx(Gs,{className:"w-[150px] h-9",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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||X!=="all"||ne!=="all"||le!=="all"||xe!=="all")&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-9",onClick:()=>{B(""),ce("all"),re("all"),pe("all"),_e("all"),Y(1)},children:[e.jsx(Or,{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:Zm?`Showing all ${Km} members`:`Showing ${G0+1}-${Math.min(Zx,Km)} of ${Km} members`}),e.jsxs(Ys,{value:J.toString(),onValueChange:wt=>Yx(Number(wt)),children:[e.jsx(Gs,{className:"h-9 w-[110px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Fv,{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:Z0,disabled:Be,children:[Be?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-1"}):e.jsx(dr,{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:Y0,disabled:Be,children:[Be?e.jsx(ws,{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:Hw,children:[e.jsx(Ci,{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:Vw,disabled:Be,children:[Be?e.jsx(ws,{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:im,disabled:Be,children:e.jsx(Or,{className:"h-4 w-4"})})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"w-[50px]",children:e.jsx(Lo,{checked:Ml.length>0&&Ml.every(wt=>$t.has(wt.id)),onCheckedChange:CC,"aria-label":"Select all on page"})}),e.jsx(gl,{sortKey:"name",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Name"}),e.jsx(gl,{sortKey:"brokerage",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Brokerage"}),e.jsx(gl,{sortKey:"status",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Status"}),e.jsx(gl,{sortKey:"role",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Role"}),e.jsx(gl,{sortKey:"last_login",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Last Login"}),e.jsx(gl,{sortKey:"created_at",currentSortKey:Bd,currentDirection:Sd,onSort:cu,children:"Member Since"}),e.jsx(kt,{className:"w-[100px]"})]})}),e.jsx(On,{children:Ml.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:8,className:"text-center py-12 text-muted-foreground",children:"No members found"})}):Ml.map(wt=>e.jsxs(Ss,{className:`hover:bg-muted/30 ${$t.has(wt.id)?"bg-primary/5":""}`,children:[e.jsx(dt,{children:e.jsx(Lo,{checked:$t.has(wt.id),onCheckedChange:()=>SC(wt.id),"aria-label":`Select ${wt.name}`})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("button",{onClick:()=>Pa(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 Ms=wt.is_trial&&wt.trial_expires_at||!wt.is_trial&&wt.subscription_status==="trialing"&&wt.subscription_end_date,Js=wt.trial_expires_at||wt.subscription_end_date;if(Ms&&Js){const pn=Math.ceil((new Date(Js).getTime()-Date.now())/864e5),fn=pn<=0,oa=pn<=3;return e.jsx(tt,{variant:"outline",className:Pt("w-fit",fn?"border-destructive text-destructive":oa?"border-amber-500 text-amber-600":"border-violet-300 text-violet-700 bg-violet-50"),children:fn?"Trial Expired":`Trial · ${pn}d left`})}return e.jsx(tt,{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")&&ya[wt.id]&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["→ ",ya[wt.id].agent_name||ya[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(tu,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Pa(wt),title:"Edit member",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ym(wt.id,wt.email),disabled:Rt===wt.id,title:"Sync phone with GHL",children:Rt===wt.id?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Un,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Ea(wt.id),title:"Resend welcome email",children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>lo(wt.email,wt.name),title:"Send password reset",children:e.jsx(J4,{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:()=>vy(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(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(EM,{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:()=>Mi(wt.id,wt.name),title:"Delete user",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},wt.id))})]})}),Cd>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 ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(1),disabled:V===1,children:"First"}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(wt=>Math.max(1,wt-1)),disabled:V===1,children:e.jsx(ll,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(5,Cd)},(wt,Ms)=>{let Js;return Cd<=5||V<=3?Js=Ms+1:V>=Cd-2?Js=Cd-4+Ms:Js=V-2+Ms,e.jsx(K,{variant:V===Js?"default":"outline",size:"sm",className:"h-8 w-8 p-0",onClick:()=>Y(Js),children:Js},Js)})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(wt=>Math.min(Cd,wt+1)),disabled:V===Cd,children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>Y(Cd),disabled:V===Cd,children:"Last"})]})]})]}),e.jsx(xs,{open:$e,onOpenChange:ct,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Edit Member"}),e.jsx(Wr,{children:"Update member details, roles, and app access"})]}),Ce&&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(ye,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:Te.name,onChange:wt=>ft({...Te,name:wt.target.value}),maxLength:100})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:Te.email,onChange:wt=>ft({...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(ye,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:Te.phone,onChange:wt=>ft({...Te,phone:wt.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"edit-brokerage",children:"Brokerage"}),e.jsxs(Ys,{value:Te.brokerage_id||"none",onValueChange:wt=>ft({...Te,brokerage_id:wt==="none"?"":wt}),children:[e.jsx(Gs,{id:"edit-brokerage",children:e.jsx(Qs,{placeholder:"Select brokerage"})}),e.jsxs(Ks,{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:[Ce.roles.map(wt=>e.jsxs(tt,{variant:"default",className:"gap-1",children:[e.jsx(Th,{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:()=>co(Ce.id,wt,"remove"),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove role",children:e.jsx(Or,{className:"h-3 w-3"})})]},wt)),Ce.roles.length===0&&e.jsx("span",{className:"text-sm text-muted-foreground",children:"No roles assigned"})]}),e.jsxs(Ys,{onValueChange:wt=>co(Ce.id,wt,"add"),children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Qs,{placeholder:"Add role..."})}),e.jsxs(Ks,{children:[!Ce.roles.includes("admin")&&e.jsx(Mt,{value:"admin",children:"Admin"}),!Ce.roles.includes("user")&&e.jsx(Mt,{value:"user",children:"User"})]})]}),!Ce.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"})]}),(yr.length>0||fr.length>0||Ce.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(mr,{className:"h-4 w-4"}),"Assistant Relationships"]}),In?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):e.jsxs("div",{className:"space-y-3",children:[yr.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:"}),yr.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(tt,{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(([,Ms])=>Ms).map(([Ms])=>e.jsx(tt,{variant:"secondary",className:"text-[10px] capitalize",children:Ms},Ms))})]},wt.id))]}),fr.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:"}),fr.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(tt,{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(([,Ms])=>Ms).map(([Ms])=>e.jsx(tt,{variant:"secondary",className:"text-[10px] capitalize",children:Ms},Ms))})]},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 Ms=Nc(Ce.tags,wt.required_tags),Js=`${Ce.id}-${wt.id}`,pn=me===Js,fn=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}),fn&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Available to all members"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:pn?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):fn?e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Always On"}):e.jsx($r,{checked:Ms,onCheckedChange:()=>Uc(Ce.id,wt,Ms)})})]},wt.id)})})]}),(Ce.is_trial||Ce.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(mn,{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:[Ce.trial_expires_at&&e.jsx(u8e,{expiresAt:Ce.trial_expires_at}),!Ce.trial_expires_at&&Ce.subscription_status==="trialing"&&Ce.subscription_end_date&&e.jsx(u8e,{expiresAt:Ce.subscription_end_date})]}),(Ce.trial_expires_at||Ce.subscription_end_date)&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Expires: ",new Date(Ce.trial_expires_at||Ce.subscription_end_date).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>qw(Ce.id,7),disabled:fe,children:[e.jsx(D_,{className:"h-4 w-4 mr-1"}),"+7 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>qw(Ce.id,14),disabled:fe,children:[e.jsx(D_,{className:"h-4 w-4 mr-1"}),"+14 Days"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>qw(Ce.id,30),disabled:fe,children:[e.jsx(D_,{className:"h-4 w-4 mr-1"}),"+30 Days"]}),e.jsxs(K,{size:"sm",variant:"default",onClick:()=>kC(Ce.id),disabled:Ie,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(V_,{className:"h-4 w-4 mr-1"}),"Convert to Full Account"]})]}),Ce.trial_started_at&&e.jsxs("div",{className:"mt-3 text-xs text-muted-foreground",children:["Trial started: ",new Date(Ce.trial_started_at).toLocaleDateString(),Ce.trial_claimed_at&&e.jsxs("span",{children:[" • Claimed: ",new Date(Ce.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:[Ce.email_confirmed_at&&e.jsxs("div",{children:["Claimed: ",new Date(Ce.email_confirmed_at).toLocaleString()]}),Ce.last_sign_in_at&&e.jsxs("div",{children:["Last login: ",new Date(Ce.last_sign_in_at).toLocaleString()]}),e.jsxs("div",{children:["Created: ",new Date(Ce.created_at).toLocaleString()]})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:yy,children:"Cancel"}),e.jsx(K,{onClick:Uw,children:"Save Changes"})]})]})}),e.jsxs(ks,{value:"access",children:[c.length===0?e.jsx(Pe,{children:e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Member Access Matrix"}),e.jsx(xr,{children:"Toggle switches to grant or revoke app access for each member"})]}),e.jsxs(Re,{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:[Ml.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(Ms=>{const Js=Nc(wt.tags,Ms.required_tags),pn=`${wt.id}-${Ms.id}`,fn=me===pn;return e.jsx("td",{className:"p-4 text-center",children:e.jsx("div",{className:"flex items-center justify-center",children:fn?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):e.jsx($r,{checked:Js,onCheckedChange:()=>Uc(wt.id,Ms,Js),disabled:Ms.required_tags.length===0})})},Ms.id)})]},wt.id)),Ml.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"})})]})]})}),Cd>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 ",G0+1,"-",Math.min(Zx,Km)," of ",Km," • Page ",V," of ",Cd]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(wt=>Math.max(1,wt-1)),disabled:V===1,children:e.jsx(ll,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>Y(wt=>Math.min(Cd,wt+1)),disabled:V===Cd,children:e.jsx(xa,{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(ks,{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(hn,{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:ir,onChange:wt=>Bn(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(ir.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 qr of p){const uo=g[qr.id]??[];for(const Xx of uo){const Op=l.find(Kr=>Kr.id===Xx);if(Op){const Kr=(Op.name||"").trim().split(/\s+/),X0=Kr[0]||"",Q0=Kr.slice(1).join(" ")||"";wt.push({firstName:X0,lastName:Q0,email:Op.email,brokerageName:qr.name})}}}if(wt.length===0){o({title:"No managers found to export"});return}const Js=[["First Name","Last Name","Email","Brokerage Name"].join(","),...wt.map(qr=>[qr.firstName,qr.lastName,qr.email,qr.brokerageName].map(uo=>`"${(uo||"").replace(/"/g,'""')}"`).join(","))].join(` `),pn=new Blob([Js],{type:"text/csv"}),fn=URL.createObjectURL(pn),oa=document.createElement("a");oa.href=fn,oa.download=`brokerage-managers-${new Date().toISOString().slice(0,10)}.csv`,oa.click(),URL.revokeObjectURL(fn),o({title:`Exported ${wt.length} managers`})},children:[e.jsx(Ci,{className:"mr-2 h-4 w-4"}),"Export Managers"]}),e.jsxs(xs,{open:nt,onOpenChange:et,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(wa,{className:"mr-2 h-4 w-4"}),"Add Brokerage"]})}),e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"brokerage-name",placeholder:"Enter brokerage name",value:Se,onChange:wt=>rt(wt.target.value),maxLength:100})]})}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>et(!1),children:"Cancel"}),e.jsx(K,{onClick:ou,disabled:Ge,children:Ge?"Creating...":"Create Brokerage"})]})]})]})]})]}),e.jsx("div",{className:"border rounded-lg bg-card overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Brokerage Name"}),e.jsx(kt,{className:"font-semibold",children:"Manager(s)"}),e.jsx(kt,{className:"font-semibold",children:"Agents"}),e.jsx(kt,{className:"w-[150px]"})]})}),e.jsx(On,{children:(()=>{const wt=p.filter(Ms=>Ms.name.toLowerCase().includes(ir.toLowerCase()));return wt.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-12 text-muted-foreground",children:ir?"No brokerages match your search":"No brokerages found"})}):wt.map(Ms=>{const Js=l.filter(qr=>qr.brokerage_id===Ms.id),fn=(g[Ms.id]??[]).map(qr=>l.find(uo=>uo.id===qr)).filter(Boolean),oa=Js.length;return e.jsxs(Ss,{className:"hover:bg-muted/30",children:[e.jsx(dt,{children:e.jsx("button",{onClick:()=>Df(Ms),className:"text-primary hover:underline font-medium",children:Ms.name})}),e.jsx(dt,{children:fn.length>0?e.jsx("div",{className:"flex flex-wrap gap-1",children:fn.map(qr=>e.jsx(tt,{variant:"secondary",className:"text-xs",children:qr.name},qr.id))}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"No manager"})}),e.jsxs(dt,{children:[oa," member",oa!==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:()=>Kx(Ms),children:[e.jsx(mr,{className:"h-4 w-4 mr-1"}),"Manage"]}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>Df(Ms),title:"Edit brokerage",children:e.jsx(Da,{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:()=>Gm(Ms),title:"Delete brokerage",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ms.id)})})()})]})}),e.jsx(xs,{open:qe,onOpenChange:Ze,children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"edit-brokerage-name",children:"Brokerage Name"}),e.jsx(ze,{id:"edit-brokerage-name",value:Qe,onChange:wt=>at(wt.target.value),maxLength:100})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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 Ms=(g[Je.id]??[]).map(Js=>l.find(pn=>pn.id===Js)).filter(Boolean);return Ms.length===0?e.jsx("span",{className:"text-sm text-muted-foreground",children:"No managers assigned"}):Ms.map(Js=>e.jsxs(tt,{variant:"default",className:"gap-1",children:[e.jsx(Th,{className:"h-3 w-3"}),Js.name,e.jsx("button",{onClick:()=>co(Js.id,"brokerage_manager","remove",Je.id),className:"ml-1 rounded-full hover:bg-destructive/20",title:"Remove manager from this brokerage",children:e.jsx(Or,{className:"h-3 w-3"})})]},Js.id))})()}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm text-muted-foreground",children:"Assign manager from existing members:"}),e.jsxs(Bo,{open:Cr,onOpenChange:jr,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Cr,className:"w-full justify-between",children:["Search for a member...",e.jsx(hn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-full p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search by name or email..."}),e.jsxs(Ox,{className:"max-h-[200px]",children:[e.jsx(Rx,{children:"No members found."}),e.jsx(Fx,{children:(()=>{const wt=new Set(g[Je.id]??[]);return l.filter(Ms=>!wt.has(Ms.id)&&(r||Ms.brokerage_id===Je.id)).map(Ms=>e.jsxs(vp,{value:`${Ms.name} ${Ms.email}`,onSelect:()=>{kd(Ms.id,Je.id),jr(!1)},children:[Ms.name," (",Ms.email,")"]},Ms.id))})()})]})]})})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(tt,{variant:"outline",className:"text-xs",children:"Manager"})]},wt.id))})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:Rl,children:"Cancel"}),e.jsx(K,{onClick:oh,disabled:It,children:It?"Saving...":"Save Changes"})]})]})}),e.jsx(xs,{open:hs,onOpenChange:Yt,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{className:"text-destructive",children:"Delete Brokerage"}),e.jsxs(Wr,{children:['Are you sure you want to delete "',ts==null?void 0:ts.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 "',ts==null?void 0:ts.name,'"']}),e.jsxs("li",{children:["All ",l.filter(wt=>wt.brokerage_id===(ts==null?void 0:ts.id)).length," member(s) assigned to this brokerage"]}),e.jsx("li",{children:"All their data, roles, and access"})]})]})}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Yt(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Fl,disabled:vr,children:vr?"Deleting...":"Yes, Delete Brokerage"})]})]})}),e.jsx(xs,{open:As,onOpenChange:Us,children:e.jsxs(fs,{className:"max-w-4xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(wa,{className:"h-5 w-5"}),"Manage ",kr==null?void 0:kr.name]}),e.jsx(Wr,{children:"Add, remove, or manage users in this brokerage"})]}),kr&&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(hn,{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:ka,onChange:wt=>Li(wt.target.value),className:"pl-10 h-9"})]}),e.jsxs(xs,{open:Wa,onOpenChange:cr,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{size:"sm",children:[e.jsx(rc,{className:"h-4 w-4 mr-1"}),"Add New Agent"]})}),e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Add New Agent"}),e.jsxs(Wr,{children:["Create a new agent for ",kr.name]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-name",children:"Name"}),e.jsx(ze,{id:"agent-name",placeholder:"John Doe",value:Qr.name,onChange:wt=>Hr({...Qr,name:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-email",children:"Email"}),e.jsx(ze,{id:"agent-email",type:"email",placeholder:"john@example.com",value:Qr.email,onChange:wt=>Hr({...Qr,email:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-password",children:"Password"}),e.jsx(ze,{id:"agent-password",type:"password",placeholder:"Min 6 characters",value:Qr.password,onChange:wt=>Hr({...Qr,password:wt.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"agent-phone",children:"Phone (optional)"}),e.jsx(ze,{id:"agent-phone",type:"tel",placeholder:"555-123-4567",value:Qr.phone,onChange:wt=>Hr({...Qr,phone:wt.target.value})})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>cr(!1),children:"Cancel"}),e.jsx(K,{onClick:H1,disabled:ln,children:ln?"Creating...":"Create Agent"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"text-sm text-muted-foreground whitespace-nowrap",children:"Add existing user:"}),e.jsxs(Bo,{open:Xn,onOpenChange:Aa,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":Xn,className:"w-[300px] justify-between",children:["Select a user to add...",e.jsx(hn,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search users...",value:Pi,onValueChange:Oo}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No users found."}),e.jsx(Fx,{children:lu(kr.id).filter(wt=>Pi===""||wt.name.toLowerCase().includes(Pi.toLowerCase())||wt.email.toLowerCase().includes(Pi.toLowerCase())).map(wt=>e.jsxs(vp,{value:`${wt.name} ${wt.email}`,onSelect:()=>{V1(wt.id,kr.id),Aa(!1),Oo("")},children:[wt.name," (",wt.email,")"]},wt.id))})]})]})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto border rounded-lg",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30 hover:bg-muted/30",children:[e.jsx(kt,{className:"font-semibold",children:"Name"}),e.jsx(kt,{className:"font-semibold",children:"Email"}),e.jsx(kt,{className:"font-semibold",children:"Status"}),e.jsx(kt,{className:"font-semibold",children:"Role"}),e.jsx(kt,{className:"w-[120px]"})]})}),e.jsx(On,{children:nm(kr.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:ka?"No matching members found":"No members in this brokerage"})}):nm(kr.id).map(wt=>e.jsxs(Ss,{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(tt,{variant:"default",className:"bg-green-500/10 text-green-600 hover:bg-green-500/20",children:"Active"}):e.jsx(tt,{variant:"secondary",children:"Pending"})}),e.jsx(dt,{children:wt.roles.includes("brokerage_manager")?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Th,{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:()=>Ea(wt.id),title:"Resend welcome email",children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"h-8 w-8",onClick:()=>U1(wt.id),title:"Remove from brokerage",children:e.jsx(Or,{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:()=>vy(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(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(EM,{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:()=>Mi(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(kr.id).length," total member",Dp(kr.id).length!==1?"s":""," •",Dp(kr.id).filter(wt=>wt.roles.includes("brokerage_manager")).length," manager",Dp(kr.id).filter(wt=>wt.roles.includes("brokerage_manager")).length!==1?"s":""]})]}),e.jsx(zn,{children:e.jsx(K,{variant:"outline",onClick:gy,children:"Close"})})]})})]}),e.jsx(ks,{value:"teams",children:e.jsx(ZUt,{})}),e.jsx(ks,{value:"trials",children:e.jsx(HUt,{})}),e.jsx(ks,{value:"celebrations",children:e.jsx(VUt,{})}),e.jsx(ks,{value:"deletions",children:e.jsx(WUt,{})})]})]}),e.jsx(Qet,{open:yi,onOpenChange:pt,brokerages:p,onSuccess:Ja}),Es&&e.jsx(Jet,{open:Vt,onOpenChange:wt=>{Qt(wt),wt||ys(null)},userId:Es.id,userName:Es.name})]})},XUt=()=>{const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState("");k.useEffect(()=>{_()},[]);const _=async()=>{const{data:L,error:R}=await H.from("invite_codes").select("*").order("created_at",{ascending:!1});R?(he.error("Failed to load invite codes"),console.error(R)):s(L||[]),n(!1)},j=async L=>{if(L.preventDefault(),!l.trim()){he.error("Please enter a code");return}o(!0);const{error:R}=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});R?R.code==="23505"?he.error("This code already exists"):(he.error("Failed to create invite code"),console.error(R)):(he.success("Invite code created"),i(""),u(""),f(""),b(""),_()),o(!1)},w=async(L,R)=>{const{error:q}=await H.from("invite_codes").update({is_active:!R}).eq("id",L);q?he.error("Failed to update code"):s(t.map(U=>U.id===L?{...U,is_active:!R}:U))},N=async L=>{const{error:R}=await H.from("invite_codes").delete().eq("id",L);R?he.error("Failed to delete code"):(he.success("Code deleted"),s(t.filter(q=>q.id!==L)))},C="https://dashboard.relevelup.com",M=L=>{const R=`${C}/join?code=${L}`;navigator.clipboard.writeText(R),he.success("Link copied to clipboard")},I=`${C}/join`;return e.jsx(Ts,{title:"Invite Codes",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{title:"Invite Codes",description:"Manage signup invite codes"}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Create New Code"}),e.jsxs(xr,{children:["Share link: ",e.jsx("code",{className:"bg-muted px-2 py-1 rounded text-sm",children:I})]})]}),e.jsx(Re,{children:e.jsxs("form",{onSubmit:j,className:"flex flex-wrap gap-4 items-end",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"code",children:"Code"}),e.jsx(ze,{id:"code",placeholder:"WELCOME2024",value:l,onChange:L=>i(L.target.value),className:"w-40"})]}),e.jsxs("div",{className:"space-y-2 flex-1 min-w-[200px]",children:[e.jsx(ye,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"For marketing campaign",value:c,onChange:L=>u(L.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"maxUses",children:"Max Uses"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Unlimited",value:p,onChange:L=>f(L.target.value),className:"w-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"trialDays",children:"Trial Days"}),e.jsx(ze,{id:"trialDays",type:"number",placeholder:"None",value:g,onChange:L=>b(L.target.value),className:"w-28"})]}),e.jsxs(K,{type:"submit",disabled:a,children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create"]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Active Codes"})}),e.jsx(Re,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Code"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Uses"}),e.jsx(kt,{children:"Trial"}),e.jsx(kt,{children:"Created"}),e.jsx(kt,{children:"Active"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:t.map(L=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:L.code}),e.jsx(dt,{className:"text-muted-foreground",children:L.description||"—"}),e.jsxs(dt,{children:[L.uses_count,L.max_uses&&` / ${L.max_uses}`]}),e.jsx(dt,{children:L.trial_days?e.jsxs("span",{className:"text-amber-600 dark:text-amber-400 font-medium",children:[L.trial_days," days"]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-muted-foreground",children:ps(new Date(L.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsx($r,{checked:L.is_active,onCheckedChange:()=>w(L.id,L.is_active)})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>M(L.code),title:"Copy invite link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>N(L.id),className:"text-destructive hover:text-destructive",title:"Delete code",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},L.id))})]})})]})]})})},ZO=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}},iE=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}}},QUt=async(t,s)=>await ZO("new_templates")?iE({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}),JUt=async(t,s)=>iE({title:"New Academy Video",body:`New video added: ${t}`,url:`/academy/${s}`}),eVt=async(t,s)=>await ZO("new_events")?iE({title:"New Event",body:`New event: ${t}`,url:`/events/${s}`}):(console.log("New event notifications are disabled"),{success:!1,skipped:!0}),tVt=async(t,s)=>await ZO("new_toolbox")?iE({title:"New Resource Kit",body:`New resource kit available: ${t}`,url:`/toolbox/${s}`}):(console.log("New toolbox notifications are disabled"),{success:!1,skipped:!0}),tbe=async(t,s)=>await ZO("new_social_swag")?iE({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}),sVt=async(t,s)=>await ZO("new_newsletters")?iE({title:"New Newsletter",body:`New newsletter available: ${t}`,url:`/newsletters/${s}`}):(console.log("New newsletter notifications are disabled"),{success:!1,skipped:!0}),jz={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 rVt(){const t=pr(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState(jz),[c,u]=k.useState(null),[p,f]=k.useState(null),[g,b]=k.useState(!1),_=k.useRef(null),[j,w]=k.useState(!1),[N,C]=k.useState(null),[M,I]=k.useState(!1),[L,R]=k.useState(null),[q,U]=k.useState(null),[B,V]=k.useState(!0),[Y,J]=k.useState(""),{data:te,isLoading:X}=mt({queryKey:["admin-events"],queryFn:async()=>{const{data:Se,error:rt}=await H.from("events").select("*").order("event_date",{ascending:!0});if(rt)throw rt;return Se}}),{data:ce}=mt({queryKey:["event-registrations-count"],queryFn:async()=>{let Se=[],rt=0;const Ge=1e3;for(;;){const{data:qe,error:Ze}=await H.from("event_registrations").select("event_id").range(rt,rt+Ge-1);if(Ze)throw Ze;if(!qe||qe.length===0||(Se=Se.concat(qe),qe.length{lt[qe.event_id]=(lt[qe.event_id]||0)+1}),lt}}),{data:ne,isLoading:re}=mt({queryKey:["event-registrations-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Se,error:rt}=await H.from("event_registrations").select("id, user_id, registered_at, zoom_join_url, zoom_name, zoom_email").eq("event_id",N.id).order("registered_at",{ascending:!1});if(rt)throw rt;if(!Se||Se.length===0)return[];const Ge=Se.map(Ze=>Ze.user_id).filter(Boolean);let lt=[];if(Ge.length>0){const{data:Ze,error:Je}=await H.from("profiles").select("id, name, email").in("id",Ge);if(Je)throw Je;lt=Ze||[]}const qe=new Map((lt==null?void 0:lt.map(Ze=>[Ze.id,Ze]))||[]);return Se.map(Ze=>({...Ze,profiles:Ze.user_id&&qe.get(Ze.user_id)||null}))},enabled:!!N}),{data:le,isLoading:pe}=mt({queryKey:["event-attendees-details",N==null?void 0:N.id],queryFn:async()=>{if(!N)return[];const{data:Se,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",N.id).order("created_at",{ascending:!1});if(rt)throw rt;if(!Se||Se.length===0)return[];const Ge=Se.map(He=>He.user_id).filter(Boolean);let lt=[];if(Ge.length>0){const{data:He,error:Qe}=await H.from("profiles").select("id, name, email").in("id",Ge);if(Qe)throw Qe;lt=He||[]}const{data:qe}=await H.from("agent_points").select("user_id").eq("event_id",N.id),Ze=new Set((qe==null?void 0:qe.map(He=>He.user_id))||[]),Je=new Map((lt==null?void 0:lt.map(He=>[He.id,He]))||[]);return Se.map(He=>({...He,profiles:He.user_id&&Je.get(He.user_id)||null,points_awarded:He.user_id?Ze.has(He.user_id):!1}))},enabled:!!N}),xe=Se=>{C(Se),w(!0)},_e=Lt({mutationFn:async Se=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const Ge=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:Se})}),lt=await Ge.json();if(!Ge.ok)throw new Error(lt.error||"Failed to sync");return lt},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-registrations-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-registrations-count"]}),he.success(Se.message)},onError:Se=>{he.error("Failed to sync: "+Se.message)}}),fe=Lt({mutationFn:async Se=>{const{data:{session:rt}}=await H.auth.getSession();if(!rt)throw new Error("Not authenticated");const Ge=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:Se})}),lt=await Ge.json();if(!Ge.ok)throw new Error(lt.error||"Failed to sync attendees");return lt},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]}),Se!=null&&Se.message?he.success(Se.message):he.success(`Synced ${Se.synced||0} attendees. ${Se.points_awarded||0} points awarded!`)},onError:Se=>{he.error("Failed to sync attendees: "+Se.message)}}),we=Lt({mutationFn:async({eventId:Se,testMode:rt})=>{const{data:{session:Ge}}=await H.auth.getSession();if(!Ge)throw new Error("Not authenticated");const lt=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/send-event-reminder",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${Ge.access_token}`},body:JSON.stringify({event_id:Se,test_mode:rt})}),qe=await lt.json();if(!lt.ok)throw new Error(qe.error||"Failed to send reminders");return qe},onSuccess:Se=>{Se.test?he.success(Se.message||"Test email sent!"):he.success(Se.message||`Reminder emails sent to ${Se.sent} registrants!`)},onError:Se=>{he.error("Failed to send reminders: "+Se.message)}}),{data:Ie}=mt({queryKey:["all-profiles-for-linking"],queryFn:async()=>{let Se=[],rt=0;const Ge=1e3;for(;;){const{data:lt,error:qe}=await H.from("profiles").select("id, name, email").order("name",{ascending:!0}).range(rt,rt+Ge-1);if(qe)throw qe;if(!lt||lt.length===0||(Se=[...Se,...lt],lt.length{const{error:qe}=await H.from("event_attendees").update({user_id:rt}).eq("id",Se);if(qe)throw qe;if(lt&&Ge){const{error:Je}=await H.from("zoom_email_aliases").upsert({user_id:rt,zoom_email:Ge.toLowerCase()},{onConflict:"zoom_email"});Je&&console.error("Failed to save alias:",Je)}const Ze=N==null?void 0:N.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:He}=await H.from("agent_points").select("id").eq("user_id",rt).eq("event_id",Ze).single();He||(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:Ge,shouldSaveAlias:lt}},onSuccess:Se=>{s.invalidateQueries({queryKey:["event-attendees-details",N==null?void 0:N.id]}),s.invalidateQueries({queryKey:["event-leaderboard"]}),s.invalidateQueries({queryKey:["admin-agent-points"]});let rt="Attendee linked and points awarded!";Se.shouldSaveAlias&&Se.zoomEmail&&(rt+=` Email "${Se.zoomEmail}" will be auto-matched in the future.`),he.success(rt),I(!1),R(null),U(null),J("")},onError:Se=>{he.error("Failed to link attendee: "+Se.message)}}),Ae=Se=>{R(Se),U(null),V(!0),J(""),I(!0)},Fe=()=>{!L||!q||Ne.mutate({attendeeId:L.id,userId:q,zoomEmail:L.zoom_email,shouldSaveAlias:B})},Ce=(Ie==null?void 0:Ie.filter(Se=>{var Ge,lt;if(!Y)return!0;const rt=Y.toLowerCase();return((Ge=Se.name)==null?void 0:Ge.toLowerCase().includes(rt))||((lt=Se.email)==null?void 0:lt.toLowerCase().includes(rt))}))||[],Me=async Se=>{const rt=Se.name.split(".").pop(),lt=`${`${crypto.randomUUID()}.${rt}`}`,{error:qe}=await H.storage.from("event-images").upload(lt,Se);if(qe)throw qe;const{data:{publicUrl:Ze}}=H.storage.from("event-images").getPublicUrl(lt);return Ze},$e=Se=>{var Ge;const rt=(Ge=Se.target.files)==null?void 0:Ge[0];if(rt){if(rt.size>5*1024*1024){he.error("Image must be less than 5MB");return}u(rt),f(URL.createObjectURL(rt))}},ct=()=>{u(null),f(null),i({...l,image_url:""}),_.current&&(_.current.value="")},Te=Lt({mutationFn:async Se=>{b(!0);let rt=Se.image_url;c&&(rt=await Me(c)||"");const Ge=new Date(Se.event_date),[lt,qe]=Se.event_time.split(":");Ge.setHours(parseInt(lt),parseInt(qe));const Ze=[new Date(Ge)];if(Se.is_recurring&&Se.recurrence_end_date){let at=new Date(Ge);for(;Se.recurrence_pattern==="weekly"?at=p4(at,1):Se.recurrence_pattern==="biweekly"?at=p4(at,2):at=zm(at,1),!(at>Se.recurrence_end_date);)Ze.push(new Date(at))}const Je=Ze.map(at=>({title:Se.title,description:Se.description||null,image_url:rt||null,video_url:Se.video_url||null,event_date:at.toISOString(),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||null,capacity:Se.capacity?parseInt(Se.capacity):null,is_published:Se.is_published})),{data:He,error:Qe}=await H.from("events").insert(Je).select();if(Qe)throw Qe;return He&&He.length>0&&eVt(Se.title,He[0].id),Ze.length},onSuccess:Se=>{s.invalidateQueries({queryKey:["admin-events"]}),he.success(Se>1?`${Se} recurring events created successfully`:"Event created successfully"),n(!1),i(jz),u(null),f(null),b(!1)},onError:Se=>{he.error("Failed to create event: "+Se.message),b(!1)}}),ft=Lt({mutationFn:async({id:Se,data:rt})=>{b(!0);let Ge=rt.image_url;c&&(Ge=await Me(c)||"");const lt=new Date(rt.event_date),[qe,Ze]=rt.event_time.split(":");lt.setHours(parseInt(qe),parseInt(Ze));const{error:Je}=await H.from("events").update({title:rt.title,description:rt.description||null,image_url:Ge||null,video_url:rt.video_url||null,event_date:lt.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",Se);if(Je)throw Je},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),he.success("Event updated successfully"),n(!1),o(null),i(jz),u(null),f(null),b(!1)},onError:Se=>{he.error("Failed to update event: "+Se.message),b(!1)}}),me=Lt({mutationFn:async Se=>{const{error:rt}=await H.from("events").delete().eq("id",Se);if(rt)throw rt},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-events"]}),he.success("Event deleted successfully")},onError:Se=>{he.error("Failed to delete event: "+Se.message)}}),Ve=Se=>{var Ge;const rt=new Date(Se.event_date);o(Se),i({title:Se.title,description:Se.description||"",image_url:Se.image_url||"",video_url:Se.video_url||"",event_date:rt,event_time:ps(rt,"HH:mm"),zoom_link:Se.zoom_link,zoom_meeting_id:Se.zoom_meeting_id||"",capacity:((Ge=Se.capacity)==null?void 0:Ge.toString())||"",is_published:Se.is_published,is_recurring:!1,recurrence_pattern:"weekly",recurrence_end_date:void 0}),f(Se.image_url||null),u(null),n(!0)},nt=Se=>{if(Se.preventDefault(),!l.event_date){he.error("Please select a date");return}if(l.is_recurring&&!l.recurrence_end_date){he.error("Please select an end date for recurring events");return}a?ft.mutate({id:a.id,data:l}):Te.mutate(l)},et=()=>{n(!1),o(null),i(jz),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(ri,{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(Pe,{className:"mb-6",children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"All Events"}),e.jsxs(xs,{open:r,onOpenChange:Se=>!Se&&et(),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(_s,{children:e.jsx(bs,{children:a?"Edit Event":"Create New Event"})}),e.jsxs("form",{onSubmit:nt,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:l.title,onChange:Se=>i({...l,title:Se.target.value}),placeholder:"Event title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:l.description,onChange:Se=>i({...l,description:Se}),placeholder:"Event description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Event Image"}),e.jsx("input",{type:"file",ref:_,accept:"image/*",onChange:$e,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:ct,children:e.jsx(Or,{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 Se;return(Se=_.current)==null?void 0:Se.click()},children:[e.jsx(oi,{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(ye,{children:"Date *"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.event_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),l.event_date?ps(l.event_date,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:l.event_date,onSelect:Se=>i({...l,event_date:Se}),initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"time",children:"Time *"}),e.jsx(ze,{id:"time",type:"time",value:l.event_time,onChange:Se=>i({...l,event_time:Se.target.value}),required:!0})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zoom_link",children:"Zoom Link *"}),e.jsx(ze,{id:"zoom_link",value:l.zoom_link,onChange:Se=>i({...l,zoom_link:Se.target.value}),placeholder:"https://zoom.us/j/...",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zoom_meeting_id",children:"Zoom Meeting ID (for API registration)"}),e.jsx(ze,{id:"zoom_meeting_id",value:l.zoom_meeting_id,onChange:Se=>i({...l,zoom_meeting_id:Se.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(ye,{htmlFor:"video_url",children:"Promo Video URL (optional)"}),e.jsx(ze,{id:"video_url",value:l.video_url,onChange:Se=>i({...l,video_url:Se.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(ye,{htmlFor:"capacity",children:"Capacity (optional)"}),e.jsx(ze,{id:"capacity",type:"number",value:l.capacity,onChange:Se=>i({...l,capacity:Se.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(vL,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{htmlFor:"is_recurring",children:"Recurring Event"})]}),e.jsx($r,{id:"is_recurring",checked:l.is_recurring,onCheckedChange:Se=>i({...l,is_recurring:Se})})]}),l.is_recurring&&e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Frequency"}),e.jsxs(Ys,{value:l.recurrence_pattern,onValueChange:Se=>i({...l,recurrence_pattern:Se}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Repeat Until"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!l.recurrence_end_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),l.recurrence_end_date?ps(l.recurrence_end_date,"PPP"):"Pick end date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:l.recurrence_end_date,onSelect:Se=>i({...l,recurrence_end_date:Se}),disabled:Se=>Se<(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 Se=1,rt=new Date(l.event_date);for(;rt=l.recurrence_pattern==="weekly"?p4(rt,1):l.recurrence_pattern==="biweekly"?p4(rt,2):zm(rt,1),!(rt>l.recurrence_end_date);)Se++;return Se})()," events with the same Zoom link"]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{htmlFor:"is_published",children:"Published"}),e.jsx($r,{id:"is_published",checked:l.is_published,onCheckedChange:Se=>i({...l,is_published:Se})})]}),e.jsxs("div",{className:"flex gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:et,className:"flex-1",children:"Cancel"}),e.jsx(K,{type:"submit",className:"flex-1",disabled:Te.isPending||ft.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(Re,{children:X?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading events..."}):(te==null?void 0:te.length)===0?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No events yet. Create your first event!"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Date & Time"}),e.jsx(kt,{children:"Registrations"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:te==null?void 0:te.map(Se=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Se.title}),e.jsx(dt,{children:ps(new Date(Se.event_date),"PPP p")}),e.jsx(dt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"gap-1",onClick:()=>xe(Se),children:[e.jsx(mr,{className:"h-4 w-4"}),(ce==null?void 0:ce[Se.id])||0,Se.capacity&&` / ${Se.capacity}`]})}),e.jsx(dt,{children:e.jsx("span",{className:Pt("px-2 py-1 rounded-full text-xs font-medium",Se.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:Se.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(Se.zoom_link,"_blank"),title:"Open Zoom Link",children:e.jsx(an,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(Se),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this event?")&&me.mutate(Se.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Se.id))})]})})]}),e.jsx(xs,{open:j,onOpenChange:w,children:e.jsxs(fs,{className:"max-w-3xl max-h-[80vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),N==null?void 0:N.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:()=>we.mutate({eventId:N.id,testMode:!0}),disabled:we.isPending,children:[e.jsx(dr,{className:Pt("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),"Send Test to Me"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>we.mutate({eventId:N.id}),disabled:we.isPending||!(ne!=null&&ne.length),children:[e.jsx(dr,{className:Pt("h-4 w-4 mr-2",we.isPending&&"animate-spin")}),we.isPending?"Sending...":"Send Reminder to All"]}),(N==null?void 0:N.zoom_meeting_id)&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>_e.mutate(N.id),disabled:_e.isPending,children:[e.jsx(Wo,{className:Pt("h-4 w-4 mr-2",_e.isPending&&"animate-spin")}),_e.isPending?"Syncing...":"Sync Registrations"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>fe.mutate(N.id),disabled:fe.isPending,children:[e.jsx(xo,{className:Pt("h-4 w-4 mr-2",fe.isPending&&"animate-spin")}),fe.isPending?"Syncing...":"Sync Attendees & Award Points"]})]})]}),e.jsxs(ja,{defaultValue:"registrations",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(us,{value:"registrations",className:"gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),"Registrations (",(ne==null?void 0:ne.length)||0,")"]}),e.jsxs(us,{value:"attendees",className:"gap-2",children:[e.jsx(la,{className:"h-4 w-4"}),"Attendees (",(le==null?void 0:le.length)||0,")"]})]}),e.jsx(ks,{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."}),(N==null?void 0:N.zoom_meeting_id)&&e.jsx("p",{className:"text-xs mt-2",children:'Click "Sync Registrations" to import from Zoom.'})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Registered"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(On,{children:ne==null?void 0:ne.map(Se=>{var qe,Ze;const rt=((qe=Se.profiles)==null?void 0:qe.name)||Se.zoom_name||"Unknown",Ge=((Ze=Se.profiles)==null?void 0:Ze.email)||Se.zoom_email||null,lt=!Se.user_id;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,lt&&e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:"External"})]})}),e.jsx(dt,{children:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(dr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{className:"text-muted-foreground text-sm",children:ps(new Date(Se.registered_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:Se.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"})})]},Se.id)})})]})}),e.jsx(ks,{value:"attendees",className:"mt-4",children:pe?e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"Loading attendees..."}):(le==null?void 0:le.length)===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx("p",{children:"No attendees recorded yet."}),(N==null?void 0:N.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:[(le==null?void 0:le.filter(Se=>!Se.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(Nl,{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 (",le==null?void 0:le.filter(Se=>!Se.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:le==null?void 0:le.filter(Se=>!Se.user_id).map(Se=>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:Se.zoom_name||"Unknown"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:Se.zoom_email||"No email"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ae(Se),className:"gap-1",children:[e.jsx(cl,{className:"h-3 w-3"}),"Link to Profile"]})]},Se.id))})]}),e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Points"})]})}),e.jsx(On,{children:le==null?void 0:le.filter(Se=>Se.user_id).map(Se=>{var lt,qe;const rt=((lt=Se.profiles)==null?void 0:lt.name)||Se.zoom_name||"Unknown",Ge=((qe=Se.profiles)==null?void 0:qe.email)||Se.zoom_email||null;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[rt,Se.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:Ge?e.jsxs("a",{href:`mailto:${Ge}`,className:"flex items-center gap-1 text-primary hover:underline",children:[e.jsx(dr,{className:"h-3 w-3"}),Ge]}):e.jsx("span",{className:"text-muted-foreground",children:"No email"})}),e.jsx(dt,{children:Se.duration_minutes?e.jsxs("span",{className:"flex items-center gap-1 text-muted-foreground text-sm",children:[e.jsx(mn,{className:"h-3 w-3"}),Se.duration_minutes," min"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"—"})}),e.jsx(dt,{children:Se.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(xo,{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"})})]},Se.id)})})]})]})})]})]})}),e.jsx(xs,{open:M,onOpenChange:I,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(cl,{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."})]}),L&&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:L.zoom_name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:L.zoom_email||"No email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Search for a profile"}),e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:Y,onChange:Se=>J(Se.target.value),className:"pl-9"})]})]}),e.jsx("div",{className:"max-h-48 overflow-y-auto border rounded-md",children:Ce.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:Ce.slice(0,20).map(Se=>e.jsxs("button",{type:"button",onClick:()=>U(Se.id),className:Pt("w-full p-3 text-left hover:bg-muted/50 transition-colors",q===Se.id&&"bg-primary/10 border-l-2 border-primary"),children:[e.jsx("p",{className:"text-sm font-medium",children:Se.name||"Unnamed"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Se.email})]},Se.id))})}),L.zoom_email&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Lo,{id:"save-alias",checked:B,onCheckedChange:Se=>V(Se)}),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:()=>I(!1),children:"Cancel"}),e.jsx(K,{onClick:Fe,disabled:!q||Ne.isPending,children:Ne.isPending?"Linking...":"Link & Award Points"})]})]})]})})]})})}function nVt({selectedKitIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.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(ye,{className:"flex items-center gap-2",children:[e.jsx(Cl,{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(tt,{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(Or,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Bo,{open:a,onOpenChange:o,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(Cl,{className:"h-3.5 w-3.5"}),"Add Toolkit"]})}),e.jsxs(Do,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(hn,{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(Cl,{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 aVt=()=>{const{user:t}=Rs(),{toast:s}=qa(),r=es(),[n,a]=qc(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.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]=k.useState(null),[b,_]=k.useState(0),[j,w]=k.useState(!1),[N,C]=k.useState(null),[M,I]=k.useState(""),[L,R]=k.useState([]),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,J]=k.useState(!1),[te,X]=k.useState(!1),{data:ce=[]}=mt({queryKey:["template-categories"],queryFn:async()=>{const{data:Ve,error:nt}=await H.from("template_categories").select("*").order("name");if(nt)throw nt;return Ve}}),{data:ne=[]}=mt({queryKey:["template-types"],queryFn:async()=>{const{data:Ve,error:nt}=await H.from("template_types").select("*").order("name");if(nt)throw nt;return Ve}}),{data:re=[],isLoading:le}=mt({queryKey:["canva-templates-admin"],queryFn:async()=>{const{data:Ve,error:nt}=await H.from("canva_templates").select(` *, category:template_categories(id, name), type:template_types(id, name) `).order("publish_date",{ascending:!1});if(nt)throw nt;const{data:et,error:Se}=await H.from("template_links").select("*").order("sort_order");if(Se)throw Se;const{data:rt,error:Ge}=await H.from("template_guides").select("*").order("sort_order");if(Ge)throw Ge;return Ve.map(qe=>({...qe,links:(et==null?void 0:et.filter(Ze=>Ze.template_id===qe.id))||[],guides:(rt==null?void 0:rt.filter(Ze=>Ze.template_id===qe.id))||[]}))}});k.useEffect(()=>{const Ve=n.get("edit");if(Ve&&re.length>0){const nt=re.find(et=>et.id===Ve);nt&&(Ie(nt),a({},{replace:!0}))}},[re,n]);const pe=Lt({mutationFn:async Ve=>{const{data:nt,error:et}=await H.from("template_categories").insert({name:Ve}).select().single();if(et)throw et;return nt},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-categories"]}),p({...u,category_id:Ve.id}),U(""),J(!1),s({title:"Category added"})},onError:Ve=>{s({title:"Error adding category",description:Ve.message,variant:"destructive"})}}),xe=Lt({mutationFn:async Ve=>{const{data:nt,error:et}=await H.from("template_types").insert({name:Ve}).select().single();if(et)throw et;return nt},onSuccess:Ve=>{r.invalidateQueries({queryKey:["template-types"]}),p({...u,type_id:Ve.id}),V(""),X(!1),s({title:"Type added"})},onError:Ve=>{s({title:"Error adding type",description:Ve.message,variant:"destructive"})}}),_e=Lt({mutationFn:async Ve=>{var Ge;let nt=Ve.existingImageUrl;if(Ve.image){const lt=Ve.image.name.split(".").pop(),qe=`${Date.now()}-${Math.random().toString(36).substring(7)}.${lt}`,{error:Ze}=await H.storage.from("template-previews").upload(qe,Ve.image);if(Ze)throw Ze;const{data:Je}=H.storage.from("template-previews").getPublicUrl(qe);nt=Je.publicUrl}const et={name:Ve.template.name,description:Ve.template.description||null,category_id:Ve.template.category_id||null,type_id:Ve.template.type_id||null,preview_image_url:nt,video_url:Ve.videoUrl||null,publish_date:Ve.template.publish_date?new Date(Ve.template.publish_date).toISOString():new Date().toISOString(),created_by:t==null?void 0:t.id};let Se=Ve.templateId;if(Se){const{error:lt}=await H.from("canva_templates").update(et).eq("id",Se);if(lt)throw lt;const{error:qe}=await H.from("template_links").delete().eq("template_id",Se);if(qe)throw qe;const Ze=((Ge=Ve.existingGuides)==null?void 0:Ge.map(Qe=>Qe.id).filter(Boolean))||[],Je=Ve.template.guides.map(Qe=>Qe.id).filter(Boolean),He=Ze.filter(Qe=>!Je.includes(Qe));He.length>0&&await H.from("template_guides").delete().in("id",He)}else{const{data:lt,error:qe}=await H.from("canva_templates").insert(et).select().single();if(qe)throw qe;Se=lt.id,QUt(Ve.template.name,lt.id)}const rt=Ve.template.links.filter(lt=>lt.title.trim()&<.canva_share_link.trim());if(rt.length>0){const lt=rt.map((Ze,Je)=>({template_id:Se,title:Ze.title.trim(),canva_share_link:Ze.canva_share_link.trim(),sort_order:Je})),{error:qe}=await H.from("template_links").insert(lt);if(qe)throw qe}for(let lt=0;lt0)){const{error:lt}=await H.from("resource_kit_templates").insert(Ve.linkedKitIds.map(qe=>({template_id:Se,kit_id:qe})));if(lt)throw lt}},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),we(),l(!1),s({title:i?"Template updated":"Template created"})},onError:Ve=>{s({title:"Error saving template",description:Ve.message,variant:"destructive"})}}),fe=Lt({mutationFn:async Ve=>{const{error:nt}=await H.from("canva_templates").delete().eq("id",Ve);if(nt)throw nt},onSuccess:()=>{r.invalidateQueries({queryKey:["canva-templates-admin"]}),r.invalidateQueries({queryKey:["canva-templates"]}),s({title:"Template deleted"})},onError:Ve=>{s({title:"Error deleting template",description:Ve.message,variant:"destructive"})}}),we=()=>{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:""}),C(null),I(""),c(null),J(!1),X(!1),U(""),V(""),g(null),_(0),w(!1),R([])},Ie=async Ve=>{var et;c(Ve),p({name:Ve.name,description:Ve.description||"",category_id:Ve.category_id||"",type_id:Ve.type_id||"",publish_date:Ve.publish_date?new Date(Ve.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],links:Ve.links&&Ve.links.length>0?Ve.links.map(Se=>({id:Se.id,title:Se.title,canva_share_link:Se.canva_share_link,sort_order:Se.sort_order})):[{title:"",canva_share_link:"",sort_order:0}],guides:((et=Ve.guides)==null?void 0:et.map(Se=>({id:Se.id,name:Se.name,file_url:Se.file_url,file_type:Se.file_type,file_size:Se.file_size,sort_order:Se.sort_order})))||[],video_url:Ve.video_url||""}),I(Ve.preview_image_url||""),g(null);const{data:nt}=await H.from("resource_kit_templates").select("kit_id").eq("template_id",Ve.id);R((nt||[]).map(Se=>Se.kit_id)),l(!0)},Ne=Ve=>{var et;const nt=(et=Ve.target.files)==null?void 0:et[0];nt&&(C(nt),I(URL.createObjectURL(nt)))},Ae=()=>{p({...u,links:[...u.links,{title:"",canva_share_link:"",sort_order:u.links.length}]})},Fe=Ve=>{if(u.links.length<=1)return;const nt=u.links.filter((et,Se)=>Se!==Ve);p({...u,links:nt})},Ce=(Ve,nt,et)=>{const Se=[...u.links];Se[Ve]={...Se[Ve],[nt]:et},p({...u,links:Se})},Me=Ve=>{const nt=Ve.target.files;if(!nt)return;const et=Array.from(nt).map((Se,rt)=>({name:Se.name.replace(/\.[^/.]+$/,""),file_url:"",file_type:Se.type,file_size:Se.size,sort_order:u.guides.length+rt,file:Se}));p({...u,guides:[...u.guides,...et]}),Ve.target.value=""},$e=Ve=>{const nt=u.guides.filter((et,Se)=>Se!==Ve);p({...u,guides:nt})},ct=(Ve,nt)=>{const et=[...u.guides];et[Ve]={...et[Ve],name:nt},p({...u,guides:et})},Te=async()=>{if(!f)return null;w(!0),_(0);try{const{data:Ve,error:nt}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.name||f.name}});if(nt)throw new Error(nt.message);const{videoId:et,libraryId:Se}=Ve,{data:rt,error:Ge}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:et}});if(Ge)throw new Error(Ge.message);const lt=new XMLHttpRequest;return await new Promise((Ze,Je)=>{lt.upload.addEventListener("progress",He=>{if(He.lengthComputable){const Qe=Math.round(He.loaded/He.total*100);_(Qe)}}),lt.addEventListener("load",()=>{lt.status>=200&<.status<300?Ze():Je(new Error(`Upload failed with status ${lt.status}`))}),lt.addEventListener("error",()=>Je(new Error("Upload failed"))),lt.open("PUT",rt.uploadUrl),lt.setRequestHeader("AccessKey",rt.apiKey),lt.send(f)}),`https://player.mediadelivery.net/embed/${Se}/${et}`}catch(Ve){return console.error("Bunny upload error:",Ve),s({title:"Video upload failed",description:Ve instanceof Error?Ve.message:"Unknown error",variant:"destructive"}),null}finally{w(!1)}},ft=Ve=>{var et;const nt=(et=Ve.target.files)==null?void 0:et[0];nt&&g(nt),Ve.target.value=""},me=async Ve=>{if(Ve.preventDefault(),!u.name.trim()){s({title:"Please enter a template name",variant:"destructive"});return}if(u.links.filter(Se=>Se.title.trim()&&Se.canva_share_link.trim()).length===0){s({title:"Please add at least one Canva link",variant:"destructive"});return}let et=u.video_url;if(f){const Se=await Te();if(!Se)return;et=Se}_e.mutate({template:u,image:N,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:et,linkedKitIds:L})};return e.jsx(Ts,{title:"Manage Templates",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Templates"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:re.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Categories"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ce.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Template Types"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:ne.length})})]})]}),e.jsxs(xs,{open:o,onOpenChange:Ve=>{l(Ve),Ve||we()},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(_s,{children:e.jsx(bs,{children:i?"Edit Template":"Add New Template"})}),e.jsxs("form",{onSubmit:me,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:u.name,onChange:Ve=>p({...u,name:Ve.target.value}),placeholder:"Template name",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:u.description,onChange:Ve=>p({...u,description:Ve}),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(ye,{children:"Canva Links *"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:Ae,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((Ve,nt)=>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:Ve.title,onChange:et=>Ce(nt,"title",et.target.value),placeholder:"Link title (e.g., Instagram Post, Story)"}),e.jsx(ze,{value:Ve.canva_share_link,onChange:et=>Ce(nt,"canva_share_link",et.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:()=>Fe(nt),children:e.jsx(Or,{className:"h-4 w-4"})})]},nt))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Category"}),Y?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:Ve=>U(Ve.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&pe.mutate(q.trim()),disabled:pe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{J(!1),U("")},children:e.jsx(Or,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ys,{value:u.category_id,onValueChange:Ve=>p({...u,category_id:Ve}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsx(Ks,{children:ce.map(Ve=>e.jsx(Mt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>J(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Template Type"}),te?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:B,onChange:Ve=>V(Ve.target.value),placeholder:"New type name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>B.trim()&&xe.mutate(B.trim()),disabled:xe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{X(!1),V("")},children:e.jsx(Or,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ys,{value:u.type_id,onValueChange:Ve=>p({...u,type_id:Ve}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Qs,{placeholder:"Select type"})}),e.jsx(Ks,{children:ne.map(Ve=>e.jsx(Mt,{value:Ve.id,children:Ve.name},Ve.id))})]}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>X(!0),children:e.jsx(qs,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:Ve=>p({...u,publish_date:Ve.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(ye,{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:()=>{C(null),I("")},children:e.jsx(Or,{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(fl,{className:"h-8 w-8 text-muted-foreground/50"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:Ne,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(ye,{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})})]}):j?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(ws,{className:"h-4 w-4 animate-spin"}),e.jsxs("span",{className:"text-sm",children:["Uploading video... ",b,"%"]})]}),e.jsx(Bi,{value:b,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(Or,{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:ft,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(ye,{children:"Guide Files (PDFs)"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx(ze,{type:"file",accept:".pdf,.doc,.docx",multiple:!0,onChange:Me,className:"hidden"}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",asChild:!0,children:e.jsxs("span",{children:[e.jsx(oi,{className:"h-3 w-3"}),"Add Files"]})})]})]}),u.guides.length>0?e.jsx("div",{className:"space-y-2",children:u.guides.map((Ve,nt)=>e.jsxs("div",{className:"flex gap-2 items-center p-3 border rounded-lg bg-muted/30",children:[e.jsx(En,{className:"h-5 w-5 text-muted-foreground shrink-0"}),e.jsx(ze,{value:Ve.name,onChange:et=>ct(nt,et.target.value),placeholder:"Guide name",className:"flex-1"}),Ve.file_size&&e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[(Ve.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:()=>$e(nt),children:e.jsx(Or,{className:"h-4 w-4"})})]},Ve.id||nt))}):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(nVt,{selectedKitIds:L,onChange:R}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{l(!1),we()},children:"Cancel"}),e.jsx(K,{type:"submit",disabled:_e.isPending,children:_e.isPending?"Saving...":i?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:le?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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Preview"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Links"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:re.map(Ve=>{var nt,et,Se,rt,Ge;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("div",{className:"w-16 h-12 rounded overflow-hidden bg-muted",children:Ve.preview_image_url?e.jsx("img",{src:Ve.preview_image_url,alt:Ve.name,className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(fl,{className:"h-4 w-4 text-muted-foreground"})})})}),e.jsx(dt,{className:"font-medium",children:Ve.name}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs(tt,{variant:"secondary",children:[((nt=Ve.links)==null?void 0:nt.length)||0," link",(((et=Ve.links)==null?void 0:et.length)||0)!==1?"s":""]}),(((Se=Ve.guides)==null?void 0:Se.length)||0)>0&&e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(En,{className:"h-3 w-3"}),(rt=Ve.guides)==null?void 0:rt.length," guide",(((Ge=Ve.guides)==null?void 0:Ge.length)||0)!==1?"s":""]})]})}),e.jsx(dt,{children:Ve.category?e.jsx(tt,{variant:"secondary",children:Ve.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{children:Ve.type?e.jsx(tt,{variant:"outline",children:Ve.type.name}):e.jsx("span",{className:"text-muted-foreground",children:"-"})}),e.jsx(dt,{className:"text-muted-foreground",children:new Date(Ve.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:()=>Ie(Ve),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>{confirm("Delete this template?")&&fe.mutate(Ve.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ve.id)})})]})})})]})})};function att({selectedTemplateIds:t,onChange:s}){const[r,n]=k.useState(""),[a,o]=k.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(ye,{className:"flex items-center gap-2",children:[e.jsx(tS,{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(tt,{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(Or,{className:"h-3 w-3"})})]},f.id))}),e.jsxs(Bo,{open:a,onOpenChange:o,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-1",children:[e.jsx(tS,{className:"h-3.5 w-3.5"}),"Add Template"]})}),e.jsxs(Do,{className:"w-80 p-2",align:"start",children:[e.jsxs("div",{className:"relative mb-2",children:[e.jsx(hn,{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(tS,{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"}],oVt=()=>{const{user:t}=Rs(),[s,r]=qc(),{toast:n}=qa(),a=es(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState({title:"",description:"",video_url:"",video_type:"youtube",duration:"",category_id:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState([]),[N,C]=k.useState([]),[M,I]=k.useState([]),[L,R]=k.useState([]),[q,U]=k.useState(""),[B,V]=k.useState(!1),[Y,J]=k.useState(null),[te,X]=k.useState(0),[ce,ne]=k.useState(!1),[re,le]=k.useState(null),{data:pe=[]}=mt({queryKey:["academy-categories"],queryFn:async()=>{const{data:me,error:Ve}=await H.from("academy_categories").select("*").order("sort_order",{ascending:!0});if(Ve)throw Ve;return me}}),{data:xe=[],isLoading:_e}=mt({queryKey:["academy-videos-admin"],queryFn:async()=>{const{data:me,error:Ve}=await H.from("academy_videos").select(` *, category:academy_categories(id, name) `).order("publish_date",{ascending:!1});if(Ve)throw Ve;const{data:nt,error:et}=await H.from("academy_resources").select("*").order("sort_order");if(et)throw et;return me.map(rt=>({...rt,resources:(nt==null?void 0:nt.filter(Ge=>Ge.video_id===rt.id))||[]}))}});k.useEffect(()=>{const me=s.get("edit");if(me&&xe.length>0){const Ve=xe.find(nt=>nt.id===me);Ve&&(Fe(Ve),r({},{replace:!0}))}},[xe,s]);const fe=Lt({mutationFn:async me=>{const{data:Ve,error:nt}=await H.from("academy_categories").insert({name:me,sort_order:pe.length}).select().single();if(nt)throw nt;return Ve},onSuccess:me=>{a.invalidateQueries({queryKey:["academy-categories"]}),p({...u,category_id:me.id}),U(""),V(!1),n({title:"Category added"})},onError:me=>{n({title:"Error adding category",description:me.message,variant:"destructive"})}}),we=Lt({mutationFn:async me=>{let Ve=me.existingThumbnailUrl;if(me.thumbnail){const Se=me.thumbnail.name.split(".").pop(),rt=`thumbnails/${Date.now()}-${Math.random().toString(36).substring(7)}.${Se}`,{error:Ge}=await H.storage.from("academy-resources").upload(rt,me.thumbnail);if(Ge)throw Ge;const{data:lt}=H.storage.from("academy-resources").getPublicUrl(rt);Ve=lt.publicUrl}const nt={title:me.video.title,description:me.video.description||null,video_url:me.video.video_url,video_type:me.video.video_type,duration:me.video.duration||null,thumbnail_url:Ve,category_id:me.video.category_id||null,publish_date:me.video.publish_date?new Date(me.video.publish_date).toISOString():new Date().toISOString(),is_published:me.video.is_published,created_by:t==null?void 0:t.id};let et=me.videoId;if(et){const{error:Se}=await H.from("academy_videos").update(nt).eq("id",et);if(Se)throw Se}else{const{data:Se,error:rt}=await H.from("academy_videos").insert(nt).select().single();if(rt)throw rt;et=Se.id,JUt(me.video.title,Se.id)}if(me.resourcesToDelete.length>0){const{error:Se}=await H.from("academy_resources").delete().in("id",me.resourcesToDelete);if(Se)throw Se}for(let Se=0;Se0){const{error:Se}=await H.from("academy_video_templates").insert(L.map(rt=>({video_id:et,template_id:rt})));if(Se)throw Se}},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),Ae(),l(!1),n({title:i?"Video updated":"Video created"})},onError:me=>{n({title:"Error saving video",description:me.message,variant:"destructive"})}}),Ie=Lt({mutationFn:async me=>{const{error:Ve}=await H.from("academy_videos").delete().eq("id",me);if(Ve)throw Ve},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]}),n({title:"Video deleted"})},onError:me=>{n({title:"Error deleting video",description:me.message,variant:"destructive"})}}),Ne=Lt({mutationFn:async({id:me,is_published:Ve})=>{const{error:nt}=await H.from("academy_videos").update({is_published:Ve}).eq("id",me);if(nt)throw nt},onSuccess:()=>{a.invalidateQueries({queryKey:["academy-videos-admin"]}),a.invalidateQueries({queryKey:["academy-videos"]})},onError:me=>{n({title:"Error updating video",description:me.message,variant:"destructive"})}}),Ae=()=>{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),_(""),w([]),C([]),I([]),c(null),R([]),U(""),J(null),X(0),ne(!1),le(null)},Fe=async me=>{c(me),p({title:me.title,description:me.description||"",video_url:me.video_url,video_type:me.video_type,duration:me.duration||"",category_id:me.category_id||"",publish_date:me.publish_date?new Date(me.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:me.is_published}),_(me.thumbnail_url||""),C(me.resources||[]),w([]),I([]);const{data:Ve}=await H.from("academy_video_templates").select("template_id").eq("video_id",me.id);R((Ve||[]).map(nt=>nt.template_id)),l(!0)},Ce=me=>{var nt;const Ve=(nt=me.target.files)==null?void 0:nt[0];Ve&&(g(Ve),_(URL.createObjectURL(Ve)))},Me=me=>{const Ve=me.target.files;if(Ve){const nt=Array.from(Ve).map(et=>({file:et,title:et.name.replace(/\.[^/.]+$/,"")}));w([...j,...nt])}me.target.value=""},$e=me=>{w(j.filter((Ve,nt)=>nt!==me))},ct=me=>{I([...M,me]),C(N.filter(Ve=>Ve.id!==me))},Te=async()=>{if(!Y)return null;ne(!0),X(0);try{const{data:me,error:Ve}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:u.title||Y.name}});if(Ve)throw new Error(Ve.message);const{videoId:nt,libraryId:et}=me;le(nt);const{data:Se,error:rt}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:nt}});if(rt)throw new Error(rt.message);const Ge=new XMLHttpRequest;return await new Promise((qe,Ze)=>{Ge.upload.addEventListener("progress",Je=>{if(Je.lengthComputable){const He=Math.round(Je.loaded/Je.total*100);X(He)}}),Ge.addEventListener("load",()=>{Ge.status>=200&&Ge.status<300?qe():Ze(new Error(`Upload failed with status ${Ge.status}`))}),Ge.addEventListener("error",()=>Ze(new Error("Upload failed"))),Ge.open("PUT",Se.uploadUrl),Ge.setRequestHeader("AccessKey",Se.apiKey),Ge.send(Y)}),`https://player.mediadelivery.net/embed/${et}/${nt}`}catch(me){return console.error("Bunny upload error:",me),n({title:"Video upload failed",description:me instanceof Error?me.message:"Unknown error",variant:"destructive"}),null}finally{ne(!1)}},ft=async me=>{if(me.preventDefault(),!u.title.trim()){n({title:"Please enter a video title",variant:"destructive"});return}let Ve=u.video_url;if(u.video_type==="bunny_stream"&&Y&&!i){const nt=await Te();if(!nt)return;Ve=nt}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"&&!Y&&!u.video_url&&!i){n({title:"Please select a video file to upload",variant:"destructive"});return}we.mutate({video:{...u,video_url:Ve},thumbnail:f,existingThumbnailUrl:(i==null?void 0:i.thumbnail_url)||null,videoId:i==null?void 0:i.id,newResources:j,resourcesToDelete:M})};return e.jsx(Ts,{title:"Manage Academy",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Videos"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:xe.filter(me=>me.is_published).length})})]})]}),e.jsxs(xs,{open:o,onOpenChange:me=>{l(me),me||Ae()},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(_s,{children:e.jsx(bs,{children:i?"Edit Video":"Add New Video"})}),e.jsxs("form",{onSubmit:ft,className:"space-y-6 pt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:u.title,onChange:me=>p({...u,title:me.target.value}),placeholder:"Video title",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:u.description,onChange:me=>p({...u,description:me}),placeholder:"Brief description of the video",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Video Type"}),e.jsxs(Ys,{value:u.video_type,onValueChange:me=>{p({...u,video_type:me,video_url:""}),J(null)},disabled:ce,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:iVt.map(me=>e.jsx(Mt,{value:me.value,children:me.label},me.value))})]})]}),u.video_type==="bunny_stream"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs(ye,{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:me=>{var nt;const Ve=(nt=me.target.files)==null?void 0:nt[0];Ve&&J(Ve)},disabled:ce}),Y&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Cn,{className:"h-4 w-4"}),Y.name," (",(Y.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(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"text-sm",children:"Uploading to Bunny.net..."})]}),e.jsx(Bi,{value:te,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[te,"%"]})]})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"video_url",children:"Video URL *"}),e.jsx(ze,{id:"video_url",value:u.video_url,onChange:me=>p({...u,video_url:me.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(ye,{htmlFor:"duration",children:"Duration"}),e.jsx(ze,{id:"duration",value:u.duration,onChange:me=>p({...u,duration:me.target.value}),placeholder:"e.g., 45:30"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:u.publish_date,onChange:me=>p({...u,publish_date:me.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Category"}),B?e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:q,onChange:me=>U(me.target.value),placeholder:"New category name",className:"flex-1"}),e.jsx(K,{type:"button",size:"sm",onClick:()=>q.trim()&&fe.mutate(q.trim()),disabled:fe.isPending,children:"Add"}),e.jsx(K,{type:"button",size:"sm",variant:"ghost",onClick:()=>{V(!1),U("")},children:e.jsx(Or,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ys,{value:u.category_id,onValueChange:me=>p({...u,category_id:me}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsx(Ks,{children:pe.map(me=>e.jsx(Mt,{value:me.id,children:me.name},me.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(ye,{children:"Thumbnail Image"}),e.jsxs("div",{className:"flex items-start gap-4",children:[b&&e.jsx("img",{src:b,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:Ce,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(ye,{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(oi,{className:"h-3 w-3"}),"Add Files",e.jsx("input",{type:"file",multiple:!0,accept:".pdf,.pptx,.ppt,.xlsx,.xls,.docx,.doc,.zip",onChange:Me,className:"hidden"})]})})]}),(N.length>0||j.length>0)&&e.jsxs("div",{className:"space-y-2 mt-2",children:[N.map(me=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm truncate",children:me.title}),e.jsx(tt,{variant:"outline",className:"text-xs",children:me.file_type}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>ct(me.id),className:"text-destructive hover:text-destructive",children:e.jsx(Or,{className:"h-4 w-4"})})]},me.id)),j.map((me,Ve)=>e.jsxs("div",{className:"flex items-center gap-2 p-2 border rounded-md bg-muted/30",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:me.title,onChange:nt=>{const et=[...j];et[Ve].title=nt.target.value,w(et)},className:"flex-1 h-8",placeholder:"Resource title"}),e.jsx(tt,{variant:"secondary",className:"text-xs",children:"New"}),e.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>$e(Ve),className:"text-destructive hover:text-destructive",children:e.jsx(Or,{className:"h-4 w-4"})})]},Ve))]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Supported: PDF, PowerPoint, Excel, Word, ZIP"})]}),e.jsx(att,{selectedTemplateIds:L,onChange:R}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"is_published",checked:u.is_published,onCheckedChange:me=>p({...u,is_published:me})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs(zn,{children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),disabled:ce,children:"Cancel"}),e.jsx(K,{type:"submit",disabled:we.isPending||ce,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):we.isPending?"Saving...":i?"Update Video":"Add Video"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:_e?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"})}):xe.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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Resources"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-[120px]",children:"Actions"})]})}),e.jsx(On,{children:xe.map(me=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[me.thumbnail_url?e.jsx("img",{src:me.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:me.title}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:me.video_type.replace("_"," ")})]})]})}),e.jsx(dt,{children:me.category?e.jsx(tt,{variant:"outline",children:me.category.name}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:me.duration||"-"}),e.jsx(dt,{children:me.resources&&me.resources.length>0?e.jsxs(tt,{variant:"secondary",children:[me.resources.length," file(s)"]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"-"})}),e.jsx(dt,{children:new Date(me.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx($r,{checked:me.is_published,onCheckedChange:Ve=>Ne.mutate({id:me.id,is_published:Ve})})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Fe(me),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>Ie.mutate(me.id),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},me.id))})]})})})]})})};function lVt(){var we,Ie,Ne;const t=es(),[s,r]=qc(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,g]=k.useState(""),[b,_]=k.useState([]),[j,w]=k.useState([]),[N,C]=k.useState([]),[M,I]=k.useState(null),{data:L,isLoading:R}=mt({queryKey:["resource-kits"],queryFn:async()=>{const{data:Ae,error:Fe}=await H.from("resource_kits").select("*").order("publish_date",{ascending:!1});if(Fe)throw Fe;return Ae}}),{data:q}=mt({queryKey:["resource-kit-files"],queryFn:async()=>{const{data:Ae,error:Fe}=await H.from("resource_kit_files").select("*").order("sort_order",{ascending:!0});if(Fe)throw Fe;return Ae}}),{data:U}=mt({queryKey:["resource-kit-links"],queryFn:async()=>{const{data:Ae,error:Fe}=await H.from("resource_kit_links").select("*").order("sort_order",{ascending:!0});if(Fe)throw Fe;return Ae}});k.useEffect(()=>{const Ae=s.get("edit");if(Ae&&L&&L.length>0&&q&&U){const Fe=L.find(Ce=>Ce.id===Ae);Fe&&(V(Fe),r({},{replace:!0}))}},[L,q,U,s]);const B=()=>{c({name:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),_([]),w([]),C([]),l(null)},V=async Ae=>{l(Ae),c({name:Ae.name,description:Ae.description||"",publish_date:Ae.publish_date.split("T")[0],is_published:Ae.is_published}),g(Ae.featured_image_url||"");const Fe=(q==null?void 0:q.filter($e=>$e.kit_id===Ae.id))||[];_(Fe.map($e=>({id:$e.id,name:$e.name,file_url:$e.file_url,file_type:$e.file_type,file_size:$e.file_size,sort_order:$e.sort_order})));const Ce=(U==null?void 0:U.filter($e=>$e.kit_id===Ae.id))||[];w(Ce.map($e=>({id:$e.id,title:$e.title,canva_share_link:$e.canva_share_link,sort_order:$e.sort_order})));const{data:Me}=await H.from("resource_kit_templates").select("template_id").eq("kit_id",Ae.id);C((Me||[]).map($e=>$e.template_id)),a(!0)},Y=Ae=>{var Ce;const Fe=(Ce=Ae.target.files)==null?void 0:Ce[0];Fe&&(p(Fe),g(URL.createObjectURL(Fe)))},J=()=>{_([...b,{name:"",file_url:"",sort_order:b.length}])},te=Ae=>{_(b.filter((Fe,Ce)=>Ce!==Ae))},X=(Ae,Fe,Ce)=>{const Me=[...b];Me[Ae]={...Me[Ae],[Fe]:Ce},_(Me)},ce=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},ne=Ae=>{w(j.filter((Fe,Ce)=>Ce!==Ae))},re=(Ae,Fe,Ce)=>{const Me=[...j];Me[Ae]={...Me[Ae],[Fe]:Ce},w(Me)},le=(Ae,Fe)=>{var Me;const Ce=(Me=Fe.target.files)==null?void 0:Me[0];if(Ce){const $e=[...b],ct=Ce.name.replace(/\.[^/.]+$/,"");$e[Ae]={...$e[Ae],file:Ce,file_type:Ce.type,file_size:Ce.size,name:$e[Ae].name||ct},_($e)}},pe=Lt({mutationFn:async()=>{let Ae=(o==null?void 0:o.featured_image_url)||null;if(u){const ct=u.name.split(".").pop(),Te=`${Date.now()}.${ct}`,{error:ft}=await H.storage.from("resource-kits").upload(`featured/${Te}`,u);if(ft)throw ft;const{data:me}=H.storage.from("resource-kits").getPublicUrl(`featured/${Te}`);Ae=me.publicUrl}const Fe={name:i.name,description:i.description||null,featured_image_url:Ae,publish_date:i.publish_date,is_published:i.is_published};let Ce;const Me=!o,$e=(o==null?void 0:o.is_published)||!1;if(o){const{error:ct}=await H.from("resource_kits").update(Fe).eq("id",o.id);if(ct)throw ct;Ce=o.id;const Te=(q==null?void 0:q.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],ft=b.filter(Se=>Se.id).map(Se=>Se.id),me=Te.filter(Se=>!ft.includes(Se));me.length>0&&await H.from("resource_kit_files").delete().in("id",me);const Ve=(U==null?void 0:U.filter(Se=>Se.kit_id===o.id).map(Se=>Se.id))||[],nt=j.filter(Se=>Se.id).map(Se=>Se.id),et=Ve.filter(Se=>!nt.includes(Se));et.length>0&&await H.from("resource_kit_links").delete().in("id",et)}else{const{data:ct,error:Te}=await H.from("resource_kits").insert(Fe).select().single();if(Te)throw Te;Ce=ct.id}for(let ct=0;ct0){const{error:ct}=await H.from("resource_kit_templates").insert(N.map(Te=>({kit_id:Ce,template_id:Te})));if(ct)throw ct}return{kitId:Ce,kitName:i.name,isNewKit:Me,wasPublished:$e,isPublished:i.is_published}},onSuccess:Ae=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),t.invalidateQueries({queryKey:["resource-kit-links"]}),he.success(o?"Resource kit updated":"Resource kit created"),Ae.isPublished&&(Ae.isNewKit||!Ae.wasPublished)&&tVt(Ae.kitName,Ae.kitId),a(!1),B()},onError:Ae=>{he.error("Failed to save resource kit: "+Ae.message)}}),xe=Lt({mutationFn:async Ae=>{const{error:Fe}=await H.from("resource_kits").delete().eq("id",Ae);if(Fe)throw Fe},onSuccess:()=>{t.invalidateQueries({queryKey:["resource-kits"]}),t.invalidateQueries({queryKey:["resource-kit-files"]}),he.success("Resource kit deleted")},onError:Ae=>{he.error("Failed to delete: "+Ae.message)}}),_e=Ae=>{if(Ae.preventDefault(),!i.name){he.error("Please enter a name");return}pe.mutate()},fe=Ae=>(q==null?void 0:q.filter(Fe=>Fe.kit_id===Ae).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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Kits"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(L==null?void 0:L.filter(Ae=>Ae.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(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Files"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:R?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):(L==null?void 0:L.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No resource kits yet. Create your first one!"})}):L==null?void 0:L.map(Ae=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ae.featured_image_url?e.jsx("img",{src:Ae.featured_image_url,alt:Ae.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(Cl,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ae.name}),Ae.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ae.description})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),fe(Ae.id)]})}),e.jsx(dt,{children:ps(new Date(Ae.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 ${Ae.is_published?"bg-green-100 text-green-800":"bg-yellow-100 text-yellow-800"}`,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:()=>{const Fe=(q==null?void 0:q.filter(Me=>Me.kit_id===Ae.id))||[],Ce=(U==null?void 0:U.filter(Me=>Me.kit_id===Ae.id))||[];I({...Ae,files:Fe,links:Ce})},children:e.jsx(qn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>V(Ae),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource kit?")&&xe.mutate(Ae.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ae.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(_s,{children:e.jsx(bs,{children:o?"Edit Resource Kit":"Add Resource Kit"})}),e.jsxs("form",{onSubmit:_e,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Cl,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx(ze,{type:"file",accept:"image/*",onChange:Y})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:Ae=>c({...i,name:Ae.target.value}),placeholder:"Resource Kit Name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:i.description,onChange:Ae=>c({...i,description:Ae}),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(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:Ae=>c({...i,publish_date:Ae.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx($r,{checked:i.is_published,onCheckedChange:Ae=>c({...i,is_published:Ae})}),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(ye,{children:"Resource Files"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:J,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add File"]})]}),b.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:b.map((Ae,Fe)=>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 ",Fe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>te(Fe),children:e.jsx(Or,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"File name (e.g., Getting Started Guide)",value:Ae.name,onChange:Ce=>X(Fe,"name",Ce.target.value)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",onChange:Ce=>le(Fe,Ce),className:"flex-1"}),Ae.file_url&&!Ae.file&&e.jsx("a",{href:Ae.file_url,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-primary hover:underline whitespace-nowrap",children:"Current file"}),Ae.file&&e.jsx("span",{className:"text-sm text-green-600 whitespace-nowrap",children:"New file selected"})]})]},Fe))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ye,{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"]})]}),j.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:j.map((Ae,Fe)=>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 ",Fe+1]}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>ne(Fe),children:e.jsx(Or,{className:"h-4 w-4"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Social Media Post Template)",value:Ae.title,onChange:Ce=>re(Fe,"title",Ce.target.value)}),e.jsx(ze,{placeholder:"Canva share link (e.g., https://www.canva.com/design/...)",value:Ae.canva_share_link,onChange:Ce=>re(Fe,"canva_share_link",Ce.target.value)})]},Fe))})]}),e.jsx(att,{selectedTemplateIds:N,onChange:C}),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:pe.isPending,children:pe.isPending?"Saving...":o?"Update":"Create"})]})]})]})}),e.jsx(xs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(bs,{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 (",((we=M==null?void 0:M.files)==null?void 0:we.length)||0,")"]}),((Ie=M==null?void 0:M.files)==null?void 0:Ie.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:(Ne=M==null?void 0:M.files)==null?void 0:Ne.map(Ae=>e.jsxs("a",{href:Ae.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(En,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.name})]},Ae.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(Ae=>e.jsxs("a",{href:Ae.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(zo,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm",children:Ae.title})]},Ae.id))})]})]})]})})]})})}const cVt=()=>{const{user:t}=Rs(),{toast:s}=qa(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,links:[{title:"",canva_share_link:"",sort_order:0}]}),[u,p]=k.useState(null),[f,g]=k.useState(""),{data:b=[],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:Y}=await H.from("social_swag_links").select("*").order("sort_order");if(Y)throw Y;return U.map(te=>({...te,links:(V==null?void 0:V.filter(X=>X.swag_id===te.id))||[]}))}}),j=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:le}=H.storage.from("template-previews").getPublicUrl(ne);B=le.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 Y=U.itemId;const J=!Y,te=(o==null?void 0:o.is_published)||!1;if(Y){const{error:ce}=await H.from("social_swag").update(V).eq("id",Y);if(ce)throw ce;await H.from("social_swag_links").delete().eq("swag_id",Y)}else{const{data:ce,error:ne}=await H.from("social_swag").insert(V).select().single();if(ne)throw ne;Y=ce.id}const X=U.item.links.filter(ce=>ce.title.trim()&&ce.canva_share_link.trim());if(X.length>0){const ce=X.map((re,le)=>({swag_id:Y,title:re.title.trim(),canva_share_link:re.canva_share_link.trim(),sort_order:le})),{error:ne}=await H.from("social_swag_links").insert(ce);if(ne)throw ne}return{itemId:Y,itemTitle:U.item.title,isNewItem:J,wasPublished:te,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)&&tbe(U.itemTitle,U.itemId),a(!1),N()},onError:U=>{s({title:"Error saving item",description:U.message,variant:"destructive"})}}),w=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"})}}),N=()=>{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)},C=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)))},I=()=>{c({...i,links:[...i.links,{title:"",canva_share_link:"",sort_order:i.links.length}]})},L=U=>{if(i.links.length<=1)return;const B=i.links.filter((V,Y)=>Y!==U);c({...i,links:B})},R=(U,B,V)=>{const Y=[...i.links];Y[U]={...Y[U],[B]:V},c({...i,links:Y})},q=U=>{if(U.preventDefault(),!i.title.trim()){s({title:"Title is required",variant:"destructive"});return}j.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(ah,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Items"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(U=>U.is_published).length})})]})]}),e.jsxs(xs,{open:n,onOpenChange:U=>{a(U),U||N()},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(_s,{children:e.jsx(bs,{children:o?"Edit Item":"Add New Item"})}),e.jsxs("form",{onSubmit:q,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{children:"Description"}),e.jsx(hy,{content:i.description,onChange:U=>c({...i,description:U}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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($r,{id:"is_published",checked:i.is_published,onCheckedChange:U=>c({...i,is_published:U})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Or,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(fl,{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(ye,{children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:I,children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"Add Link"]})]}),i.links.map((U,B)=>e.jsx(Pe,{children:e.jsxs(Re,{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:()=>L(B),children:e.jsx(Or,{className:"h-3 w-3"})})]}),e.jsx(ze,{placeholder:"Link title (e.g., Instagram Post)",value:U.title,onChange:V=>R(B,"title",V.target.value)}),e.jsx(ze,{placeholder:"Canva share link",value:U.canva_share_link,onChange:V=>R(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:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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"})}):b.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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-16",children:"Preview"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Links"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:b.map(U=>{var B;return e.jsxs(Ss,{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(fl,{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(tt,{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(qn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(U),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this item?")&&w.mutate(U.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},U.id)})})]})})})]})})};function dVt(){for(var t=arguments.length,s=new Array(t),r=0;rn=>{s.forEach(a=>a(n))},s)}const Vue=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function oE(t){const s=Object.prototype.toString.call(t);return s==="[object Window]"||s==="[object global]"}function Lke(t){return"nodeType"in t}function Pp(t){var s,r;return t?oE(t)?t:Lke(t)&&(s=(r=t.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Dke(t){const{Document:s}=Pp(t);return t instanceof s}function YO(t){return oE(t)?!1:t instanceof Pp(t).HTMLElement}function itt(t){return t instanceof Pp(t).SVGElement}function lE(t){return t?oE(t)?t.document:Lke(t)?Dke(t)?t:YO(t)||itt(t)?t.ownerDocument:document:document:document}const T0=Vue?k.useLayoutEffect:k.useEffect;function Oke(t){const s=k.useRef(t);return T0(()=>{s.current=t}),k.useCallback(function(){for(var r=arguments.length,n=new Array(r),a=0;a{t.current=setInterval(n,a)},[]),r=k.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[s,r]}function gD(t,s){s===void 0&&(s=[t]);const r=k.useRef(t);return T0(()=>{r.current!==t&&(r.current=t)},s),r}function XO(t,s){const r=k.useRef();return k.useMemo(()=>{const n=t(r.current);return r.current=n,n},[...s])}function Fle(t){const s=Oke(t),r=k.useRef(null),n=k.useCallback(a=>{a!==r.current&&(s==null||s(a,r.current)),r.current=a},[]);return[r,n]}function sbe(t){const s=k.useRef();return k.useEffect(()=>{s.current=t},[t]),s.current}let Age={};function QO(t,s){return k.useMemo(()=>{if(s)return s;const r=Age[t]==null?0:Age[t]+1;return Age[t]=r,t+"-"+r},[t,s])}function ott(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 tT=ott(1),yD=ott(-1);function hVt(t){return"clientX"in t&&"clientY"in t}function Rke(t){if(!t)return!1;const{KeyboardEvent:s}=Pp(t.target);return s&&t instanceof s}function mVt(t){if(!t)return!1;const{TouchEvent:s}=Pp(t.target);return s&&t instanceof s}function rbe(t){if(mVt(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 hVt(t)?{x:t.clientX,y:t.clientY}:null}const GS=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[GS.Translate.toString(t),GS.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:s,duration:r,easing:n}=t;return s+" "+r+"ms "+n}}}),h8e="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function pVt(t){return t.matches(h8e)?t:t.querySelector(h8e)}const fVt={display:"none"};function xVt(t){let{id:s,value:r}=t;return ht.createElement("div",{id:s,style:fVt},r)}function gVt(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 yVt(){const[t,s]=k.useState("");return{announce:k.useCallback(n=>{n!=null&&s(n)},[]),announcement:t}}const ltt=k.createContext(null);function vVt(t){const s=k.useContext(ltt);k.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of ");return s(t)},[t,s])}function bVt(){const[t]=k.useState(()=>new Set),s=k.useCallback(n=>(t.add(n),()=>t.delete(n)),[t]);return[k.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 _Vt={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. `},wVt={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 jVt(t){let{announcements:s=wVt,container:r,hiddenTextDescribedById:n,screenReaderInstructions:a=_Vt}=t;const{announce:o,announcement:l}=yVt(),i=QO("DndLiveRegion"),[c,u]=k.useState(!1);if(k.useEffect(()=>{u(!0)},[]),vVt(k.useMemo(()=>({onDragStart(f){let{active:g}=f;o(s.onDragStart({active:g}))},onDragMove(f){let{active:g,over:b}=f;s.onDragMove&&o(s.onDragMove({active:g,over:b}))},onDragOver(f){let{active:g,over:b}=f;o(s.onDragOver({active:g,over:b}))},onDragEnd(f){let{active:g,over:b}=f;o(s.onDragEnd({active:g,over:b}))},onDragCancel(f){let{active:g,over:b}=f;o(s.onDragCancel({active:g,over:b}))}}),[o,s])),!c)return null;const p=ht.createElement(ht.Fragment,null,ht.createElement(xVt,{id:n,value:a.draggable}),ht.createElement(gVt,{id:i,announcement:l}));return r?gp.createPortal(p,r):p}var gu;(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"})(gu||(gu={}));function zle(){}function Ble(t,s){return k.useMemo(()=>({sensor:t,options:s??{}}),[t,s])}function Fke(){for(var t=arguments.length,s=new Array(t),r=0;r[...s].filter(n=>n!=null),[...s])}const cy=Object.freeze({x:0,y:0});function ctt(t,s){return Math.sqrt(Math.pow(t.x-s.x,2)+Math.pow(t.y-s.y,2))}function dtt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return r-n}function NVt(t,s){let{data:{value:r}}=t,{data:{value:n}}=s;return n-r}function m8e(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 utt(t,s){if(!t||t.length===0)return null;const[r]=t;return r[s]}function p8e(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 zke=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=p8e(s,s.left,s.top),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=ctt(p8e(c),a);o.push({id:i,data:{droppableContainer:l,value:u}})}}return o.sort(dtt)},kVt=t=>{let{collisionRect:s,droppableRects:r,droppableContainers:n}=t;const a=m8e(s),o=[];for(const l of n){const{id:i}=l,c=r.get(i);if(c){const u=m8e(c),p=a.reduce((g,b,_)=>g+ctt(u[_],b),0),f=Number((p/4).toFixed(4));o.push({id:i,data:{droppableContainer:l,value:f}})}}return o.sort(dtt)};function SVt(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=SVt(i,s);c>0&&a.push({id:l,data:{droppableContainer:o,value:c}})}}return a.sort(NVt)};function MVt(t,s,r){return{...t,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function htt(t,s){return t&&s?{x:t.left-s.left,y:t.top-s.top}:cy}function TVt(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 AVt=TVt(1);function EVt(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 PVt(t,s,r){const n=EVt(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 IVt={ignoreTransform:!1};function cE(t,s){s===void 0&&(s=IVt);let r=t.getBoundingClientRect();if(s.ignoreTransform){const{transform:u,transformOrigin:p}=Pp(t).getComputedStyle(t);u&&(r=PVt(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 f8e(t){return cE(t,{ignoreTransform:!0})}function LVt(t){const s=t.innerWidth,r=t.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function DVt(t,s){return s===void 0&&(s=Pp(t).getComputedStyle(t)),s.position==="fixed"}function OVt(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 Hue(t,s){const r=[];function n(a){if(s!=null&&r.length>=s||!a)return r;if(Dke(a)&&a.scrollingElement!=null&&!r.includes(a.scrollingElement))return r.push(a.scrollingElement),r;if(!YO(a)||itt(a)||r.includes(a))return r;const o=Pp(t).getComputedStyle(a);return a!==t&&OVt(a,o)&&r.push(a),DVt(a,o)?r:n(a.parentNode)}return t?n(t):r}function mtt(t){const[s]=Hue(t,1);return s??null}function Ege(t){return!Vue||!t?null:oE(t)?t:Lke(t)?Dke(t)||t===lE(t).scrollingElement?window:YO(t)?t:null:null}function ptt(t){return oE(t)?t.scrollX:t.scrollLeft}function ftt(t){return oE(t)?t.scrollY:t.scrollTop}function nbe(t){return{x:ptt(t),y:ftt(t)}}var Hu;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Hu||(Hu={}));function xtt(t){return!Vue||!t?!1:t===document.scrollingElement}function gtt(t){const s={x:0,y:0},r=xtt(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 RVt={x:.2,y:.2};function FVt(t,s,r,n,a){let{top:o,left:l,right:i,bottom:c}=r;n===void 0&&(n=10),a===void 0&&(a=RVt);const{isTop:u,isBottom:p,isLeft:f,isRight:g}=gtt(t),b={x:0,y:0},_={x:0,y:0},j={height:s.height*a.y,width:s.width*a.x};return!u&&o<=s.top+j.height?(b.y=Hu.Backward,_.y=n*Math.abs((s.top+j.height-o)/j.height)):!p&&c>=s.bottom-j.height&&(b.y=Hu.Forward,_.y=n*Math.abs((s.bottom-j.height-c)/j.height)),!g&&i>=s.right-j.width?(b.x=Hu.Forward,_.x=n*Math.abs((s.right-j.width-i)/j.width)):!f&&l<=s.left+j.width&&(b.x=Hu.Backward,_.x=n*Math.abs((s.left+j.width-l)/j.width)),{direction:b,speed:_}}function zVt(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 ytt(t){return t.reduce((s,r)=>tT(s,nbe(r)),cy)}function BVt(t){return t.reduce((s,r)=>s+ptt(r),0)}function $Vt(t){return t.reduce((s,r)=>s+ftt(r),0)}function qVt(t,s){if(s===void 0&&(s=cE),!t)return;const{top:r,left:n,bottom:a,right:o}=s(t);mtt(t)&&(a<=0||o<=0||r>=window.innerHeight||n>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const UVt=[["x",["left","right"],BVt],["y",["top","bottom"],$Vt]];class Bke{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=Hue(r),a=ytt(n);this.rect={...s},this.width=s.width,this.height=s.height;for(const[o,l,i]of UVt)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 o8{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 VVt(t){const{EventTarget:s}=Pp(t);return t instanceof s?t:lE(t)}function Pge(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 dx;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(dx||(dx={}));function x8e(t){t.preventDefault()}function HVt(t){t.stopPropagation()}var Mo;(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"})(Mo||(Mo={}));const vtt={start:[Mo.Space,Mo.Enter],cancel:[Mo.Esc],end:[Mo.Space,Mo.Enter,Mo.Tab]},WVt=(t,s)=>{let{currentCoordinates:r}=s;switch(t.code){case Mo.Right:return{...r,x:r.x+25};case Mo.Left:return{...r,x:r.x-25};case Mo.Down:return{...r,y:r.y+25};case Mo.Up:return{...r,y:r.y-25}}};class $ke{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 o8(lE(r)),this.windowListeners=new o8(Pp(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(dx.Resize,this.handleCancel),this.windowListeners.add(dx.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(dx.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,n=s.node.current;n&&qVt(n),r(cy)}handleKeyDown(s){if(Rke(s)){const{active:r,context:n,options:a}=this.props,{keyboardCodes:o=vtt,coordinateGetter:l=WVt,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}:cy;this.referenceCoordinates||(this.referenceCoordinates=p);const f=l(s,{active:r,context:n.current,currentCoordinates:p});if(f){const g=yD(f,p),b={x:0,y:0},{scrollableAncestors:_}=n.current;for(const j of _){const w=s.code,{isTop:N,isRight:C,isLeft:M,isBottom:I,maxScroll:L,minScroll:R}=gtt(j),q=zVt(j),U={x:Math.min(w===Mo.Right?q.right-q.width/2:q.right,Math.max(w===Mo.Right?q.left:q.left+q.width/2,f.x)),y:Math.min(w===Mo.Down?q.bottom-q.height/2:q.bottom,Math.max(w===Mo.Down?q.top:q.top+q.height/2,f.y))},B=w===Mo.Right&&!C||w===Mo.Left&&!M,V=w===Mo.Down&&!I||w===Mo.Up&&!N;if(B&&U.x!==f.x){const Y=j.scrollLeft+g.x,J=w===Mo.Right&&Y<=L.x||w===Mo.Left&&Y>=R.x;if(J&&!g.y){j.scrollTo({left:Y,behavior:i});return}J?b.x=j.scrollLeft-Y:b.x=w===Mo.Right?j.scrollLeft-L.x:j.scrollLeft-R.x,b.x&&j.scrollBy({left:-b.x,behavior:i});break}else if(V&&U.y!==f.y){const Y=j.scrollTop+g.y,J=w===Mo.Down&&Y<=L.y||w===Mo.Up&&Y>=R.y;if(J&&!g.x){j.scrollTo({top:Y,behavior:i});return}J?b.y=j.scrollTop-Y:b.y=w===Mo.Down?j.scrollTop-L.y:j.scrollTop-R.y,b.y&&j.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(s,tT(yD(f,this.referenceCoordinates),b))}}}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()}}$ke.activators=[{eventName:"onKeyDown",handler:(t,s,r)=>{let{keyboardCodes:n=vtt,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 g8e(t){return!!(t&&"distance"in t)}function y8e(t){return!!(t&&"delay"in t)}class qke{constructor(s,r,n){var a;n===void 0&&(n=VVt(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=lE(l),this.documentListeners=new o8(this.document),this.listeners=new o8(n),this.windowListeners=new o8(Pp(l)),this.initialCoordinates=(a=rbe(o))!=null?a:cy,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(dx.Resize,this.handleCancel),this.windowListeners.add(dx.DragStart,x8e),this.windowListeners.add(dx.VisibilityChange,this.handleCancel),this.windowListeners.add(dx.ContextMenu,x8e),this.documentListeners.add(dx.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(y8e(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(g8e(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(dx.Click,HVt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(dx.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=rbe(s))!=null?r:cy,u=yD(a,c);if(!n&&i){if(g8e(i)){if(i.tolerance!=null&&Pge(u,i.tolerance))return this.handleCancel();if(Pge(u,i.distance))return this.handleStart()}if(y8e(i)&&Pge(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===Mo.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const GVt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class JO extends qke{constructor(s){const{event:r}=s,n=lE(r.target);super(s,GVt,n)}}JO.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 KVt={move:{name:"mousemove"},end:{name:"mouseup"}};var abe;(function(t){t[t.RightClick=2]="RightClick"})(abe||(abe={}));class ZVt extends qke{constructor(s){super(s,KVt,lE(s.event.target))}}ZVt.activators=[{eventName:"onMouseDown",handler:(t,s)=>{let{nativeEvent:r}=t,{onActivation:n}=s;return r.button===abe.RightClick?!1:(n==null||n({event:r}),!0)}}];const Ige={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class YVt extends qke{constructor(s){super(s,Ige)}static setup(){return window.addEventListener(Ige.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Ige.move.name,s)};function s(){}}}YVt.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 l8;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(l8||(l8={}));var $le;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})($le||($le={}));function XVt(t){let{acceleration:s,activator:r=l8.Pointer,canScroll:n,draggingRect:a,enabled:o,interval:l=5,order:i=$le.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:f,threshold:g}=t;const b=JVt({delta:f,disabled:!o}),[_,j]=uVt(),w=k.useRef({x:0,y:0}),N=k.useRef({x:0,y:0}),C=k.useMemo(()=>{switch(r){case l8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case l8.DraggableRect:return a}},[r,a,c]),M=k.useRef(null),I=k.useCallback(()=>{const R=M.current;if(!R)return;const q=w.current.x*N.current.x,U=w.current.y*N.current.y;R.scrollBy(q,U)},[]),L=k.useMemo(()=>i===$le.TreeOrder?[...u].reverse():u,[i,u]);k.useEffect(()=>{if(!o||!u.length||!C){j();return}for(const R of L){if((n==null?void 0:n(R))===!1)continue;const q=u.indexOf(R),U=p[q];if(!U)continue;const{direction:B,speed:V}=FVt(R,U,C,s,g);for(const Y of["x","y"])b[Y][B[Y]]||(V[Y]=0,B[Y]=0);if(V.x>0||V.y>0){j(),M.current=R,_(I,l),w.current=V,N.current=B;return}}w.current={x:0,y:0},N.current={x:0,y:0},j()},[s,I,n,j,o,l,JSON.stringify(C),JSON.stringify(b),_,u,L,p,JSON.stringify(g)])}const QVt={x:{[Hu.Backward]:!1,[Hu.Forward]:!1},y:{[Hu.Backward]:!1,[Hu.Forward]:!1}};function JVt(t){let{delta:s,disabled:r}=t;const n=sbe(s);return XO(a=>{if(r||!n||!a)return QVt;const o={x:Math.sign(s.x-n.x),y:Math.sign(s.y-n.y)};return{x:{[Hu.Backward]:a.x[Hu.Backward]||o.x===-1,[Hu.Forward]:a.x[Hu.Forward]||o.x===1},y:{[Hu.Backward]:a.y[Hu.Backward]||o.y===-1,[Hu.Forward]:a.y[Hu.Forward]||o.y===1}}},[r,s,n])}function eHt(t,s){const r=s!=null?t.get(s):void 0,n=r?r.node.current:null;return XO(a=>{var o;return s==null?null:(o=n??a)!=null?o:null},[n,s])}function tHt(t,s){return k.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 vD;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(vD||(vD={}));var ibe;(function(t){t.Optimized="optimized"})(ibe||(ibe={}));const v8e=new Map;function sHt(t,s){let{dragging:r,dependencies:n,config:a}=s;const[o,l]=k.useState(null),{frequency:i,measure:c,strategy:u}=a,p=k.useRef(t),f=w(),g=gD(f),b=k.useCallback(function(N){N===void 0&&(N=[]),!g.current&&l(C=>C===null?N:C.concat(N.filter(M=>!C.includes(M))))},[g]),_=k.useRef(null),j=XO(N=>{if(f&&!r)return v8e;if(!N||N===v8e||p.current!==t||o!=null){const C=new Map;for(let M of t){if(!M)continue;if(o&&o.length>0&&!o.includes(M.id)&&M.rect.current){C.set(M.id,M.rect.current);continue}const I=M.node.current,L=I?new Bke(c(I),I):null;M.rect.current=L,L&&C.set(M.id,L)}return C}return N},[t,o,r,f,c]);return k.useEffect(()=>{p.current=t},[t]),k.useEffect(()=>{f||b()},[r,f]),k.useEffect(()=>{o&&o.length>0&&l(null)},[JSON.stringify(o)]),k.useEffect(()=>{f||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{b(),_.current=null},i))},[i,f,b,...n]),{droppableRects:j,measureDroppableContainers:b,measuringScheduled:o!=null};function w(){switch(u){case vD.Always:return!1;case vD.BeforeDragging:return r;default:return!r}}}function btt(t,s){return XO(r=>t?r||(typeof s=="function"?s(t):t):null,[s,t])}function rHt(t,s){return btt(t,s)}function nHt(t){let{callback:s,disabled:r}=t;const n=Oke(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(n)},[n,r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function Wue(t){let{callback:s,disabled:r}=t;const n=Oke(s),a=k.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(n)},[r]);return k.useEffect(()=>()=>a==null?void 0:a.disconnect(),[a]),a}function aHt(t){return new Bke(cE(t),t)}function b8e(t,s,r){s===void 0&&(s=aHt);const[n,a]=k.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=nHt({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=Wue({callback:o});return T0(()=>{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=btt(t);return htt(t,s)}const _8e=[];function oHt(t){const s=k.useRef(t),r=XO(n=>t?n&&n!==_8e&&t&&s.current&&t.parentNode===s.current.parentNode?n:Hue(t):_8e,[t]);return k.useEffect(()=>{s.current=t},[t]),r}function lHt(t){const[s,r]=k.useState(null),n=k.useRef(t),a=k.useCallback(o=>{const l=Ege(o.target);l&&r(i=>i?(i.set(l,nbe(l)),new Map(i)):null)},[]);return k.useEffect(()=>{const o=n.current;if(t!==o){l(o);const i=t.map(c=>{const u=Ege(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,nbe(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=Ege(c);u==null||u.removeEventListener("scroll",a)})}},[a,t]),k.useMemo(()=>t.length?s?Array.from(s.values()).reduce((o,l)=>tT(o,l),cy):ytt(t):cy,[t,s])}function w8e(t,s){s===void 0&&(s=[]);const r=k.useRef(null);return k.useEffect(()=>{r.current=null},s),k.useEffect(()=>{const n=t!==cy;n&&!r.current&&(r.current=t),!n&&r.current&&(r.current=null)},[t]),r.current?yD(t,r.current):cy}function cHt(t){k.useEffect(()=>{if(!Vue)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 dHt(t,s){return k.useMemo(()=>t.reduce((r,n)=>{let{eventName:a,handler:o}=n;return r[a]=l=>{o(l,s)},r},{}),[t,s])}function _tt(t){return k.useMemo(()=>t?LVt(t):null,[t])}const j8e=[];function uHt(t,s){s===void 0&&(s=cE);const[r]=t,n=_tt(r?Pp(r):null),[a,o]=k.useState(j8e);function l(){o(()=>t.length?t.map(c=>xtt(c)?n:new Bke(s(c),c)):j8e)}const i=Wue({callback:l});return T0(()=>{i==null||i.disconnect(),l(),t.forEach(c=>i==null?void 0:i.observe(c))},[t]),a}function hHt(t){if(!t)return null;if(t.children.length>1)return t;const s=t.children[0];return YO(s)?s:t}function mHt(t){let{measure:s}=t;const[r,n]=k.useState(null),a=k.useCallback(u=>{for(const{target:p}of u)if(YO(p)){n(f=>{const g=s(p);return f?{...f,width:g.width,height:g.height}:g});break}},[s]),o=Wue({callback:a}),l=k.useCallback(u=>{const p=hHt(u);o==null||o.disconnect(),p&&(o==null||o.observe(p)),n(p?s(p):null)},[s,o]),[i,c]=Fle(l);return k.useMemo(()=>({nodeRef:i,rect:r,setRef:c}),[r,i,c])}const pHt=[{sensor:JO,options:{}},{sensor:$ke,options:{}}],fHt={current:{}},Tie={draggable:{measure:f8e},droppable:{measure:f8e,strategy:vD.WhileDragging,frequency:ibe.Optimized},dragOverlay:{measure:cE}};class c8 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 xHt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new c8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:zle},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Tie,measureDroppableContainers:zle,windowRect:null,measuringScheduled:!1},gHt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:zle,draggableNodes:new Map,over:null,measureDroppableContainers:zle},Gue=k.createContext(gHt),wtt=k.createContext(xHt);function yHt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new c8}}}function vHt(t,s){switch(s.type){case gu.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case gu.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 gu.DragEnd:case gu.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case gu.RegisterDroppable:{const{element:r}=s,{id:n}=r,a=new c8(t.droppable.containers);return a.set(n,r),{...t,droppable:{...t.droppable,containers:a}}}case gu.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 c8(t.droppable.containers);return l.set(r,{...o,disabled:a}),{...t,droppable:{...t.droppable,containers:l}}}case gu.UnregisterDroppable:{const{id:r,key:n}=s,a=t.droppable.containers.get(r);if(!a||n!==a.key)return t;const o=new c8(t.droppable.containers);return o.delete(r),{...t,droppable:{...t.droppable,containers:o}}}default:return t}}function bHt(t){let{disabled:s}=t;const{active:r,activatorEvent:n,draggableNodes:a}=k.useContext(Gue),o=sbe(n),l=sbe(r==null?void 0:r.id);return k.useEffect(()=>{if(!s&&!n&&o&&l!=null){if(!Rke(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=pVt(p);if(f){f.focus();break}}})}},[n,s,a,l,o]),null}function _Ht(t,s){let{transform:r,...n}=s;return t!=null&&t.length?t.reduce((a,o)=>o({transform:a,...n}),r):r}function wHt(t){return k.useMemo(()=>({draggable:{...Tie.draggable,...t==null?void 0:t.draggable},droppable:{...Tie.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Tie.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 jHt(t){let{activeNode:s,measure:r,initialRect:n,config:a=!0}=t;const o=k.useRef(!1),{x:l,y:i}=typeof a=="boolean"?{x:a,y:a}:a;T0(()=>{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=htt(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=mtt(u);g&&g.scrollBy({top:f.y,left:f.x})}},[s,l,i,n,r])}const jtt=k.createContext({...cy,scaleX:1,scaleY:1});var Xb;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Xb||(Xb={}));const Uke=k.memo(function(s){var r,n,a,o;let{id:l,accessibility:i,autoScroll:c=!0,children:u,sensors:p=pHt,collisionDetection:f=CVt,measuring:g,modifiers:b,..._}=s;const j=k.useReducer(vHt,void 0,yHt),[w,N]=j,[C,M]=bVt(),[I,L]=k.useState(Xb.Uninitialized),R=I===Xb.Initialized,{draggable:{active:q,nodes:U,translate:B},droppable:{containers:V}}=w,Y=q!=null?U.get(q):null,J=k.useRef({initial:null,translated:null}),te=k.useMemo(()=>{var Wa;return q!=null?{id:q,data:(Wa=Y==null?void 0:Y.data)!=null?Wa:fHt,rect:J}:null},[q,Y]),X=k.useRef(null),[ce,ne]=k.useState(null),[re,le]=k.useState(null),pe=gD(_,Object.values(_)),xe=QO("DndDescribedBy",l),_e=k.useMemo(()=>V.getEnabled(),[V]),fe=wHt(g),{droppableRects:we,measureDroppableContainers:Ie,measuringScheduled:Ne}=sHt(_e,{dragging:R,dependencies:[B.x,B.y],config:fe.droppable}),Ae=eHt(U,q),Fe=k.useMemo(()=>re?rbe(re):null,[re]),Ce=Li(),Me=rHt(Ae,fe.draggable.measure);jHt({activeNode:q!=null?U.get(q):null,config:Ce.layoutShiftCompensation,initialRect:Me,measure:fe.draggable.measure});const $e=b8e(Ae,fe.draggable.measure,Me),ct=b8e(Ae?Ae.parentElement:null),Te=k.useRef({activatorEvent:null,active:null,activeNode:Ae,collisionRect:null,collisions:null,droppableRects:we,draggableNodes:U,draggingNode:null,draggingNodeRect:null,droppableContainers:V,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ft=V.getNodeFor((r=Te.current.over)==null?void 0:r.id),me=mHt({measure:fe.dragOverlay.measure}),Ve=(n=me.nodeRef.current)!=null?n:Ae,nt=R?(a=me.rect)!=null?a:$e:null,et=!!(me.nodeRef.current&&me.rect),Se=iHt(et?null:$e),rt=_tt(Ve?Pp(Ve):null),Ge=oHt(R?ft??Ae:null),lt=uHt(Ge),qe=_Ht(b,{transform:{x:B.x-Se.x,y:B.y-Se.y,scaleX:1,scaleY:1},activatorEvent:re,active:te,activeNodeRect:$e,containerNodeRect:ct,draggingNodeRect:nt,over:Te.current.over,overlayNodeRect:me.rect,scrollableAncestors:Ge,scrollableAncestorRects:lt,windowRect:rt}),Ze=Fe?tT(Fe,B):null,Je=lHt(Ge),He=w8e(Je),Qe=w8e(Je,[$e]),at=tT(qe,He),It=nt?AVt(nt,qe):null,Ut=te&&It?f({active:te,collisionRect:It,droppableRects:we,droppableContainers:_e,pointerCoordinates:Ze}):null,hs=utt(Ut,"id"),[Yt,ts]=k.useState(null),Ds=et?qe:tT(qe,Qe),vr=MVt(Ds,(o=Yt==null?void 0:Yt.rect)!=null?o:null,$e),Ct=k.useRef(null),As=k.useCallback((Wa,cr)=>{let{sensor:Qr,options:Hr}=cr;if(X.current==null)return;const ln=U.get(X.current);if(!ln)return;const Zr=Wa.nativeEvent,yi=new Qr({active:X.current,activeNode:ln,event:Zr,options:Hr,context:Te,onAbort(ir){if(!U.get(ir))return;const{onDragAbort:Cr}=pe.current,jr={id:ir};Cr==null||Cr(jr),C({type:"onDragAbort",event:jr})},onPending(ir,Bn,Cr,jr){if(!U.get(ir))return;const{onDragPending:Aa}=pe.current,Pi={id:ir,constraint:Bn,initialCoordinates:Cr,offset:jr};Aa==null||Aa(Pi),C({type:"onDragPending",event:Pi})},onStart(ir){const Bn=X.current;if(Bn==null)return;const Cr=U.get(Bn);if(!Cr)return;const{onDragStart:jr}=pe.current,Xn={activatorEvent:Zr,active:{id:Bn,data:Cr.data,rect:J}};gp.unstable_batchedUpdates(()=>{jr==null||jr(Xn),L(Xb.Initializing),N({type:gu.DragStart,initialCoordinates:ir,active:Bn}),C({type:"onDragStart",event:Xn}),ne(Ct.current),le(Zr)})},onMove(ir){N({type:gu.DragMove,coordinates:ir})},onEnd:pt(gu.DragEnd),onCancel:pt(gu.DragCancel)});Ct.current=yi;function pt(ir){return async function(){const{active:Cr,collisions:jr,over:Xn,scrollAdjustedTranslate:Aa}=Te.current;let Pi=null;if(Cr&&Aa){const{cancelDrop:Oo}=pe.current;Pi={activatorEvent:Zr,active:Cr,collisions:jr,delta:Aa,over:Xn},ir===gu.DragEnd&&typeof Oo=="function"&&await Promise.resolve(Oo(Pi))&&(ir=gu.DragCancel)}X.current=null,gp.unstable_batchedUpdates(()=>{N({type:ir}),L(Xb.Uninitialized),ts(null),ne(null),le(null),Ct.current=null;const Oo=ir===gu.DragEnd?"onDragEnd":"onDragCancel";if(Pi){const $t=pe.current[Oo];$t==null||$t(Pi),C({type:Oo,event:Pi})}})}}},[U]),Us=k.useCallback((Wa,cr)=>(Qr,Hr)=>{const ln=Qr.nativeEvent,Zr=U.get(Hr);if(X.current!==null||!Zr||ln.dndKit||ln.defaultPrevented)return;const yi={active:Zr};Wa(Qr,cr.options,yi)===!0&&(ln.dndKit={capturedBy:cr.sensor},X.current=Hr,As(Qr,cr))},[U,As]),kr=tHt(p,Us);cHt(p),T0(()=>{$e&&I===Xb.Initializing&&L(Xb.Initialized)},[$e,I]),k.useEffect(()=>{const{onDragMove:Wa}=pe.current,{active:cr,activatorEvent:Qr,collisions:Hr,over:ln}=Te.current;if(!cr||!Qr)return;const Zr={active:cr,activatorEvent:Qr,collisions:Hr,delta:{x:at.x,y:at.y},over:ln};gp.unstable_batchedUpdates(()=>{Wa==null||Wa(Zr),C({type:"onDragMove",event:Zr})})},[at.x,at.y]),k.useEffect(()=>{const{active:Wa,activatorEvent:cr,collisions:Qr,droppableContainers:Hr,scrollAdjustedTranslate:ln}=Te.current;if(!Wa||X.current==null||!cr||!ln)return;const{onDragOver:Zr}=pe.current,yi=Hr.get(hs),pt=yi&&yi.rect.current?{id:yi.id,rect:yi.rect.current,data:yi.data,disabled:yi.disabled}:null,ir={active:Wa,activatorEvent:cr,collisions:Qr,delta:{x:ln.x,y:ln.y},over:pt};gp.unstable_batchedUpdates(()=>{ts(pt),Zr==null||Zr(ir),C({type:"onDragOver",event:ir})})},[hs]),T0(()=>{Te.current={activatorEvent:re,active:te,activeNode:Ae,collisionRect:It,collisions:Ut,droppableRects:we,draggableNodes:U,draggingNode:Ve,draggingNodeRect:nt,droppableContainers:V,over:Yt,scrollableAncestors:Ge,scrollAdjustedTranslate:at},J.current={initial:nt,translated:It}},[te,Ae,Ut,It,U,Ve,nt,we,V,Yt,Ge,at]),XVt({...Ce,delta:B,draggingRect:It,pointerCoordinates:Ze,scrollableAncestors:Ge,scrollableAncestorRects:lt});const ta=k.useMemo(()=>({active:te,activeNode:Ae,activeNodeRect:$e,activatorEvent:re,collisions:Ut,containerNodeRect:ct,dragOverlay:me,draggableNodes:U,droppableContainers:V,droppableRects:we,over:Yt,measureDroppableContainers:Ie,scrollableAncestors:Ge,scrollableAncestorRects:lt,measuringConfiguration:fe,measuringScheduled:Ne,windowRect:rt}),[te,Ae,$e,re,Ut,ct,me,U,V,we,Yt,Ie,Ge,lt,fe,Ne,rt]),ka=k.useMemo(()=>({activatorEvent:re,activators:kr,active:te,activeNodeRect:$e,ariaDescribedById:{draggable:xe},dispatch:N,draggableNodes:U,over:Yt,measureDroppableContainers:Ie}),[re,kr,te,$e,N,xe,U,Yt,Ie]);return ht.createElement(ltt.Provider,{value:M},ht.createElement(Gue.Provider,{value:ka},ht.createElement(wtt.Provider,{value:ta},ht.createElement(jtt.Provider,{value:vr},u)),ht.createElement(bHt,{disabled:(i==null?void 0:i.restoreFocus)===!1})),ht.createElement(jVt,{...i,hiddenTextDescribedById:xe}));function Li(){const Wa=(ce==null?void 0:ce.autoScrollEnabled)===!1,cr=typeof c=="object"?c.enabled===!1:c===!1,Qr=R&&!Wa&&!cr;return typeof c=="object"?{...c,enabled:Qr}:{enabled:Qr}}}),NHt=k.createContext(null),N8e="button",kHt="Draggable";function SHt(t){let{id:s,data:r,disabled:n=!1,attributes:a}=t;const o=QO(kHt),{activators:l,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:f,over:g}=k.useContext(Gue),{role:b=N8e,roleDescription:_="draggable",tabIndex:j=0}=a??{},w=(c==null?void 0:c.id)===s,N=k.useContext(w?jtt:NHt),[C,M]=Fle(),[I,L]=Fle(),R=dHt(l,s),q=gD(r);T0(()=>(f.set(s,{id:s,key:o,node:C,activatorNode:I,data:q}),()=>{const B=f.get(s);B&&B.key===o&&f.delete(s)}),[f,s]);const U=k.useMemo(()=>({role:b,tabIndex:j,"aria-disabled":n,"aria-pressed":w&&b===N8e?!0:void 0,"aria-roledescription":_,"aria-describedby":p.draggable}),[n,b,j,w,_,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:U,isDragging:w,listeners:n?void 0:R,node:C,over:g,setNodeRef:M,setActivatorNodeRef:L,transform:N}}function CHt(){return k.useContext(wtt)}const MHt="Droppable",THt={timeout:25};function AHt(t){let{data:s,disabled:r=!1,id:n,resizeObserverConfig:a}=t;const o=QO(MHt),{active:l,dispatch:i,over:c,measureDroppableContainers:u}=k.useContext(Gue),p=k.useRef({disabled:r}),f=k.useRef(!1),g=k.useRef(null),b=k.useRef(null),{disabled:_,updateMeasurementsFor:j,timeout:w}={...THt,...a},N=gD(j??n),C=k.useCallback(()=>{if(!f.current){f.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{u(Array.isArray(N.current)?N.current:[N.current]),b.current=null},w)},[w]),M=Wue({callback:C,disabled:_||!l}),I=k.useCallback((U,B)=>{M&&(B&&(M.unobserve(B),f.current=!1),U&&M.observe(U))},[M]),[L,R]=Fle(I),q=gD(s);return k.useEffect(()=>{!M||!L.current||(M.disconnect(),f.current=!1,M.observe(L.current))},[L,M]),k.useEffect(()=>(i({type:gu.RegisterDroppable,element:{id:n,key:o,disabled:r,node:L,rect:g,data:q}}),()=>i({type:gu.UnregisterDroppable,key:o,id:n})),[n]),k.useEffect(()=>{r!==p.current.disabled&&(i({type:gu.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:L,over:c,setNodeRef:R}}function Vke(t,s,r){const n=t.slice();return n.splice(r<0?n.length+r:r,0,n.splice(s,1)[0]),n}function EHt(t,s){return t.reduce((r,n,a)=>{const o=s.get(n);return o&&(r[a]=o),r},Array(t.length))}function Nz(t){return t!==null&&t>=0}function PHt(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=LHt(r,l,a);if(l===a){const u=r[o];return u?{x:aa&&l<=o?{x:-i.width-c,y:0,...kz}:l=o?{x:i.width+c,y:0,...kz}:{x:0,y:0,...kz}};function LHt(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=Vke(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}},Ntt="Sortable",ktt=ht.createContext({activeIndex:-1,containerId:Ntt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:eR,disabled:{draggable:!1,droppable:!1}});function Hke(t){let{children:s,id:r,items:n,strategy:a=eR,disabled:o=!1}=t;const{active:l,dragOverlay:i,droppableRects:c,over:u,measureDroppableContainers:p}=CHt(),f=QO(Ntt,r),g=i.rect!==null,b=k.useMemo(()=>n.map(R=>typeof R=="object"&&"id"in R?R.id:R),[n]),_=l!=null,j=l?b.indexOf(l.id):-1,w=u?b.indexOf(u.id):-1,N=k.useRef(b),C=!PHt(b,N.current),M=w!==-1&&j===-1||C,I=IHt(o);T0(()=>{C&&_&&p(b)},[C,b,_,p]),k.useEffect(()=>{N.current=b},[b]);const L=k.useMemo(()=>({activeIndex:j,containerId:f,disabled:I,disableTransforms:M,items:b,overIndex:w,useDragOverlay:g,sortedRects:EHt(b,c),strategy:a}),[j,f,I.draggable,I.droppable,M,b,w,c,g,a]);return ht.createElement(ktt.Provider,{value:L},s)}const DHt=t=>{let{id:s,items:r,activeIndex:n,overIndex:a}=t;return Vke(r,n,a).indexOf(s)},OHt=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},RHt={duration:200,easing:"ease"},Stt="transform",FHt=GS.Transition.toString({property:Stt,duration:0,easing:"linear"}),zHt={roleDescription:"sortable"};function BHt(t){let{disabled:s,index:r,node:n,rect:a}=t;const[o,l]=k.useState(null),i=k.useRef(r);return T0(()=>{if(!s&&r!==i.current&&n.current){const c=a.current;if(c){const u=cE(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]),k.useEffect(()=>{o&&l(null)},[o]),o}function Wke(t){let{animateLayoutChanges:s=OHt,attributes:r,disabled:n,data:a,getNewIndex:o=DHt,id:l,strategy:i,resizeObserverConfig:c,transition:u=RHt}=t;const{items:p,containerId:f,activeIndex:g,disabled:b,disableTransforms:_,sortedRects:j,overIndex:w,useDragOverlay:N,strategy:C}=k.useContext(ktt),M=$Ht(n,b),I=p.indexOf(l),L=k.useMemo(()=>({sortable:{containerId:f,index:I,items:p},...a}),[f,a,I,p]),R=k.useMemo(()=>p.slice(p.indexOf(l)),[p,l]),{rect:q,node:U,isOver:B,setNodeRef:V}=AHt({id:l,data:L,disabled:M.droppable,resizeObserverConfig:{updateMeasurementsFor:R,...c}}),{active:Y,activatorEvent:J,activeNodeRect:te,attributes:X,setNodeRef:ce,listeners:ne,isDragging:re,over:le,setActivatorNodeRef:pe,transform:xe}=SHt({id:l,data:L,attributes:{...zHt,...r},disabled:M.draggable}),_e=dVt(V,ce),fe=!!Y,we=fe&&!_&&Nz(g)&&Nz(w),Ie=!N&&re,Ne=Ie&&we?xe:null,Fe=we?Ne??(i??C)({rects:j,activeNodeRect:te,activeIndex:g,overIndex:w,index:I}):null,Ce=Nz(g)&&Nz(w)?o({id:l,items:p,activeIndex:g,overIndex:w}):I,Me=Y==null?void 0:Y.id,$e=k.useRef({activeId:Me,items:p,newIndex:Ce,containerId:f}),ct=p!==$e.current.items,Te=s({active:Y,containerId:f,isDragging:re,isSorting:fe,id:l,index:I,items:p,newIndex:$e.current.newIndex,previousItems:$e.current.items,previousContainerId:$e.current.containerId,transition:u,wasDragging:$e.current.activeId!=null}),ft=BHt({disabled:!Te,index:I,node:U,rect:q});return k.useEffect(()=>{fe&&$e.current.newIndex!==Ce&&($e.current.newIndex=Ce),f!==$e.current.containerId&&($e.current.containerId=f),p!==$e.current.items&&($e.current.items=p)},[fe,Ce,f,p]),k.useEffect(()=>{if(Me===$e.current.activeId)return;if(Me!=null&&$e.current.activeId==null){$e.current.activeId=Me;return}const Ve=setTimeout(()=>{$e.current.activeId=Me},50);return()=>clearTimeout(Ve)},[Me]),{active:Y,activeIndex:g,attributes:X,data:L,rect:q,index:I,newIndex:Ce,items:p,isOver:B,isSorting:fe,isDragging:re,listeners:ne,node:U,overIndex:w,over:le,setNodeRef:_e,setActivatorNodeRef:pe,setDroppableNodeRef:V,setDraggableNodeRef:ce,transform:ft??Fe,transition:me()};function me(){if(ft||ct&&$e.current.newIndex===I)return FHt;if(!(Ie&&!Rke(J)||!u)&&(fe||Te))return GS.Transition.toString({...u,property:Stt})}}function $Ht(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 qle(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 qHt=[Mo.Down,Mo.Right,Mo.Up,Mo.Left],UHt=(t,s)=>{let{context:{active:r,collisionRect:n,droppableRects:a,droppableContainers:o,over:l,scrollableAncestors:i}}=s;if(qHt.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 Mo.Down:n.topg.top&&c.push(f);break;case Mo.Left:n.left>g.left&&c.push(f);break;case Mo.Right:n.left1&&(p=u[1].id),p!=null){const f=o.get(r.id),g=o.get(p),b=g?a.get(g.id):null,_=g==null?void 0:g.node.current;if(_&&b&&f&&g){const w=Hue(_).some((R,q)=>i[q]!==R),N=Ctt(f,g),C=VHt(f,g),M=w||!N?{x:0,y:0}:{x:C?n.width-b.width:0,y:C?n.height-b.height:0},I={x:b.left,y:b.top};return M.x&&M.y?I:yD(I,M)}}}};function Ctt(t,s){return!qle(t)||!qle(s)?!1:t.data.current.sortable.containerId===s.data.current.sortable.containerId}function VHt(t,s){return!qle(t)||!qle(s)||!Ctt(t,s)?!1:t.data.current.sortable.indexs(t),children:e.jsx(Da,{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(tt,{className:"bg-primary/90 text-primary-foreground text-[10px] gap-1 backdrop-blur-sm px-1.5 py-0.5",children:[e.jsx(cn,{className:"h-2.5 w-2.5"}),ps(new Date(t.post_date+"T00:00:00"),"MMM d")]})})]}),e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-3",children:t.caption}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:Pt("w-full h-7 text-[11px] gap-1 justify-start font-normal",!t.post_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-3 w-3"}),t.post_date?ps(new Date(t.post_date+"T00:00:00"),"MMM d, yyyy"):"Set post date"]})}),e.jsxs(Do,{className:"w-auto p-0",align:"start",children:[e.jsx(_f,{mode:"single",selected:t.post_date?new Date(t.post_date+"T00:00:00"):void 0,onSelect:f=>n(t.id,f?ps(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 WHt=()=>{const t=es(),[s,r]=k.useState("all"),[n,a]=k.useState(!1),[o,l]=k.useState(ps(new Date,"yyyy-MM")),[i,c]=k.useState([]),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(""),[N,C]=k.useState(null),[M,I]=k.useState(!1),[L,R]=k.useState(!1),[q,U]=k.useState(ps(new Date,"yyyy-MM")),[B,V]=k.useState(null),[Y,J]=k.useState(""),[te,X]=k.useState(""),[ce,ne]=k.useState(""),[re,le]=k.useState(!1),pe=Fke(Ble(JO,{activationConstraint:{distance:5}}),Ble($ke,{coordinateGetter:UHt})),{data:xe=[],isLoading:_e}=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:fe=[]}=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:we=[]}=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}}),Ie=[...new Set(xe.map(Ze=>Ze.month))].sort((Ze,Je)=>Je.localeCompare(Ze)),Ne=s==="all"?xe:xe.filter(Ze=>Ze.month===s),Ae=Ze=>{const Je=xje(Ze,"yyyy-MM",new Date);return ps(Je,"MMMM yyyy")},Fe=Ze=>{_(Ze),w(Ze.caption),C(Ze.post_date)},Ce=async()=>{if(b){I(!0);try{const{error:Ze}=await H.from("social_swag_2").update({caption:j,post_date:N}).eq("id",b.id);if(Ze)throw Ze;he.success("Image updated"),_(null),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})}catch{he.error("Failed to update image")}finally{I(!1)}}},Me=async Ze=>{const{active:Je,over:He}=Ze;if(!He||Je.id===He.id)return;const Qe=Ne,at=Qe.findIndex(hs=>hs.id===Je.id),It=Qe.findIndex(hs=>hs.id===He.id);if(at===-1||It===-1)return;const Ut=Vke(Qe,at,It);t.setQueryData(["admin-social-swag-2"],hs=>{if(!hs)return hs;const Yt={};return Ut.forEach((ts,Ds)=>{Yt[ts.id]=Ds}),hs.map(ts=>Yt[ts.id]!==void 0?{...ts,sort_order:Yt[ts.id]}:ts).sort((ts,Ds)=>ts.month!==Ds.month?Ds.month.localeCompare(ts.month):ts.sort_order-Ds.sort_order)});try{await Promise.all(Ut.map((hs,Yt)=>H.from("social_swag_2").update({sort_order:Yt}).eq("id",hs.id)))}catch{he.error("Failed to save order"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})}},$e=Ze=>{const He=Array.from(Ze.target.files||[]).sort((Qe,at)=>Qe.name.localeCompare(at.name,void 0,{numeric:!0,sensitivity:"base"})).slice(0,16-i.length).map(Qe=>({file:Qe,preview:URL.createObjectURL(Qe),caption:""}));c(Qe=>[...Qe,...He].slice(0,16))},ct=Ze=>{c(Je=>{const He=[...Je];return URL.revokeObjectURL(He[Ze].preview),He.splice(Ze,1),He})},Te=(Ze,Je)=>{c(He=>{const Qe=[...He];return Qe[Ze]={...Qe[Ze],caption:Je},Qe})},ft=async()=>{var Je;if(i.length===0){he.error("Please add at least one image");return}if(i.filter(He=>!He.caption.trim()).length>0){he.error("Please add captions to all images");return}p(!0);try{const{data:He}=await H.from("social_swag_2").select("sort_order").eq("month",o).order("sort_order",{ascending:!1}).limit(1),Qe=(((Je=He==null?void 0:He[0])==null?void 0:Je.sort_order)??-1)+1;for(let at=0;at{const Je=Ze.image_url.split("/social-swag-2/");Je[1]&&await H.storage.from("social-swag-2").remove([Je[1]]);const{error:He}=await H.from("social_swag_2").delete().eq("id",Ze.id);if(He)throw He},onSuccess:()=>{he.success("Image deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2"]})},onError:()=>he.error("Failed to delete image")}),Ve=Lt({mutationFn:async({id:Ze,postDate:Je})=>{const{error:He}=await H.from("social_swag_2").update({post_date:Je}).eq("id",Ze);if(He)throw He},onSuccess:()=>{he.success("Post date updated"),t.invalidateQueries({queryKey:["admin-social-swag-2"]}),t.invalidateQueries({queryKey:["social-swag-2"]})},onError:()=>he.error("Failed to update post date")}),nt=Lt({mutationFn:async({month:Ze,link:Je})=>{const{error:He}=await H.from("social_swag_2_months").upsert({month:Ze,canva_link:Je||null},{onConflict:"month"});if(He)throw He},onSuccess:()=>{he.success("Canva link updated"),g(null),t.invalidateQueries({queryKey:["admin-social-swag-2-months"]})},onError:()=>he.error("Failed to update Canva link")}),et=Ze=>{var Je;return((Je=fe.find(He=>He.month===Ze))==null?void 0:Je.canva_link)||""},Se=Ze=>we.find(Je=>Je.month===Ze)||null,rt=Ze=>{var He;const Je=(He=Ze.target.files)==null?void 0:He[0];Je&&(V(Je),J(URL.createObjectURL(Je)))},Ge=()=>{Y&&URL.revokeObjectURL(Y),V(null),J(""),X(""),ne("")},lt=async()=>{if(!B){he.error("Please select an image");return}le(!0);try{const Ze=B.name.split(".").pop(),Je=`reels/${q}-${Date.now()}.${Ze}`,{error:He}=await H.storage.from("social-swag-2").upload(Je,B);if(He)throw He;const{data:{publicUrl:Qe}}=H.storage.from("social-swag-2").getPublicUrl(Je),{error:at}=await H.from("social_swag_2_reels").upsert({month:q,image_url:Qe,canva_link:ce||null,caption:te||null},{onConflict:"month"});if(at)throw at;he.success("Reel uploaded successfully!"),tbe(`${Ae(q)} Reel`,"social-swag-2"),Ge(),R(!1),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})}catch(Ze){console.error("Reel upload error:",Ze),he.error("Failed to upload reel")}finally{le(!1)}},qe=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:He}=await H.from("social_swag_2_reels").delete().eq("id",Ze.id);if(He)throw He},onSuccess:()=>{he.success("Reel deleted"),t.invalidateQueries({queryKey:["admin-social-swag-2-reels"]})},onError:()=>he.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(_s,{children:e.jsx(bs,{children:"Upload Social Swag Images"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{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:$e,className:"hidden",id:"swag-upload",disabled:i.length>=16}),e.jsxs("label",{htmlFor:"swag-upload",className:"cursor-pointer",children:[e.jsx(oi,{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:()=>ct(Je),children:e.jsx(Or,{className:"h-3 w-3"})})]}),e.jsx(Er,{placeholder:"Caption...",value:Ze.caption,onChange:He=>Te(Je,He.target.value),className:"text-xs h-20"})]},Je))}),e.jsx(K,{onClick:ft,disabled:u||i.length===0,className:"w-full gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-4 w-4"}),"Upload ",i.length," Images"]})})]})]})]}),e.jsxs(xs,{open:L,onOpenChange:Ze=>{R(Ze),Ze||Ge()},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"gap-2",children:[e.jsx(xu,{className:"h-4 w-4"}),"Upload Reel"]})}),e.jsxs(fs,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Upload Monthly Reel"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Month"}),e.jsx(ze,{type:"month",value:q,onChange:Ze=>U(Ze.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Reel Preview Image"}),Y?e.jsxs("div",{className:"relative aspect-[9/16] max-w-[120px] mx-auto rounded-lg overflow-hidden bg-muted",children:[e.jsx("img",{src:Y,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(Y),V(null),J("")},children:e.jsx(Or,{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(xu,{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(ye,{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(ye,{children:"Caption"}),e.jsx(Er,{value:te,onChange:Ze=>X(Ze.target.value),placeholder:"Enter caption for this reel...",className:"h-24"})]}),e.jsx(K,{onClick:lt,disabled:re||!B,className:"w-full gap-2",children:re?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-4 w-4"}),"Upload Reel"]})})]})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:xe.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Total Images"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsx("div",{className:"text-2xl font-bold",children:Ie.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Months"})]})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(ja,{value:s,onValueChange:r,children:e.jsxs(ga,{children:[e.jsx(us,{value:"all",children:"All"}),Ie.map(Ze=>e.jsx(us,{value:Ze,children:Ae(Ze)},Ze))]})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(zo,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ye,{className:"text-sm text-muted-foreground",children:["Canva Edit Link for ",Ae(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:()=>nt.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:et(s)||"No link set"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>g({month:s,link:et(s)}),children:"Edit"})]})]})]})})}),s!=="all"&&e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(xu,{className:"h-4 w-4 text-muted-foreground mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs(ye,{className:"text-sm text-muted-foreground",children:["Reel for ",Ae(s)]}),(()=>{const Ze=Se(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:()=>qe.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"})})()]})]})})})]}),_e?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading..."}):Ne.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(fl,{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(Uke,{sensors:pe,collisionDetection:zke,onDragEnd:Me,children:e.jsx(Hke,{items:Ne.map(Ze=>Ze.id),strategy:eR,children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-6 gap-4",children:Ne.map(Ze=>e.jsx(HHt,{item:Ze,onEdit:Fe,onDelete:Je=>me.mutate(Je),onDateChange:(Je,He)=>Ve.mutate({id:Je,postDate:He})},Ze.id))})})})]}),e.jsx(xs,{open:!!b,onOpenChange:Ze=>{Ze||_(null)},children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Edit Image"})}),b&&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:b.image_url,alt:"Preview",className:"w-full h-full object-cover"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Caption"}),e.jsx(Er,{value:j,onChange:Ze=>w(Ze.target.value),placeholder:"Enter caption...",className:"h-28"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Post Date"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("flex-1 justify-start gap-2 font-normal",!N&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-4 w-4"}),N?ps(new Date(N+"T00:00:00"),"MMM d, yyyy"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:N?new Date(N+"T00:00:00"):void 0,onSelect:Ze=>C(Ze?ps(Ze,"yyyy-MM-dd"):null),className:"p-3 pointer-events-auto"})})]}),N&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>C(null),children:e.jsx(Or,{className:"h-4 w-4"})})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>_(null),children:"Cancel"}),e.jsx(K,{onClick:Ce,disabled:M,className:"gap-2",children:M?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Saving..."]}):"Save Changes"})]})]})})]})},GHt=()=>{const{toast:t}=qa(),s=es(),[r,n]=k.useState("categories"),[a,o]=k.useState(!1),[l,i]=k.useState(null),[c,u]=k.useState({name:"",description:"",icon:""}),[p,f]=k.useState(!1),[g,b]=k.useState(null),[_,j]=k.useState({name:"",description:"",icon:""}),[w,N]=k.useState(!1),[C,M]=k.useState(null),[I,L]=k.useState(""),{data:R=[],isLoading:q}=mt({queryKey:["admin-community-categories"],queryFn:async()=>{const{data:Me,error:$e}=await H.from("community_categories").select("*").order("sort_order");if($e)throw $e;return Me}}),{data:U=[],isLoading:B}=mt({queryKey:["admin-private-groups"],queryFn:async()=>{const{data:Me,error:$e}=await H.from("community_private_groups").select("*").order("sort_order");if($e)throw $e;return Me}}),{data:V=[]}=mt({queryKey:["admin-group-members",C==null?void 0:C.id],queryFn:async()=>{if(!C)return[];const{data:Me,error:$e}=await H.from("community_private_group_members").select("*").eq("group_id",C.id);if($e)throw $e;return Me},enabled:!!C}),{data:Y=[]}=mt({queryKey:["admin-all-profiles"],queryFn:async()=>{let $e=[],ct=0,Te=!0;for(;Te;){const{data:ft,error:me}=await H.from("profiles").select("id, name, email, brokerage_id").order("name").range(ct,ct+1e3-1);if(me)throw me;ft&&ft.length>0?($e=[...$e,...ft],ct+=1e3,Te=ft.length===1e3):Te=!1}return $e}}),{data:J=[]}=mt({queryKey:["admin-all-brokerages"],queryFn:async()=>{const{data:Me,error:$e}=await H.from("brokerages").select("*").order("name");if($e)throw $e;return Me}}),te=Lt({mutationFn:async Me=>{if(Me.id){const{error:$e}=await H.from("community_categories").update({name:Me.name,description:Me.description||null,icon:Me.icon||null}).eq("id",Me.id);if($e)throw $e}else{const $e=Math.max(...R.map(Te=>Te.sort_order),0),{error:ct}=await H.from("community_categories").insert({name:Me.name,description:Me.description||null,icon:Me.icon||null,sort_order:$e+1});if(ct)throw ct}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),o(!1),i(null),u({name:"",description:"",icon:""}),t({title:l?"Category updated!":"Category created!"})},onError:Me=>{t({title:"Error",description:Me.message,variant:"destructive"})}}),X=Lt({mutationFn:async Me=>{const{error:$e}=await H.from("community_categories").delete().eq("id",Me);if($e)throw $e},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-community-categories"]}),t({title:"Category deleted"})}}),ce=Lt({mutationFn:async({id:Me,direction:$e})=>{const ct=R.findIndex(Te=>Te.id===Me);if($e==="up"&&ct>0){const Te=R[ct-1],ft=R[ct];await H.from("community_categories").update({sort_order:ft.sort_order}).eq("id",Te.id),await H.from("community_categories").update({sort_order:Te.sort_order}).eq("id",ft.id)}else if($e==="down"&&cts.invalidateQueries({queryKey:["admin-community-categories"]})}),ne=Lt({mutationFn:async Me=>{if(Me.id){const{error:$e}=await H.from("community_private_groups").update({name:Me.name,description:Me.description||null,icon:Me.icon||null}).eq("id",Me.id);if($e)throw $e}else{const $e=Math.max(...U.map(Te=>Te.sort_order),0),{error:ct}=await H.from("community_private_groups").insert({name:Me.name,description:Me.description||null,icon:Me.icon||null,sort_order:$e+1});if(ct)throw ct}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),f(!1),b(null),j({name:"",description:"",icon:""}),t({title:g?"Private group updated!":"Private group created!"})},onError:Me=>{t({title:"Error",description:Me.message,variant:"destructive"})}}),re=Lt({mutationFn:async Me=>{const{error:$e}=await H.from("community_private_groups").delete().eq("id",Me);if($e)throw $e},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-private-groups"]}),t({title:"Private group deleted"})}}),le=Lt({mutationFn:async({id:Me,direction:$e})=>{const ct=U.findIndex(Te=>Te.id===Me);if($e==="up"&&ct>0){const Te=U[ct-1],ft=U[ct];await H.from("community_private_groups").update({sort_order:ft.sort_order}).eq("id",Te.id),await H.from("community_private_groups").update({sort_order:Te.sort_order}).eq("id",ft.id)}else if($e==="down"&&cts.invalidateQueries({queryKey:["admin-private-groups"]})}),pe=Lt({mutationFn:async({groupId:Me,userId:$e,isMember:ct})=>{if(ct){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",Me).eq("user_id",$e);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:Me,user_id:$e});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),xe=Lt({mutationFn:async({groupId:Me,brokerageId:$e,isMember:ct})=>{if(ct){const{error:Te}=await H.from("community_private_group_members").delete().eq("group_id",Me).eq("brokerage_id",$e);if(Te)throw Te}else{const{error:Te}=await H.from("community_private_group_members").insert({group_id:Me,brokerage_id:$e});if(Te)throw Te}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-group-members",C==null?void 0:C.id]})}}),_e=Me=>{i(Me),u({name:Me.name,description:Me.description||"",icon:Me.icon||""}),o(!0)},fe=()=>{i(null),u({name:"",description:"",icon:""}),o(!0)},we=Me=>{b(Me),j({name:Me.name,description:Me.description||"",icon:Me.icon||""}),f(!0)},Ie=()=>{b(null),j({name:"",description:"",icon:""}),f(!0)},Ne=Me=>{M(Me),L(""),N(!0)},Ae=Me=>V.some($e=>$e.user_id===Me),Fe=Me=>V.some($e=>$e.brokerage_id===Me),Ce=Y.filter(Me=>Me.name.toLowerCase().includes(I.toLowerCase())||Me.email.toLowerCase().includes(I.toLowerCase()));return e.jsx(Ts,{title:"Community Management",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{title:"Community Management",description:"Manage categories and private groups for community discussions"}),e.jsxs(ja,{value:r,onValueChange:n,children:[e.jsxs(ga,{children:[e.jsx(us,{value:"categories",children:"Public Categories"}),e.jsxs(us,{value:"private-groups",children:[e.jsx(Mh,{className:"h-4 w-4 mr-1"}),"Private Groups"]})]}),e.jsxs(ks,{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:fe,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[50px]",children:"Order"}),e.jsx(kt,{className:"w-[80px]",children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(On,{children:q?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):R.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first one!"})}):R.map((Me,$e)=>e.jsxs(Ss,{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:$e===0,onClick:()=>ce.mutate({id:Me.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===R.length-1,onClick:()=>ce.mutate({id:Me.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:Me.icon||"📁"}),e.jsx(dt,{className:"font-medium",children:Me.name}),e.jsx(dt,{className:"text-muted-foreground",children:Me.description||"—"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_e(Me),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{confirm("Delete this category? Posts will be uncategorized.")&&X.mutate(Me.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Me.id))})]})})})]}),e.jsxs(ks,{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(wa,{className:"h-3 w-3"}),"Brokerage groups are created automatically and sync with brokerage names"]})]}),e.jsxs(K,{onClick:Ie,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Private Group"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[50px]",children:"Order"}),e.jsx(kt,{className:"w-[80px]",children:"Icon"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"w-[120px]",children:"Members"}),e.jsx(kt,{className:"w-[140px]",children:"Actions"})]})}),e.jsx(On,{children:B?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):U.length===0?e.jsx(Ss,{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((Me,$e)=>e.jsxs(Ss,{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:$e===0,onClick:()=>le.mutate({id:Me.id,direction:"up"}),children:"↑"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",disabled:$e===U.length-1,onClick:()=>le.mutate({id:Me.id,direction:"down"}),children:"↓"})]})}),e.jsx(dt,{className:"text-2xl",children:Me.icon||"🔒"}),e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{className:"flex items-center gap-2",children:[Me.name,Me.brokerage_id?e.jsxs(tt,{variant:"outline",className:"text-xs bg-blue-50 text-blue-700 border-blue-200",children:[e.jsx(wa,{className:"h-3 w-3 mr-1"}),"Auto-managed"]}):e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(Mh,{className:"h-3 w-3 mr-1"}),"Private"]})]})}),e.jsx(dt,{className:"text-muted-foreground",children:Me.description||"—"}),e.jsx(dt,{children:e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>Ne(Me),children:[e.jsx(mr,{className:"h-4 w-4 mr-1"}),"Manage"]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex gap-1",children:[!Me.brokerage_id&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>we(Me),children:e.jsx(Da,{className:"h-4 w-4"})}),!Me.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(Me.id)},children:e.jsx(Nr,{className:"h-4 w-4"})}),Me.brokerage_id&&e.jsx("span",{className:"text-xs text-muted-foreground italic",children:"Managed via brokerage"})]})})]},Me.id))})]})})})]})]}),e.jsx(xs,{open:a,onOpenChange:o,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{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:Me=>u($e=>({...$e,icon:Me.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:Me=>u($e=>({...$e,name:Me.target.value})),placeholder:"Category name",className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Description"}),e.jsx(Er,{value:c.description,onChange:Me=>u($e=>({...$e,description:Me.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:()=>te.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(_s,{children:e.jsx(bs,{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:Me=>j($e=>({...$e,icon:Me.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:Me=>j($e=>({...$e,name:Me.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(Er,{value:_.description,onChange:Me=>j($e=>({...$e,description:Me.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:w,onOpenChange:N,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(bs,{children:["Manage Members: ",C==null?void 0:C.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ja,{defaultValue:"brokerages",children:[e.jsxs(ga,{className:"w-full",children:[e.jsx(us,{value:"brokerages",className:"flex-1",children:"By Brokerage"}),e.jsx(us,{value:"users",className:"flex-1",children:"Individual Users"})]}),e.jsxs(ks,{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(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[J.map(Me=>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(Lo,{checked:Fe(Me.id),onCheckedChange:()=>{C&&xe.mutate({groupId:C.id,brokerageId:Me.id,isMember:Fe(Me.id)})}}),e.jsx("span",{className:"font-medium",children:Me.name})]}),e.jsxs(tt,{variant:"secondary",children:[Y.filter($e=>$e.brokerage_id===Me.id).length," agents"]})]},Me.id)),J.length===0&&e.jsx("p",{className:"text-center text-muted-foreground py-4",children:"No brokerages found"})]})})]}),e.jsxs(ks,{value:"users",className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:I,onChange:Me=>L(Me.target.value),className:"pl-9"})]}),e.jsx(Gi,{className:"h-[300px] border rounded-md p-4",children:e.jsxs("div",{className:"space-y-2",children:[Ce.map(Me=>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(Lo,{checked:Ae(Me.id),onCheckedChange:()=>{C&&pe.mutate({groupId:C.id,userId:Me.id,isMember:Ae(Me.id)})}}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Me.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:Me.email})]})]})},Me.id)),Ce.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:()=>N(!1),children:"Done"})})]})]})})]})})},k8e=t=>{switch(t){case"academy_video":return e.jsx(rl,{className:"h-3 w-3"});case"template":return e.jsx(En,{className:"h-3 w-3"});case"toolbox":return e.jsx(Cl,{className:"h-3 w-3"});case"newsletter":return e.jsx(i1,{className:"h-3 w-3"});case"social_swag":return e.jsx(un,{className:"h-3 w-3"});default:return e.jsx(an,{className:"h-3 w-3"})}},KHt=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}},ZHt=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}},YHt=()=>{const{toast:t}=qa(),[s,r]=k.useState([]),[n,a]=k.useState([]),[o,l]=k.useState([]),[i,c]=k.useState(!0),[u,p]=k.useState(""),[f,g]=k.useState(null),[b,_]=k.useState([]),[j,w]=k.useState([]);k.useEffect(()=>{N()},[]);const N=async()=>{try{c(!0);const{data:V,error:Y}=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(Y)throw Y;const{data:J,error:te}=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(te)throw te;const X=[...new Set((J==null?void 0:J.map(_e=>_e.user_id))||[])],{data:ce}=await H.from("profiles").select(` id, name, email, brokerages ( name ) `).in("id",X),ne=new Map((ce==null?void 0:ce.map(_e=>[_e.id,_e]))||[]),re=(V==null?void 0:V.map(_e=>{var fe,we,Ie,Ne;return{id:_e.id,user_id:_e.user_id,app_name:_e.app_name,launched_at:_e.launched_at,user_name:((fe=_e.profiles)==null?void 0:fe.name)||"Unknown",user_email:((we=_e.profiles)==null?void 0:we.email)||"Unknown",brokerage_name:((Ne=(Ie=_e.profiles)==null?void 0:Ie.brokerages)==null?void 0:Ne.name)||null}}))||[],le=(J==null?void 0:J.map(_e=>{var we;const fe=ne.get(_e.user_id);return{id:_e.id,user_id:_e.user_id,resource_type:_e.resource_type,resource_id:_e.resource_id,resource_title:_e.resource_title,action_type:_e.action_type,created_at:_e.created_at,user_name:(fe==null?void 0:fe.name)||"Unknown",user_email:(fe==null?void 0:fe.email)||"Unknown",brokerage_name:((we=fe==null?void 0:fe.brokerages)==null?void 0:we.name)||null}}))||[];r(re),a(le);const pe=new Map;re.forEach(_e=>{if(!pe.has(_e.user_id))pe.set(_e.user_id,{user_id:_e.user_id,user_name:_e.user_name,user_email:_e.user_email,brokerage_name:_e.brokerage_name,last_activity_type:"app",last_activity_name:_e.app_name,last_activity_at:_e.launched_at,total_app_launches:1,total_content_views:0});else{const fe=pe.get(_e.user_id);fe.total_app_launches++,new Date(_e.launched_at)>new Date(fe.last_activity_at)&&(fe.last_activity_type="app",fe.last_activity_name=_e.app_name,fe.last_activity_at=_e.launched_at)}}),le.forEach(_e=>{if(!pe.has(_e.user_id))pe.set(_e.user_id,{user_id:_e.user_id,user_name:_e.user_name,user_email:_e.user_email,brokerage_name:_e.brokerage_name,last_activity_type:_e.resource_type,last_activity_name:_e.resource_title,last_activity_at:_e.created_at,total_app_launches:0,total_content_views:1});else{const fe=pe.get(_e.user_id);fe.total_content_views++,new Date(_e.created_at)>new Date(fe.last_activity_at)&&(fe.last_activity_type=_e.resource_type,fe.last_activity_name=_e.resource_title,fe.last_activity_at=_e.created_at)}});const xe=Array.from(pe.values()).sort((_e,fe)=>new Date(fe.last_activity_at).getTime()-new Date(_e.last_activity_at).getTime());l(xe)}catch(V){console.error("Error loading activity:",V),t({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{c(!1)}},C=V=>{g({id:V.user_id,name:V.user_name,email:V.user_email});const Y=s.filter(te=>te.user_id===V.user_id),J=n.filter(te=>te.user_id===V.user_id);_(Y),w(J)},M=()=>{g(null),_([]),w([])},{sortKey:I,sortDirection:L,handleSort:R,sortData:q}=KO("last_activity_at","desc"),U=o.filter(V=>{var J;if(!u)return!0;const Y=u.toLowerCase();return V.user_name.toLowerCase().includes(Y)||V.user_email.toLowerCase().includes(Y)||((J=V.brokerage_name)==null?void 0:J.toLowerCase().includes(Y))}),B=q(U,{user:V=>{var Y;return((Y=V.user_name)==null?void 0:Y.toLowerCase())||""},brokerage:V=>{var Y;return((Y=V.brokerage_name)==null?void 0:Y.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(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"User Activity"}),e.jsx(xr,{children:"App launches and content engagement - click to see full history"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"mb-4",children:e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(gl,{sortKey:"user",currentSortKey:I,currentDirection:L,onSort:R,children:"User"}),e.jsx(gl,{sortKey:"brokerage",currentSortKey:I,currentDirection:L,onSort:R,children:"Brokerage"}),e.jsx(kt,{children:"Last Activity"}),e.jsx(gl,{sortKey:"last_activity_at",currentSortKey:I,currentDirection:L,onSort:R,children:"Last Active"}),e.jsx(gl,{sortKey:"apps",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Apps"}),e.jsx(gl,{sortKey:"content",currentSortKey:I,currentDirection:L,onSort:R,className:"text-right",children:"Content"})]})}),e.jsx(On,{children:B.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground",children:"No activity found"})}):B.map(V=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>C(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(tt,{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(tt,{variant:"secondary",children:[e.jsx(an,{className:"h-3 w-3 mr-1"}),V.last_activity_name]}):e.jsxs(tt,{variant:"outline",className:"flex items-center gap-1",children:[k8e(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:_d(new Date(V.last_activity_at),{addSuffix:!0})}),e.jsx(dt,{className:"text-right",children:e.jsx(tt,{variant:"outline",children:V.total_app_launches})}),e.jsx(dt,{className:"text-right",children:e.jsx(tt,{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(_s,{children:[e.jsxs(bs,{children:[f==null?void 0:f.name,"'s Activity"]}),e.jsx(Wr,{children:f==null?void 0:f.email})]}),e.jsxs(ja,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(us,{value:"content",children:["Content (",j.length,")"]}),e.jsxs(us,{value:"apps",children:["App Launches (",b.length,")"]})]}),e.jsx(ks,{value:"content",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(On,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement"})}):j.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs(tt,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[k8e(V.resource_type),KHt(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(tt,{variant:"secondary",children:ZHt(V.action_type)})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:_d(new Date(V.created_at),{addSuffix:!0})})]},V.id))})]})})}),e.jsx(ks,{value:"apps",className:"flex-1 overflow-auto mt-4",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(On,{children:b.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches"})}):b.map(V=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(tt,{variant:"secondary",children:V.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:_d(new Date(V.launched_at),{addSuffix:!0})})]},V.id))})]})})})]})]})})]})},XHt=()=>{const{toast:t}=qa(),[s,r]=k.useState({totalUsers:0,activeUsers:0,pendingUsers:0,totalBrokerages:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0,uniqueActiveThisWeek:0}),[n,a]=k.useState(!0);k.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()),b=new Date;b.setMonth(b.getMonth()-1);const{count:_}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).gte("launched_at",b.toISOString()),{data:j}=await H.from("activity_logs").select("user_id").gte("launched_at",f.toISOString()),w=new Set(j==null?void 0:j.map(N=>N.user_id)).size;r({totalUsers:l||0,activeUsers:i||0,pendingUsers:c,totalBrokerages:u||0,totalLaunches:p||0,launchesThisWeek:g||0,launchesThisMonth:_||0,uniqueActiveThisWeek:w})}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(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Users"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Users"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Brokerages"}),e.jsx(wa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Week"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Launches This Month"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active This Week"}),e.jsx(Ol,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:s.uniqueActiveThisWeek}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique users"})]})]})]})},S8e={event:"Event",template:"Template",academy_video:"Academy Video",resource_kit:"Resource Kit",newsletter:"Newsletter",social_swag:"Social Swag"},C8e={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 Mtt({brokerageOnly:t=!1,brokerageId:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!0),[l,i]=k.useState(""),[c,u]=k.useState("all");k.useEffect(()=>{p()},[s]);const p=async()=>{o(!0);try{let R=[];if(t&&s){const{data:X}=await H.from("profiles").select("id").eq("brokerage_id",s);if(R=(X==null?void 0:X.map(ce=>ce.id))||[],R.length===0){n([]),o(!1);return}}let q=H.from("resource_shares").select("*").order("created_at",{ascending:!1});t&&R.length>0&&(q=q.or(`sender_id.in.(${R.join(",")}),recipient_id.in.(${R.join(",")})`));const{data:U,error:B}=await q;if(B)throw B;const V=new Set;U==null||U.forEach(X=>{V.add(X.sender_id),V.add(X.recipient_id)});const{data:Y}=await H.from("profiles").select("id, name, email").in("id",Array.from(V)),J=new Map((Y==null?void 0:Y.map(X=>[X.id,X]))||[]),te=(U==null?void 0:U.map(X=>({...X,sender:J.get(X.sender_id),recipient:J.get(X.recipient_id)})))||[];n(te)}catch(R){console.error("Error loading shares:",R)}finally{o(!1)}},{sortKey:f,sortDirection:g,handleSort:b,sortData:_}=KO("created_at","desc"),j=r.filter(R=>{var B,V;const q=l===""||R.resource_title.toLowerCase().includes(l.toLowerCase())||((B=R.sender)==null?void 0:B.name.toLowerCase().includes(l.toLowerCase()))||((V=R.recipient)==null?void 0:V.name.toLowerCase().includes(l.toLowerCase())),U=c==="all"||R.resource_type===c;return q&&U}),w=_(j,{resource:R=>{var q;return((q=R.resource_title)==null?void 0:q.toLowerCase())||""},type:R=>R.resource_type,sender:R=>{var q,U;return((U=(q=R.sender)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},recipient:R=>{var q,U;return((U=(q=R.recipient)==null?void 0:q.name)==null?void 0:U.toLowerCase())||""},status:R=>R.is_read?1:0,created_at:R=>new Date(R.created_at).getTime()}),N=r.length,C=new Set(r.map(R=>R.sender_id)).size,M=new Set(r.map(R=>R.recipient_id)).size,I=r.length>0?Math.round(r.filter(R=>R.is_read).length/r.length*100):0,L=r.reduce((R,q)=>(R[q.resource_type]=(R[q.resource_type]||0)+1,R),{});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((R,q)=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(vs,{className:"h-8 w-16"})})]},q))}),e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Shares"}),e.jsx(bd,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:N})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Sharers"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:C})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Recipients Reached"}),e.jsx(Ol,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:M})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Read Rate"}),e.jsx(En,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"text-2xl font-bold",children:[I,"%"]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-sm font-medium",children:"Shares by Resource Type"})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Object.entries(L).map(([R,q])=>e.jsxs(tt,{variant:"secondary",className:C8e[R],children:[S8e[R],": ",q]},R)),Object.keys(L).length===0&&e.jsx("span",{className:"text-muted-foreground text-sm",children:"No shares yet"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Share History"}),e.jsxs(xr,{children:["All resource shares ",t?"in your brokerage":"across the platform"]})]}),e.jsxs(Re,{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(hn,{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:R=>i(R.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Resource type"})}),e.jsxs(Ks,{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(Gi,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(gl,{sortKey:"resource",currentSortKey:f,currentDirection:g,onSort:b,children:"Resource"}),e.jsx(gl,{sortKey:"type",currentSortKey:f,currentDirection:g,onSort:b,children:"Type"}),e.jsx(gl,{sortKey:"sender",currentSortKey:f,currentDirection:g,onSort:b,children:"Sender"}),e.jsx(gl,{sortKey:"recipient",currentSortKey:f,currentDirection:g,onSort:b,children:"Recipient"}),e.jsx(gl,{sortKey:"status",currentSortKey:f,currentDirection:g,onSort:b,children:"Status"}),e.jsx(gl,{sortKey:"created_at",currentSortKey:f,currentDirection:g,onSort:b,children:"Date"})]})}),e.jsx(On,{children:w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No shares found"})}):w.map(R=>{var q,U;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium max-w-[200px] truncate",children:R.resource_title}),e.jsx(dt,{children:e.jsx(tt,{variant:"secondary",className:C8e[R.resource_type],children:S8e[R.resource_type]})}),e.jsx(dt,{children:((q=R.sender)==null?void 0:q.name)||"Unknown"}),e.jsx(dt,{children:((U=R.recipient)==null?void 0:U.name)||"Unknown"}),e.jsx(dt,{children:e.jsx(tt,{variant:R.is_read?"default":"outline",children:R.is_read?"Read":"Unread"})}),e.jsx(dt,{className:"text-muted-foreground",children:ps(new Date(R.created_at),"MMM d, yyyy")})]},R.id)})})]})})]})]})]})}const Lge={academy_video:{label:"Academy Videos",icon:Cn,color:"bg-purple-100 text-purple-800",actionLabel:"Watched",actionIcon:qn},template:{label:"Templates",icon:Ov,color:"bg-blue-100 text-blue-800",actionLabel:"Accessed",actionIcon:bh},toolbox:{label:"Toolkit",icon:Jg,color:"bg-amber-100 text-amber-800",actionLabel:"Downloaded",actionIcon:Ci},newsletter:{label:"Newsletters",icon:dr,color:"bg-emerald-100 text-emerald-800",actionLabel:"Clicked",actionIcon:bh},social_swag:{label:"Social Swag",icon:sc,color:"bg-pink-100 text-pink-800",actionLabel:"Accessed",actionIcon:bh},event:{label:"Events",icon:cn,color:"bg-cyan-100 text-cyan-800",actionLabel:"Registered",actionIcon:bh}};function M8e(t){return t.resource_type==="toolbox"?t.total_downloads:t.total_clicks}function QHt(t,s){return t==="toolbox"?s.downloads:s.clicks}function JHt(){var R;const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(null),l=k.useRef(null),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=KO("total_views","desc");k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:q,error:U}=await H.rpc("get_admin_content_engagement");if(U)throw U;s(q||[])}catch(q){console.error("Error loading content engagement:",q)}finally{n(!1)}},g=q=>{o(U=>{const B=U===q?null:q;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((q,U)=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Re,{children:e.jsx(vs,{className:"h-8 w-16"})})]},U))}),e.jsx(Pe,{children:e.jsx(Re,{className:"py-8",children:e.jsx(vs,{className:"h-64 w-full"})})})]});const b=t.reduce((q,U)=>q+U.total_views,0),_=t.reduce((q,U)=>q+U.total_clicks,0),j=t.reduce((q,U)=>q+U.total_downloads,0),w=t.length,N=t.reduce((q,U)=>(q[U.resource_type]||(q[U.resource_type]={views:0,clicks:0,downloads:0,assets:0,uniqueUsers:0}),q[U.resource_type].views+=U.total_views,q[U.resource_type].clicks+=U.total_clicks,q[U.resource_type].downloads+=U.total_downloads,q[U.resource_type].assets+=1,q[U.resource_type].uniqueUsers+=U.unique_users,q),{}),C=a?t.filter(q=>q.resource_type===a):t,M=p(C,{asset:q=>{var U;return((U=q.resource_title)==null?void 0:U.toLowerCase())||""},type:q=>q.resource_type,views:q=>q.total_views,actions:q=>M8e(q),unique_users:q=>q.unique_users,last_activity:q=>q.last_engaged_at?new Date(q.last_engaged_at).getTime():0}),I=a?Lge[a]||{label:a,icon:qn,actionLabel:"Actions"}:null,L=I==null?void 0:I.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Views"}),e.jsx(qn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:b.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Across all content"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Clicks"}),e.jsx(bh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Downloads"}),e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:j.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF downloads"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Assets Tracked"}),e.jsx(Ol,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsx("div",{className:"text-2xl font-bold",children:w}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Unique content items"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(bh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{children:[e.jsxs("div",{className:"text-2xl font-bold",children:[b>0?Math.round((_+j)/b*100):0,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Of views → actions"})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Engagement by Content Type"}),e.jsx(xr,{children:"Click a category to see individual asset performance"})]}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-3 grid-cols-2 md:grid-cols-3",children:Object.entries(N).map(([q,U])=>{const B=Lge[q]||{label:q,icon:qn,color:"bg-muted text-muted-foreground",actionIcon:bh},V=B.icon,Y=a===q;return e.jsxs("button",{type:"button",onClick:()=>g(q),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors cursor-pointer ${Y?"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(qn,{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"})," ",QHt(q,U)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mr,{className:"h-3 w-3"})," ",U.uniqueUsers]})]})]}),e.jsxs(tt,{variant:"secondary",className:"text-[10px]",children:[U.assets," items"]})]},q)})})})]}),e.jsx("div",{ref:l,children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm font-medium flex items-center gap-2",children:I&&L?e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"h-4 w-4"}),I.label," — Top Performers"]}):"Top Content by Engagement"}),e.jsx(xr,{children:a?`${C.length} ${((R=I==null?void 0:I.label)==null?void 0:R.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(ri,{className:"h-3.5 w-3.5"}),"Show All"]})]})}),e.jsx(Re,{children:C.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(Gi,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[40px]",children:"#"}),e.jsx(gl,{sortKey:"asset",currentSortKey:i,currentDirection:c,onSort:u,children:"Asset"}),!a&&e.jsx(gl,{sortKey:"type",currentSortKey:i,currentDirection:c,onSort:u,children:"Type"}),e.jsx(gl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Views"}),e.jsx(gl,{sortKey:"actions",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:I?I.actionLabel:"Actions"}),e.jsx(gl,{sortKey:"unique_users",currentSortKey:i,currentDirection:c,onSort:u,className:"text-right",children:"Unique Users"}),e.jsx(gl,{sortKey:"last_activity",currentSortKey:i,currentDirection:c,onSort:u,children:"Last Activity"})]})}),e.jsx(On,{children:M.map((q,U)=>{const B=Lge[q.resource_type]||{label:q.resource_type,color:"bg-muted text-muted-foreground"};return e.jsxs(Ss,{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:q.resource_title})}),!a&&e.jsx(dt,{children:e.jsx(tt,{className:`text-[10px] ${B.color}`,children:B.label})}),e.jsx(dt,{className:"text-right font-medium",children:q.total_views}),e.jsx(dt,{className:"text-right font-medium",children:M8e(q)}),e.jsx(dt,{className:"text-right",children:q.unique_users}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:q.last_engaged_at?_d(new Date(q.last_engaged_at),{addSuffix:!0}):"—"})]},`${q.resource_type}-${q.resource_id}`)})})]})})})]})})]})}var eWt=Array.isArray,Ip=eWt,tWt=typeof Vv=="object"&&Vv&&Vv.Object===Object&&Vv,Ttt=tWt,sWt=Ttt,rWt=typeof self=="object"&&self&&self.Object===Object&&self,nWt=sWt||rWt||Function("return this")(),F0=nWt,aWt=F0,iWt=aWt.Symbol,tR=iWt,T8e=tR,Att=Object.prototype,oWt=Att.hasOwnProperty,lWt=Att.toString,XP=T8e?T8e.toStringTag:void 0;function cWt(t){var s=oWt.call(t,XP),r=t[XP];try{t[XP]=void 0;var n=!0}catch{}var a=lWt.call(t);return n&&(s?t[XP]=r:delete t[XP]),a}var dWt=cWt,uWt=Object.prototype,hWt=uWt.toString;function mWt(t){return hWt.call(t)}var pWt=mWt,A8e=tR,fWt=dWt,xWt=pWt,gWt="[object Null]",yWt="[object Undefined]",E8e=A8e?A8e.toStringTag:void 0;function vWt(t){return t==null?t===void 0?yWt:gWt:E8e&&E8e in Object(t)?fWt(t):xWt(t)}var B1=vWt;function bWt(t){return t!=null&&typeof t=="object"}var $1=bWt,_Wt=B1,wWt=$1,jWt="[object Symbol]";function NWt(t){return typeof t=="symbol"||wWt(t)&&_Wt(t)==jWt}var dE=NWt,kWt=Ip,SWt=dE,CWt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,MWt=/^\w*$/;function TWt(t,s){if(kWt(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||SWt(t)?!0:MWt.test(t)||!CWt.test(t)||s!=null&&t in Object(s)}var Gke=TWt;function AWt(t){var s=typeof t;return t!=null&&(s=="object"||s=="function")}var Ow=AWt;const uE=Ao(Ow);var EWt=B1,PWt=Ow,IWt="[object AsyncFunction]",LWt="[object Function]",DWt="[object GeneratorFunction]",OWt="[object Proxy]";function RWt(t){if(!PWt(t))return!1;var s=EWt(t);return s==LWt||s==DWt||s==IWt||s==OWt}var Kke=RWt;const Si=Ao(Kke);var FWt=F0,zWt=FWt["__core-js_shared__"],BWt=zWt,Dge=BWt,P8e=function(){var t=/[^.]+$/.exec(Dge&&Dge.keys&&Dge.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function $Wt(t){return!!P8e&&P8e in t}var qWt=$Wt,UWt=Function.prototype,VWt=UWt.toString;function HWt(t){if(t!=null){try{return VWt.call(t)}catch{}try{return t+""}catch{}}return""}var Ett=HWt,WWt=Kke,GWt=qWt,KWt=Ow,ZWt=Ett,YWt=/[\\^$.*+?()[\]{}|]/g,XWt=/^\[object .+?Constructor\]$/,QWt=Function.prototype,JWt=Object.prototype,eGt=QWt.toString,tGt=JWt.hasOwnProperty,sGt=RegExp("^"+eGt.call(tGt).replace(YWt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function rGt(t){if(!KWt(t)||GWt(t))return!1;var s=WWt(t)?sGt:XWt;return s.test(ZWt(t))}var nGt=rGt;function aGt(t,s){return t==null?void 0:t[s]}var iGt=aGt,oGt=nGt,lGt=iGt;function cGt(t,s){var r=lGt(t,s);return oGt(r)?r:void 0}var xC=cGt,dGt=xC,uGt=dGt(Object,"create"),Kue=uGt,I8e=Kue;function hGt(){this.__data__=I8e?I8e(null):{},this.size=0}var mGt=hGt;function pGt(t){var s=this.has(t)&&delete this.__data__[t];return this.size-=s?1:0,s}var fGt=pGt,xGt=Kue,gGt="__lodash_hash_undefined__",yGt=Object.prototype,vGt=yGt.hasOwnProperty;function bGt(t){var s=this.__data__;if(xGt){var r=s[t];return r===gGt?void 0:r}return vGt.call(s,t)?s[t]:void 0}var _Gt=bGt,wGt=Kue,jGt=Object.prototype,NGt=jGt.hasOwnProperty;function kGt(t){var s=this.__data__;return wGt?s[t]!==void 0:NGt.call(s,t)}var SGt=kGt,CGt=Kue,MGt="__lodash_hash_undefined__";function TGt(t,s){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=CGt&&s===void 0?MGt:s,this}var AGt=TGt,EGt=mGt,PGt=fGt,IGt=_Gt,LGt=SGt,DGt=AGt;function hE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s-1}var QGt=XGt,JGt=Zue;function eKt(t,s){var r=this.__data__,n=JGt(r,t);return n<0?(++this.size,r.push([t,s])):r[n][1]=s,this}var tKt=eKt,sKt=FGt,rKt=WGt,nKt=ZGt,aKt=QGt,iKt=tKt;function mE(t){var s=-1,r=t==null?0:t.length;for(this.clear();++s0?1:-1},j4=function(s){return KS(s)&&s.indexOf("%")===s.length-1},on=function(s){return SZt(s)&&!sR(s)},AZt=function(s){return $i(s)},wu=function(s){return on(s)||KS(s)},EZt=0,fE=function(s){var r=++EZt;return"".concat(s||"").concat(r)},Tm=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(!on(s)&&!KS(s))return n;var o;if(j4(s)){var l=s.indexOf("%");o=r*parseFloat(s.slice(0,l))/100}else o=+s;return sR(o)&&(o=n),a&&o>r&&(o=r),o},i_=function(s){if(!s)return null;var r=Object.keys(s);return r&&r.length?s[r[0]]:null},PZt=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 zZt(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 lbe(t){"@babel/helpers - typeof";return lbe=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},lbe(t)}var B8e={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"},x1=function(s){return typeof s=="string"?s:s?s.displayName||s.name||"Component":""},$8e=null,Rge=null,n4e=function t(s){if(s===$8e&&Array.isArray(Rge))return Rge;var r=[];return k.Children.forEach(s,function(n){$i(n)||(_Zt.isFragment(n)?r=r.concat(t(n.props.children)):r.push(n))}),Rge=r,$8e=s,r};function jf(t,s){var r=[],n=[];return Array.isArray(s)?n=s.map(function(a){return x1(a)}):n=[x1(s)],n4e(t).forEach(function(a){var o=wf(a,"type.displayName")||wf(a,"type.name");n.indexOf(o)!==-1&&r.push(a)}),r}function tf(t,s){var r=jf(t,s);return r&&r[0]}var q8e=function(s){if(!s||!s.props)return!1;var r=s.props,n=r.width,a=r.height;return!(!on(n)||n<=0||!on(a)||a<=0)},BZt=["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"],$Zt=function(s){return s&&s.type&&KS(s.type)&&BZt.indexOf(s.type)>=0},qZt=function(s){return s&&lbe(s)==="object"&&"clipDot"in s},UZt=function(s,r,n,a){var o,l=(o=Oge==null?void 0:Oge[a])!==null&&o!==void 0?o:[];return r.startsWith("data-")||!Si(s)&&(a&&l.includes(r)||DZt.includes(r))||n&&r4e.includes(r)},si=function(s,r,n){if(!s||typeof s=="function"||typeof s=="boolean")return null;var a=s;if(k.isValidElement(s)&&(a=s.props),!uE(a))return null;var o={};return Object.keys(a).forEach(function(l){var i;UZt((i=a)===null||i===void 0?void 0:i[l],l,r,n)&&(o[l]=a[l])}),o},cbe=function t(s,r){if(s===r)return!0;var n=k.Children.count(s);if(n!==k.Children.count(r))return!1;if(n===0)return!0;if(n===1)return U8e(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 KZt(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 ube(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=GZt(t,WZt),p=a||{width:r,height:n,x:0,y:0},f=Vi("recharts-surface",o);return ht.createElement("svg",dbe({},si(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 ZZt=["children","className"];function hbe(){return hbe=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 XZt(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 Ko=ht.forwardRef(function(t,s){var r=t.children,n=t.className,a=YZt(t,ZZt),o=Vi("recharts-layer",n);return ht.createElement("g",hbe({className:o},si(a,!0),{ref:s}),r)}),ty=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:eYt(t,s,r)}var sYt=tYt,rYt="\\ud800-\\udfff",nYt="\\u0300-\\u036f",aYt="\\ufe20-\\ufe2f",iYt="\\u20d0-\\u20ff",oYt=nYt+aYt+iYt,lYt="\\ufe0e\\ufe0f",cYt="\\u200d",dYt=RegExp("["+cYt+rYt+oYt+lYt+"]");function uYt(t){return dYt.test(t)}var $tt=uYt;function hYt(t){return t.split("")}var mYt=hYt,qtt="\\ud800-\\udfff",pYt="\\u0300-\\u036f",fYt="\\ufe20-\\ufe2f",xYt="\\u20d0-\\u20ff",gYt=pYt+fYt+xYt,yYt="\\ufe0e\\ufe0f",vYt="["+qtt+"]",mbe="["+gYt+"]",pbe="\\ud83c[\\udffb-\\udfff]",bYt="(?:"+mbe+"|"+pbe+")",Utt="[^"+qtt+"]",Vtt="(?:\\ud83c[\\udde6-\\uddff]){2}",Htt="[\\ud800-\\udbff][\\udc00-\\udfff]",_Yt="\\u200d",Wtt=bYt+"?",Gtt="["+yYt+"]?",wYt="(?:"+_Yt+"(?:"+[Utt,Vtt,Htt].join("|")+")"+Gtt+Wtt+")*",jYt=Gtt+Wtt+wYt,NYt="(?:"+[Utt+mbe+"?",mbe,Vtt,Htt,vYt].join("|")+")",kYt=RegExp(pbe+"(?="+pbe+")|"+NYt+jYt,"g");function SYt(t){return t.match(kYt)||[]}var CYt=SYt,MYt=mYt,TYt=$tt,AYt=CYt;function EYt(t){return TYt(t)?AYt(t):MYt(t)}var PYt=EYt,IYt=sYt,LYt=$tt,DYt=PYt,OYt=Dtt;function RYt(t){return function(s){s=OYt(s);var r=LYt(s)?DYt(s):void 0,n=r?r[0]:s.charAt(0),a=r?IYt(r,1).join(""):s.slice(1);return n[t]()+a}}var FYt=RYt,zYt=FYt,BYt=zYt("toUpperCase"),$Yt=BYt;const che=Ao($Yt);function Wl(t){return function(){return t}}const Ktt=Math.cos,Hle=Math.sin,my=Math.sqrt,Wle=Math.PI,dhe=2*Wle,fbe=Math.PI,xbe=2*fbe,s4=1e-6,qYt=xbe-s4;function Ztt(t){this._+=t[0];for(let s=1,r=t.length;s=0))throw new Error(`invalid digits: ${t}`);if(s>15)return Ztt;const r=10**s;return function(n){this._+=n[0];for(let a=1,o=n.length;as4)if(!(Math.abs(f*c-u*p)>s4)||!o)this._append`L${this._x1=s},${this._y1=r}`;else{let b=n-l,_=a-i,j=c*c+u*u,w=b*b+_*_,N=Math.sqrt(j),C=Math.sqrt(g),M=o*Math.tan((fbe-Math.acos((j+g-w)/(2*N*C)))/2),I=M/C,L=M/N;Math.abs(I-1)>s4&&this._append`L${s+I*p},${r+I*f}`,this._append`A${o},${o},0,0,${+(f*b>p*_)},${this._x1=s+L*c},${this._y1=r+L*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)>s4||Math.abs(this._y1-p)>s4)&&this._append`L${u},${p}`,n&&(g<0&&(g=g%xbe+xbe),g>qYt?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>s4&&this._append`A${n},${n},0,${+(g>=fbe)},${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 a4e(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 VYt(s)}function i4e(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function Ytt(t){this._context=t}Ytt.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 uhe(t){return new Ytt(t)}function Xtt(t){return t[0]}function Qtt(t){return t[1]}function Jtt(t,s){var r=Wl(!0),n=null,a=uhe,o=null,l=a4e(i);t=typeof t=="function"?t:t===void 0?Xtt:Wl(t),s=typeof s=="function"?s:s===void 0?Qtt:Wl(s);function i(c){var u,p=(c=i4e(c)).length,f,g=!1,b;for(n==null&&(o=a(b=l())),u=0;u<=p;++u)!(u=b;--_)i.point(M[_],I[_]);i.lineEnd(),i.areaEnd()}N&&(M[g]=+t(w,g,f),I[g]=+s(w,g,f),i.point(n?+n(w,g,f):M[g],r?+r(w,g,f):I[g]))}if(C)return i=null,C+""||null}function p(){return Jtt().defined(a).curve(l).context(o)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Wl(+f),n=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Wl(+f),u):t},u.x1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Wl(+f),u):n},u.y=function(f){return arguments.length?(s=typeof f=="function"?f:Wl(+f),r=null,u):s},u.y0=function(f){return arguments.length?(s=typeof f=="function"?f:Wl(+f),u):s},u.y1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Wl(+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:Wl(!!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 est{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 HYt(t){return new est(t,!0)}function WYt(t){return new est(t,!1)}const o4e={draw(t,s){const r=my(s/Wle);t.moveTo(r,0),t.arc(0,0,r,0,dhe)}},GYt={draw(t,s){const r=my(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()}},tst=my(1/3),KYt=tst*2,ZYt={draw(t,s){const r=my(s/KYt),n=r*tst;t.moveTo(0,-r),t.lineTo(n,0),t.lineTo(0,r),t.lineTo(-n,0),t.closePath()}},YYt={draw(t,s){const r=my(s),n=-r/2;t.rect(n,n,r,r)}},XYt=.8908130915292852,sst=Hle(Wle/10)/Hle(7*Wle/10),QYt=Hle(dhe/10)*sst,JYt=-Ktt(dhe/10)*sst,eXt={draw(t,s){const r=my(s*XYt),n=QYt*r,a=JYt*r;t.moveTo(0,-r),t.lineTo(n,a);for(let o=1;o<5;++o){const l=dhe*o/5,i=Ktt(l),c=Hle(l);t.lineTo(c*r,-i*r),t.lineTo(i*n-c*a,c*n+i*a)}t.closePath()}},Fge=my(3),tXt={draw(t,s){const r=-my(s/(Fge*3));t.moveTo(0,r*2),t.lineTo(-Fge*r,-r),t.lineTo(Fge*r,-r),t.closePath()}},Xf=-.5,Qf=my(3)/2,gbe=1/my(12),sXt=(gbe/2+1)*3,rXt={draw(t,s){const r=my(s/sXt),n=r/2,a=r*gbe,o=n,l=r*gbe+r,i=-o,c=l;t.moveTo(n,a),t.lineTo(o,l),t.lineTo(i,c),t.lineTo(Xf*n-Qf*a,Qf*n+Xf*a),t.lineTo(Xf*o-Qf*l,Qf*o+Xf*l),t.lineTo(Xf*i-Qf*c,Qf*i+Xf*c),t.lineTo(Xf*n+Qf*a,Xf*a-Qf*n),t.lineTo(Xf*o+Qf*l,Xf*l-Qf*o),t.lineTo(Xf*i+Qf*c,Xf*c-Qf*i),t.closePath()}};function nXt(t,s){let r=null,n=a4e(a);t=typeof t=="function"?t:Wl(t||o4e),s=typeof s=="function"?s:Wl(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:Wl(o),a):t},a.size=function(o){return arguments.length?(s=typeof o=="function"?o:Wl(+o),a):s},a.context=function(o){return arguments.length?(r=o??null,a):r},a}function Gle(){}function Kle(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 rst(t){this._context=t}rst.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:Kle(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:Kle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function aXt(t){return new rst(t)}function nst(t){this._context=t}nst.prototype={areaStart:Gle,areaEnd:Gle,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:Kle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function iXt(t){return new nst(t)}function ast(t){this._context=t}ast.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:Kle(this,t,s);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s}};function oXt(t){return new ast(t)}function ist(t){this._context=t}ist.prototype={areaStart:Gle,areaEnd:Gle,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 lXt(t){return new ist(t)}function H8e(t){return t<0?-1:1}function W8e(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(H8e(o)+H8e(l))*Math.min(Math.abs(o),Math.abs(l),.5*Math.abs(i))||0}function G8e(t,s){var r=t._x1-t._x0;return r?(3*(t._y1-t._y0)/r-s)/2:s}function zge(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 Zle(t){this._context=t}Zle.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:zge(this,this._t0,G8e(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,zge(this,G8e(this,r=W8e(this,t,s)),r);break;default:zge(this,this._t0,r=W8e(this,t,s));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=s,this._t0=r}}};function ost(t){this._context=new lst(t)}(ost.prototype=Object.create(Zle.prototype)).point=function(t,s){Zle.prototype.point.call(this,s,t)};function lst(t){this._context=t}lst.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 cXt(t){return new Zle(t)}function dXt(t){return new ost(t)}function cst(t){this._context=t}cst.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=K8e(t),a=K8e(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 hXt(t){return new hhe(t,.5)}function mXt(t){return new hhe(t,0)}function pXt(t){return new hhe(t,1)}function ZT(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 fXt(t,s){return t[s]}function xXt(t){const s=[];return s.key=t,s}function gXt(){var t=Wl([]),s=ybe,r=ZT,n=fXt;function a(o){var l=Array.from(t.apply(this,arguments),xXt),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 SXt(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 dst={symbolCircle:o4e,symbolCross:GYt,symbolDiamond:ZYt,symbolSquare:YYt,symbolStar:eXt,symbolTriangle:tXt,symbolWye:rXt},CXt=Math.PI/180,MXt=function(s){var r="symbol".concat(che(s));return dst[r]||o4e},TXt=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*CXt;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}},AXt=function(s,r){dst["symbol".concat(che(s))]=r},l4e=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=kXt(s,_Xt),u=Y8e(Y8e({},c),{},{type:n,size:o,sizeType:i}),p=function(){var w=MXt(n),N=nXt().type(w).size(TXt(o,i,n));return N()},f=u.className,g=u.cx,b=u.cy,_=si(u,!0);return g===+g&&b===+b&&o===+o?ht.createElement("path",vbe({},_,{className:Vi("recharts-symbols",f),transform:"translate(".concat(g,", ").concat(b,")"),d:p()})):null};l4e.registerSymbol=AXt;function YT(t){"@babel/helpers - typeof";return YT=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},YT(t)}function bbe(){return bbe=Object.assign?Object.assign.bind():function(t){for(var s=1;s`);var C=b.inactive?u:b.color;return ht.createElement("li",bbe({className:w,style:f,key:"legend-item-".concat(_)},ZS(n.props,b,_)),ht.createElement(ube,{width:l,height:l,viewBox:p,style:g},n.renderIcon(b)),ht.createElement("span",{className:"recharts-legend-item-text",style:{color:C}},j?j(N,b,_):N))})}},{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())}}])}(k.PureComponent);_D(c4e,"displayName","Legend");_D(c4e,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"middle",inactiveColor:"#ccc"});var BXt=Yue;function $Xt(){this.__data__=new BXt,this.size=0}var qXt=$Xt;function UXt(t){var s=this.__data__,r=s.delete(t);return this.size=s.size,r}var VXt=UXt;function HXt(t){return this.__data__.get(t)}var WXt=HXt;function GXt(t){return this.__data__.has(t)}var KXt=GXt,ZXt=Yue,YXt=Yke,XXt=Xke,QXt=200;function JXt(t,s){var r=this.__data__;if(r instanceof ZXt){var n=r.__data__;if(!YXt||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,b=r&_Qt?new gQt:void 0;for(o.set(t,s),o.set(s,t);++f-1&&t%1==0&&t-1&&t%1==0&&t<=kJt}var m4e=SJt,CJt=B1,MJt=m4e,TJt=$1,AJt="[object Arguments]",EJt="[object Array]",PJt="[object Boolean]",IJt="[object Date]",LJt="[object Error]",DJt="[object Function]",OJt="[object Map]",RJt="[object Number]",FJt="[object Object]",zJt="[object RegExp]",BJt="[object Set]",$Jt="[object String]",qJt="[object WeakMap]",UJt="[object ArrayBuffer]",VJt="[object DataView]",HJt="[object Float32Array]",WJt="[object Float64Array]",GJt="[object Int8Array]",KJt="[object Int16Array]",ZJt="[object Int32Array]",YJt="[object Uint8Array]",XJt="[object Uint8ClampedArray]",QJt="[object Uint16Array]",JJt="[object Uint32Array]",hc={};hc[HJt]=hc[WJt]=hc[GJt]=hc[KJt]=hc[ZJt]=hc[YJt]=hc[XJt]=hc[QJt]=hc[JJt]=!0;hc[AJt]=hc[EJt]=hc[UJt]=hc[PJt]=hc[VJt]=hc[IJt]=hc[LJt]=hc[DJt]=hc[OJt]=hc[RJt]=hc[FJt]=hc[zJt]=hc[BJt]=hc[$Jt]=hc[qJt]=!1;function ees(t){return TJt(t)&&MJt(t.length)&&!!hc[CJt(t)]}var tes=ees;function ses(t){return function(s){return t(s)}}var _st=ses,Jle={exports:{}};Jle.exports;(function(t,s){var r=Ttt,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})(Jle,Jle.exports);var res=Jle.exports,nes=tes,aes=_st,rDe=res,nDe=rDe&&rDe.isTypedArray,ies=nDe?aes(nDe):nes,wst=ies,oes=dJt,les=u4e,ces=Ip,des=bst,ues=h4e,hes=wst,mes=Object.prototype,pes=mes.hasOwnProperty;function fes(t,s){var r=ces(t),n=!r&&les(t),a=!r&&!n&&des(t),o=!r&&!n&&!a&&hes(t),l=r||n||a||o,i=l?oes(t.length,String):[],c=i.length;for(var u in t)(s||pes.call(t,u))&&!(l&&(u=="length"||a&&(u=="offset"||u=="parent")||o&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||ues(u,c)))&&i.push(u);return i}var xes=fes,ges=Object.prototype;function yes(t){var s=t&&t.constructor,r=typeof s=="function"&&s.prototype||ges;return t===r}var ves=yes;function bes(t,s){return function(r){return t(s(r))}}var jst=bes,_es=jst,wes=_es(Object.keys,Object),jes=wes,Nes=ves,kes=jes,Ses=Object.prototype,Ces=Ses.hasOwnProperty;function Mes(t){if(!Nes(t))return kes(t);var s=[];for(var r in Object(t))Ces.call(t,r)&&r!="constructor"&&s.push(r);return s}var Tes=Mes,Aes=Kke,Ees=m4e;function Pes(t){return t!=null&&Ees(t.length)&&!Aes(t)}var rR=Pes,Ies=xes,Les=Tes,Des=rR;function Oes(t){return Des(t)?Ies(t):Les(t)}var mhe=Oes,Res=QQt,Fes=lJt,zes=mhe;function Bes(t){return Res(t,zes,Fes)}var $es=Bes,aDe=$es,qes=1,Ues=Object.prototype,Ves=Ues.hasOwnProperty;function Hes(t,s,r,n,a,o){var l=r&qes,i=aDe(t),c=i.length,u=aDe(s),p=u.length;if(c!=p&&!l)return!1;for(var f=c;f--;){var g=i[f];if(!(l?g in s:Ves.call(s,g)))return!1}var b=o.get(t),_=o.get(s);if(b&&_)return b==s&&_==t;var j=!0;o.set(t,s),o.set(s,t);for(var w=l;++f-1}var Uss=qss;function Vss(t,s,r){for(var n=-1,a=t==null?0:t.length;++n=ars){var u=s?null:rrs(t);if(u)return nrs(u);l=!1,a=srs,c=new Jss}else c=s?[]:i;e:for(;++n=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function _rs(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 wrs(t){return t.value}function jrs(t,s){if(ht.isValidElement(t))return ht.cloneElement(t,s);if(typeof t=="function")return ht.createElement(t,s);s.ref;var r=brs(s,hrs);return ht.createElement(c4e,r)}var _De=1,rT=function(t){function s(){var r;mrs(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?Nv({},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 b=this.getBBoxSnapshot();f={left:((u||0)-b.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 Nv(Nv({},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=Nv(Nv({position:"absolute",width:l||"auto",height:i||"auto"},this.getDefaultPosition(c)),c);return ht.createElement("div",{className:"recharts-legend-wrapper",style:f,ref:function(b){n.wrapperNode=b}},jrs(o,Nv(Nv({},this.props),{},{payload:Ast(p,u,wrs)})))}}],[{key:"getWithHeight",value:function(n,a){var o=Nv(Nv({},this.defaultProps),n.props),l=o.layout;return l==="vertical"&&on(n.props.height)?{height:n.props.height}:l==="horizontal"?{width:n.props.width||a}:null}}])}(k.PureComponent);phe(rT,"displayName","Legend");phe(rT,"defaultProps",{iconSize:14,layout:"horizontal",align:"center",verticalAlign:"bottom"});var wDe=tR,Nrs=u4e,krs=Ip,jDe=wDe?wDe.isConcatSpreadable:void 0;function Srs(t){return krs(t)||Nrs(t)||!!(jDe&&t&&t[jDe])}var Crs=Srs,Mrs=yst,Trs=Crs;function Ist(t,s,r,n,a){var o=-1,l=t.length;for(r||(r=Trs),a||(a=[]);++o0&&r(i)?s>1?Ist(i,s-1,r,n,a):Mrs(a,i):n||(a[a.length]=i)}return a}var Lst=Ist;function Ars(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 Ers=Ars,Prs=Ers,Irs=Prs(),Lrs=Irs,Drs=Lrs,Ors=mhe;function Rrs(t,s){return t&&Drs(t,s,Ors)}var Dst=Rrs,Frs=rR;function zrs(t,s){return function(r,n){if(r==null)return r;if(!Frs(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 Jrs=Qrs,Uge=Jke,ens=e4e,tns=z0,sns=Ost,rns=Krs,nns=_st,ans=Jrs,ins=yE,ons=Ip;function lns(t,s,r){s.length?s=Uge(s,function(o){return ons(o)?function(l){return ens(l,o.length===1?o[0]:o)}:o}):s=[ins];var n=-1;s=Uge(s,nns(tns));var a=sns(t,function(o,l,i){var c=Uge(s,function(u){return u(o)});return{criteria:c,index:++n,value:o}});return rns(a,function(o,l){return ans(o,l,r)})}var cns=lns;function dns(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 uns=dns,hns=uns,kDe=Math.max;function mns(t,s,r){return s=kDe(s===void 0?t.length-1:s,0),function(){for(var n=arguments,a=-1,o=kDe(n.length-s,0),l=Array(o);++a0){if(++s>=jns)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}var Cns=Sns,Mns=wns,Tns=Cns,Ans=Tns(Mns),Ens=Ans,Pns=yE,Ins=pns,Lns=Ens;function Dns(t,s){return Lns(Ins(t,s,Pns),t+"")}var Ons=Dns,Rns=Zke,Fns=rR,zns=h4e,Bns=Ow;function $ns(t,s,r){if(!Bns(r))return!1;var n=typeof s;return(n=="number"?Fns(r)&&zns(s,r.length):n=="string"&&s in r)?Rns(r[s],t):!1}var fhe=$ns,qns=Lst,Uns=cns,Vns=Ons,CDe=fhe,Hns=Vns(function(t,s){if(t==null)return[];var r=s.length;return r>1&&CDe(t,s[0],s[1])?s=[]:r>2&&CDe(s[0],s[1],s[2])&&(s=[s[0]]),Uns(t,qns(s,1),[])}),Wns=Hns;const x4e=Ao(Wns);function wD(t){"@babel/helpers - typeof";return wD=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},wD(t)}function Mbe(){return Mbe=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(QP,"-left"),on(r)&&s&&on(s.x)&&r=s.y),"".concat(QP,"-top"),on(n)&&s&&on(s.y)&&nj?Math.max(p,c[n]):Math.max(f,c[n])}function oas(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 las(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=ADe({allowEscapeViewBox:s,coordinate:r,key:"x",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.width,viewBox:c,viewBoxDimension:c.width}),f=ADe({allowEscapeViewBox:s,coordinate:r,key:"y",offsetTopLeft:n,position:a,reverseDirection:o,tooltipDimension:l.height,viewBox:c,viewBoxDimension:c.height}),u=oas({translateX:p,translateY:f,useTranslate3d:i})):u=aas,{cssProperties:u,cssClasses:ias({translateX:p,translateY:f,coordinate:r})}}function QT(t){"@babel/helpers - typeof";return QT=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},QT(t)}function EDe(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 PDe(t){for(var s=1;sIDe||Math.abs(n.height-this.state.lastBoundingBox.height)>IDe)&&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,b=a.offset,_=a.position,j=a.reverseDirection,w=a.useTranslate3d,N=a.viewBox,C=a.wrapperStyle,M=las({allowEscapeViewBox:l,coordinate:p,offsetTopLeft:b,position:_,reverseDirection:j,tooltipBox:this.state.lastBoundingBox,useTranslate3d:w,viewBox:N}),I=M.cssClasses,L=M.cssProperties,R=PDe(PDe({transition:g&&o?"transform ".concat(i,"ms ").concat(c):void 0},L),{},{pointerEvents:"none",visibility:!this.state.dismissed&&o&&f?"visible":"hidden",position:"absolute",top:0,left:0},C);return ht.createElement("div",{tabIndex:-1,className:I,style:R,ref:function(U){n.wrapperNode=U}},u)}}])}(k.PureComponent),yas=function(){return!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout)},gC={isSsr:yas()};function JT(t){"@babel/helpers - typeof";return JT=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},JT(t)}function LDe(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 DDe(t){for(var s=1;s0;return ht.createElement(gas,{allowEscapeViewBox:l,animationDuration:i,animationEasing:c,isAnimationActive:g,active:o,coordinate:p,hasPayload:R,offset:b,position:w,reverseDirection:N,useTranslate3d:C,viewBox:M,wrapperStyle:I},Mas(u,DDe(DDe({},this.props),{},{payload:L})))}}])}(k.PureComponent);g4e(up,"displayName","Tooltip");g4e(up,"defaultProps",{accessibilityLayer:!1,allowEscapeViewBox:{x:!1,y:!1},animationDuration:400,animationEasing:"ease",contentStyle:{},coordinate:{x:0,y:0},cursor:!0,cursorStyle:{},filterNull:!0,isAnimationActive:!gC.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 Tas=F0,Aas=function(){return Tas.Date.now()},Eas=Aas,Pas=/\s/;function Ias(t){for(var s=t.length;s--&&Pas.test(t.charAt(s)););return s}var Las=Ias,Das=Las,Oas=/^\s+/;function Ras(t){return t&&t.slice(0,Das(t)+1).replace(Oas,"")}var Fas=Ras,zas=Fas,ODe=Ow,Bas=dE,RDe=NaN,$as=/^[-+]0x[0-9a-f]+$/i,qas=/^0b[01]+$/i,Uas=/^0o[0-7]+$/i,Vas=parseInt;function Has(t){if(typeof t=="number")return t;if(Bas(t))return RDe;if(ODe(t)){var s=typeof t.valueOf=="function"?t.valueOf():t;t=ODe(s)?s+"":s}if(typeof t!="string")return t===0?t:+t;t=zas(t);var r=qas.test(t);return r||Uas.test(t)?Vas(t.slice(2),r?2:8):$as.test(t)?RDe:+t}var qst=Has,Was=Ow,Hge=Eas,FDe=qst,Gas="Expected a function",Kas=Math.max,Zas=Math.min;function Yas(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(Gas);s=FDe(s)||0,Was(r)&&(p=!!r.leading,f="maxWait"in r,o=f?Kas(FDe(r.maxWait)||0,s):o,g="trailing"in r?!!r.trailing:g);function b(R){var q=n,U=a;return n=a=void 0,u=R,l=t.apply(U,q),l}function _(R){return u=R,i=setTimeout(N,s),p?b(R):l}function j(R){var q=R-c,U=R-u,B=s-q;return f?Zas(B,o-U):B}function w(R){var q=R-c,U=R-u;return c===void 0||q>=s||q<0||f&&U>=o}function N(){var R=Hge();if(w(R))return C(R);i=setTimeout(N,j(R))}function C(R){return i=void 0,g&&n?b(R):(n=a=void 0,l)}function M(){i!==void 0&&clearTimeout(i),u=0,n=c=a=i=void 0}function I(){return i===void 0?l:C(Hge())}function L(){var R=Hge(),q=w(R);if(n=arguments,a=this,c=R,q){if(i===void 0)return _(c);if(f)return clearTimeout(i),i=setTimeout(N,s),b(c)}return i===void 0&&(i=setTimeout(N,s)),l}return L.cancel=M,L.flush=I,L}var Xas=Yas,Qas=Xas,Jas=Ow,eis="Expected a function";function tis(t,s,r){var n=!0,a=!0;if(typeof t!="function")throw new TypeError(eis);return Jas(r)&&(n="leading"in r?!!r.leading:n,a="trailing"in r?!!r.trailing:a),Qas(t,s,{leading:n,maxWait:s,trailing:a})}var sis=tis;const Ust=Ao(sis);function ND(t){"@babel/helpers - typeof";return ND=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},ND(t)}function zDe(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 Tz(t){for(var s=1;st.length)&&(s=t.length);for(var r=0,n=new Array(s);r0&&(te=Ust(te,j,{trailing:!0,leading:!1}));var X=new ResizeObserver(te),ce=L.current.getBoundingClientRect(),ne=ce.width,re=ce.height;return Y(ne,re),X.observe(L.current),function(){X.disconnect()}},[Y,j]);var J=k.useMemo(function(){var te=B.containerWidth,X=B.containerHeight;if(te<0||X<0)return null;ty(j4(l)||j4(c),`The width(%s) and height(%s) are both fixed numbers, maybe you don't need to use a ResponsiveContainer.`,l,c),ty(!r||r>0,"The aspect(%s) must be greater than zero.",r);var ce=j4(l)?te:l,ne=j4(c)?X:c;r&&r>0&&(ce?ne=ce/r:ne&&(ce=ne*r),g&&ne>g&&(ne=g)),ty(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(b)&&x1(b.type).endsWith("Chart");return ht.Children.map(b,function(le){return ht.isValidElement(le)?k.cloneElement(le,Tz({width:ce,height:ne},re?{style:Tz({height:"100%",width:"100%",maxHeight:ne,maxWidth:ce},le.props.style)}:{})):le})},[r,b,c,g,f,p,B,l]);return ht.createElement("div",{id:w?"".concat(w):void 0,className:Vi("recharts-responsive-container",N),style:Tz(Tz({},I),{},{width:l,height:c,minWidth:p,minHeight:f,maxHeight:g}),ref:L},J)}),nR=function(s){return null};nR.displayName="Cell";function kD(t){"@babel/helpers - typeof";return kD=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},kD(t)}function $De(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 Pbe(t){for(var s=1;s1&&arguments[1]!==void 0?arguments[1]:{};if(s==null||gC.isSsr)return{width:0,height:0};var n=xis(r),a=JSON.stringify({text:s,copyStyle:n});if(j5.widthCache[a])return j5.widthCache[a];try{var o=document.getElementById(qDe);o||(o=document.createElement("span"),o.setAttribute("id",qDe),o.setAttribute("aria-hidden","true"),document.body.appendChild(o));var l=Pbe(Pbe({},fis),n);Object.assign(o.style,l),o.textContent="".concat(s);var i=o.getBoundingClientRect(),c={width:i.width,height:i.height};return j5.widthCache[a]=c,++j5.cacheCount>pis&&(j5.cacheCount=0,j5.widthCache={}),c}catch{return{width:0,height:0}}},gis=function(s){return{top:s.top+window.scrollY-document.documentElement.clientTop,left:s.left+window.scrollX-document.documentElement.clientLeft}};function SD(t){"@babel/helpers - typeof";return SD=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},SD(t)}function rce(t,s){return _is(t)||bis(t,s)||vis(t,s)||yis()}function yis(){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 vis(t,s){if(t){if(typeof t=="string")return UDe(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 UDe(t,s)}}function UDe(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 Dis(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 ZDe(t,s){return zis(t)||Fis(t,s)||Ris(t,s)||Ois()}function Ois(){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 Ris(t,s){if(t){if(typeof t=="string")return YDe(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 YDe(t,s)}}function YDe(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 le=re.word,pe=re.width,xe=ne[ne.length-1];if(xe&&(a==null||o||xe.width+pe+nre.width?ne:re})};if(!p)return b;for(var j="…",w=function(ce){var ne=f.slice(0,ce),re=Gst({breakAll:u,style:c,children:ne+j}).wordsWithComputedWidth,le=g(re),pe=le.length>l||_(le).width>Number(a);return[pe,le]},N=0,C=f.length-1,M=0,I;N<=C&&M<=f.length-1;){var L=Math.floor((N+C)/2),R=L-1,q=w(R),U=ZDe(q,2),B=U[0],V=U[1],Y=w(L),J=ZDe(Y,1),te=J[0];if(!B&&!te&&(N=L+1),B&&te&&(C=L-1),!B&&te){I=V;break}M++}return I||b},XDe=function(s){var r=$i(s)?[]:s.toString().split(Wst);return[{words:r}]},$is=function(s){var r=s.width,n=s.scaleToFit,a=s.children,o=s.style,l=s.breakAll,i=s.maxLines;if((r||n)&&!gC.isSsr){var c,u,p=Gst({breakAll:l,children:a,style:o});if(p){var f=p.wordsWithComputedWidth,g=p.spaceWidth;c=f,u=g}else return XDe(a);return Bis({breakAll:l,children:a,maxLines:i,style:o},c,u,r,n)}return XDe(a)},QDe="#808080",YS=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,b=g===void 0?"start":g,_=s.verticalAnchor,j=_===void 0?"end":_,w=s.fill,N=w===void 0?QDe:w,C=KDe(s,Iis),M=k.useMemo(function(){return $is({breakAll:C.breakAll,children:C.children,maxLines:C.maxLines,scaleToFit:f,style:C.style,width:C.width})},[C.breakAll,C.children,C.maxLines,f,C.style,C.width]),I=C.dx,L=C.dy,R=C.angle,q=C.className,U=C.breakAll,B=KDe(C,Lis);if(!wu(n)||!wu(o))return null;var V=n+(on(I)?I:0),Y=o+(on(L)?L:0),J;switch(j){case"start":J=Wge("calc(".concat(u,")"));break;case"middle":J=Wge("calc(".concat((M.length-1)/2," * -").concat(i," + (").concat(u," / 2))"));break;default:J=Wge("calc(".concat(M.length-1," * -").concat(i,")"));break}var te=[];if(f){var X=M[0].width,ce=C.width;te.push("scale(".concat((on(ce)?ce/X:1)/X,")"))}return R&&te.push("rotate(".concat(R,", ").concat(V,", ").concat(Y,")")),te.length&&(B.transform=te.join(" ")),ht.createElement("text",Ibe({},si(B,!0),{x:V,y:Y,className:Vi("recharts-text",q),textAnchor:b,fill:N.includes("url")?QDe:N}),M.map(function(ne,re){var le=ne.words.join(U?"":" ");return ht.createElement("tspan",{x:V,dy:re===0?J:i,key:"".concat(le,"-").concat(re)},le)}))};function ew(t,s){return t==null||s==null?NaN:ts?1:t>=s?0:NaN}function qis(t,s){return t==null||s==null?NaN:st?1:s>=t?0:NaN}function y4e(t){let s,r,n;t.length!==2?(s=ew,r=(i,c)=>ew(t(i),c),n=(i,c)=>t(i)-c):(s=t===ew||t===qis?t:Uis,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 Uis(){return 0}function Kst(t){return t===null?NaN:+t}function*Vis(t,s){for(let r of t)r!=null&&(r=+r)>=r&&(yield r)}const His=y4e(ew),aR=His.right;y4e(Kst).center;class JDe extends Map{constructor(s,r=Kis){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(eOe(this,s))}has(s){return super.has(eOe(this,s))}set(s,r){return super.set(Wis(this,s),r)}delete(s){return super.delete(Gis(this,s))}}function eOe({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):r}function Wis({_intern:t,_key:s},r){const n=s(r);return t.has(n)?t.get(n):(t.set(n,r),r)}function Gis({_intern:t,_key:s},r){const n=s(r);return t.has(n)&&(r=t.get(n),t.delete(n)),r}function Kis(t){return t!==null&&typeof t=="object"?t.valueOf():t}function Zis(t=ew){if(t===ew)return Zst;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 Zst(t,s){return(t==null||!(t>=t))-(s==null||!(s>=s))||(ts?1:0)}const Yis=Math.sqrt(50),Xis=Math.sqrt(10),Qis=Math.sqrt(2);function nce(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>=Yis?10:o>=Xis?5:o>=Qis?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 sOe(t,s){let r;for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);return r}function Yst(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?Zst:Zis(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),b=Math.max(r,Math.floor(s-u*f/c+g)),_=Math.min(n,Math.floor(s+(c-u)*f/c+g));Yst(t,s,b,_,a)}const o=t[s];let l=r,i=n;for(JP(t,r,s),a(t[n],o)>0&&JP(t,r,n);l0;)--i}a(t[r],o)===0?JP(t,r,i):(++i,JP(t,i,n)),i<=s&&(r=i+1),s<=i&&(n=i-1)}return t}function JP(t,s,r){const n=t[s];t[s]=t[r],t[r]=n}function Jis(t,s,r){if(t=Float64Array.from(Vis(t)),!(!(n=t.length)||isNaN(s=+s))){if(s<=0||n<2)return sOe(t);if(s>=1)return tOe(t);var n,a=(n-1)*s,o=Math.floor(a),l=tOe(Yst(t,o).subarray(0,o+1)),i=sOe(t.subarray(o+1));return l+(i-l)*(a-o)}}function eos(t,s,r=Kst){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?Ez(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):r===4?Ez(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=ros.exec(t))?new bp(s[1],s[2],s[3],1):(s=nos.exec(t))?new bp(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=aos.exec(t))?Ez(s[1],s[2],s[3],s[4]):(s=ios.exec(t))?Ez(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=oos.exec(t))?cOe(s[1],s[2]/100,s[3]/100,1):(s=los.exec(t))?cOe(s[1],s[2]/100,s[3]/100,s[4]):rOe.hasOwnProperty(t)?iOe(rOe[t]):t==="transparent"?new bp(NaN,NaN,NaN,0):null}function iOe(t){return new bp(t>>16&255,t>>8&255,t&255,1)}function Ez(t,s,r,n){return n<=0&&(t=s=r=NaN),new bp(t,s,r,n)}function uos(t){return t instanceof iR||(t=AD(t)),t?(t=t.rgb(),new bp(t.r,t.g,t.b,t.opacity)):new bp}function Fbe(t,s,r,n){return arguments.length===1?uos(t):new bp(t,s,r,n??1)}function bp(t,s,r,n){this.r=+t,this.g=+s,this.b=+r,this.opacity=+n}b4e(bp,Fbe,Qst(iR,{brighter(t){return t=t==null?ace:Math.pow(ace,t),new bp(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?MD:Math.pow(MD,t),new bp(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new bp(vS(this.r),vS(this.g),vS(this.b),ice(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:oOe,formatHex:oOe,formatHex8:hos,formatRgb:lOe,toString:lOe}));function oOe(){return`#${N4(this.r)}${N4(this.g)}${N4(this.b)}`}function hos(){return`#${N4(this.r)}${N4(this.g)}${N4(this.b)}${N4((isNaN(this.opacity)?1:this.opacity)*255)}`}function lOe(){const t=ice(this.opacity);return`${t===1?"rgb(":"rgba("}${vS(this.r)}, ${vS(this.g)}, ${vS(this.b)}${t===1?")":`, ${t})`}`}function ice(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function vS(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function N4(t){return t=vS(t),(t<16?"0":"")+t.toString(16)}function cOe(t,s,r,n){return n<=0?t=s=r=NaN:r<=0||r>=1?t=s=NaN:s<=0&&(t=NaN),new Ug(t,s,r,n)}function Jst(t){if(t instanceof Ug)return new Ug(t.h,t.s,t.l,t.opacity);if(t instanceof iR||(t=AD(t)),!t)return new Ug;if(t instanceof Ug)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 Ug(l,i,c,t.opacity)}function mos(t,s,r,n){return arguments.length===1?Jst(t):new Ug(t,s,r,n??1)}function Ug(t,s,r,n){this.h=+t,this.s=+s,this.l=+r,this.opacity=+n}b4e(Ug,mos,Qst(iR,{brighter(t){return t=t==null?ace:Math.pow(ace,t),new Ug(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?MD:Math.pow(MD,t),new Ug(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 bp(Gge(t>=240?t-240:t+120,a,n),Gge(t,a,n),Gge(t<120?t+240:t-120,a,n),this.opacity)},clamp(){return new Ug(dOe(this.h),Pz(this.s),Pz(this.l),ice(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=ice(this.opacity);return`${t===1?"hsl(":"hsla("}${dOe(this.h)}, ${Pz(this.s)*100}%, ${Pz(this.l)*100}%${t===1?")":`, ${t})`}`}}));function dOe(t){return t=(t||0)%360,t<0?t+360:t}function Pz(t){return Math.max(0,Math.min(1,t||0))}function Gge(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 _4e=t=>()=>t;function pos(t,s){return function(r){return t+r*s}}function fos(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 xos(t){return(t=+t)==1?ert:function(s,r){return r-s?fos(s,r,t):_4e(isNaN(s)?r:s)}}function ert(t,s){var r=s-t;return r?pos(t,r):_4e(isNaN(t)?s:t)}const uOe=function t(s){var r=xos(s);function n(a,o){var l=r((a=Fbe(a)).r,(o=Fbe(o)).r),i=r(a.g,o.g),c=r(a.b,o.b),u=ert(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 gos(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:oce(n,a)})),r=Kge.lastIndex;return rs&&(r=t,t=s,s=r),function(n){return Math.max(t,Math.min(s,n))}}function Mos(t,s,r){var n=t[0],a=t[1],o=s[0],l=s[1];return a2?Tos:Mos,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),oce)))(g)))},f.domain=function(g){return arguments.length?(t=Array.from(g,lce),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=w4e,p()},f.clamp=function(g){return arguments.length?(l=g?!0:Am,p()):l!==Am},f.interpolate=function(g){return arguments.length?(r=g,p()):r},f.unknown=function(g){return arguments.length?(o=g,f):o},function(g,b){return n=g,a=b,p()}}function j4e(){return xhe()(Am,Am)}function Aos(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function cce(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 eA(t){return t=cce(Math.abs(t)),t?t[1]:NaN}function Eos(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 Pos(t){return function(s){return s.replace(/[0-9]/g,function(r){return t[+r]})}}var Ios=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function ED(t){if(!(s=Ios.exec(t)))throw new Error("invalid format: "+t);var s;return new N4e({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]})}ED.prototype=N4e.prototype;function N4e(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+""}N4e.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 Los(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 trt;function Dos(t,s){var r=cce(t,s);if(!r)return t+"";var n=r[0],a=r[1],o=a-(trt=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")+cce(t,Math.max(0,s+o-1))[0]}function mOe(t,s){var r=cce(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 pOe={"%":(t,s)=>(t*100).toFixed(s),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Aos,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)=>mOe(t*100,s),r:mOe,s:Dos,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function fOe(t){return t}var xOe=Array.prototype.map,gOe=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Oos(t){var s=t.grouping===void 0||t.thousands===void 0?fOe:Eos(xOe.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?fOe:Pos(xOe.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=ED(f);var g=f.fill,b=f.align,_=f.sign,j=f.symbol,w=f.zero,N=f.width,C=f.comma,M=f.precision,I=f.trim,L=f.type;L==="n"?(C=!0,L="g"):pOe[L]||(M===void 0&&(M=12),I=!0,L="g"),(w||g==="0"&&b==="=")&&(w=!0,g="0",b="=");var R=j==="$"?r:j==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():"",q=j==="$"?n:/[%p]/.test(L)?l:"",U=pOe[L],B=/[defgprs%]/.test(L);M=M===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,M)):Math.max(0,Math.min(20,M));function V(Y){var J=R,te=q,X,ce,ne;if(L==="c")te=U(Y)+te,Y="";else{Y=+Y;var re=Y<0||1/Y<0;if(Y=isNaN(Y)?c:U(Math.abs(Y),M),I&&(Y=Los(Y)),re&&+Y==0&&_!=="+"&&(re=!1),J=(re?_==="("?_:i:_==="-"||_==="("?"":_)+J,te=(L==="s"?gOe[8+trt/3]:"")+te+(re&&_==="("?")":""),B){for(X=-1,ce=Y.length;++Xne||ne>57){te=(ne===46?a+Y.slice(X+1):Y.slice(X))+te,Y=Y.slice(0,X);break}}}C&&!w&&(Y=s(Y,1/0));var le=J.length+Y.length+te.length,pe=le>1)+J+Y+te+pe.slice(le);break;default:Y=pe+J+Y+te;break}return o(Y)}return V.toString=function(){return f+""},V}function p(f,g){var b=u((f=ED(f),f.type="f",f)),_=Math.max(-8,Math.min(8,Math.floor(eA(g)/3)))*3,j=Math.pow(10,-_),w=gOe[8+_/3];return function(N){return b(j*N)+w}}return{format:u,formatPrefix:p}}var Iz,k4e,srt;Ros({thousands:",",grouping:[3],currency:["$",""]});function Ros(t){return Iz=Oos(t),k4e=Iz.format,srt=Iz.formatPrefix,Iz}function Fos(t){return Math.max(0,-eA(Math.abs(t)))}function zos(t,s){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(eA(s)/3)))*3-eA(Math.abs(t)))}function Bos(t,s){return t=Math.abs(t),s=Math.abs(s)-t,Math.max(0,eA(s)-eA(t))+1}function rrt(t,s,r,n){var a=Obe(t,s,r),o;switch(n=ED(n??",f"),n.type){case"s":{var l=Math.max(Math.abs(t),Math.abs(s));return n.precision==null&&!isNaN(o=zos(a,l))&&(n.precision=o),srt(n,l)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Bos(a,Math.max(Math.abs(t),Math.abs(s))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=Fos(a))&&(n.precision=o-(n.type==="%")*2);break}}return k4e(n)}function Rw(t){var s=t.domain;return t.ticks=function(r){var n=s();return Lbe(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var a=s();return rrt(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=Dbe(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 dce(){var t=j4e();return t.copy=function(){return oR(t,dce())},Hx.apply(t,arguments),Rw(t)}function nrt(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,lce),r):t.slice()},r.unknown=function(n){return arguments.length?(s=n,r):s},r.copy=function(){return nrt(t).unknown(s)},t=arguments.length?Array.from(t,lce):[0,1],Rw(r)}function art(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 Hos(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 S4e(t){const s=t(yOe,vOe),r=s.domain;let n=10,a,o;function l(){return a=Hos(n),o=Vos(n),r()[0]<0?(a=bOe(a),o=bOe(o),t($os,qos)):t(yOe,vOe),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<=b;++g)for(_=1;_p)break;N.push(j)}}else for(;g<=b;++g)for(_=n-1;_>=1;--_)if(j=g>0?_/o(-g):_*o(g),!(jp)break;N.push(j)}N.length*2{if(i==null&&(i=10),c==null&&(c=n===10?"s":","),typeof c!="function"&&(!(n%1)&&(c=ED(c)).precision==null&&(c.trim=!0),c=k4e(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(art(r(),{floor:i=>o(Math.floor(a(i))),ceil:i=>o(Math.ceil(a(i)))})),s}function irt(){const t=S4e(xhe()).domain([1,10]);return t.copy=()=>oR(t,irt()).base(t.base()),Hx.apply(t,arguments),t}function _Oe(t){return function(s){return Math.sign(s)*Math.log1p(Math.abs(s/t))}}function wOe(t){return function(s){return Math.sign(s)*Math.expm1(Math.abs(s))*t}}function C4e(t){var s=1,r=t(_Oe(s),wOe(s));return r.constant=function(n){return arguments.length?t(_Oe(s=+n),wOe(s)):s},Rw(r)}function ort(){var t=C4e(xhe());return t.copy=function(){return oR(t,ort()).constant(t.constant())},Hx.apply(t,arguments)}function jOe(t){return function(s){return s<0?-Math.pow(-s,t):Math.pow(s,t)}}function Wos(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Gos(t){return t<0?-t*t:t*t}function M4e(t){var s=t(Am,Am),r=1;function n(){return r===1?t(Am,Am):r===.5?t(Wos,Gos):t(jOe(r),jOe(1/r))}return s.exponent=function(a){return arguments.length?(r=+a,n()):r},Rw(s)}function T4e(){var t=M4e(xhe());return t.copy=function(){return oR(t,T4e()).exponent(t.exponent())},Hx.apply(t,arguments),t}function Kos(){return T4e.apply(null,arguments).exponent(.5)}function NOe(t){return Math.sign(t)*t*t}function Zos(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function lrt(){var t=j4e(),s=[0,1],r=!1,n;function a(o){var l=Zos(t(o));return isNaN(l)?n:r?Math.round(l):l}return a.invert=function(o){return t.invert(NOe(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,lce)).map(NOe)),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 lrt(t.domain(),s).round(r).clamp(t.clamp()).unknown(n)},Hx.apply(a,arguments),Rw(a)}function crt(){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 drt().domain([t,s]).range(a).unknown(o)},Hx.apply(Rw(l),arguments)}function urt(){var t=[.5],s=[0,1],r,n=1;function a(o){return o!=null&&o<=o?s[aR(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 urt().domain(t).range(s).unknown(r)},Hx.apply(a,arguments)}const Zge=new Date,Yge=new Date;function Iu(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(uIu(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)=>(Zge.setTime(+o),Yge.setTime(+l),t(Zge),t(Yge),Math.floor(r(Zge,Yge))),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 uce=Iu(()=>{},(t,s)=>{t.setTime(+t+s)},(t,s)=>s-t);uce.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?Iu(s=>{s.setTime(Math.floor(s/t)*t)},(s,r)=>{s.setTime(+s+r*t)},(s,r)=>(r-s)/t):uce);uce.range;const Zv=1e3,_x=Zv*60,Yv=_x*60,T1=Yv*24,A4e=T1*7,kOe=T1*30,Xge=T1*365,k4=Iu(t=>{t.setTime(t-t.getMilliseconds())},(t,s)=>{t.setTime(+t+s*Zv)},(t,s)=>(s-t)/Zv,t=>t.getUTCSeconds());k4.range;const E4e=Iu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zv)},(t,s)=>{t.setTime(+t+s*_x)},(t,s)=>(s-t)/_x,t=>t.getMinutes());E4e.range;const P4e=Iu(t=>{t.setUTCSeconds(0,0)},(t,s)=>{t.setTime(+t+s*_x)},(t,s)=>(s-t)/_x,t=>t.getUTCMinutes());P4e.range;const I4e=Iu(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Zv-t.getMinutes()*_x)},(t,s)=>{t.setTime(+t+s*Yv)},(t,s)=>(s-t)/Yv,t=>t.getHours());I4e.range;const L4e=Iu(t=>{t.setUTCMinutes(0,0,0)},(t,s)=>{t.setTime(+t+s*Yv)},(t,s)=>(s-t)/Yv,t=>t.getUTCHours());L4e.range;const lR=Iu(t=>t.setHours(0,0,0,0),(t,s)=>t.setDate(t.getDate()+s),(t,s)=>(s-t-(s.getTimezoneOffset()-t.getTimezoneOffset())*_x)/T1,t=>t.getDate()-1);lR.range;const ghe=Iu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/T1,t=>t.getUTCDate()-1);ghe.range;const hrt=Iu(t=>{t.setUTCHours(0,0,0,0)},(t,s)=>{t.setUTCDate(t.getUTCDate()+s)},(t,s)=>(s-t)/T1,t=>Math.floor(t/T1));hrt.range;function yC(t){return Iu(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())*_x)/A4e)}const yhe=yC(0),hce=yC(1),Yos=yC(2),Xos=yC(3),tA=yC(4),Qos=yC(5),Jos=yC(6);yhe.range;hce.range;Yos.range;Xos.range;tA.range;Qos.range;Jos.range;function vC(t){return Iu(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)/A4e)}const vhe=vC(0),mce=vC(1),els=vC(2),tls=vC(3),sA=vC(4),sls=vC(5),rls=vC(6);vhe.range;mce.range;els.range;tls.range;sA.range;sls.range;rls.range;const D4e=Iu(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());D4e.range;const O4e=Iu(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());O4e.range;const A1=Iu(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());A1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Iu(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)});A1.range;const E1=Iu(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());E1.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:Iu(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)});E1.range;function mrt(t,s,r,n,a,o){const l=[[k4,1,Zv],[k4,5,5*Zv],[k4,15,15*Zv],[k4,30,30*Zv],[o,1,_x],[o,5,5*_x],[o,15,15*_x],[o,30,30*_x],[a,1,Yv],[a,3,3*Yv],[a,6,6*Yv],[a,12,12*Yv],[n,1,T1],[n,2,2*T1],[r,1,A4e],[s,1,kOe],[s,3,3*kOe],[t,1,Xge]];function i(u,p,f){const g=pw).right(l,g);if(b===l.length)return t.every(Obe(u/Xge,p/Xge,f));if(b===0)return uce.every(Math.max(Obe(u,p,f),1));const[_,j]=l[g/l[b-1][2]53)return null;"w"in Te||(Te.w=1),"Z"in Te?(me=Jge(eI(Te.y,0,1)),Ve=me.getUTCDay(),me=Ve>4||Ve===0?mce.ceil(me):mce(me),me=ghe.offset(me,(Te.V-1)*7),Te.y=me.getUTCFullYear(),Te.m=me.getUTCMonth(),Te.d=me.getUTCDate()+(Te.w+6)%7):(me=Qge(eI(Te.y,0,1)),Ve=me.getDay(),me=Ve>4||Ve===0?hce.ceil(me):hce(me),me=lR.offset(me,(Te.V-1)*7),Te.y=me.getFullYear(),Te.m=me.getMonth(),Te.d=me.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),Ve="Z"in Te?Jge(eI(Te.y,0,1)).getUTCDay():Qge(eI(Te.y,0,1)).getDay(),Te.m=0,Te.d="W"in Te?(Te.w+6)%7+Te.W*7-(Ve+5)%7:Te.w+Te.U*7-(Ve+6)%7);return"Z"in Te?(Te.H+=Te.Z/100|0,Te.M+=Te.Z%100,Jge(Te)):Qge(Te)}}function U(Me,$e,ct,Te){for(var ft=0,me=$e.length,Ve=ct.length,nt,et;ft=Ve)return-1;if(nt=$e.charCodeAt(ft++),nt===37){if(nt=$e.charAt(ft++),et=L[nt in SOe?$e.charAt(ft++):nt],!et||(Te=et(Me,ct,Te))<0)return-1}else if(nt!=ct.charCodeAt(Te++))return-1}return Te}function B(Me,$e,ct){var Te=u.exec($e.slice(ct));return Te?(Me.p=p.get(Te[0].toLowerCase()),ct+Te[0].length):-1}function V(Me,$e,ct){var Te=b.exec($e.slice(ct));return Te?(Me.w=_.get(Te[0].toLowerCase()),ct+Te[0].length):-1}function Y(Me,$e,ct){var Te=f.exec($e.slice(ct));return Te?(Me.w=g.get(Te[0].toLowerCase()),ct+Te[0].length):-1}function J(Me,$e,ct){var Te=N.exec($e.slice(ct));return Te?(Me.m=C.get(Te[0].toLowerCase()),ct+Te[0].length):-1}function te(Me,$e,ct){var Te=j.exec($e.slice(ct));return Te?(Me.m=w.get(Te[0].toLowerCase()),ct+Te[0].length):-1}function X(Me,$e,ct){return U(Me,s,$e,ct)}function ce(Me,$e,ct){return U(Me,r,$e,ct)}function ne(Me,$e,ct){return U(Me,n,$e,ct)}function re(Me){return l[Me.getDay()]}function le(Me){return o[Me.getDay()]}function pe(Me){return c[Me.getMonth()]}function xe(Me){return i[Me.getMonth()]}function _e(Me){return a[+(Me.getHours()>=12)]}function fe(Me){return 1+~~(Me.getMonth()/3)}function we(Me){return l[Me.getUTCDay()]}function Ie(Me){return o[Me.getUTCDay()]}function Ne(Me){return c[Me.getUTCMonth()]}function Ae(Me){return i[Me.getUTCMonth()]}function Fe(Me){return a[+(Me.getUTCHours()>=12)]}function Ce(Me){return 1+~~(Me.getUTCMonth()/3)}return{format:function(Me){var $e=R(Me+="",M);return $e.toString=function(){return Me},$e},parse:function(Me){var $e=q(Me+="",!1);return $e.toString=function(){return Me},$e},utcFormat:function(Me){var $e=R(Me+="",I);return $e.toString=function(){return Me},$e},utcParse:function(Me){var $e=q(Me+="",!0);return $e.toString=function(){return Me},$e}}}var SOe={"-":"",_:" ",0:"0"},ih=/^\s*\d+/,cls=/^%/,dls=/[\\^$*+?|[\]().{}]/g;function Xo(t,s,r){var n=t<0?"-":"",a=(n?-t:t)+"",o=a.length;return n+(o[s.toLowerCase(),r]))}function hls(t,s,r){var n=ih.exec(s.slice(r,r+1));return n?(t.w=+n[0],r+n[0].length):-1}function mls(t,s,r){var n=ih.exec(s.slice(r,r+1));return n?(t.u=+n[0],r+n[0].length):-1}function pls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.U=+n[0],r+n[0].length):-1}function fls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.V=+n[0],r+n[0].length):-1}function xls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.W=+n[0],r+n[0].length):-1}function COe(t,s,r){var n=ih.exec(s.slice(r,r+4));return n?(t.y=+n[0],r+n[0].length):-1}function MOe(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.y=+n[0]+(+n[0]>68?1900:2e3),r+n[0].length):-1}function gls(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 yls(t,s,r){var n=ih.exec(s.slice(r,r+1));return n?(t.q=n[0]*3-3,r+n[0].length):-1}function vls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.m=n[0]-1,r+n[0].length):-1}function TOe(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.d=+n[0],r+n[0].length):-1}function bls(t,s,r){var n=ih.exec(s.slice(r,r+3));return n?(t.m=0,t.d=+n[0],r+n[0].length):-1}function AOe(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.H=+n[0],r+n[0].length):-1}function _ls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.M=+n[0],r+n[0].length):-1}function wls(t,s,r){var n=ih.exec(s.slice(r,r+2));return n?(t.S=+n[0],r+n[0].length):-1}function jls(t,s,r){var n=ih.exec(s.slice(r,r+3));return n?(t.L=+n[0],r+n[0].length):-1}function Nls(t,s,r){var n=ih.exec(s.slice(r,r+6));return n?(t.L=Math.floor(n[0]/1e3),r+n[0].length):-1}function kls(t,s,r){var n=cls.exec(s.slice(r,r+1));return n?r+n[0].length:-1}function Sls(t,s,r){var n=ih.exec(s.slice(r));return n?(t.Q=+n[0],r+n[0].length):-1}function Cls(t,s,r){var n=ih.exec(s.slice(r));return n?(t.s=+n[0],r+n[0].length):-1}function EOe(t,s){return Xo(t.getDate(),s,2)}function Mls(t,s){return Xo(t.getHours(),s,2)}function Tls(t,s){return Xo(t.getHours()%12||12,s,2)}function Als(t,s){return Xo(1+lR.count(A1(t),t),s,3)}function prt(t,s){return Xo(t.getMilliseconds(),s,3)}function Els(t,s){return prt(t,s)+"000"}function Pls(t,s){return Xo(t.getMonth()+1,s,2)}function Ils(t,s){return Xo(t.getMinutes(),s,2)}function Lls(t,s){return Xo(t.getSeconds(),s,2)}function Dls(t){var s=t.getDay();return s===0?7:s}function Ols(t,s){return Xo(yhe.count(A1(t)-1,t),s,2)}function frt(t){var s=t.getDay();return s>=4||s===0?tA(t):tA.ceil(t)}function Rls(t,s){return t=frt(t),Xo(tA.count(A1(t),t)+(A1(t).getDay()===4),s,2)}function Fls(t){return t.getDay()}function zls(t,s){return Xo(hce.count(A1(t)-1,t),s,2)}function Bls(t,s){return Xo(t.getFullYear()%100,s,2)}function $ls(t,s){return t=frt(t),Xo(t.getFullYear()%100,s,2)}function qls(t,s){return Xo(t.getFullYear()%1e4,s,4)}function Uls(t,s){var r=t.getDay();return t=r>=4||r===0?tA(t):tA.ceil(t),Xo(t.getFullYear()%1e4,s,4)}function Vls(t){var s=t.getTimezoneOffset();return(s>0?"-":(s*=-1,"+"))+Xo(s/60|0,"0",2)+Xo(s%60,"0",2)}function POe(t,s){return Xo(t.getUTCDate(),s,2)}function Hls(t,s){return Xo(t.getUTCHours(),s,2)}function Wls(t,s){return Xo(t.getUTCHours()%12||12,s,2)}function Gls(t,s){return Xo(1+ghe.count(E1(t),t),s,3)}function xrt(t,s){return Xo(t.getUTCMilliseconds(),s,3)}function Kls(t,s){return xrt(t,s)+"000"}function Zls(t,s){return Xo(t.getUTCMonth()+1,s,2)}function Yls(t,s){return Xo(t.getUTCMinutes(),s,2)}function Xls(t,s){return Xo(t.getUTCSeconds(),s,2)}function Qls(t){var s=t.getUTCDay();return s===0?7:s}function Jls(t,s){return Xo(vhe.count(E1(t)-1,t),s,2)}function grt(t){var s=t.getUTCDay();return s>=4||s===0?sA(t):sA.ceil(t)}function ecs(t,s){return t=grt(t),Xo(sA.count(E1(t),t)+(E1(t).getUTCDay()===4),s,2)}function tcs(t){return t.getUTCDay()}function scs(t,s){return Xo(mce.count(E1(t)-1,t),s,2)}function rcs(t,s){return Xo(t.getUTCFullYear()%100,s,2)}function ncs(t,s){return t=grt(t),Xo(t.getUTCFullYear()%100,s,2)}function acs(t,s){return Xo(t.getUTCFullYear()%1e4,s,4)}function ics(t,s){var r=t.getUTCDay();return t=r>=4||r===0?sA(t):sA.ceil(t),Xo(t.getUTCFullYear()%1e4,s,4)}function ocs(){return"+0000"}function IOe(){return"%"}function LOe(t){return+t}function DOe(t){return Math.floor(+t/1e3)}var N5,yrt,vrt;lcs({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 lcs(t){return N5=lls(t),yrt=N5.format,N5.parse,vrt=N5.utcFormat,N5.utcParse,N5}function ccs(t){return new Date(t)}function dcs(t){return t instanceof Date?+t:+new Date(+t)}function R4e(t,s,r,n,a,o,l,i,c,u){var p=j4e(),f=p.invert,g=p.domain,b=u(".%L"),_=u(":%S"),j=u("%I:%M"),w=u("%I %p"),N=u("%a %d"),C=u("%b %d"),M=u("%B"),I=u("%Y");function L(R){return(c(R)s(a/(t.length-1)))},r.quantiles=function(n){return Array.from({length:n+1},(a,o)=>Jis(t,o/n))},r.copy=function(){return jrt(s).domain(t)},q1.apply(r,arguments)}function _he(){var t=0,s=.5,r=1,n=1,a,o,l,i,c,u=Am,p,f=!1,g;function b(j){return isNaN(j=+j)?g:(j=.5+((j=+p(j))-o)*(n*js}var Crt=gcs,ycs=whe,vcs=Crt,bcs=yE;function _cs(t){return t&&t.length?ycs(t,bcs,vcs):void 0}var wcs=_cs;const jhe=Ao(wcs);function jcs(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};ra.decimalPlaces=ra.dp=function(){var t=this,s=t.d.length-1,r=(s-t.e)*fc;if(s=t.d[s],s)for(;s%10==0;s/=10)r--;return r<0?0:r};ra.dividedBy=ra.div=function(t){return g1(this,new this.constructor(t))};ra.dividedToIntegerBy=ra.idiv=function(t){var s=this,r=s.constructor;return Dl(g1(s,new r(t),0,1),r.precision)};ra.equals=ra.eq=function(t){return!this.cmp(t)};ra.exponent=function(){return su(this)};ra.greaterThan=ra.gt=function(t){return this.cmp(t)>0};ra.greaterThanOrEqualTo=ra.gte=function(t){return this.cmp(t)>=0};ra.isInteger=ra.isint=function(){return this.e>this.d.length-2};ra.isNegative=ra.isneg=function(){return this.s<0};ra.isPositive=ra.ispos=function(){return this.s>0};ra.isZero=function(){return this.s===0};ra.lessThan=ra.lt=function(t){return this.cmp(t)<0};ra.lessThanOrEqualTo=ra.lte=function(t){return this.cmp(t)<1};ra.logarithm=ra.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(df))throw Error(zx+"NaN");if(r.s<1)throw Error(zx+(r.s?"NaN":"-Infinity"));return r.eq(df)?new n(0):(Fc=!1,s=g1(PD(r,o),PD(t,o),o),Fc=!0,Dl(s,a))};ra.minus=ra.sub=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Prt(s,t):Art(s,(t.s=-t.s,t))};ra.modulo=ra.mod=function(t){var s,r=this,n=r.constructor,a=n.precision;if(t=new n(t),!t.s)throw Error(zx+"NaN");return r.s?(Fc=!1,s=g1(r,t,0,1).times(t),Fc=!0,r.minus(s)):Dl(new n(r),a)};ra.naturalExponential=ra.exp=function(){return Ert(this)};ra.naturalLogarithm=ra.ln=function(){return PD(this)};ra.negated=ra.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};ra.plus=ra.add=function(t){var s=this;return t=new s.constructor(t),s.s==t.s?Art(s,t):Prt(s,(t.s=-t.s,t))};ra.precision=ra.sd=function(t){var s,r,n,a=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(bS+t);if(s=su(a)+1,n=a.d.length-1,r=n*fc+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};ra.squareRoot=ra.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(zx+"NaN")}for(t=su(i),Fc=!1,a=Math.sqrt(+i),a==0||a==1/0?(s=o0(i.d),(s.length+t)%2==0&&(s+="0"),a=Math.sqrt(s),t=_E((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(g1(i,o,l+2)).times(.5),o0(o.d).slice(0,l)===(s=o0(n.d)).slice(0,l)){if(s=s.slice(l-3,l+1),a==l&&s=="4999"){if(Dl(o,r+1,0),o.times(o).eq(i)){n=o;break}}else if(s!="9999")break;l+=4}return Fc=!0,Dl(n,r)};ra.times=ra.mul=function(t){var s,r,n,a,o,l,i,c,u,p=this,f=p.constructor,g=p.d,b=(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=b.length,c=0;){for(s=0,a=c+n;a>n;)i=o[a]+b[n]*g[a-n-1]+s,o[a--]=i%Uu|0,s=i/Uu|0;o[a]=(o[a]+s)%Uu|0}for(;!o[--l];)o.pop();return s?++r:o.shift(),t.d=o,t.e=r,Fc?Dl(t,f.precision):t};ra.toDecimalPlaces=ra.todp=function(t,s){var r=this,n=r.constructor;return r=new n(r),t===void 0?r:(A0(t,0,bE),s===void 0?s=n.rounding:A0(s,0,8),Dl(r,t+su(r)+1,s))};ra.toExponential=function(t,s){var r,n=this,a=n.constructor;return t===void 0?r=XS(n,!0):(A0(t,0,bE),s===void 0?s=a.rounding:A0(s,0,8),n=Dl(new a(n),t+1,s),r=XS(n,!0,t+1)),r};ra.toFixed=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?XS(a):(A0(t,0,bE),s===void 0?s=o.rounding:A0(s,0,8),n=Dl(new o(a),t+su(a)+1,s),r=XS(n.abs(),!1,t+su(n)+1),a.isneg()&&!a.isZero()?"-"+r:r)};ra.toInteger=ra.toint=function(){var t=this,s=t.constructor;return Dl(new s(t),su(t)+1,s.rounding)};ra.toNumber=function(){return+this};ra.toPower=ra.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(df);if(i=new c(i),!i.s){if(t.s<1)throw Error(zx+"Infinity");return i}if(i.eq(df))return i;if(n=c.precision,t.eq(df))return Dl(i,n);if(s=t.e,r=t.d.length-1,l=s>=r,o=i.s,l){if((r=p<0?-p:p)<=Trt){for(a=new c(df),s=Math.ceil(n/fc+4),Fc=!1;r%2&&(a=a.times(i),FOe(a.d,s)),r=_E(r/2),r!==0;)i=i.times(i),FOe(i.d,s);return Fc=!0,t.s<0?new c(df).div(a):Dl(a,n)}}else if(o<0)throw Error(zx+"NaN");return o=o<0&&t.d[Math.max(s,r)]&1?-1:1,i.s=1,Fc=!1,a=t.times(PD(i,n+u)),Fc=!0,a=Ert(a),a.s=o,a};ra.toPrecision=function(t,s){var r,n,a=this,o=a.constructor;return t===void 0?(r=su(a),n=XS(a,r<=o.toExpNeg||r>=o.toExpPos)):(A0(t,1,bE),s===void 0?s=o.rounding:A0(s,0,8),a=Dl(new o(a),t,s),r=su(a),n=XS(a,t<=r||r<=o.toExpNeg,t)),n};ra.toSignificantDigits=ra.tosd=function(t,s){var r=this,n=r.constructor;return t===void 0?(t=n.precision,s=n.rounding):(A0(t,1,bE),s===void 0?s=n.rounding:A0(s,0,8)),Dl(new n(r),t,s)};ra.toString=ra.valueOf=ra.val=ra.toJSON=ra[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,s=su(t),r=t.constructor;return XS(t,s<=r.toExpNeg||s>=r.toExpPos)};function Art(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)),Fc?Dl(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/fc),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)/Uu|0,c[o]%=Uu;for(r&&(c.unshift(r),++a),i=c.length;c[--i]==0;)c.pop();return s.d=c,s.e=a,Fc?Dl(s,f):s}function A0(t,s,r){if(t!==~~t||tr)throw Error(bS+t)}function o0(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,b,_,j,w,N,C,M,I,L,R,q,U,B=n.constructor,V=n.s==a.s?1:-1,Y=n.d,J=a.d;if(!n.s)return new B(n);if(!a.s)throw Error(zx+"Division by zero");for(c=n.e-a.e,q=J.length,L=Y.length,b=new B(V),_=b.d=[],u=0;J[u]==(Y[u]||0);)++u;if(J[u]>(Y[u]||0)&&--c,o==null?C=o=B.precision:l?C=o+(su(n)-su(a))+1:C=o,C<0)return new B(0);if(C=C/fc+2|0,u=0,q==1)for(p=0,J=J[0],C++;(u1&&(J=t(J,p),Y=t(Y,p),q=J.length,L=Y.length),I=q,j=Y.slice(0,q),w=j.length;w=Uu/2&&++R;do p=0,i=s(J,j,q,w),i<0?(N=j[0],q!=w&&(N=N*Uu+(j[1]||0)),p=N/R|0,p>1?(p>=Uu&&(p=Uu-1),f=t(J,p),g=f.length,w=j.length,i=s(f,j,g,w),i==1&&(p--,r(f,q16)throw Error(B4e+su(t));if(!t.s)return new p(df);for(Fc=!1,i=f,l=new p(.03125);t.abs().gte(.1);)t=t.times(l),u+=5;for(n=Math.log(n4(2,u))/Math.LN10*2+5|0,i+=n,r=a=o=new p(df),p.precision=i;;){if(a=Dl(a.times(t),i),r=r.times(++c),l=o.plus(g1(a,r,i)),o0(l.d).slice(0,i)===o0(o.d).slice(0,i)){for(;u--;)o=Dl(o.times(o),i);return p.precision=f,s==null?(Fc=!0,Dl(o,f)):o}o=l}}function su(t){for(var s=t.e*fc,r=t.d[0];r>=10;r/=10)s++;return s}function eye(t,s,r){if(s>t.LN10.sd())throw Fc=!0,r&&(t.precision=r),Error(zx+"LN10 precision limit exceeded");return Dl(new t(t.LN10),s)}function Qb(t){for(var s="";t--;)s+="0";return s}function PD(t,s){var r,n,a,o,l,i,c,u,p,f=1,g=10,b=t,_=b.d,j=b.constructor,w=j.precision;if(b.s<1)throw Error(zx+(b.s?"NaN":"-Infinity"));if(b.eq(df))return new j(0);if(s==null?(Fc=!1,u=w):u=s,b.eq(10))return s==null&&(Fc=!0),eye(j,u);if(u+=g,j.precision=u,r=o0(_),n=r.charAt(0),o=su(b),Math.abs(o)<15e14){for(;n<7&&n!=1||n==1&&r.charAt(1)>3;)b=b.times(t),r=o0(b.d),n=r.charAt(0),f++;o=su(b),n>1?(b=new j("0."+r),o++):b=new j(n+"."+r.slice(1))}else return c=eye(j,u+2,w).times(o+""),b=PD(new j(n+"."+r.slice(1)),u-g).plus(c),j.precision=w,s==null?(Fc=!0,Dl(b,w)):b;for(i=l=b=g1(b.minus(df),b.plus(df),u),p=Dl(b.times(b),u),a=3;;){if(l=Dl(l.times(p),u),c=i.plus(g1(l,new j(a),u)),o0(c.d).slice(0,u)===o0(i.d).slice(0,u))return i=i.times(2),o!==0&&(i=i.plus(eye(j,u+2,w).times(o+""))),i=g1(i,new j(f),u),j.precision=w,s==null?(Fc=!0,Dl(i,w)):i;i=c,a+=2}}function ROe(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=_E(r/fc),t.d=[],n=(r+1)%fc,r<0&&(n+=fc),npce||t.e<-pce))throw Error(B4e+r)}else t.s=0,t.e=0,t.d=[0];return t}function Dl(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+=fc,a=s,u=f[p=0];else{if(p=Math.ceil((n+1)/fc),o=f.length,p>=o)return t;for(u=o=f[p],l=1;o>=10;o/=10)l++;n%=fc,a=n-fc+l}if(r!==void 0&&(o=n4(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/n4(10,l-a):0:f[p-1])%10&1||r==(t.s<0?8:7))),s<1||!f[0])return c?(o=su(t),f.length=1,s=s-o-1,f[0]=n4(10,(fc-s%fc)%fc),t.e=_E(-s/fc)||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=n4(10,fc-n),f[p]=a>0?(u/n4(10,l-a)%n4(10,a)|0)*o:0),c)for(;;)if(p==0){(f[0]+=o)==Uu&&(f[0]=1,++t.e);break}else{if(f[p]+=o,f[p]!=Uu)break;f[p--]=0,o=1}for(n=f.length;f[--n]===0;)f.pop();if(Fc&&(t.e>pce||t.e<-pce))throw Error(B4e+su(t));return t}function Prt(t,s){var r,n,a,o,l,i,c,u,p,f,g=t.constructor,b=g.precision;if(!t.s||!s.s)return s.s?s.s=-s.s:s=new g(t),Fc?Dl(s,b):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(b/fc),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)+Qb(n):l>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(a<0?"e":"e+")+a):a<0?(o="0."+Qb(-a-1)+o,r&&(n=r-l)>0&&(o+=Qb(n))):a>=l?(o+=Qb(a+1-l),r&&(n=r-a-1)>0&&(o=o+"."+Qb(n))):((n=a+1)0&&(a+1===l&&(o+="."),o+=Qb(n))),t.s<0?"-"+o:o}function FOe(t,s){if(t.length>s)return t.length=s,!0}function Irt(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(bS+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 ROe(l,o.toString())}else if(typeof o!="string")throw Error(bS+o);if(o.charCodeAt(0)===45?(o=o.slice(1),l.s=-1):l.s=1,Vcs.test(o))ROe(l,o);else throw Error(bS+o)}if(a.prototype=ra,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=Irt,a.config=a.set=Hcs,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(bS+r+": "+n);if((n=t[r="LN10"])!==void 0)if(n==Math.LN10)this[r]=new this(n);else throw Error(bS+r+": "+n);return this}var $4e=Irt(Ucs);df=new $4e(1);const jl=$4e;function Wcs(t){return Ycs(t)||Zcs(t)||Kcs(t)||Gcs()}function Gcs(){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 Kcs(t,s){if(t){if(typeof t=="string")return $be(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 $be(t,s)}}function Zcs(t){if(typeof Symbol<"u"&&Symbol.iterator in Object(t))return Array.from(t)}function Ycs(t){if(Array.isArray(t))return $be(t)}function $be(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,zOe(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 uds(t){if(Array.isArray(t))return t}function Frt(t){var s=ID(t,2),r=s[0],n=s[1],a=r,o=n;return r>n&&(a=n,o=r),[a,o]}function zrt(t,s,r){if(t.lte(0))return new jl(0);var n=She.getDigitCount(t.toNumber()),a=new jl(10).pow(n),o=t.div(a),l=n!==1?.05:.1,i=new jl(Math.ceil(o.div(l).toNumber())).add(r).mul(l),c=i.mul(a);return s?c:new jl(Math.ceil(c))}function hds(t,s,r){var n=1,a=new jl(t);if(!a.isint()&&r){var o=Math.abs(t);o<1?(n=new jl(10).pow(She.getDigitCount(t)-1),a=new jl(Math.floor(a.div(n).toNumber())).mul(n)):o>1&&(a=new jl(Math.floor(t)))}else t===0?a=new jl(Math.floor((s-1)/2)):r||(a=new jl(Math.floor(t)));var l=Math.floor((s-1)/2),i=eds(Jcs(function(c){return a.add(new jl(c-l).mul(n)).toNumber()}),qbe);return i(0,s)}function Brt(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 jl(0),tickMin:new jl(0),tickMax:new jl(0)};var o=zrt(new jl(s).sub(t).div(r-1),n,a),l;t<=0&&s>=0?l=new jl(0):(l=new jl(t).add(s).div(2),l=l.sub(new jl(l).mod(o)));var i=Math.ceil(l.sub(t).div(o).toNumber()),c=Math.ceil(new jl(s).sub(l).div(o).toNumber()),u=i+c+1;return u>r?Brt(t,s,r,n,a+1):(u0?c+(r-u):c,i=s>0?i:i+(r-u)),{step:o,tickMin:l.sub(new jl(i).mul(o)),tickMax:l.add(new jl(c).mul(o))})}function mds(t){var s=ID(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=Frt([r,n]),c=ID(i,2),u=c[0],p=c[1];if(u===-1/0||p===1/0){var f=p===1/0?[u].concat(Vbe(qbe(0,a-1).map(function(){return 1/0}))):[].concat(Vbe(qbe(0,a-1).map(function(){return-1/0})),[p]);return r>n?Ube(f):f}if(u===p)return hds(u,a,o);var g=Brt(u,p,l,o),b=g.step,_=g.tickMin,j=g.tickMax,w=She.rangeStep(_,j.add(new jl(.1).mul(b)),b);return r>n?Ube(w):w}function pds(t,s){var r=ID(t,2),n=r[0],a=r[1],o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,l=Frt([n,a]),i=ID(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=zrt(new jl(u).sub(c).div(p-1),o,0),g=[].concat(Vbe(She.rangeStep(new jl(c),new jl(u).sub(new jl(.99).mul(f)),f)),[u]);return n>a?Ube(g):g}var fds=Ort(mds),xds=Ort(pds),gds="Invariant failed";function QS(t,s){throw new Error(gds)}var yds=["offset","layout","width","dataKey","data","dataPointFormatter","xAxis","yAxis"];function rA(t){"@babel/helpers - typeof";return rA=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},rA(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)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function kds(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 Sds(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Cds(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,b=void 0;if(Mm(f-p)!==Mm(g-f)){var _=[];if(Mm(g-f)===Mm(c[1]-c[0])){b=g;var j=f+c[1]-c[0];_[0]=Math.min(j,(j+p)/2),_[1]=Math.max(j,(j+p)/2)}else{b=p;var w=g+c[1]-c[0];_[0]=Math.min(f,(w+f)/2),_[1]=Math.max(f,(w+f)/2)}var N=[Math.min(f,(b+f)/2),Math.max(f,(b+f)/2)];if(s>N[0]&&s<=N[1]||s>=_[0]&&s<=_[1]){l=a[u].index;break}}else{var C=Math.min(p,g),M=Math.max(p,g);if(s>(C+f)/2&&s<=(M+f)/2){l=a[u].index;break}}}else for(var I=0;I0&&I(n[I].coordinate+n[I-1].coordinate)/2&&s<=(n[I].coordinate+n[I+1].coordinate)/2||I===i-1&&s>(n[I].coordinate+n[I-1].coordinate)/2){l=n[I].index;break}return l},q4e=function(s){var r,n=s,a=n.type.displayName,o=(r=s.type)!==null&&r!==void 0&&r.defaultProps?md(md({},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},Vds=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(N&&N.length){var C=N[0].type.defaultProps,M=C!==void 0?md(md({},C),N[0].props):N[0].props,I=M.barSize,L=M[w];l[L]||(l[L]=[]);var R=$i(I)?r:I;l[L].push({item:N[0],stackList:N.slice(1),barSize:$i(R)?void 0:Tm(R,n,0)})}}return l},Hds=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=Tm(r,a,0,!0),p,f=[];if(l[0].barSize===+l[0].barSize){var g=!1,b=a/c,_=l.reduce(function(I,L){return I+L.barSize||0},0);_+=(c-1)*u,_>=a&&(_-=(c-1)*u,u=0),_>=a&&b>0&&(g=!0,b*=.9,_=c*b);var j=(a-_)/2>>0,w={offset:j-u,size:0};p=l.reduce(function(I,L){var R={item:L.item,position:{offset:w.offset+w.size+u,size:g?b:L.barSize}},q=[].concat(qOe(I),[R]);return w=q[q.length-1].position,L.stackList&&L.stackList.length&&L.stackList.forEach(function(U){q.push({item:U,position:w})}),q},f)}else{var N=Tm(n,a,0,!0);a-2*N-(c-1)*u<=0&&(u=0);var C=(a-2*N-(c-1)*u)/c;C>1&&(C>>=0);var M=i===+i?Math.min(C,i):C;p=l.reduce(function(I,L,R){var q=[].concat(qOe(I),[{item:L.item,position:{offset:N+(C+u)*R+(C-M)/2,size:M}}]);return L.stackList&&L.stackList.length&&L.stackList.forEach(function(U){q.push({item:U,position:q[q.length-1].position})}),q},f)}return p},Wds=function(s,r,n,a){var o=n.children,l=n.width,i=n.margin,c=l-(i.left||0)-(i.right||0),u=Vrt({children:o,legendWidth:c});if(u){var p=a||{},f=p.width,g=p.height,b=u.align,_=u.verticalAlign,j=u.layout;if((j==="vertical"||j==="horizontal"&&_==="middle")&&b!=="center"&&on(s[b]))return md(md({},s),{},iT({},b,s[b]+(f||0)));if((j==="horizontal"||j==="vertical"&&b==="center")&&_!=="middle"&&on(s[_]))return md(md({},s),{},iT({},_,s[_]+(g||0)))}return s},Gds=function(s,r,n){return $i(r)?!0:s==="horizontal"?r==="yAxis":s==="vertical"||n==="x"?r==="xAxis":n==="y"?r==="yAxis":!0},Hrt=function(s,r,n,a,o){var l=r.props.children,i=jf(l,dR).filter(function(u){return Gds(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=bu(p,n);if($i(f))return u;var g=Array.isArray(f)?[Nhe(f),jhe(f)]:[f,f],b=c.reduce(function(_,j){var w=bu(p,j,0),N=g[0]-Math.abs(Array.isArray(w)?w[0]:w),C=g[1]+Math.abs(Array.isArray(w)?w[1]:w);return[Math.min(N,_[0]),Math.max(C,_[1])]},[1/0,-1/0]);return[Math.min(b[0],u[0]),Math.max(b[1],u[1])]},[1/0,-1/0])}return null},Kds=function(s,r,n,a,o){var l=r.map(function(i){return Hrt(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},Wrt=function(s,r,n,a,o){var l=r.map(function(c){var u=c.props.dataKey;return n==="number"&&u&&Hrt(s,c,u,a)||h8(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?Mm(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!sR(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}})},tye=new WeakMap,Lz=function(s,r){if(typeof r!="function")return s;tye.has(s)||tye.set(s,new WeakMap);var n=tye.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},Zrt=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:CD(),realScaleType:"band"}:l==="radial"&&i==="angleAxis"?{scale:dce(),realScaleType:"linear"}:o==="category"&&r&&(r.indexOf("LineChart")>=0||r.indexOf("AreaChart")>=0||r.indexOf("ComposedChart")>=0&&!n)?{scale:u8(),realScaleType:"point"}:o==="category"?{scale:CD(),realScaleType:"band"}:{scale:dce(),realScaleType:"linear"};if(KS(a)){var c="scale".concat(che(a));return{scale:(OOe[c]||u8)(),realScaleType:OOe[c]?c:"point"}}return Si(a)?{scale:a}:{scale:u8(),realScaleType:"point"}},VOe=1e-4,Yrt=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])-VOe,l=Math.max(a[0],a[1])+VOe,i=s(r[0]),c=s(r[n-1]);(il||cl)&&s.domain([r[0],r[n-1]])}},Zds=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])}},Qds=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)}},Jds={sign:Xds,expand:yXt,none:ZT,silhouette:vXt,wiggle:bXt,positive:Qds},eus=function(s,r,n){var a=r.map(function(i){return i.props.dataKey}),o=Jds[n],l=gXt().keys(a).value(function(i,c){return+bu(i,c,0)}).order(ybe).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 b,_=(b=g.type)!==null&&b!==void 0&&b.defaultProps?md(md({},g.type.defaultProps),g.props):g.props,j=_.stackId,w=_.hide;if(w)return f;var N=_[n],C=f[N]||{hasStack:!1,stackGroups:{}};if(wu(j)){var M=C.stackGroups[j]||{numericAxisId:n,cateAxisId:a,items:[]};M.items.push(g),C.hasStack=!0,C.stackGroups[j]=M}else C.stackGroups[fE("_stackId_")]={numericAxisId:n,cateAxisId:a,items:[g]};return md(md({},f),{},iT({},N,C))},c),p={};return Object.keys(u).reduce(function(f,g){var b=u[g];if(b.hasStack){var _={};b.stackGroups=Object.keys(b.stackGroups).reduce(function(j,w){var N=b.stackGroups[w];return md(md({},j),{},iT({},w,{numericAxisId:n,cateAxisId:a,items:N.items,stackedData:eus(s,N.items,o)}))},_)}return md(md({},f),{},iT({},g,b))},p)},Xrt=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=fds(u,o,i);return s.domain([Nhe(p),jhe(p)]),{niceTicks:p}}if(o&&a==="number"){var f=s.domain(),g=xds(f,o,i);return{niceTicks:g}}return null};function HOe(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=Ule(r,"value",a[s.dataKey]);if(i)return i.coordinate+n/2}return r[o]?r[o].coordinate+n/2:null}var c=bu(a,$i(l)?s.dataKey:l);return $i(c)?null:s.scale(c)}var WOe=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=bu(l,r.dataKey,r.domain[i]);return $i(c)?null:r.scale(c)-o/2+a},sus=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]},rus=function(s,r){var n,a=(n=s.type)!==null&&n!==void 0&&n.defaultProps?md(md({},s.type.defaultProps),s.props):s.props,o=a.stackId;if(wu(o)){var l=r[o];if(l){var i=l.items.indexOf(s);return i>=0?l.stackedData[i]:null}}return null},nus=function(s){return s.reduce(function(r,n){return[Nhe(n.concat([r[0]]).filter(on)),jhe(n.concat([r[1]]).filter(on))]},[1/0,-1/0])},Qrt=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=nus(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})},GOe=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,KOe=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Kbe=function(s,r,n){if(Si(s))return s(r,n);if(!Array.isArray(s))return r;var a=[];if(on(s[0]))a[0]=n?s[0]:Math.min(s[0],r[0]);else if(GOe.test(s[0])){var o=+GOe.exec(s[0])[1];a[0]=r[0]-o}else Si(s[0])?a[0]=s[0](r[0]):a[0]=r[0];if(on(s[1]))a[1]=n?s[1]:Math.max(s[1],r[1]);else if(KOe.test(s[1])){var l=+KOe.exec(s[1])[1];a[1]=r[1]+l}else Si(s[1])?a[1]=s[1](r[1]):a[1]=r[1];return a},gce=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=x4e(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},mus=function(s,r,n,a,o){var l=s.width,i=s.height,c=s.startAngle,u=s.endAngle,p=Tm(s.cx,l,l/2),f=Tm(s.cy,i,i/2),g=tnt(l,i,n),b=Tm(s.innerRadius,g,0),_=Tm(s.outerRadius,g,g*.8),j=Object.keys(r);return j.reduce(function(w,N){var C=r[N],M=C.domain,I=C.reversed,L;if($i(C.range))a==="angleAxis"?L=[c,u]:a==="radiusAxis"&&(L=[b,_]),I&&(L=[L[1],L[0]]);else{L=C.range;var R=L,q=ous(R,2);c=q[0],u=q[1]}var U=Zrt(C,o),B=U.realScaleType,V=U.scale;V.domain(M).range(L),Yrt(V);var Y=Xrt(V,Pv(Pv({},C),{},{realScaleType:B})),J=Pv(Pv(Pv({},C),Y),{},{range:L,radius:_,realScaleType:B,scale:V,cx:p,cy:f,innerRadius:b,outerRadius:_,startAngle:c,endAngle:u});return Pv(Pv({},w),{},ent({},N,J))},{})},pus=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))},fus=function(s,r){var n=s.x,a=s.y,o=r.cx,l=r.cy,i=pus({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:hus(u),angleInRadian:u}},xus=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}},gus=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},QOe=function(s,r){var n=s.x,a=s.y,o=fus({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=xus(r),f=p.startAngle,g=p.endAngle,b=i,_;if(f<=g){for(;b>g;)b-=360;for(;b=f&&b<=g}else{for(;b>f;)b-=360;for(;b=g&&b<=f}return _?Pv(Pv({},r),{},{radius:l,angle:gus(b,r)}):null},snt=function(s){return!k.isValidElement(s)&&!Si(s)&&typeof s!="boolean"?s.className:""};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)}var yus=["offset"];function vus(t){return jus(t)||wus(t)||_us(t)||bus()}function bus(){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 _us(t,s){if(t){if(typeof t=="string")return Zbe(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 Zbe(t,s)}}function wus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function jus(t){if(Array.isArray(t))return Zbe(t)}function Zbe(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 kus(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 JOe(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 uu(t){for(var s=1;s=0?1:-1,M,I;a==="insideStart"?(M=b+C*l,I=j):a==="insideEnd"?(M=_-C*l,I=!j):a==="end"&&(M=_+C*l,I=j),I=N<=0?I:!I;var L=tc(u,p,w,M),R=tc(u,p,w,M+(I?1:-1)*359),q="M".concat(L.x,",").concat(L.y,` A`).concat(w,",").concat(w,",0,1,").concat(I?0:1,`, `).concat(R.x,",").concat(R.y),U=$i(s.id)?fE("recharts-radial-line-"):s.id;return ht.createElement("text",FD({},n,{dominantBaseline:"central",className:Vi("recharts-radial-bar-label",i)}),ht.createElement("defs",null,ht.createElement("path",{id:U,d:q})),ht.createElement("textPath",{xlinkHref:"#".concat(U)},r))},Pus=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 b=tc(l,i,u+n,g),_=b.x,j=b.y;return{x:_,y:j,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 w=(c+u)/2,N=tc(l,i,w,g),C=N.x,M=N.y;return{x:C,y:M,textAnchor:"middle",verticalAnchor:"middle"}},Ius=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,b=f>0?"end":"start",_=f>0?"start":"end",j=u>=0?1:-1,w=j*a,N=j>0?"end":"start",C=j>0?"start":"end";if(o==="top"){var M={x:i+u/2,y:c-f*a,textAnchor:"middle",verticalAnchor:b};return uu(uu({},M),n?{height:Math.max(c-n.y,0),width:u}:{})}if(o==="bottom"){var I={x:i+u/2,y:c+p+g,textAnchor:"middle",verticalAnchor:_};return uu(uu({},I),n?{height:Math.max(n.y+n.height-(c+p),0),width:u}:{})}if(o==="left"){var L={x:i-w,y:c+p/2,textAnchor:N,verticalAnchor:"middle"};return uu(uu({},L),n?{width:Math.max(L.x-n.x,0),height:p}:{})}if(o==="right"){var R={x:i+u+w,y:c+p/2,textAnchor:C,verticalAnchor:"middle"};return uu(uu({},R),n?{width:Math.max(n.x+n.width-R.x,0),height:p}:{})}var q=n?{width:u,height:p}:{};return o==="insideLeft"?uu({x:i+w,y:c+p/2,textAnchor:C,verticalAnchor:"middle"},q):o==="insideRight"?uu({x:i+u-w,y:c+p/2,textAnchor:N,verticalAnchor:"middle"},q):o==="insideTop"?uu({x:i+u/2,y:c+g,textAnchor:"middle",verticalAnchor:_},q):o==="insideBottom"?uu({x:i+u/2,y:c+p-g,textAnchor:"middle",verticalAnchor:b},q):o==="insideTopLeft"?uu({x:i+w,y:c+g,textAnchor:C,verticalAnchor:_},q):o==="insideTopRight"?uu({x:i+u-w,y:c+g,textAnchor:N,verticalAnchor:_},q):o==="insideBottomLeft"?uu({x:i+w,y:c+p-g,textAnchor:C,verticalAnchor:b},q):o==="insideBottomRight"?uu({x:i+u-w,y:c+p-g,textAnchor:N,verticalAnchor:b},q):uE(o)&&(on(o.x)||j4(o.x))&&(on(o.y)||j4(o.y))?uu({x:i+Tm(o.x,u),y:c+Tm(o.y,p),textAnchor:"end",verticalAnchor:"end"},q):uu({x:i+u/2,y:c+p/2,textAnchor:"middle",verticalAnchor:"middle"},q)},Lus=function(s){return"cx"in s&&on(s.cx)};function Zu(t){var s=t.offset,r=s===void 0?5:s,n=Nus(t,yus),a=uu({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)&&!k.isValidElement(u)&&!Si(u))return null;if(k.isValidElement(u))return k.cloneElement(u,a);var b;if(Si(u)){if(b=k.createElement(u,a),k.isValidElement(b))return b}else b=Tus(a);var _=Lus(o),j=si(a,!0);if(_&&(l==="insideStart"||l==="insideEnd"||l==="end"))return Eus(a,b,j);var w=_?Pus(a):Ius(a);return ht.createElement(YS,FD({className:Vi("recharts-label",f)},j,w,{breakAll:g}),b)}Zu.displayName="Label";var rnt=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,b=s.top,_=s.left,j=s.width,w=s.height,N=s.clockWise,C=s.labelViewBox;if(C)return C;if(on(j)&&on(w)){if(on(f)&&on(g))return{x:f,y:g,width:j,height:w};if(on(b)&&on(_))return{x:b,y:_,width:j,height:w}}return on(f)&&on(g)?{x:f,y:g,width:0,height:0}:on(r)&&on(n)?{cx:r,cy:n,startAngle:o||a||0,endAngle:l||a||0,innerRadius:u||0,outerRadius:p||c||i||0,clockWise:N}:s.viewBox?s.viewBox:{}},Dus=function(s,r){return s?s===!0?ht.createElement(Zu,{key:"label-implicit",viewBox:r}):wu(s)?ht.createElement(Zu,{key:"label-implicit",viewBox:r,value:s}):k.isValidElement(s)?s.type===Zu?k.cloneElement(s,{key:"label-implicit",viewBox:r}):ht.createElement(Zu,{key:"label-implicit",content:s,viewBox:r}):Si(s)?ht.createElement(Zu,{key:"label-implicit",content:s,viewBox:r}):uE(s)?ht.createElement(Zu,FD({viewBox:r},s,{key:"label-implicit"})):null:null},Ous=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=rnt(s),l=jf(a,Zu).map(function(c,u){return k.cloneElement(c,{viewBox:r||o,key:"label-".concat(u)})});if(!n)return l;var i=Dus(s.label,r||o);return[i].concat(vus(l))};Zu.parseViewBox=rnt;Zu.renderCallByParent=Ous;function Rus(t){var s=t==null?0:t.length;return s?t[s-1]:void 0}var Fus=Rus;const zus=Ao(Fus);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)}var Bus=["valueAccessor"],$us=["data","dataKey","clockWise","id","textBreakAll"];function qus(t){return Wus(t)||Hus(t)||Vus(t)||Uus()}function Uus(){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 Vus(t,s){if(t){if(typeof t=="string")return Ybe(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 Ybe(t,s)}}function Hus(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Wus(t){if(Array.isArray(t))return Ybe(t)}function Ybe(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 Yus(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 Xus=function(s){return Array.isArray(s.value)?zus(s.value):s.value};function y1(t){var s=t.valueAccessor,r=s===void 0?Xus:s,n=sRe(t,Bus),a=n.data,o=n.dataKey,l=n.clockWise,i=n.id,c=n.textBreakAll,u=sRe(n,$us);return!a||!a.length?null:ht.createElement(Ko,{className:"recharts-label-list"},a.map(function(p,f){var g=$i(o)?r(p,f):bu(p&&p.payload,o),b=$i(i)?{}:{id:"".concat(i,"-").concat(f)};return ht.createElement(Zu,vce({},si(p,!0),u,b,{parentViewBox:p.parentViewBox,value:g,textBreakAll:c,viewBox:Zu.parseViewBox($i(l)?p:tRe(tRe({},p),{},{clockWise:l})),key:"label-".concat(f),index:f}))}))}y1.displayName="LabelList";function Qus(t,s){return t?t===!0?ht.createElement(y1,{key:"labelList-implicit",data:s}):ht.isValidElement(t)||Si(t)?ht.createElement(y1,{key:"labelList-implicit",data:s,content:t}):uE(t)?ht.createElement(y1,vce({data:s},t,{key:"labelList-implicit"})):null:null}function Jus(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=jf(n,y1).map(function(l,i){return k.cloneElement(l,{data:s,key:"labelList-".concat(i)})});if(!r)return a;var o=Qus(t.label,s);return[o].concat(qus(a))}y1.renderCallByParent=Jus;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 Xbe(){return Xbe=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 b=tc(r,n,a,l),_=tc(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(b.x,",").concat(b.y," Z")}else g+="L ".concat(r,",").concat(n," Z");return g},nhs=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=Mm(p-u),g=Dz({cx:r,cy:n,radius:o,angle:u,sign:f,cornerRadius:l,cornerIsExternal:c}),b=g.circleTangency,_=g.lineTangency,j=g.theta,w=Dz({cx:r,cy:n,radius:o,angle:p,sign:-f,cornerRadius:l,cornerIsExternal:c}),N=w.circleTangency,C=w.lineTangency,M=w.theta,I=c?Math.abs(u-p):Math.abs(u-p)-j-M;if(I<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 `):nnt({cx:r,cy:n,innerRadius:a,outerRadius:o,startAngle:u,endAngle:p});var L="M ".concat(_.x,",").concat(_.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(b.x,",").concat(b.y,` A`).concat(o,",").concat(o,",0,").concat(+(I>180),",").concat(+(f<0),",").concat(N.x,",").concat(N.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(C.x,",").concat(C.y,` `);if(a>0){var R=Dz({cx:r,cy:n,radius:a,angle:u,sign:f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),q=R.circleTangency,U=R.lineTangency,B=R.theta,V=Dz({cx:r,cy:n,radius:a,angle:p,sign:-f,isExternal:!0,cornerRadius:l,cornerIsExternal:c}),Y=V.circleTangency,J=V.lineTangency,te=V.theta,X=c?Math.abs(u-p):Math.abs(u-p)-B-te;if(X<0&&l===0)return"".concat(L,"L").concat(r,",").concat(n,"Z");L+="L".concat(J.x,",").concat(J.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(Y.x,",").concat(Y.y,` A`).concat(a,",").concat(a,",0,").concat(+(X>180),",").concat(+(f>0),",").concat(q.x,",").concat(q.y,` A`).concat(l,",").concat(l,",0,0,").concat(+(f<0),",").concat(U.x,",").concat(U.y,"Z")}else L+="L".concat(r,",").concat(n,"Z");return L},ahs={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},ant=function(s){var r=nRe(nRe({},ahs),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?w=nhs({cx:n,cy:a,innerRadius:o,outerRadius:l,cornerRadius:Math.min(j,_/2),forceCornerRadius:c,cornerIsExternal:u,startAngle:p,endAngle:f}):w=nnt({cx:n,cy:a,innerRadius:o,outerRadius:l,startAngle:p,endAngle:f}),ht.createElement("path",Xbe({},si(r,!0),{className:b,d:w,role:"img"}))};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 Qbe(){return Qbe=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 Nhs(t,s){return bC(t.getTime(),s.getTime())}function khs(t,s){return t.name===s.name&&t.message===s.message&&t.cause===s.cause&&t.stack===s.stack}function Shs(t,s){return t===s}function hRe(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,b=i.value;if(r.equals(g[0],b[0],c,f,t,s,r)&&r.equals(g[1],b[1],g[0],b[0],t,s,r)){p=a[f]=!0;break}f++}if(!p)return!1;c++}return!0}var Chs=bC;function Mhs(t,s,r){var n=uRe(t),a=n.length;if(uRe(s).length!==a)return!1;for(;a-- >0;)if(!cnt(t,s,r,n[a]))return!1;return!0}function aI(t,s,r){var n=cRe(t),a=n.length;if(cRe(s).length!==a)return!1;for(var o,l,i;a-- >0;)if(o=n[a],!cnt(t,s,r,o)||(l=dRe(t,o),i=dRe(s,o),(l||i)&&(!l||!i||l.configurable!==i.configurable||l.enumerable!==i.enumerable||l.writable!==i.writable)))return!1;return!0}function Ths(t,s){return bC(t.valueOf(),s.valueOf())}function Ahs(t,s){return t.source===s.source&&t.flags===s.flags}function mRe(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 Ehs(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 Phs(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 cnt(t,s,r,n){return(n===whs||n===_hs||n===bhs)&&(t.$$typeof||s.$$typeof)?!0:vhs(s,n)&&r.equals(t[n],s[n],n,n,t,s,r)}var Ihs="[object Arguments]",Lhs="[object Boolean]",Dhs="[object Date]",Ohs="[object Error]",Rhs="[object Map]",Fhs="[object Number]",zhs="[object Object]",Bhs="[object RegExp]",$hs="[object Set]",qhs="[object String]",Uhs="[object URL]",Vhs=Array.isArray,pRe=typeof ArrayBuffer=="function"&&ArrayBuffer.isView?ArrayBuffer.isView:null,fRe=Object.assign,Hhs=Object.prototype.toString.call.bind(Object.prototype.toString);function Whs(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(_,j,w){if(_===j)return!0;if(_==null||j==null)return!1;var N=typeof _;if(N!==typeof j)return!1;if(N!=="object")return N==="number"?l(_,j,w):N==="function"?a(_,j,w):!1;var C=_.constructor;if(C!==j.constructor)return!1;if(C===Object)return i(_,j,w);if(Vhs(_))return s(_,j,w);if(pRe!=null&&pRe(_))return f(_,j,w);if(C===Date)return r(_,j,w);if(C===RegExp)return u(_,j,w);if(C===Map)return o(_,j,w);if(C===Set)return p(_,j,w);var M=Hhs(_);return M===Dhs?r(_,j,w):M===Bhs?u(_,j,w):M===Rhs?o(_,j,w):M===$hs?p(_,j,w):M===zhs?typeof _.then!="function"&&typeof j.then!="function"&&i(_,j,w):M===Uhs?g(_,j,w):M===Ohs?n(_,j,w):M===Ihs?i(_,j,w):M===Lhs||M===Fhs||M===qhs?c(_,j,w):!1}}function Ghs(t){var s=t.circular,r=t.createCustomConfig,n=t.strict,a={areArraysEqual:n?aI:jhs,areDatesEqual:Nhs,areErrorsEqual:khs,areFunctionsEqual:Shs,areMapsEqual:n?lRe(hRe,aI):hRe,areNumbersEqual:Chs,areObjectsEqual:n?aI:Mhs,arePrimitiveWrappersEqual:Ths,areRegExpsEqual:Ahs,areSetsEqual:n?lRe(mRe,aI):mRe,areTypedArraysEqual:n?aI:Ehs,areUrlsEqual:Phs};if(r&&(a=fRe({},a,r(a))),s){var o=Rz(a.areArraysEqual),l=Rz(a.areMapsEqual),i=Rz(a.areObjectsEqual),c=Rz(a.areSetsEqual);a=fRe({},a,{areArraysEqual:o,areMapsEqual:l,areObjectsEqual:i,areSetsEqual:c})}return a}function Khs(t){return function(s,r,n,a,o,l,i){return t(s,r,i)}}function Zhs(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,b=p.meta;return r(c,u,{cache:g,equals:a,meta:b,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 Yhs=zw();zw({strict:!0});zw({circular:!0});zw({circular:!0,strict:!0});zw({createInternalComparator:function(){return bC}});zw({strict:!0,createInternalComparator:function(){return bC}});zw({circular:!0,createInternalComparator:function(){return bC}});zw({circular:!0,createInternalComparator:function(){return bC},strict:!0});function zw(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=Ghs(t),c=Whs(i),u=n?n(c):Khs(c);return Zhs({circular:r,comparator:c,createState:a,equals:u,strict:l})}function Xhs(t){typeof requestAnimationFrame<"u"&&requestAnimationFrame(t)}function xRe(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):Xhs(a)};requestAnimationFrame(n)}function Jbe(t){"@babel/helpers - typeof";return Jbe=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},Jbe(t)}function Qhs(t){return sms(t)||tms(t)||ems(t)||Jhs()}function Jhs(){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 ems(t,s){if(t){if(typeof t=="string")return gRe(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 gRe(t,s)}}function gRe(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:N<0?0:N},j=function(N){for(var C=N>1?1:N,M=C,I=0;I<8;++I){var L=f(M)-C,R=b(M);if(Math.abs(L-C)<_ce||R<_ce)return g(M);M=_(M-L/R)}return g(M)};return j.isStepper=!1,j},yms=function(){var s=arguments.length>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 b=-(p-f)*n,_=g*o,j=g+(b-_)*i/1e3,w=g*i/1e3+p;return Math.abs(w-f)<_ce&&Math.abs(j)<_ce?[f,0]:[w,j]};return c.isStepper=!0,c.dt=i,c},vms=function(){for(var s=arguments.length,r=new Array(s),n=0;nt.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 Ims(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 sye(t){return Rms(t)||Oms(t)||Dms(t)||Lms()}function Lms(){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 Dms(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 Oms(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function Rms(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);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 jce(t){return jce=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},jce(t)}var E0=function(t){qms(r,t);var s=Ums(r);function r(n,a){var o;Fms(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,b=l.duration;if(o.handleStyleChange=o.handleStyleChange.bind(o_e(o)),o.changeStyle=o.changeStyle.bind(o_e(o)),!i||b<=0)return o.state={style:{}},typeof g=="function"&&(o.state={style:p}),i_e(o);if(f&&f.length)o.state={style:f[0].style};else if(u){if(typeof g=="function")return o.state={style:u},i_e(o);o.state={style:c?SI({},c,u):u}}else o.state={style:{}};return o}return Bms(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 b={style:c?SI({},c,p):p};this.state&&g&&(c&&g[c]!==p||!c&&g!==p)&&this.setState(b);return}if(!(Yhs(a.to,p)&&a.canBegin&&a.isActive)){var _=!a.canBegin||!a.isActive;this.manager&&this.manager.stop(),this.stopJSAnimation&&this.stopJSAnimation();var j=_||u?f:a.to;if(this.state&&g){var w={style:c?SI({},c,j):j};(c&&g[c]!==j||!c&&g!==j)&&this.setState(w)}this.runAnimation(Ng(Ng({},this.props),{},{from:j,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,b=Ams(l,i,vms(u),c,this.changeStyle),_=function(){o.stopJSAnimation=b()};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,b=function(j,w,N){if(N===0)return j;var C=w.duration,M=w.easing,I=M===void 0?"ease":M,L=w.style,R=w.properties,q=w.onAnimationEnd,U=N>0?l[N-1]:w,B=R||Object.keys(L);if(typeof I=="function"||I==="spring")return[].concat(sye(j),[o.runJSAnimation.bind(o,{from:U.style,to:L,duration:C,easing:I}),C]);var V=bRe(B,C,I),Y=Ng(Ng(Ng({},U.style),L),{},{transition:V});return[].concat(sye(j),[Y,C,q]).filter(oms)};return this.manager.start([c].concat(sye(l.reduce(b,[p,Math.max(g,i)])),[a.onAnimationEnd]))}},{key:"runAnimation",value:function(a){this.manager||(this.manager=rms());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,b=a.children,_=this.manager;if(this.unSubscribe=_.subscribe(this.handleStyleChange),typeof u=="function"||typeof b=="function"||u==="spring"){this.runJSAnimation(a);return}if(g.length>1){this.runStepAnimation(a);return}var j=i?SI({},i,c):c,w=bRe(Object.keys(j),l,u);_.start([p,o,Ng(Ng({},j),{},{transition:w}),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=Pms(a,Ems),u=k.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(b){var _=b.props,j=_.style,w=j===void 0?{}:j,N=_.className,C=k.cloneElement(b,Ng(Ng({},c),{},{style:Ng(Ng({},w),p),className:N}));return C};return u===1?f(k.Children.only(o)):ht.createElement("div",null,k.Children.map(o,function(g){return f(g)}))}}]),r}(k.PureComponent);E0.displayName="Animate";E0.defaultProps={begin:0,duration:1e3,from:"",to:"",attributeName:"",easing:"ease",isActive:!0,canBegin:!0,steps:[],onAnimationEnd:function(){},onAnimationStart:function(){}};E0.propTypes={from:il.oneOfType([il.object,il.string]),to:il.oneOfType([il.object,il.string]),attributeName:il.string,duration:il.number,begin:il.number,easing:il.oneOfType([il.string,il.func]),steps:il.arrayOf(il.shape({duration:il.number.isRequired,style:il.object.isRequired,easing:il.oneOfType([il.oneOf(["ease","ease-in","ease-out","ease-in-out","linear"]),il.func]),properties:il.arrayOf("string"),onAnimationEnd:il.func})),children:il.oneOfType([il.node,il.func]),isActive:il.bool,canBegin:il.bool,onAnimationEnd:il.func,shouldReAnimate:il.bool,onAnimationStart:il.func,onAnimationReStart:il.func};function VD(t){"@babel/helpers - typeof";return VD=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},VD(t)}function Nce(){return Nce=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,b=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},Jms=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},eps={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},U4e=function(s){var r=MRe(MRe({},eps),s),n=k.useRef(),a=k.useState(-1),o=Hms(a,2),l=o[0],i=o[1];k.useEffect(function(){if(n.current&&n.current.getTotalLength)try{var I=n.current.getTotalLength();I&&i(I)}catch{}},[]);var c=r.x,u=r.y,p=r.width,f=r.height,g=r.radius,b=r.className,_=r.animationEasing,j=r.animationDuration,w=r.animationBegin,N=r.isAnimationActive,C=r.isUpdateAnimationActive;if(c!==+c||u!==+u||p!==+p||f!==+f||p===0||f===0)return null;var M=Vi("recharts-rectangle",b);return C?ht.createElement(E0,{canBegin:l>0,from:{width:p,height:f,x:c,y:u},to:{width:p,height:f,x:c,y:u},duration:j,animationEasing:_,isActive:C},function(I){var L=I.width,R=I.height,q=I.x,U=I.y;return ht.createElement(E0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,isActive:N,easing:_},ht.createElement("path",Nce({},si(r,!0),{className:M,d:TRe(q,U,L,R,g),ref:n})))}):ht.createElement("path",Nce({},si(r,!0),{className:M,d:TRe(c,u,p,f,g)}))},tps=["points","className","baseLinePoints","connectNulls"];function oM(){return oM=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 rps(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 ARe(t){return ops(t)||ips(t)||aps(t)||nps()}function nps(){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 aps(t,s){if(t){if(typeof t=="string")return l_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 l_e(t,s)}}function ips(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function ops(t){if(Array.isArray(t))return l_e(t)}function l_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){ERe(n)?r[r.length-1].push(n):r[r.length-1].length>0&&r.push([])}),ERe(s[0])&&r[r.length-1].push(s[0]),r[r.length-1].length<=0&&(r=r.slice(0,-1)),r},p8=function(s,r){var n=lps(s);r&&(n=[n.reduce(function(o,l){return[].concat(ARe(o),ARe(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},cps=function(s,r,n){var a=p8(s,n);return"".concat(a.slice(-1)==="Z"?a.slice(0,-1):a,"L").concat(p8(r.reverse(),n).slice(1))},dps=function(s){var r=s.points,n=s.className,a=s.baseLinePoints,o=s.connectNulls,l=sps(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=cps(r,a,o);return ht.createElement("g",{className:i},ht.createElement("path",oM({},si(l,!0),{fill:u.slice(-1)==="Z"?l.fill:"none",stroke:"none",d:u})),c?ht.createElement("path",oM({},si(l,!0),{fill:"none",d:p8(r,o)})):null,c?ht.createElement("path",oM({},si(l,!0),{fill:"none",d:p8(a,o)})):null)}var p=p8(r,o);return ht.createElement("path",oM({},si(l,!0),{fill:p.slice(-1)==="Z"?l.fill:"none",className:i,d:p}))};function c_e(){return c_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 gps(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 yps=function(s,r,n,a,o,l){return"M".concat(s,",").concat(o,"v").concat(a,"M").concat(l,",").concat(r,"h").concat(n)},vps=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,b=g===void 0?0:g,_=s.className,j=xps(s,ups),w=hps({x:n,y:o,top:i,left:u,width:f,height:b},j);return!on(n)||!on(o)||!on(f)||!on(b)||!on(i)||!on(u)?null:ht.createElement("path",d_e({},si(w,!0),{className:Vi("recharts-cross",_),d:yps(n,o,f,b,i,u)}))},bps=whe,_ps=Crt,wps=z0;function jps(t,s){return t&&t.length?bps(t,wps(s),_ps):void 0}var Nps=jps;const kps=Ao(Nps);var Sps=whe,Cps=z0,Mps=Mrt;function Tps(t,s){return t&&t.length?Sps(t,Cps(s),Mps):void 0}var Aps=Tps;const Eps=Ao(Aps);var Pps=["cx","cy","angle","ticks","axisLine"],Ips=["ticks","tick","angle","tickFormatter","stroke"];function aA(t){"@babel/helpers - typeof";return aA=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},aA(t)}function f8(){return f8=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 Lps(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 Dps(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function DRe(t,s){for(var r=0;rFRe?l=a==="outer"?"start":"end":o<-FRe?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=z2(z2({},si(this.props,!1)),{},{fill:"none"},si(i,!1));if(c==="circle")return ht.createElement(Che,c4({className:"recharts-polar-angle-axis-line"},u,{cx:a,cy:o,r:l}));var p=this.props.ticks,f=p.map(function(g){return tc(a,o,l,g.coordinate)});return ht.createElement(dps,c4({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=si(this.props,!1),f=si(l,!1),g=z2(z2({},p),{},{fill:"none"},si(i,!1)),b=o.map(function(_,j){var w=n.getTickLineCoord(_),N=n.getTickTextAnchor(_),C=z2(z2(z2({textAnchor:N},p),{},{stroke:"none",fill:u},f),{},{index:j,payload:_,x:w.x2,y:w.y2});return ht.createElement(Ko,c4({className:Vi("recharts-polar-angle-axis-tick",snt(l)),key:"tick-".concat(_.coordinate)},ZS(n.props,_,j)),i&&ht.createElement("line",c4({className:"recharts-polar-angle-axis-tick-line"},g,w)),l&&s.renderTickItem(l,C,c?c(_.value,j):_.value))});return ht.createElement(Ko,{className:"recharts-polar-angle-axis-ticks"},b)}},{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(Ko,{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):Si(n)?l=n(a):l=ht.createElement(YS,c4({},a,{className:"recharts-polar-angle-axis-tick-value"}),o),l}}])}(k.PureComponent);Ahe(Ehe,"displayName","PolarAngleAxis");Ahe(Ehe,"axisType","angleAxis");Ahe(Ehe,"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 Yps=jst,Xps=Yps(Object.getPrototypeOf,Object),Qps=Xps,Jps=B1,efs=Qps,tfs=$1,sfs="[object Object]",rfs=Function.prototype,nfs=Object.prototype,bnt=rfs.toString,afs=nfs.hasOwnProperty,ifs=bnt.call(Object);function ofs(t){if(!tfs(t)||Jps(t)!=sfs)return!1;var s=efs(t);if(s===null)return!0;var r=afs.call(s,"constructor")&&s.constructor;return typeof r=="function"&&r instanceof r&&bnt.call(r)==ifs}var lfs=ofs;const cfs=Ao(lfs);var dfs=B1,ufs=$1,hfs="[object Boolean]";function mfs(t){return t===!0||t===!1||ufs(t)&&dfs(t)==hfs}var pfs=mfs;const ffs=Ao(pfs);function WD(t){"@babel/helpers - typeof";return WD=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},WD(t)}function Cce(){return Cce=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:j,animationEasing:_,isActive:N},function(M){var I=M.upperWidth,L=M.lowerWidth,R=M.height,q=M.x,U=M.y;return ht.createElement(E0,{canBegin:l>0,from:"0px ".concat(l===-1?1:l,"px"),to:"".concat(l,"px 0px"),attributeName:"strokeDasharray",begin:w,duration:j,easing:_},ht.createElement("path",Cce({},si(r,!0),{className:C,d:qRe(q,U,I,L,R),ref:n})))}):ht.createElement("g",null,ht.createElement("path",Cce({},si(r,!0),{className:C,d:qRe(c,u,p,f,g)})))},Sfs=["option","shapeType","propTransformer","activeClassName","isActive"];function GD(t){"@babel/helpers - typeof";return GD=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},GD(t)}function Cfs(t,s){if(t==null)return{};var r=Mfs(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 Mfs(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 URe(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 Mce(t){for(var s=1;s0?wf(M,"paddingAngle",0):0;if(L){var q=nf(L.endAngle-L.startAngle,M.endAngle-M.startAngle),U=Hl(Hl({},M),{},{startAngle:C+R,endAngle:C+q(j)+R});w.push(U),C=U.endAngle}else{var B=M.endAngle,V=M.startAngle,Y=nf(0,B-V),J=Y(j),te=Hl(Hl({},M),{},{startAngle:C+R,endAngle:C+J+R});w.push(te),C=te.endAngle}}),ht.createElement(Ko,null,n.renderSectorsStatically(w))})}},{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||!cR(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,b=a.isAnimationActive,_=this.state.isAnimationFinished;if(o||!l||!l.length||!on(u)||!on(p)||!on(f)||!on(g))return null;var j=Vi("recharts-pie",i);return ht.createElement(Ko,{tabIndex:this.props.rootTabIndex,className:j,ref:function(N){n.pieRef=N}},this.renderSectors(),c&&this.renderLabels(l),Zu.renderCallByParent(this.props,null,!1),(!b||_)&&y1.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?C:C-1)*c,I=w-C*b-M,L=a.reduce(function(U,B){var V=bu(B,N,0);return U+(on(V)?V:0)},0),R;if(L>0){var q;R=a.map(function(U,B){var V=bu(U,N,0),Y=bu(U,p,B),J=(on(V)?V:0)/L,te;B?te=q.endAngle+Mm(j)*c*(V!==0?1:0):te=l;var X=te+Mm(j)*((V!==0?b:0)+J*I),ce=(te+X)/2,ne=(_.innerRadius+_.outerRadius)/2,re=[{name:Y,value:V,payload:U,dataKey:N,type:g}],le=tc(_.cx,_.cy,ne,ce);return q=Hl(Hl(Hl({percent:J,cornerRadius:o,name:Y,tooltipPayload:re,midAngle:ce,middleRadius:ne,tooltipPosition:le},U),_),{},{value:bu(U,N),startAngle:te,endAngle:X,payload:U,paddingAngle:Mm(j)*c}),q})}return Hl(Hl({},_),{},{sectors:R,data:a})});var Zfs=Math.ceil,Yfs=Math.max;function Xfs(t,s,r,n){for(var a=-1,o=Yfs(Zfs((s-t)/(r||1)),0),l=Array(o);o--;)l[n?o:++a]=t,t+=r;return l}var Qfs=Xfs,Jfs=qst,GRe=1/0,exs=17976931348623157e292;function txs(t){if(!t)return t===0?t:0;if(t=Jfs(t),t===GRe||t===-GRe){var s=t<0?-1:1;return s*exs}return t===t?t:0}var Nnt=txs,sxs=Qfs,rxs=fhe,rye=Nnt;function nxs(t){return function(s,r,n){return n&&typeof n!="number"&&rxs(s,r,n)&&(r=n=void 0),s=rye(s),r===void 0?(r=s,s=0):r=rye(r),n=n===void 0?s0&&n.handleDrag(a.changedTouches[0])}),Jp(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()}),Jp(n,"handleLeaveWrapper",function(){(n.state.isTravellerMoving||n.state.isSlideMoving)&&(n.leaveTimer=window.setTimeout(n.handleDragEnd,n.props.leaveTimeOut))}),Jp(n,"handleEnterSlideOrTraveller",function(){n.setState({isTextActive:!0})}),Jp(n,"handleLeaveSlideOrTraveller",function(){n.setState({isTextActive:!1})}),Jp(n,"handleSlideDragStart",function(a){var o=QRe(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 yxs(s,t),pxs(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),b=s.getIndexInRange(l,f),_=s.getIndexInRange(l,g);return{startIndex:b-b%c,endIndex:_===p?p:_-_%c}}},{key:"getTextOfTick",value:function(n){var a=this.props,o=a.data,l=a.tickFormatter,i=a.dataKey,c=bu(o[n],i,n);return Si(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,b=c.endIndex,_=c.onChange,j=n.pageX-o;j>0?j=Math.min(j,u+p-f-i,u+p-f-l):j<0&&(j=Math.max(j,u-l,u-i));var w=this.getIndex({startX:l+j,endX:i+j});(w.startIndex!==g||w.endIndex!==b)&&_&&_(w),this.setState({startX:l+j,endX:i+j,slideMoveStartX:n.pageX})}},{key:"handleTravellerDragStart",value:function(n,a){var o=QRe(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,b=p.travellerWidth,_=p.onChange,j=p.gap,w=p.data,N={startX:this.state.startX,endX:this.state.endX},C=n.pageX-o;C>0?C=Math.min(C,f+g-b-u):C<0&&(C=Math.max(C,f-u)),N[l]=u+C;var M=this.getIndex(N),I=M.startIndex,L=M.endIndex,R=function(){var U=w.length-1;return l==="startX"&&(i>c?I%j===0:L%j===0)||ic?L%j===0:I%j===0)||i>c&&L===U};this.setState(Jp(Jp({},l,u+C),"brushMoveStartX",n.pageX),function(){_&&R()&&_(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 b=i[g];a==="startX"&&b>=u||a==="endX"&&b<=c||this.setState(Jp({},a,b),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=k.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,b=c.ariaLabel,_=c.data,j=c.startIndex,w=c.endIndex,N=Math.max(n,this.props.x),C=nye(nye({},si(this.props,!1)),{},{x:N,y:u,width:p,height:f}),M=b||"Min value: ".concat((o=_[j])===null||o===void 0?void 0:o.name,", Max value: ").concat((l=_[w])===null||l===void 0?void 0:l.name);return ht.createElement(Ko,{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(L){["ArrowLeft","ArrowRight"].includes(L.key)&&(L.preventDefault(),L.stopPropagation(),i.handleTravellerMoveKeyboard(L.key==="ArrowRight"?1:-1,a))},onFocus:function(){i.setState({isTravellerFocused:!0})},onBlur:function(){i.setState({isTravellerFocused:!1})},style:{cursor:"col-resize"}},s.renderTraveller(g,C))}},{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,b=5,_={pointerEvents:"none",fill:u};return ht.createElement(Ko,{className:"recharts-brush-texts"},ht.createElement(YS,Ece({textAnchor:"end",verticalAnchor:"middle",x:Math.min(f,g)-b,y:l+i/2},_),this.getTextOfTick(a)),ht.createElement(YS,Ece({textAnchor:"start",verticalAnchor:"middle",x:Math.max(f,g)+c+b,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,b=g.startX,_=g.endX,j=g.isTextActive,w=g.isSlideMoving,N=g.isTravellerMoving,C=g.isTravellerFocused;if(!a||!a.length||!on(i)||!on(c)||!on(u)||!on(p)||u<=0||p<=0)return null;var M=Vi("recharts-brush",o),I=ht.Children.count(l)===1,L=hxs("userSelect","none");return ht.createElement(Ko,{className:M,onMouseLeave:this.handleLeaveWrapper,onTouchMove:this.handleTouchMove,style:L},this.renderBackground(),I&&this.renderPanorama(),this.renderSlide(b,_),this.renderTravellerLayer(b,"startX"),this.renderTravellerLayer(_,"endX"),(j||w||N||C||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):Si(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 nye({prevData:o,prevTravellerWidth:c,prevUpdateId:u,prevX:i,prevWidth:l},o&&o.length?bxs({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(b){return a.scale(b)});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}}])}(k.PureComponent);Jp(cA,"displayName","Brush");Jp(cA,"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 _xs=f4e;function wxs(t,s){var r;return _xs(t,function(n,a,o){return r=s(n,a,o),!r}),!!r}var jxs=wxs,Nxs=fst,kxs=z0,Sxs=jxs,Cxs=Ip,Mxs=fhe;function Txs(t,s,r){var n=Cxs(t)?Nxs:Sxs;return r&&Mxs(t,s,r)&&(s=void 0),n(t,kxs(s))}var Axs=Txs;const Exs=Ao(Axs);var w0=function(s,r){var n=s.alwaysShow,a=s.ifOverflow;return n&&(a="extendDomain"),a===r},JRe=Rst;function Pxs(t,s,r){s=="__proto__"&&JRe?JRe(t,s,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[s]=r}var Ixs=Pxs,Lxs=Ixs,Dxs=Dst,Oxs=z0;function Rxs(t,s){var r={};return s=Oxs(s),Dxs(t,function(n,a,o){Lxs(r,a,s(n,a,o))}),r}var Fxs=Rxs;const zxs=Ao(Fxs);function Bxs(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 rgs(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 ngs(t,s){var r=t.x,n=t.y,a=sgs(t,Qxs),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 iI(iI(iI(iI(iI({},s),a),l?{x:l}:{}),c?{y:c}:{}),{},{height:p,width:g,name:s.name,radius:s.radius})}function tFe(t){return ht.createElement(_nt,f_e({shapeType:"rectangle",propTransformer:ngs,activeClassName:"recharts-active-bar"},t))}var ags=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=on(n)||AZt(n);return o?s(n,a):(o||QS(),r)}},igs=["value","background"],Tnt;function dA(t){"@babel/helpers - typeof";return dA=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},dA(t)}function ogs(t,s){if(t==null)return{};var r=lgs(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 lgs(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 Ice(){return Ice=Object.assign?Object.assign.bind():function(t){for(var s=1;s0&&Math.abs(ce)0&&Math.abs(X)0&&(te=Math.min((Ie||0)-(X[Ne-1]||0),te))}),Number.isFinite(te)){var ce=te/J,ne=j.layout==="vertical"?n.height:n.width;if(j.padding==="gap"&&(q=ce*ne/2),j.padding==="no-gap"){var re=Tm(s.barCategoryGap,ce*ne),le=ce*ne/2;q=le-re-(le-re)/ne*re}}}a==="xAxis"?U=[n.left+(M.left||0)+(q||0),n.left+n.width-(M.right||0)-(q||0)]:a==="yAxis"?U=c==="horizontal"?[n.top+n.height-(M.bottom||0),n.top+(M.top||0)]:[n.top+(M.top||0)+(q||0),n.top+n.height-(M.bottom||0)-(q||0)]:U=j.range,L&&(U=[U[1],U[0]]);var pe=Zrt(j,o,g),xe=pe.scale,_e=pe.realScaleType;xe.domain(N).range(U),Yrt(xe);var fe=Xrt(xe,Rg(Rg({},j),{},{realScaleType:_e}));a==="xAxis"?(Y=w==="top"&&!I||w==="bottom"&&I,B=n.left,V=f[R]-Y*j.height):a==="yAxis"&&(Y=w==="left"&&!I||w==="right"&&I,B=f[R]-Y*j.width,V=n.top);var we=Rg(Rg(Rg({},j),fe),{},{realScaleType:_e,x:B,y:V,scale:xe,width:a==="xAxis"?n.width:j.width,height:a==="yAxis"?n.height:j.height});return we.bandSize=gce(we,fe),!j.hide&&a==="xAxis"?f[R]+=(Y?-1:1)*we.height:j.hide||(f[R]+=(Y?-1:1)*we.width),Rg(Rg({},b),{},Lhe({},_,we))},{})},Lnt=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)}},vgs=function(s){var r=s.x1,n=s.y1,a=s.x2,o=s.y2;return Lnt({x:r,y:n},{x:a,y:o})},Dnt=function(){function t(s){xgs(this,t),this.scale=s}return ggs(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)}}])}();Lhe(Dnt,"EPS",1e-4);var V4e=function(s){var r=Object.keys(s).reduce(function(n,a){return Rg(Rg({},n),{},Lhe({},a,Dnt.create(s[a])))},{});return Rg(Rg({},r),{},{apply:function(a){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=o.bandAware,i=o.position;return zxs(a,function(c,u){return r[u].apply(c,{bandAware:l,position:i})})},isInRange:function(a){return Mnt(a,function(o,l){return r[l].isInRange(o)})}})};function bgs(t){return(t%180+180)%180}var _gs=function(s){var r=s.width,n=s.height,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,o=bgs(a),l=o*Math.PI/180,i=Math.atan(n/r),c=l>i&&l-1?a[o?s[l]:l]:void 0}}var Sgs=kgs,Cgs=Nnt;function Mgs(t){var s=Cgs(t),r=s%1;return s===s?r?s-r:s:0}var Tgs=Mgs,Ags=Tst,Egs=z0,Pgs=Tgs,Igs=Math.max;function Lgs(t,s,r){var n=t==null?0:t.length;if(!n)return-1;var a=r==null?0:Pgs(r);return a<0&&(a=Igs(n+a,0)),Ags(t,Egs(s),a)}var Dgs=Lgs,Ogs=Sgs,Rgs=Dgs,Fgs=Ogs(Rgs),zgs=Fgs;const Bgs=Ao(zgs);var $gs=OKt(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("")}),H4e=k.createContext(void 0),W4e=k.createContext(void 0),Ont=k.createContext(void 0),Rnt=k.createContext({}),Fnt=k.createContext(void 0),znt=k.createContext(0),Bnt=k.createContext(0),iFe=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=$gs(o);return ht.createElement(H4e.Provider,{value:n},ht.createElement(W4e.Provider,{value:a},ht.createElement(Rnt.Provider,{value:o},ht.createElement(Ont.Provider,{value:p},ht.createElement(Fnt.Provider,{value:l},ht.createElement(znt.Provider,{value:u},ht.createElement(Bnt.Provider,{value:c},i)))))))},qgs=function(){return k.useContext(Fnt)},$nt=function(s){var r=k.useContext(H4e);r==null&&QS();var n=r[s];return n==null&&QS(),n},Ugs=function(){var s=k.useContext(H4e);return i_(s)},Vgs=function(){var s=k.useContext(W4e),r=Bgs(s,function(n){return Mnt(n.domain,Number.isFinite)});return r||i_(s)},qnt=function(s){var r=k.useContext(W4e);r==null&&QS();var n=r[s];return n==null&&QS(),n},Hgs=function(){var s=k.useContext(Ont);return s},Wgs=function(){return k.useContext(Rnt)},G4e=function(){return k.useContext(Bnt)},K4e=function(){return k.useContext(znt)};function uA(t){"@babel/helpers - typeof";return uA=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},uA(t)}function Ggs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function Kgs(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 Tys(t,s){return Znt(t,s+1)}function Ays(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:Znt(n,u)};var j=c,w,N=function(){return w===void 0&&(w=r(_,j)),w},C=_.coordinate,M=c===0||Fce(t,C,N,p,i);M||(c=0,p=l,u+=1),M&&(p=C+t*(N()/2+a),c+=u)},g;u<=o.length;)if(g=f(),g)return g.v;return[]}function QD(t){"@babel/helpers - typeof";return QD=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},QD(t)}function pFe(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 Bh(t){for(var s=1;s0?b.coordinate-w*t:b.coordinate})}else o[g]=b=Bh(Bh({},b),{},{tickCoord:b.coordinate});var N=Fce(t,b.tickCoord,j,i,c);N&&(c=b.tickCoord-t*(j()/2+a),o[g]=Bh(Bh({},b),{},{isShow:!0}))},p=l-1;p>=0;p--)u(p);return o}function Dys(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=Bh(Bh({},p),{},{tickCoord:g>0?p.coordinate-g*t:p.coordinate});var b=Fce(t,p.tickCoord,function(){return f},c,u);b&&(u=p.tickCoord-t*(f/2+a),l[i-1]=Bh(Bh({},p),{},{isShow:!0}))}for(var _=o?i-1:i,j=function(C){var M=l[C],I,L=function(){return I===void 0&&(I=r(M,C)),I};if(C===0){var R=t*(M.coordinate-t*L()/2-c);l[C]=M=Bh(Bh({},M),{},{tickCoord:R<0?M.coordinate-R*t:M.coordinate})}else l[C]=M=Bh(Bh({},M),{},{tickCoord:M.coordinate});var q=Fce(t,M.tickCoord,L,c,u);q&&(c=M.tickCoord+t*(L()/2+a),l[C]=Bh(Bh({},M),{},{isShow:!0}))},w=0;w<_;w++)j(w);return l}function X4e(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(on(c)||gC.isSsr)return Tys(a,typeof c=="number"&&on(c)?c:0);var g=[],b=i==="top"||i==="bottom"?"width":"height",_=p&&b==="width"?d8(p,{fontSize:s,letterSpacing:r}):{width:0,height:0},j=function(M,I){var L=Si(u)?u(M.value,I):M.value;return b==="width"?Cys(d8(L,{fontSize:s,letterSpacing:r}),_,f):d8(L,{fontSize:s,letterSpacing:r})[b]},w=a.length>=2?Mm(a[1].coordinate-a[0].coordinate):1,N=Mys(o,w,b);return c==="equidistantPreserveStart"?Ays(w,N,j,a,l):(c==="preserveStart"||c==="preserveStartEnd"?g=Dys(w,N,j,a,l,c==="preserveStartEnd"):g=Lys(w,N,j,a,l),g.filter(function(C){return C.isShow}))}var Oys=["viewBox"],Rys=["viewBox"],Fys=["ticks"];function pA(t){"@babel/helpers - typeof";return pA=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},pA(t)}function cM(){return cM=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 zys(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 Bys(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function xFe(t,s){for(var r=0;r0?c(this.props):c(b)),l<=0||i<=0||!_||!_.length?null:ht.createElement(Ko,{className:Vi("recharts-cartesian-axis",u),ref:function(w){n.layerReference=w}},o&&this.renderAxisLine(),this.renderTicks(_,this.state.fontSize,this.state.letterSpacing),Zu.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,du(du({},a),{},{className:i})):Si(n)?l=n(du(du({},a),{},{className:i})):l=ht.createElement(YS,cM({},a,{className:"recharts-cartesian-axis-tick-value"}),o),l}}])}(k.Component);Q4e(wE,"displayName","CartesianAxis");Q4e(wE,"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 Gys=["x1","y1","x2","y2","key"],Kys=["offset"];function JS(t){"@babel/helpers - typeof";return JS=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},JS(t)}function gFe(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;s=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function Qys(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 Jys=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 Qnt(t,s){var r;if(ht.isValidElement(t))r=ht.cloneElement(t,s);else if(Si(t))r=t(s);else{var n=s.x1,a=s.y1,o=s.x2,l=s.y2,i=s.key,c=yFe(s,Gys),u=si(c,!1);u.offset;var p=yFe(u,Kys);r=ht.createElement("line",S4({},p,{x1:n,y1:a,x2:o,y2:l,fill:"none",key:i}))}return r}function e0s(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=Uh(Uh({},t),{},{x1:s,y1:i,x2:s+r,y2:i,key:"line-".concat(c),index:c});return Qnt(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=Uh(Uh({},t),{},{x1:i,y1:s,x2:i,y2:s+r,key:"line-".concat(c),index:c});return Qnt(a,u)});return ht.createElement("g",{className:"recharts-cartesian-grid-vertical"},l)}function s0s(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,b){return g-b});a!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?a+l-g:p[b+1]-g;if(j<=0)return null;var w=b%s.length;return ht.createElement("rect",{key:"react-".concat(b),y:g,x:n,height:j,width:o,stroke:"none",fill:s[w],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},f)}function r0s(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,b){return g-b});o!==p[0]&&p.unshift(0);var f=p.map(function(g,b){var _=!p[b+1],j=_?o+i-g:p[b+1]-g;if(j<=0)return null;var w=b%n.length;return ht.createElement("rect",{key:"react-".concat(b),x:g,y:l,width:j,height:c,stroke:"none",fill:n[w],fillOpacity:a,className:"recharts-cartesian-grid-bg"})});return ht.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},f)}var n0s=function(s,r){var n=s.xAxis,a=s.width,o=s.height,l=s.offset;return Krt(X4e(Uh(Uh(Uh({},wE.defaultProps),n),{},{ticks:Xv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.left,l.left+l.width,r)},a0s=function(s,r){var n=s.yAxis,a=s.width,o=s.height,l=s.offset;return Krt(X4e(Uh(Uh(Uh({},wE.defaultProps),n),{},{ticks:Xv(n,!0),viewBox:{x:0,y:0,width:a,height:o}})),l.top,l.top+l.height,r)},k5={horizontal:!0,vertical:!0,stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[]};function Jnt(t){var s,r,n,a,o,l,i=G4e(),c=K4e(),u=Wgs(),p=Uh(Uh({},t),{},{stroke:(s=t.stroke)!==null&&s!==void 0?s:k5.stroke,fill:(r=t.fill)!==null&&r!==void 0?r:k5.fill,horizontal:(n=t.horizontal)!==null&&n!==void 0?n:k5.horizontal,horizontalFill:(a=t.horizontalFill)!==null&&a!==void 0?a:k5.horizontalFill,vertical:(o=t.vertical)!==null&&o!==void 0?o:k5.vertical,verticalFill:(l=t.verticalFill)!==null&&l!==void 0?l:k5.verticalFill,x:on(t.x)?t.x:u.left,y:on(t.y)?t.y:u.top,width:on(t.width)?t.width:u.width,height:on(t.height)?t.height:u.height}),f=p.x,g=p.y,b=p.width,_=p.height,j=p.syncWithTicks,w=p.horizontalValues,N=p.verticalValues,C=Ugs(),M=Vgs();if(!on(b)||b<=0||!on(_)||_<=0||!on(f)||f!==+f||!on(g)||g!==+g)return null;var I=p.verticalCoordinatesGenerator||n0s,L=p.horizontalCoordinatesGenerator||a0s,R=p.horizontalPoints,q=p.verticalPoints;if((!R||!R.length)&&Si(L)){var U=w&&w.length,B=L({yAxis:M?Uh(Uh({},M),{},{ticks:U?w:M.ticks}):void 0,width:i,height:c,offset:u},U?!0:j);ty(Array.isArray(B),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(JS(B),"]")),Array.isArray(B)&&(R=B)}if((!q||!q.length)&&Si(I)){var V=N&&N.length,Y=I({xAxis:C?Uh(Uh({},C),{},{ticks:V?N:C.ticks}):void 0,width:i,height:c,offset:u},V?!0:j);ty(Array.isArray(Y),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(JS(Y),"]")),Array.isArray(Y)&&(q=Y)}return ht.createElement("g",{className:"recharts-cartesian-grid"},ht.createElement(Jys,{fill:p.fill,fillOpacity:p.fillOpacity,x:p.x,y:p.y,width:p.width,height:p.height,ry:p.ry}),ht.createElement(e0s,S4({},p,{offset:u,horizontalPoints:R,xAxis:C,yAxis:M})),ht.createElement(t0s,S4({},p,{offset:u,verticalPoints:q,xAxis:C,yAxis:M})),ht.createElement(s0s,S4({},p,{horizontalPoints:R})),ht.createElement(r0s,S4({},p,{verticalPoints:q})))}Jnt.displayName="CartesianGrid";var i0s=["type","layout","connectNulls","ref"],o0s=["key"];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 vFe(t,s){if(t==null)return{};var r=l0s(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 l0s(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 x8(){return x8=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){b=[].concat(S5(c.slice(0,_)),[f-j]);break}var w=b.length%2===0?[0,g]:[g];return[].concat(S5(s.repeat(c,p)),S5(b),w).map(function(N){return"".concat(N,"px")}).join(", ")}),Fg(r,"id",fE("recharts-line-")),Fg(r,"pathRef",function(l){r.mainCurve=l}),Fg(r,"handleAnimationEnd",function(){r.setState({isAnimationFinished:!0}),r.props.onAnimationEnd&&r.props.onAnimationEnd()}),Fg(r,"handleAnimationStart",function(){r.setState({isAnimationFinished:!1}),r.props.onAnimationStart&&r.props.onAnimationStart()}),r}return y0s(s,t),p0s(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=jf(p,dR);if(!f)return null;var g=function(j,w){return{x:j.x,y:j.y,value:j.value,errorVal:bu(j.payload,w)}},b={clipPath:n?"url(#clipPath-".concat(a,")"):null};return ht.createElement(Ko,b,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=si(this.props,!1),g=si(c,!0),b=u.map(function(j,w){var N=Qp(Qp(Qp({key:"dot-".concat(w),r:3},f),g),{},{index:w,cx:j.x,cy:j.y,value:j.value,dataKey:p,payload:j.payload,points:u});return s.renderDotItem(c,N)}),_={clipPath:n?"url(#clipPath-".concat(a?"":"dots-").concat(o,")"):null};return ht.createElement(Ko,x8({className:"recharts-line-dots",key:"dots"},_),b)}},{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=vFe(i,i0s),g=Qp(Qp(Qp({},si(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(bce,x8({},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,b=l.animationId,_=l.animateNewValues,j=l.width,w=l.height,N=this.state,C=N.prevPoints,M=N.totalLength;return ht.createElement(E0,{begin:p,duration:f,isActive:u,easing:g,from:{t:0},to:{t:1},key:"line-".concat(b),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(I){var L=I.t;if(C){var R=C.length/i.length,q=i.map(function(J,te){var X=Math.floor(te*R);if(C[X]){var ce=C[X],ne=nf(ce.x,J.x),re=nf(ce.y,J.y);return Qp(Qp({},J),{},{x:ne(L),y:re(L)})}if(_){var le=nf(j*2,J.x),pe=nf(w/2,J.y);return Qp(Qp({},J),{},{x:le(L),y:pe(L)})}return Qp(Qp({},J),{},{x:J.x,y:J.y})});return o.renderCurveStatically(q,n,a)}var U=nf(0,M),B=U(L),V;if(c){var Y="".concat(c).split(/[,\s]+/gim).map(function(J){return parseFloat(J)});V=o.getStrokeDasharray(B,M,Y)}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||!cR(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,b=a.width,_=a.height,j=a.isAnimationActive,w=a.id;if(o||!i||!i.length)return null;var N=this.state.isAnimationFinished,C=i.length===1,M=Vi("recharts-line",c),I=u&&u.allowDataOverflow,L=p&&p.allowDataOverflow,R=I||L,q=$i(w)?this.id:w,U=(n=si(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},B=U.r,V=B===void 0?3:B,Y=U.strokeWidth,J=Y===void 0?2:Y,te=qZt(l)?l:{},X=te.clipDot,ce=X===void 0?!0:X,ne=V*2+J;return ht.createElement(Ko,{className:M},I||L?ht.createElement("defs",null,ht.createElement("clipPath",{id:"clipPath-".concat(q)},ht.createElement("rect",{x:I?g:g-b/2,y:L?f:f-_/2,width:I?b:b*2,height:L?_:_*2})),!ce&&ht.createElement("clipPath",{id:"clipPath-dots-".concat(q)},ht.createElement("rect",{x:g-ne/2,y:f-ne/2,width:b+ne,height:_+ne}))):null,!C&&this.renderCurve(R,q),this.renderErrorBar(R,q),(C||l)&&this.renderDots(R,ce,q),(!j||N)&&y1.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(S5(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 ovs(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 lvs(t,s){if(!(t instanceof s))throw new TypeError("Cannot call a class as a function")}function cvs(t,s){for(var r=0;rt.length)&&(s=t.length);for(var r=0,n=new Array(s);r0?l:s&&s.length&&on(a)&&on(o)?s.slice(a,o+1):[]};function fat(t){return t==="number"?[0,"auto"]:void 0}var L_e=function(s,r,n,a){var o=s.graphicalItems,l=s.tooltipAxis,i=zhe(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 b=f===void 0?i:f;g=Ule(b,l.dataKey,a)}else g=f&&f[n]||i[n];return g?[].concat(vA(c),[Jrt(u,g)]):c},[])},CFe=function(s,r,n,a){var o=a||{x:s.chartX,y:s.chartY},l=_vs(o,n),i=s.orderedTooltipTicks,c=s.tooltipAxis,u=s.tooltipTicks,p=Uds(l,i,u,c);if(p>=0&&u){var f=u[p]&&u[p].value,g=L_e(s,r,p,f),b=wvs(n,i,p,o);return{activeTooltipIndex:p,activeLabel:f,activePayload:g,activeCoordinate:b}}return null},jvs=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,b=Grt(p,o);return n.reduce(function(_,j){var w,N=j.type.defaultProps!==void 0?wr(wr({},j.type.defaultProps),j.props):j.props,C=N.type,M=N.dataKey,I=N.allowDataOverflow,L=N.allowDuplicatedCategory,R=N.scale,q=N.ticks,U=N.includeHidden,B=N[l];if(_[B])return _;var V=zhe(s.data,{graphicalItems:a.filter(function(fe){var we,Ie=l in fe.props?fe.props[l]:(we=fe.type.defaultProps)===null||we===void 0?void 0:we[l];return Ie===B}),dataStartIndex:c,dataEndIndex:u}),Y=V.length,J,te,X;Z0s(N.domain,I,C)&&(J=Kbe(N.domain,null,I),b&&(C==="number"||R!=="auto")&&(X=h8(V,M,"category")));var ce=fat(C);if(!J||J.length===0){var ne,re=(ne=N.domain)!==null&&ne!==void 0?ne:ce;if(M){if(J=h8(V,M,C),C==="category"&&b){var le=PZt(J);L&&le?(te=J,J=Ace(0,Y)):L||(J=ZOe(re,J,j).reduce(function(fe,we){return fe.indexOf(we)>=0?fe:[].concat(vA(fe),[we])},[]))}else if(C==="category")L?J=J.filter(function(fe){return fe!==""&&!$i(fe)}):J=ZOe(re,J,j).reduce(function(fe,we){return fe.indexOf(we)>=0||we===""||$i(we)?fe:[].concat(vA(fe),[we])},[]);else if(C==="number"){var pe=Kds(V,a.filter(function(fe){var we,Ie,Ne=l in fe.props?fe.props[l]:(we=fe.type.defaultProps)===null||we===void 0?void 0:we[l],Ae="hide"in fe.props?fe.props.hide:(Ie=fe.type.defaultProps)===null||Ie===void 0?void 0:Ie.hide;return Ne===B&&(U||!Ae)}),M,o,p);pe&&(J=pe)}b&&(C==="number"||R!=="auto")&&(X=h8(V,M,"category"))}else b?J=Ace(0,Y):i&&i[B]&&i[B].hasStack&&C==="number"?J=g==="expand"?[0,1]:Qrt(i[B].stackGroups,c,u):J=Wrt(V,a.filter(function(fe){var we=l in fe.props?fe.props[l]:fe.type.defaultProps[l],Ie="hide"in fe.props?fe.props.hide:fe.type.defaultProps.hide;return we===B&&(U||!Ie)}),C,p,!0);if(C==="number")J=E_e(f,J,B,o,q),re&&(J=Kbe(re,J,I));else if(C==="category"&&re){var xe=re,_e=J.every(function(fe){return xe.indexOf(fe)>=0});_e&&(J=xe)}}return wr(wr({},_),{},hi({},B,wr(wr({},N),{},{axisType:o,domain:J,categoricalDomain:X,duplicateDomain:te,originalDomain:(w=N.domain)!==null&&w!==void 0?w:ce,isCategorical:b,layout:p})))},{})},Nvs=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=zhe(s.data,{graphicalItems:n,dataStartIndex:c,dataEndIndex:u}),b=g.length,_=Grt(p,o),j=-1;return n.reduce(function(w,N){var C=N.type.defaultProps!==void 0?wr(wr({},N.type.defaultProps),N.props):N.props,M=C[l],I=fat("number");if(!w[M]){j++;var L;return _?L=Ace(0,b):i&&i[M]&&i[M].hasStack?(L=Qrt(i[M].stackGroups,c,u),L=E_e(f,L,M,o)):(L=Kbe(I,Wrt(g,n.filter(function(R){var q,U,B=l in R.props?R.props[l]:(q=R.type.defaultProps)===null||q===void 0?void 0:q[l],V="hide"in R.props?R.props.hide:(U=R.type.defaultProps)===null||U===void 0?void 0:U.hide;return B===M&&!V}),"number",p),a.defaultProps.allowDataOverflow),L=E_e(f,L,M,o)),wr(wr({},w),{},hi({},M,wr(wr({axisType:o},a.defaultProps),{},{hide:!0,orientation:wf(vvs,"".concat(o,".").concat(j%2),null),domain:L,originalDomain:I,isCategorical:_,layout:p})))}return w},{})},kvs=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=jf(p,o),b={};return g&&g.length?b=jvs(s,{axes:g,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u}):l&&l.length&&(b=Nvs(s,{Axis:o,graphicalItems:l,axisType:a,axisIdKey:f,stackGroups:i,dataStartIndex:c,dataEndIndex:u})),b},Svs=function(s){var r=i_(s),n=Xv(r,!1,!0);return{tooltipTicks:n,orderedTooltipTicks:x4e(n,function(a){return a.coordinate}),tooltipAxis:r,tooltipAxisBandSize:gce(r,n)}},MFe=function(s){var r=s.children,n=s.defaultShowTooltip,a=tf(r,cA),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}},Cvs=function(s){return!s||!s.length?!1:s.some(function(r){var n=x1(r&&r.type);return n&&n.indexOf("Bar")>=0})},TFe=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"}},Mvs=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||{},b=tf(f,cA),_=tf(f,rT),j=Object.keys(c).reduce(function(L,R){var q=c[R],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},L),{},hi({},U,L[U]+q.width)):L},{left:g.left||0,right:g.right||0}),w=Object.keys(l).reduce(function(L,R){var q=l[R],U=q.orientation;return!q.mirror&&!q.hide?wr(wr({},L),{},hi({},U,wf(L,"".concat(U))+q.height)):L},{top:g.top||0,bottom:g.bottom||0}),N=wr(wr({},w),j),C=N.bottom;b&&(N.bottom+=b.props.height||cA.defaultProps.height),_&&r&&(N=Wds(N,a,n,r));var M=u-N.left-N.right,I=p-N.top-N.bottom;return wr(wr({brushBottom:C},N),{},{width:Math.max(M,0),height:Math.max(I,0)})},Tvs=function(s,r){if(r==="xAxis")return s[r].width;if(r==="yAxis")return s[r].height},J4e=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(N,C){var M=C.graphicalItems,I=C.stackGroups,L=C.offset,R=C.updateId,q=C.dataStartIndex,U=C.dataEndIndex,B=N.barSize,V=N.layout,Y=N.barGap,J=N.barCategoryGap,te=N.maxBarSize,X=TFe(V),ce=X.numericAxisName,ne=X.cateAxisName,re=Cvs(M),le=[];return M.forEach(function(pe,xe){var _e=zhe(N.data,{graphicalItems:[pe],dataStartIndex:q,dataEndIndex:U}),fe=pe.type.defaultProps!==void 0?wr(wr({},pe.type.defaultProps),pe.props):pe.props,we=fe.dataKey,Ie=fe.maxBarSize,Ne=fe["".concat(ce,"Id")],Ae=fe["".concat(ne,"Id")],Fe={},Ce=c.reduce(function(lt,qe){var Ze=C["".concat(qe.axisType,"Map")],Je=fe["".concat(qe.axisType,"Id")];Ze&&Ze[Je]||qe.axisType==="zAxis"||QS();var He=Ze[Je];return wr(wr({},lt),{},hi(hi({},qe.axisType,He),"".concat(qe.axisType,"Ticks"),Xv(He)))},Fe),Me=Ce[ne],$e=Ce["".concat(ne,"Ticks")],ct=I&&I[Ne]&&I[Ne].hasStack&&rus(pe,I[Ne].stackGroups),Te=x1(pe.type).indexOf("Bar")>=0,ft=gce(Me,$e),me=[],Ve=re&&Vds({barSize:B,stackGroups:I,totalSize:Tvs(Ce,ne)});if(Te){var nt,et,Se=$i(Ie)?te:Ie,rt=(nt=(et=gce(Me,$e,!0))!==null&&et!==void 0?et:Se)!==null&&nt!==void 0?nt:0;me=Hds({barGap:Y,barCategoryGap:J,bandSize:rt!==ft?rt:ft,sizeList:Ve[Ae],maxBarSize:Se}),rt!==ft&&(me=me.map(function(lt){return wr(wr({},lt),{},{position:wr(wr({},lt.position),{},{offset:lt.position.offset-rt/2})})}))}var Ge=pe&&pe.type&&pe.type.getComposedData;Ge&&le.push({props:wr(wr({},Ge(wr(wr({},Ce),{},{displayedData:_e,props:N,dataKey:we,item:pe,bandSize:ft,barPosition:me,offset:L,stackedData:ct,layout:V,dataStartIndex:q,dataEndIndex:U}))),{},hi(hi(hi({key:pe.key||"item-".concat(xe)},ce,Ce[ce]),ne,Ce[ne]),"animationId",R)),childIndex:HZt(pe,N.children),item:pe})}),le},b=function(N,C){var M=N.props,I=N.dataStartIndex,L=N.dataEndIndex,R=N.updateId;if(!q8e({props:M}))return null;var q=M.children,U=M.layout,B=M.stackOffset,V=M.data,Y=M.reverseStackOrder,J=TFe(U),te=J.numericAxisName,X=J.cateAxisName,ce=jf(q,n),ne=tus(V,ce,"".concat(te,"Id"),"".concat(X,"Id"),B,Y),re=c.reduce(function(fe,we){var Ie="".concat(we.axisType,"Map");return wr(wr({},fe),{},hi({},Ie,kvs(M,wr(wr({},we),{},{graphicalItems:ce,stackGroups:we.axisType===te&&ne,dataStartIndex:I,dataEndIndex:L}))))},{}),le=Mvs(wr(wr({},re),{},{props:M,graphicalItems:ce}),C==null?void 0:C.legendBBox);Object.keys(re).forEach(function(fe){re[fe]=p(M,re[fe],le,fe.replace("Map",""),r)});var pe=re["".concat(X,"Map")],xe=Svs(pe),_e=g(M,wr(wr({},re),{},{dataStartIndex:I,dataEndIndex:L,updateId:R,graphicalItems:ce,stackGroups:ne,offset:le}));return wr(wr({formattedGraphicalItems:_e,graphicalItems:ce,offset:le,stackGroups:ne},xe),re)},_=function(w){function N(C){var M,I,L;return lvs(this,N),L=uvs(this,N,[C]),hi(L,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),hi(L,"accessibilityManager",new K0s),hi(L,"handleLegendBBoxUpdate",function(R){if(R){var q=L.state,U=q.dataStartIndex,B=q.dataEndIndex,V=q.updateId;L.setState(wr({legendBBox:R},b({props:L.props,dataStartIndex:U,dataEndIndex:B,updateId:V},wr(wr({},L.state),{},{legendBBox:R}))))}}),hi(L,"handleReceiveSyncEvent",function(R,q,U){if(L.props.syncId===R){if(U===L.eventEmitterSymbol&&typeof L.props.syncMethod!="function")return;L.applySyncEvent(q)}}),hi(L,"handleBrushChange",function(R){var q=R.startIndex,U=R.endIndex;if(q!==L.state.dataStartIndex||U!==L.state.dataEndIndex){var B=L.state.updateId;L.setState(function(){return wr({dataStartIndex:q,dataEndIndex:U},b({props:L.props,dataStartIndex:q,dataEndIndex:U,updateId:B},L.state))}),L.triggerSyncEvent({dataStartIndex:q,dataEndIndex:U})}}),hi(L,"handleMouseEnter",function(R){var q=L.getMouseInfo(R);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});L.setState(U),L.triggerSyncEvent(U);var B=L.props.onMouseEnter;Si(B)&&B(U,R)}}),hi(L,"triggeredAfterMouseMove",function(R){var q=L.getMouseInfo(R),U=q?wr(wr({},q),{},{isTooltipActive:!0}):{isTooltipActive:!1};L.setState(U),L.triggerSyncEvent(U);var B=L.props.onMouseMove;Si(B)&&B(U,R)}),hi(L,"handleItemMouseEnter",function(R){L.setState(function(){return{isTooltipActive:!0,activeItem:R,activePayload:R.tooltipPayload,activeCoordinate:R.tooltipPosition||{x:R.cx,y:R.cy}}})}),hi(L,"handleItemMouseLeave",function(){L.setState(function(){return{isTooltipActive:!1}})}),hi(L,"handleMouseMove",function(R){R.persist(),L.throttleTriggeredAfterMouseMove(R)}),hi(L,"handleMouseLeave",function(R){L.throttleTriggeredAfterMouseMove.cancel();var q={isTooltipActive:!1};L.setState(q),L.triggerSyncEvent(q);var U=L.props.onMouseLeave;Si(U)&&U(q,R)}),hi(L,"handleOuterEvent",function(R){var q=VZt(R),U=wf(L.props,"".concat(q));if(q&&Si(U)){var B,V;/.*touch.*/i.test(q)?V=L.getMouseInfo(R.changedTouches[0]):V=L.getMouseInfo(R),U((B=V)!==null&&B!==void 0?B:{},R)}}),hi(L,"handleClick",function(R){var q=L.getMouseInfo(R);if(q){var U=wr(wr({},q),{},{isTooltipActive:!0});L.setState(U),L.triggerSyncEvent(U);var B=L.props.onClick;Si(B)&&B(U,R)}}),hi(L,"handleMouseDown",function(R){var q=L.props.onMouseDown;if(Si(q)){var U=L.getMouseInfo(R);q(U,R)}}),hi(L,"handleMouseUp",function(R){var q=L.props.onMouseUp;if(Si(q)){var U=L.getMouseInfo(R);q(U,R)}}),hi(L,"handleTouchMove",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.throttleTriggeredAfterMouseMove(R.changedTouches[0])}),hi(L,"handleTouchStart",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseDown(R.changedTouches[0])}),hi(L,"handleTouchEnd",function(R){R.changedTouches!=null&&R.changedTouches.length>0&&L.handleMouseUp(R.changedTouches[0])}),hi(L,"handleDoubleClick",function(R){var q=L.props.onDoubleClick;if(Si(q)){var U=L.getMouseInfo(R);q(U,R)}}),hi(L,"handleContextMenu",function(R){var q=L.props.onContextMenu;if(Si(q)){var U=L.getMouseInfo(R);q(U,R)}}),hi(L,"triggerSyncEvent",function(R){L.props.syncId!==void 0&&iye.emit(oye,L.props.syncId,R,L.eventEmitterSymbol)}),hi(L,"applySyncEvent",function(R){var q=L.props,U=q.layout,B=q.syncMethod,V=L.state.updateId,Y=R.dataStartIndex,J=R.dataEndIndex;if(R.dataStartIndex!==void 0||R.dataEndIndex!==void 0)L.setState(wr({dataStartIndex:Y,dataEndIndex:J},b({props:L.props,dataStartIndex:Y,dataEndIndex:J,updateId:V},L.state)));else if(R.activeTooltipIndex!==void 0){var te=R.chartX,X=R.chartY,ce=R.activeTooltipIndex,ne=L.state,re=ne.offset,le=ne.tooltipTicks;if(!re)return;if(typeof B=="function")ce=B(le,R);else if(B==="value"){ce=-1;for(var pe=0;pe=0){var ct,Te;if(te.dataKey&&!te.allowDuplicatedCategory){var ft=typeof te.dataKey=="function"?$e:"payload.".concat(te.dataKey.toString());ct=Ule(pe,ft,ce),Te=xe&&_e&&Ule(_e,ft,ce)}else ct=pe==null?void 0:pe[X],Te=xe&&_e&&_e[X];if(Ae||Ne){var me=R.props.activeIndex!==void 0?R.props.activeIndex:X;return[k.cloneElement(R,wr(wr(wr({},B.props),Ce),{},{activeIndex:me})),null,null]}if(!$i(ct))return[Me].concat(vA(L.renderActivePoints({item:B,activePoint:ct,basePoint:Te,childIndex:X,isRange:xe})))}else{var Ve,nt=(Ve=L.getItemByXY(L.state.activeCoordinate))!==null&&Ve!==void 0?Ve:{graphicalItem:Me},et=nt.graphicalItem,Se=et.item,rt=Se===void 0?R:Se,Ge=et.childIndex,lt=wr(wr(wr({},B.props),Ce),{},{activeIndex:Ge});return[k.cloneElement(rt,lt),null,null]}return xe?[Me,null,null]:[Me,null]}),hi(L,"renderCustomized",function(R,q,U){return k.cloneElement(R,wr(wr({key:"recharts-customized-".concat(U)},L.props),L.state))}),hi(L,"renderMap",{CartesianGrid:{handler:zz,once:!0},ReferenceArea:{handler:L.renderReferenceElement},ReferenceLine:{handler:zz},ReferenceDot:{handler:L.renderReferenceElement},XAxis:{handler:zz},YAxis:{handler:zz},Brush:{handler:L.renderBrush,once:!0},Bar:{handler:L.renderGraphicChild},Line:{handler:L.renderGraphicChild},Area:{handler:L.renderGraphicChild},Radar:{handler:L.renderGraphicChild},RadialBar:{handler:L.renderGraphicChild},Scatter:{handler:L.renderGraphicChild},Pie:{handler:L.renderGraphicChild},Funnel:{handler:L.renderGraphicChild},Tooltip:{handler:L.renderCursor,once:!0},PolarGrid:{handler:L.renderPolarGrid,once:!0},PolarAngleAxis:{handler:L.renderPolarAxis},PolarRadiusAxis:{handler:L.renderPolarAxis},Customized:{handler:L.renderCustomized}}),L.clipPathId="".concat((M=C.id)!==null&&M!==void 0?M:fE("recharts"),"-clip"),L.throttleTriggeredAfterMouseMove=Ust(L.triggeredAfterMouseMove,(I=C.throttleDelay)!==null&&I!==void 0?I:1e3/60),L.state={},L}return pvs(N,w),dvs(N,[{key:"componentDidMount",value:function(){var M,I;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(M=this.props.margin.left)!==null&&M!==void 0?M:0,top:(I=this.props.margin.top)!==null&&I!==void 0?I:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var M=this.props,I=M.children,L=M.data,R=M.height,q=M.layout,U=tf(I,up);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,Y=L_e(this.state,L,B,V),J=this.state.tooltipTicks[B].coordinate,te=(this.state.offset.top+R)/2,X=q==="horizontal",ce=X?{x:J,y:te}:{y:J,x:te},ne=this.state.formattedGraphicalItems.find(function(le){var pe=le.item;return pe.type.name==="Scatter"});ne&&(ce=wr(wr({},ce),ne.props.points[B].tooltipPosition),Y=ne.props.points[B].tooltipPayload);var re={activeTooltipIndex:B,isTooltipActive:!0,activeLabel:V,activePayload:Y,activeCoordinate:ce};this.setState(re),this.renderCursor(U),this.accessibilityManager.setIndex(B)}}}},{key:"getSnapshotBeforeUpdate",value:function(M,I){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==I.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 L,R;this.accessibilityManager.setDetails({offset:{left:(L=this.props.margin.left)!==null&&L!==void 0?L:0,top:(R=this.props.margin.top)!==null&&R!==void 0?R:0}})}return null}},{key:"componentDidUpdate",value:function(M){cbe([tf(M.children,up)],[tf(this.props.children,up)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var M=tf(this.props.children,up);if(M&&typeof M.props.shared=="boolean"){var I=M.props.shared?"axis":"item";return i.indexOf(I)>=0?I:o}return o}},{key:"getMouseInfo",value:function(M){if(!this.container)return null;var I=this.container,L=I.getBoundingClientRect(),R=gis(L),q={chartX:Math.round(M.pageX-R.left),chartY:Math.round(M.pageY-R.top)},U=L.width/I.offsetWidth||1,B=this.inRange(q.chartX,q.chartY,U);if(!B)return null;var V=this.state,Y=V.xAxisMap,J=V.yAxisMap,te=this.getTooltipEventType(),X=CFe(this.state,this.props.data,this.props.layout,B);if(te!=="axis"&&Y&&J){var ce=i_(Y).scale,ne=i_(J).scale,re=ce&&ce.invert?ce.invert(q.chartX):null,le=ne&&ne.invert?ne.invert(q.chartY):null;return wr(wr({},q),{},{xValue:re,yValue:le},X)}return X?wr(wr({},q),X):null}},{key:"inRange",value:function(M,I){var L=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,R=this.props.layout,q=M/L,U=I/L;if(R==="horizontal"||R==="vertical"){var B=this.state.offset,V=q>=B.left&&q<=B.left+B.width&&U>=B.top&&U<=B.top+B.height;return V?{x:q,y:U}:null}var Y=this.state,J=Y.angleAxisMap,te=Y.radiusAxisMap;if(J&&te){var X=i_(J);return QOe({x:q,y:U},X)}return null}},{key:"parseEventsOfWrapper",value:function(){var M=this.props.children,I=this.getTooltipEventType(),L=tf(M,up),R={};L&&I==="axis"&&(L.props.trigger==="click"?R={onClick:this.handleClick}:R={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 q=Vle(this.props,this.handleOuterEvent);return wr(wr({},q),R)}},{key:"addListener",value:function(){iye.on(oye,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){iye.removeListener(oye,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(M,I,L){for(var R=this.state.formattedGraphicalItems,q=0,U=R.length;q{const{data:C,error:M}=await H.from("email_campaigns").select("*").eq("status","sent").order("sent_at",{ascending:!0});if(M)throw M;return C}}),{data:n}=mt({queryKey:["campaign-agent-profiles"],queryFn:async()=>{const{data:C,error:M}=await H.from("profiles").select("id, name, email");if(M)throw M;return C}});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(C=>[C.id,C])),l=a.reduce((C,M)=>C+(M.sent_count||0),0),i=a.reduce((C,M)=>C+(M.open_count||0),0),c=a.reduce((C,M)=>C+(M.click_count||0),0),u=a.reduce((C,M)=>C+(M.bounce_count||0),0),p=a.reduce((C,M)=>C+(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",b=[{label:"Campaigns Sent",value:a.length,icon:Rn,color:"text-foreground"},{label:"Total Emails Sent",value:l,icon:mr,color:"text-green-600"},{label:"Avg Open Rate",value:`${f}%`,icon:qn,color:"text-blue-600"},{label:"Avg Click Rate",value:`${g}%`,icon:bh,color:"text-purple-600"},{label:"Total Bounces",value:u,icon:Gu,color:"text-orange-600"},{label:"Complaints",value:p,icon:Ol,color:"text-destructive"}],_=new Map;a.forEach(C=>{var L,R;const M=C.user_id,I=_.get(M)||{name:((L=o.get(M))==null?void 0:L.name)||((R=o.get(M))==null?void 0:R.email)||"Unknown",campaigns:0,sent:0,opens:0,clicks:0};I.campaigns++,I.sent+=C.sent_count||0,I.opens+=C.open_count||0,I.clicks+=C.click_count||0,_.set(M,I)});const j=[..._.entries()].map(([C,M])=>({id:C,...M,openRate:M.sent>0?+(M.opens/M.sent*100).toFixed(1):0})).sort((C,M)=>M.sent-C.sent),w=j.slice(0,6).map(C=>({name:C.name,value:C.sent})),N=a.map(C=>{var M;return{name:C.name.length>20?C.name.slice(0,20)+"…":C.name,agent:((M=o.get(C.user_id))==null?void 0:M.name)||"Unknown",openRate:C.sent_count>0?+(C.open_count/C.sent_count*100).toFixed(1):0,clickRate:C.sent_count>0?+(C.click_count/C.sent_count*100).toFixed(1):0,sent:C.sent_count,date:C.sent_at?ps(new Date(C.sent_at),"MMM d"):""}});return e.jsx("div",{className:"space-y-6",children:a.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Rn,{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:b.map(C=>e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4 text-center",children:[e.jsx(C.icon,{className:`h-5 w-5 mx-auto mb-1 ${C.color}`}),e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})},C.label))}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Open & Click Rates by Campaign"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(nT,{width:"100%",height:"100%",children:e.jsxs(xat,{data:N,children:[e.jsx(eC,{dataKey:"date",fontSize:11}),e.jsx(tC,{fontSize:11,unit:"%"}),e.jsx(up,{formatter:C=>`${C}%`}),e.jsx(P1,{dataKey:"openRate",fill:"hsl(220, 70%, 50%)",name:"Open Rate",radius:[2,2,0,0]}),e.jsx(P1,{dataKey:"clickRate",fill:"hsl(270, 70%, 50%)",name:"Click Rate",radius:[2,2,0,0]})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Send Volume by Agent"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[280px]",children:e.jsx(nT,{width:"100%",height:"100%",children:e.jsxs(gat,{children:[e.jsx(B0,{data:w,dataKey:"value",nameKey:"name",cx:"50%",cy:"50%",outerRadius:100,label:({name:C,percent:M})=>`${C} (${(M*100).toFixed(0)}%)`,fontSize:11,children:w.map((C,M)=>e.jsx(nR,{fill:AFe[M%AFe.length]},M))}),e.jsx(up,{})]})})})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Send Volume Trend"})}),e.jsx(Re,{children:e.jsx("div",{className:"h-[240px]",children:e.jsx(nT,{width:"100%",height:"100%",children:e.jsxs(Avs,{data:N,children:[e.jsx(eC,{dataKey:"date",fontSize:11}),e.jsx(tC,{fontSize:11}),e.jsx(up,{}),e.jsx(uR,{type:"monotone",dataKey:"sent",stroke:"hsl(142, 71%, 45%)",strokeWidth:2,name:"Emails Sent",dot:{r:4}})]})})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Agent Performance"})}),e.jsx(Re,{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:j.map(C=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/30",children:[e.jsx("td",{className:"py-2.5 font-medium",children:C.name}),e.jsx("td",{className:"py-2.5 text-center",children:C.campaigns}),e.jsx("td",{className:"py-2.5 text-center",children:C.sent}),e.jsx("td",{className:"py-2.5 text-center",children:C.opens}),e.jsx("td",{className:"py-2.5 text-center",children:C.clicks}),e.jsx("td",{className:"py-2.5 text-center",children:e.jsxs(tt,{variant:"outline",children:[C.openRate,"%"]})})]},C.id))})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Campaign Leaderboard"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-2",children:[...a].sort((C,M)=>{const I=C.sent_count>0?C.open_count/C.sent_count:0;return(M.sent_count>0?M.open_count/M.sent_count:0)-I}).slice(0,10).map((C,M)=>{const I=C.sent_count>0?(C.open_count/C.sent_count*100).toFixed(1):"0.0",L=C.sent_count>0?(C.click_count/C.sent_count*100).toFixed(1):"0.0",R=o.get(C.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/${C.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:C.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(R==null?void 0:R.name)||"Unknown"," · ",C.sent_at?ps(new Date(C.sent_at),"MMM d, yyyy"):""," · ",C.sent_count," sent"]})]}),e.jsxs("div",{className:"flex gap-3 text-xs",children:[e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(qn,{className:"h-3 w-3"})," ",I,"%"]}),e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(bh,{className:"h-3 w-3"})," ",L,"%"]})]})]},C.id)})})})]})]})})}const Pvs=()=>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(ja,{defaultValue:"analytics",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"analytics",children:"Analytics"}),e.jsx(us,{value:"content",children:"Content"}),e.jsx(us,{value:"email-campaigns",children:"Email Campaigns"}),e.jsx(us,{value:"activity",children:"Activity"}),e.jsx(us,{value:"shares",children:"Shares"})]}),e.jsx(ks,{value:"analytics",className:"space-y-4",children:e.jsx(XHt,{})}),e.jsx(ks,{value:"content",className:"space-y-4",children:e.jsx(JHt,{})}),e.jsx(ks,{value:"email-campaigns",className:"space-y-4",children:e.jsx(Evs,{})}),e.jsx(ks,{value:"activity",className:"space-y-4",children:e.jsx(YHt,{})}),e.jsx(ks,{value:"shares",className:"space-y-4",children:e.jsx(Mtt,{})})]})]})});function Ivs(){const t=es(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),[i,c]=k.useState(null),[u,p]=k.useState(""),[f,g]=k.useState([]),[b,_]=k.useState([]),[j,w]=k.useState([]),[N,C]=k.useState(!1),[M,I]=k.useState(null),[L,R]=k.useState(""),{data:q,isLoading:U}=mt({queryKey:["brokerage-resources"],queryFn:async()=>{const{data:Te,error:ft}=await H.from("brokerage_resources").select("*").order("publish_date",{ascending:!1});if(ft)throw ft;return Te}}),{data:B}=mt({queryKey:["brokerage-resource-pdfs"],queryFn:async()=>{const{data:Te,error:ft}=await H.from("brokerage_resource_pdfs").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Te}}),{data:V}=mt({queryKey:["brokerage-resource-videos"],queryFn:async()=>{const{data:Te,error:ft}=await H.from("brokerage_resource_videos").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Te}}),{data:Y}=mt({queryKey:["brokerage-resource-links"],queryFn:async()=>{const{data:Te,error:ft}=await H.from("brokerage_resource_links").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Te}}),{data:J,isLoading:te}=mt({queryKey:["brokerage-resource-categories"],queryFn:async()=>{const{data:Te,error:ft}=await H.from("brokerage_resource_categories").select("*").order("sort_order",{ascending:!0});if(ft)throw ft;return Te}}),X=()=>{l({title:"",description:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1,category_id:""}),c(null),p(""),g([]),_([]),w([]),a(null),R("")},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||""),R("");const ft=(B==null?void 0:B.filter(nt=>nt.resource_id===Te.id))||[];g(ft.map(nt=>({id:nt.id,name:nt.name,file_url:nt.file_url,file_size:nt.file_size,sort_order:nt.sort_order})));const me=(V==null?void 0:V.filter(nt=>nt.resource_id===Te.id))||[];_(me.map(nt=>({id:nt.id,title:nt.title,video_url:nt.video_url,sort_order:nt.sort_order})));const Ve=(Y==null?void 0:Y.filter(nt=>nt.resource_id===Te.id))||[];w(Ve.map(nt=>({id:nt.id,title:nt.title,canva_share_link:nt.canva_share_link,sort_order:nt.sort_order}))),r(!0)},ne=Te=>{var me;const ft=(me=Te.target.files)==null?void 0:me[0];ft&&(c(ft),p(URL.createObjectURL(ft)))},re=()=>{g([...f,{name:"",file_url:"",sort_order:f.length}])},le=Te=>{g(f.filter((ft,me)=>me!==Te))},pe=(Te,ft,me)=>{const Ve=[...f];if(ft==="file"&&me instanceof File){const nt=me.name.replace(/\.[^/.]+$/,"");Ve[Te]={...Ve[Te],file:me,file_size:me.size,name:Ve[Te].name||nt}}else Ve[Te]={...Ve[Te],[ft]:me};g(Ve)},xe=()=>{_([...b,{title:"",video_url:"",sort_order:b.length}])},_e=Te=>{_(b.filter((ft,me)=>me!==Te))},fe=(Te,ft,me)=>{const Ve=[...b];ft==="file"&&me instanceof File?Ve[Te]={...Ve[Te],file:me}:Ve[Te]={...Ve[Te],[ft]:me},_(Ve)},we=()=>{w([...j,{title:"",canva_share_link:"",sort_order:j.length}])},Ie=Te=>{w(j.filter((ft,me)=>me!==Te))},Ne=(Te,ft,me)=>{const Ve=[...j];Ve[Te]={...Ve[Te],[ft]:me},w(Ve)},Ae=async(Te,ft)=>{try{const me=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Te.name}});if(me.error)throw me.error;const{videoId:Ve,uploadUrl:nt,libraryId:et}=me.data,Se=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Ve,libraryId:et}});if(Se.error)throw Se.error;const{uploadUrl:rt,apiKey:Ge}=Se.data,lt=new XMLHttpRequest;return lt.open("PUT",rt,!0),lt.setRequestHeader("AccessKey",Ge),lt.upload.onprogress=qe=>{if(qe.lengthComputable){const Ze=Math.round(qe.loaded/qe.total*100),Je=[...b];Je[ft]={...Je[ft],uploadProgress:Ze},_(Je)}},await new Promise((qe,Ze)=>{lt.onload=()=>lt.status>=200&<.status<300?qe():Ze(new Error("Upload failed")),lt.onerror=()=>Ze(new Error("Upload failed")),lt.send(Te)}),`https://iframe.mediadelivery.net/embed/${et}/${Ve}`}catch(me){throw console.error("Bunny upload error:",me),me}},Fe=Lt({mutationFn:async Te=>{const{data:ft,error:me}=await H.from("brokerage_resource_categories").insert({name:Te,sort_order:(J==null?void 0:J.length)||0}).select().single();if(me)throw me;return ft},onSuccess:Te=>{t.invalidateQueries({queryKey:["brokerage-resource-categories"]}),l({...o,category_id:Te.id}),R(""),he.success("Category created")},onError:Te=>{he.error("Failed to create category: "+Te.message)}}),Ce=Lt({mutationFn:async()=>{C(!0);let Te=(n==null?void 0:n.preview_image_url)||null;if(i){const Ve=i.name.split(".").pop(),nt=`${Date.now()}.${Ve}`,{error:et}=await H.storage.from("brokerage-resources").upload(`previews/${nt}`,i);if(et)throw et;const{data:Se}=H.storage.from("brokerage-resources").getPublicUrl(`previews/${nt}`);Te=Se.publicUrl}const ft={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 me;if(n){const{error:Ve}=await H.from("brokerage_resources").update(ft).eq("id",n.id);if(Ve)throw Ve;me=n.id;const nt=(B==null?void 0:B.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],et=f.filter(He=>He.id).map(He=>He.id),Se=nt.filter(He=>!et.includes(He));Se.length>0&&await H.from("brokerage_resource_pdfs").delete().in("id",Se);const rt=(V==null?void 0:V.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],Ge=b.filter(He=>He.id).map(He=>He.id),lt=rt.filter(He=>!Ge.includes(He));lt.length>0&&await H.from("brokerage_resource_videos").delete().in("id",lt);const qe=(Y==null?void 0:Y.filter(He=>He.resource_id===n.id).map(He=>He.id))||[],Ze=j.filter(He=>He.id).map(He=>He.id),Je=qe.filter(He=>!Ze.includes(He));Je.length>0&&await H.from("brokerage_resource_links").delete().in("id",Je)}else{const{data:Ve,error:nt}=await H.from("brokerage_resources").insert(ft).select().single();if(nt)throw nt;me=Ve.id}for(let Ve=0;Ve{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),he.success(n?"Resource updated":"Resource created"),r(!1),X(),C(!1)},onError:Te=>{he.error("Failed to save resource: "+Te.message),C(!1)}}),Me=Lt({mutationFn:async Te=>{const{error:ft}=await H.from("brokerage_resources").delete().eq("id",Te);if(ft)throw ft},onSuccess:()=>{t.invalidateQueries({queryKey:["brokerage-resources"]}),t.invalidateQueries({queryKey:["brokerage-resource-pdfs"]}),t.invalidateQueries({queryKey:["brokerage-resource-videos"]}),t.invalidateQueries({queryKey:["brokerage-resource-links"]}),he.success("Resource deleted")},onError:Te=>{he.error("Failed to delete: "+Te.message)}}),$e=Te=>{if(Te.preventDefault(),!o.title){he.error("Please enter a title");return}Ce.mutate()},ct=Te=>{const ft=(B==null?void 0:B.filter(nt=>nt.resource_id===Te).length)||0,me=(V==null?void 0:V.filter(nt=>nt.resource_id===Te).length)||0,Ve=(Y==null?void 0:Y.filter(nt=>nt.resource_id===Te).length)||0;return{pdfCount:ft,videoCount:me,linkCount:Ve}};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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Resources"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(q==null?void 0:q.filter(Te=>Te.is_published).length)||0})})]})]}),e.jsxs(K,{onClick:()=>{X(),r(!0)},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Resource"]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Content"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:U?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading..."})}):(q==null?void 0:q.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No brokerage resources yet. Create your first one!"})}):q==null?void 0:q.map(Te=>{const{pdfCount:ft,videoCount:me,linkCount:Ve}=ct(Te.id),nt=J==null?void 0:J.find(et=>et.id===Te.category_id);return e.jsxs(Ss,{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(Wh,{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:nt?e.jsx("span",{className:"inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-muted",children:nt.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(En,{className:"h-3.5 w-3.5"}),ft]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),me]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zo,{className:"h-3.5 w-3.5"}),Ve]})]})}),e.jsx(dt,{children:ps(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 et=(B==null?void 0:B.filter(Ge=>Ge.resource_id===Te.id))||[],Se=(V==null?void 0:V.filter(Ge=>Ge.resource_id===Te.id))||[],rt=(Y==null?void 0:Y.filter(Ge=>Ge.resource_id===Te.id))||[];I({...Te,pdfs:et,videos:Se,links:rt})},children:e.jsx(qn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ce(Te),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Delete this resource?")&&Me.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(_s,{children:e.jsx(bs,{children:n?"Edit Brokerage Resource":"Add Brokerage Resource"})}),e.jsxs("form",{onSubmit:$e,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Wh,{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(ye,{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(ye,{className:"flex items-center gap-2",children:[e.jsx(Om,{className:"h-4 w-4"}),"Category"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ys,{value:o.category_id,onValueChange:Te=>l({...o,category_id:Te}),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Qs,{placeholder:"Select a category"})}),e.jsx(Ks,{children:J==null?void 0:J.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(Or,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Or create new category...",value:L,onChange:Te=>R(Te.target.value),className:"flex-1"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",disabled:!L.trim()||Fe.isPending,onClick:()=>Fe.mutate(L.trim()),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{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(ye,{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(ye,{children:"Published"}),e.jsxs("div",{className:"flex items-center space-x-2 pt-2",children:[e.jsx($r,{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(ye,{className:"flex items-center gap-2",children:[e.jsx(En,{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,ft)=>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:me=>pe(ft,"name",me.target.value),className:"flex-1"}),e.jsx(ze,{type:"file",accept:".pdf",onChange:me=>{var nt;const Ve=(nt=me.target.files)==null?void 0:nt[0];Ve&&pe(ft,"file",Ve)},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:()=>le(ft),children:e.jsx(Or,{className:"h-4 w-4"})})]},ft))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-4 w-4"}),"Videos (",b.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:xe,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Video"]})]}),b.map((Te,ft)=>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:me=>fe(ft,"title",me.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>_e(ft),children:e.jsx(Or,{className:"h-4 w-4"})})]}),e.jsx(ze,{type:"file",accept:"video/*",onChange:me=>{var nt;const Ve=(nt=me.target.files)==null?void 0:nt[0];Ve&&fe(ft,"file",Ve)}}),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"})]},ft))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(zo,{className:"h-4 w-4"}),"Canva Links (",j.length,")"]}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),j.map((Te,ft)=>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:me=>Ne(ft,"title",me.target.value),className:"flex-1"}),e.jsx(ze,{placeholder:"Canva Share Link",value:Te.canva_share_link,onChange:me=>Ne(ft,"canva_share_link",me.target.value),className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>Ie(ft),children:e.jsx(Or,{className:"h-4 w-4"})})]},ft))]}),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:Ce.isPending||N,children:Ce.isPending||N?"Saving...":n?"Update":"Create"})]})]})]})}),e.jsx(xs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{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(En,{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(zo,{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 yat=[{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 Lvs(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(""),[w,N]=k.useState(""),[C,M]=k.useState(""),[I,L]=k.useState(""),[R,q]=k.useState("Learn More"),[U,B]=k.useState("top"),[V,Y]=k.useState(""),[J,te]=k.useState(!0),[X,ce]=k.useState(""),[ne,re]=k.useState("");k.useEffect(()=>{le()},[]);const le=async()=>{try{const{data:Fe,error:Ce}=await H.from("dashboard_banners").select("*").order("placement").order("sort_order");if(Ce)throw Ce;s(Fe||[])}catch(Fe){he.error("Failed to load banners: "+Fe.message)}finally{n(!1)}},pe=()=>{j(""),N(""),M(""),L(""),q("Learn More"),B("top"),Y(""),te(!0),ce(""),re(""),u(null)},xe=Fe=>{u(Fe),j(Fe.title),N(Fe.description||""),M(Fe.image_url),L(Fe.link_url||""),q(Fe.link_text||"Learn More"),B(Fe.placement),Y(Fe.section_after||""),te(Fe.is_active),ce(Fe.start_date?ps(new Date(Fe.start_date),"yyyy-MM-dd'T'HH:mm"):""),re(Fe.end_date?ps(new Date(Fe.end_date),"yyyy-MM-dd'T'HH:mm"):""),o(!0)},_e=async Fe=>{var Me;const Ce=(Me=Fe.target.files)==null?void 0:Me[0];if(Ce){f(!0);try{const $e=Ce.name.split(".").pop(),ct=`${Date.now()}.${$e}`,{error:Te}=await H.storage.from("banner-images").upload(ct,Ce);if(Te)throw Te;const{data:{publicUrl:ft}}=H.storage.from("banner-images").getPublicUrl(ct);M(ft),he.success("Image uploaded successfully")}catch($e){he.error("Failed to upload image: "+$e.message)}finally{f(!1)}}},fe=async()=>{if(!_.trim()||!C){he.error("Please fill in required fields (title and image)");return}b(!0);try{const Fe={title:_.trim(),description:w.trim()||null,image_url:C,link_url:I.trim()||null,link_text:R.trim()||"Learn More",placement:U,section_after:U==="between"?V:null,is_active:J,start_date:X?new Date(X).toISOString():null,end_date:ne?new Date(ne).toISOString():null};if(c){const{error:Ce}=await H.from("dashboard_banners").update(Fe).eq("id",c.id);if(Ce)throw Ce;he.success("Banner updated successfully")}else{const Ce=t.filter($e=>$e.placement===U).length,{error:Me}=await H.from("dashboard_banners").insert({...Fe,sort_order:Ce});if(Me)throw Me;he.success("Banner created successfully")}o(!1),pe(),le()}catch(Fe){he.error("Failed to save banner: "+Fe.message)}finally{b(!1)}},we=async()=>{if(c)try{const{error:Fe}=await H.from("dashboard_banners").delete().eq("id",c.id);if(Fe)throw Fe;he.success("Banner deleted successfully"),i(!1),u(null),le()}catch(Fe){he.error("Failed to delete banner: "+Fe.message)}},Ie=async Fe=>{try{const{error:Ce}=await H.from("dashboard_banners").update({is_active:!Fe.is_active}).eq("id",Fe.id);if(Ce)throw Ce;he.success(Fe.is_active?"Banner deactivated":"Banner activated"),le()}catch(Ce){he.error("Failed to update banner: "+Ce.message)}},Ne=t.filter(Fe=>Fe.placement==="top"),Ae=t.filter(Fe=>Fe.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(fl,{className:"h-5 w-5"}),"Hero Banners (Top of Dashboard)"]}),e.jsx(xr,{children:"These banners appear in a rotating carousel at the top of the dashboard"})]}),e.jsxs(xs,{open:a&&U==="top",onOpenChange:Fe=>{Fe||pe(),o(Fe),Fe&&B("top")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),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(_s,{children:[e.jsxs(bs,{children:[c?"Edit":"Create"," Banner"]}),e.jsx(Wr,{children:"Configure the banner's content and display settings"})]}),e.jsx(EFe,{title:_,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Y,isActive:J,setIsActive:te,startDate:X,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:_e,uploading:p,showPlacementOptions:!1}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:fe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{children:Ne.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:Ne.map(Fe=>e.jsx(PFe,{banner:Fe,onEdit:()=>xe(Fe),onDelete:()=>{u(Fe),i(!0)},onToggleActive:()=>Ie(Fe)},Fe.id))})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(fl,{className:"h-5 w-5"}),"Section Banners"]}),e.jsx(xr,{children:"These banners appear between dashboard content sections"})]}),e.jsxs(xs,{open:a&&U==="between",onOpenChange:Fe=>{Fe||pe(),o(Fe),Fe&&B("between")},children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{onClick:()=>{pe(),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(_s,{children:[e.jsxs(bs,{children:[c?"Edit":"Create"," Section Banner"]}),e.jsx(Wr,{children:"Configure where this banner appears between sections"})]}),e.jsx(EFe,{title:_,setTitle:j,description:w,setDescription:N,imageUrl:C,linkUrl:I,setLinkUrl:L,linkText:R,setLinkText:q,placement:U,setPlacement:B,sectionAfter:V,setSectionAfter:Y,isActive:J,setIsActive:te,startDate:X,setStartDate:ce,endDate:ne,setEndDate:re,handleImageUpload:_e,uploading:p,showPlacementOptions:!0}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{o(!1),pe()},children:"Cancel"}),e.jsx(K,{onClick:fe,disabled:g,children:g?"Saving...":c?"Update Banner":"Create Banner"})]})]})]})]}),e.jsx(Re,{children:Ae.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:Ae.map(Fe=>e.jsx(PFe,{banner:Fe,onEdit:()=>xe(Fe),onDelete:()=>{u(Fe),i(!0)},onToggleActive:()=>Ie(Fe),showSection:!0},Fe.id))})})]})]}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>i(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:we,children:"Delete"})]})]})})]})}function EFe({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:b,setIsActive:_,startDate:j,setStartDate:w,endDate:N,setEndDate:C,handleImageUpload:M,uploading:I,showPlacementOptions:L}){return e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",placeholder:"Banner headline...",value:t,onChange:R=>s(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Optional banner description...",value:r,onChange:R=>n(R.target.value),rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Banner Image *"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:M,disabled:I,className:"flex-1"}),I&&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(ye,{htmlFor:"linkUrl",children:"Link URL (optional)"}),e.jsx(ze,{id:"linkUrl",placeholder:"https://...",value:o,onChange:R=>l(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"linkText",children:"Button Text"}),e.jsx(ze,{id:"linkText",placeholder:"Learn More",value:i,onChange:R=>c(R.target.value)})]})]}),L&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Placement"}),e.jsxs(Ys,{value:f,onValueChange:g,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select section placement..."})}),e.jsx(Ks,{children:yat.map(R=>e.jsx(Mt,{value:R.value,children:R.label},R.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"startDate",className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Start Date (optional)"]}),e.jsx(ze,{id:"startDate",type:"datetime-local",value:j,onChange:R=>w(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{htmlFor:"endDate",className:"flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"End Date (optional)"]}),e.jsx(ze,{id:"endDate",type:"datetime-local",value:N,onChange:R=>C(R.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($r,{id:"isActive",checked:b,onCheckedChange:_}),e.jsx(ye,{htmlFor:"isActive",children:"Active"})]})})]})}function PFe({banner:t,onEdit:s,onDelete:r,onToggleActive:n,showSection:a=!1}){var l;const o=(l=yat.find(i=>i.value===t.section_after))==null?void 0:l.label;return 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(Ju,{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(tt,{variant:"secondary",children:"Inactive"}),t.start_date&&new Date(t.start_date)>new Date&&e.jsx(tt,{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})]}),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(an,{className:"h-4 w-4"})})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:n,children:t.is_active?e.jsx(qn,{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(Da,{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 Bz={open:{label:"Open",icon:mn,color:"bg-yellow-500"},in_progress:{label:"In Progress",icon:zc,color:"bg-blue-500"},resolved:{label:"Resolved",icon:xi,color:"bg-green-500"},closed:{label:"Closed",icon:xc,color:"bg-muted-foreground"}},IFe={general:"General Support",technology:"Technology Support",crm:"CRM Support",marketing:"Marketing Support"};function Dvs(){var R,q;const{user:t}=Rs(),s=es(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState("all"),[p,f]=k.useState(!1),{data:g=[],isLoading:b}=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:Y,error:J}=await H.from("profiles").select("id, name, email").in("id",V);if(J)throw J;const{data:te,error:X}=await H.from("support_notification_settings").select("user_id, receive_notifications");if(X)throw X;const ce=new Map((te==null?void 0:te.map(ne=>[ne.user_id,ne.receive_notifications]))||[]);return Y.map(ne=>({...ne,receives_notifications:ce.get(ne.id)||!1}))}}),{data:j=[]}=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}),w=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:Y}=await H.from("support_notification_settings").update({receive_notifications:B}).eq("user_id",U);if(Y)throw Y}else{const{error:Y}=await H.from("support_notification_settings").insert({user_id:U,receive_notifications:B});if(Y)throw Y}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-users-notifications"]}),he.success("Notification settings updated")},onError:()=>{he.error("Failed to update settings")}}),N=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}),he.success("Status updated")},onError:()=>{he.error("Failed to update status")}}),C=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"]}),he.success("Ticket assigned")},onError:()=>{he.error("Failed to assign ticket")}}),M=Lt({mutationFn:async U=>{var V,Y;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:(Y=r.profiles)==null?void 0:Y.name}})}catch(J){console.error("Failed to send reply notification:",J)}},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-ticket-replies",r==null?void 0:r.id]}),o(""),he.success("Reply sent!")},onError:()=>{he.error("Failed to send reply")}}),I=()=>{a.trim()&&M.mutate(a)};k.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 L=g.filter(U=>U.status==="open").length;return r?(Bz[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(ri,{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(tt,{variant:"secondary",children:IFe[r.category]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["from ",((R=r.profiles)==null?void 0:R.name)||"Unknown"," (",(q=r.profiles)==null?void 0:q.email,")"]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Status"})}),e.jsx(Re,{children:e.jsxs(Ys,{value:r.status,onValueChange:U=>{N.mutate({ticketId:r.id,status:U}),n({...r,status:U})},children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm",children:"Assigned To"})}),e.jsx(Re,{children:e.jsxs(Ys,{value:r.assigned_to||"unassigned",onValueChange:U=>{const B=U==="unassigned"?null:U;C.mutate({ticketId:r.id,assignedTo:B}),n({...r,assigned_to:B})},children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Unassigned"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"unassigned",children:"Unassigned"}),_.map(U=>e.jsx(Mt,{value:U.id,children:U.name},U.id))]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(xr,{children:["Created on ",ps(new Date(r.created_at),"MMM d, yyyy 'at' h:mm a")]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:r.description})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Conversation"})}),e.jsxs(Re,{children:[e.jsx(Gi,{className:"h-[300px] pr-4",children:j.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:j.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:ps(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(sl,{className:"my-4"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(Er,{placeholder:"Type your reply...",value:a,onChange:U=>o(U.target.value),className:"min-h-[80px]"}),e.jsx(K,{onClick:I,disabled:!a.trim()||M.isPending,className:"self-end",children:e.jsx(Rn,{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",L>0&&e.jsxs(tt,{variant:"destructive",className:"ml-2",children:[L," open"]})]})]}),e.jsxs(xs,{open:p,onOpenChange:f,children:[e.jsx(qi,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Notification Settings"]})}),e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(to,{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(Pm,{className:"h-4 w-4 text-primary"}):e.jsx(e1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx($r,{checked:U.receives_notifications,onCheckedChange:B=>w.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(ja,{value:l,onValueChange:i,className:"w-auto",children:e.jsxs(ga,{children:[e.jsx(us,{value:"all",children:"All"}),e.jsx(us,{value:"open",children:"Open"}),e.jsx(us,{value:"in_progress",children:"In Progress"}),e.jsx(us,{value:"resolved",children:"Resolved"}),e.jsx(us,{value:"closed",children:"Closed"})]})}),e.jsxs(Ys,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"All Categories"})}),e.jsxs(Ks,{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:b?e.jsx("div",{className:"text-center py-12 text-muted-foreground",children:"Loading tickets..."}):g.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"text-center py-12",children:[e.jsx(zc,{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,Y;const B=Bz[U.status].icon;return e.jsx(Pe,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>n(U),children:e.jsx(Re,{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(tt,{variant:"outline",className:"text-xs",children:IFe[U.category]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[(V=U.profiles)==null?void 0:V.name," • ",ps(new Date(U.created_at),"MMM d, yyyy")]}),U.assigned_to&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),((Y=_.find(J=>J.id===U.assigned_to))==null?void 0:Y.name)||"Assigned"]})]})]}),e.jsxs(tt,{className:Bz[U.status].color,children:[e.jsx(B,{className:"h-3 w-3 mr-1"}),Bz[U.status].label]})]})})},U.id)})})})]})]})})}const vat=Ph.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 Ovs({content:t,onChange:s,variables:r}){const n=tke({extensions:[rke,mke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline"}}),pke.configure({types:["heading","paragraph"]}),fke,vat],content:t,onUpdate:({editor:l})=>{s(l.getHTML())}});k.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(W4,{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(Q4,{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(Ch,{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(h0,{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(U4,{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(V4,{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(zo,{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(K4,{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(dS,{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(oS,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),r.length>0&&e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{type:"button",variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(qM,{className:"h-4 w-4"}),"Insert Variable"]})}),e.jsx(zd,{align:"end",className:"w-64",children:r.map(l=>e.jsxs(Ca,{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(JNe,{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(tt,{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 Rvs(){const t=es(),[s,r]=k.useState(null),[n,a]=k.useState(null),[o,l]=k.useState(""),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(!0),[b,_]=k.useState("visual"),{data:j,isLoading:w}=mt({queryKey:["email-templates"],queryFn:async()=>{const{data:L,error:R}=await H.from("email_templates").select("*").order("name");if(R)throw R;return L.map(q=>({...q,available_variables:q.available_variables||[]}))}}),N=Lt({mutationFn:async L=>{const{error:R}=await H.from("email_templates").update({subject:L.subject,body_html:L.body_html,description:L.description,is_active:L.is_active}).eq("id",L.id);if(R)throw R},onSuccess:()=>{t.invalidateQueries({queryKey:["email-templates"]}),he.success("Email template updated successfully"),r(null)},onError:L=>{he.error("Failed to update template: "+L.message)}}),C=L=>{r(L),l(L.subject),c(L.body_html),p(L.description||""),g(L.is_active),_("visual")},M=()=>{s&&N.mutate({id:s.id,subject:o,body_html:i,description:u,is_active:f})},I=(L,R)=>{let q=L;return R.forEach(U=>{const B=`{{${U.key}}}`,V=`[${U.label}]`;q=q.replace(new RegExp(B.replace(/[{}]/g,"\\$&"),"g"),V)}),q};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(ri,{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(qn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{onClick:M,disabled:N.isPending,children:[e.jsx(ed,{className:"h-4 w-4 mr-2"}),N.isPending?"Saving...":"Save Changes"]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-5 w-5"}),s.name]}),e.jsxs(xr,{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(ye,{htmlFor:"active-toggle",children:"Active"}),e.jsx($r,{id:"active-toggle",checked:f,onCheckedChange:g})]})]})}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u,onChange:L=>p(L.target.value),placeholder:"Brief description of when this email is sent",rows:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"subject",children:"Email Subject"}),e.jsx(ze,{id:"subject",value:o,onChange:L=>l(L.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(ye,{children:"Email Body"}),e.jsx(ja,{value:b,onValueChange:L=>_(L),children:e.jsxs(ga,{className:"h-8",children:[e.jsxs(us,{value:"visual",className:"text-xs px-3 h-6",children:[e.jsx(aS,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(us,{value:"html",className:"text-xs px-3 h-6",children:[e.jsx(K4,{className:"h-3 w-3 mr-1"}),"HTML"]})]})})]}),b==="visual"?e.jsx(Ovs,{content:i,onChange:c,variables:s.available_variables}):e.jsx(Er,{value:i,onChange:L=>c(L.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(_s,{children:[e.jsx(bs,{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:I(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"})]}),w?e.jsx("div",{className:"grid gap-4",children:[...Array(4)].map((L,R)=>e.jsx(Pe,{children:e.jsxs(Dt,{children:[e.jsx(vs,{className:"h-5 w-48"}),e.jsx(vs,{className:"h-4 w-96"})]})},R))}):e.jsx("div",{className:"grid gap-4",children:j==null?void 0:j.map(L=>e.jsxs(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(zt,{className:"flex items-center gap-2 text-lg",children:[e.jsx(dr,{className:"h-5 w-5 text-muted-foreground"}),L.name,!L.is_active&&e.jsx(tt,{variant:"secondary",children:"Inactive"})]}),e.jsx(xr,{children:L.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>a(L),children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),"Preview"]}),e.jsxs(K,{size:"sm",onClick:()=>C(L),children:[e.jsx(dd,{className:"h-4 w-4 mr-2"}),"Edit"]})]})]})}),e.jsx(Re,{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:L.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:L.available_variables.map(R=>e.jsx(tt,{variant:"outline",className:"font-mono text-xs",children:`{{${R.key}}}`},R.key))})]})]})})]},L.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(_s,{children:[e.jsxs(bs,{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:I(n.body_html,n.available_variables)}})})]})})]})})}function Fvs(){const t=es(),[s,r]=k.useState("templates"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),[b,_]=k.useState({name:"",description:"",icon:"📧"}),{data:j=[]}=mt({queryKey:["agent-email-template-categories"],queryFn:async()=>{const{data:V,error:Y}=await H.from("email_template_categories").select("*").order("sort_order");if(Y)throw Y;return V}}),{data:w=[],isLoading:N}=mt({queryKey:["agent-email-templates-admin"],queryFn:async()=>{const{data:V,error:Y}=await H.from("agent_email_templates").select("*, category:email_template_categories(*)").order("sort_order");if(Y)throw Y;return V}}),C=Lt({mutationFn:async V=>{const Y={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:J}=await H.from("agent_email_templates").update(Y).eq("id",V.id);if(J)throw J}else{const{error:J}=await H.from("agent_email_templates").insert(Y);if(J)throw J}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),c(!1),he.success(n?"Template updated":"Template created")},onError:()=>he.error("Failed to save template")}),M=Lt({mutationFn:async V=>{const{error:Y}=await H.from("agent_email_templates").delete().eq("id",V);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-templates-admin"]}),he.success("Template deleted")}}),I=Lt({mutationFn:async V=>{const Y={name:V.name,description:V.description||null,icon:V.icon};if(V.id){const{error:J}=await H.from("email_template_categories").update(Y).eq("id",V.id);if(J)throw J}else{const J=j.length>0?Math.max(...j.map(X=>X.sort_order))+1:0,{error:te}=await H.from("email_template_categories").insert({...Y,sort_order:J});if(te)throw te}},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),p(!1),he.success(o?"Category updated":"Category created")},onError:()=>he.error("Failed to save category")}),L=Lt({mutationFn:async V=>{const{error:Y}=await H.from("email_template_categories").delete().eq("id",V);if(Y)throw Y},onSuccess:()=>{t.invalidateQueries({queryKey:["agent-email-template-categories"]}),he.success("Category deleted")}}),R=()=>{a(null),g({title:"",subject:"",body:"",description:"",tone:"",category_id:"",is_active:!0}),c(!0)},q=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(ah,{title:"Agent Email Templates",description:"Manage email templates that agents use when composing emails from Mission Control."}),e.jsxs(ja,{value:s,onValueChange:r,children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"templates",className:"gap-2",children:[e.jsx(dr,{className:"h-4 w-4"})," Templates"]}),e.jsxs(us,{value:"categories",className:"gap-2",children:[e.jsx(Lm,{className:"h-4 w-4"})," Categories"]})]}),e.jsxs(ks,{value:"templates",className:"space-y-4",children:[e.jsx("div",{className:"flex justify-end",children:e.jsxs(K,{onClick:R,className:"gap-2",children:[e.jsx(qs,{className:"h-4 w-4"})," Add Template"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Template"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Category"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Tone"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:N?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin mx-auto"})})}):w.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No templates yet. Create your first one!"})}):w.map(V=>e.jsxs(Ss,{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(tt,{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(tt,{variant:"secondary",children:V.tone}):"—"}),e.jsx(dt,{children:e.jsx(tt,{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:()=>q(V),children:e.jsx(Da,{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(ks,{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:j.map(V=>e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{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(Da,{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?")&&L.mutate(V.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})}),e.jsxs(Re,{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:[w.filter(Y=>Y.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(_s,{children:e.jsx(bs,{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(ye,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:V=>g(Y=>({...Y,title:V.target.value})),placeholder:"e.g. Quick Check-in"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Category"}),e.jsxs(Ys,{value:f.category_id,onValueChange:V=>g(Y=>({...Y,category_id:V})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsx(Ks,{children:j.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(ye,{children:"Subject Line"}),e.jsx(ze,{value:f.subject,onChange:V=>g(Y=>({...Y,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(ye,{children:"Email Body"}),e.jsx(Er,{value:f.body,onChange:V=>g(Y=>({...Y,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(ye,{children:"Description (internal)"}),e.jsx(ze,{value:f.description,onChange:V=>g(Y=>({...Y,description:V.target.value})),placeholder:"Short description for admin reference"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Tone"}),e.jsx(ze,{value:f.tone,onChange:V=>g(Y=>({...Y,tone:V.target.value})),placeholder:"e.g. Warm & Casual"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{checked:f.is_active,onCheckedChange:V=>g(Y=>({...Y,is_active:V}))}),e.jsx(ye,{children:"Active"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>C.mutate({...f,id:n==null?void 0:n.id}),disabled:C.isPending||!f.title||!f.subject||!f.body,children:[C.isPending&&e.jsx(ws,{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(_s,{children:e.jsx(bs,{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(ye,{children:"Icon"}),e.jsx(ze,{value:b.icon,onChange:V=>_(Y=>({...Y,icon:V.target.value})),className:"text-center text-lg"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Name"}),e.jsx(ze,{value:b.name,onChange:V=>_(Y=>({...Y,name:V.target.value})),placeholder:"e.g. Check-in & Stay in Touch"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Description"}),e.jsx(ze,{value:b.description,onChange:V=>_(Y=>({...Y,description:V.target.value})),placeholder:"Brief description of this category"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>p(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate({...b,id:o==null?void 0:o.id}),disabled:I.isPending||!b.name,children:[I.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),o?"Save Changes":"Create Category"]})]})]})})]})})}const zvs=({brokerageId:t})=>{var Oo,$t;const{toast:s}=qa(),r=pr(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(""),[u,p]=k.useState("all"),[f,g]=k.useState(new Set),[b,_]=k.useState(!1),[j,w]=k.useState({}),[N,C]=k.useState(!1),[M,I]=k.useState(!1),[L,R]=k.useState({email:"",name:"",password:"",phone:""}),[q,U]=k.useState(!1),[B,V]=k.useState(null),[Y,J]=k.useState(!1),[te,X]=k.useState(!1),[ce,ne]=k.useState(!1),[re,le]=k.useState(""),[pe,xe]=k.useState(!1),[_e,fe]=k.useState([]),[we,Ie]=k.useState(!1),[Ne,Ae]=k.useState(!1),[Fe,Ce]=k.useState(null),[Me,$e]=k.useState({name:"",phone:"",email:""}),[ct,Te]=k.useState(!1),[ft,me]=k.useState(!1),[Ve,nt]=k.useState(null),[et,Se]=k.useState("asc"),[rt,Ge]=k.useState(!1),[lt,qe]=k.useState(null),[Ze,Je]=k.useState(!1),[He,Qe]=k.useState(null),[at,It]=k.useState(""),[Ut,hs]=k.useState(!1),[Yt,ts]=k.useState(null);k.useEffect(()=>{vr(),Ds()},[t]);const Ds=async()=>{try{const{data:je,error:Be}=await H.from("brokerage_manager_assignments").select("user_id").eq("brokerage_id",t);if(Be)throw Be;fe((je==null?void 0:je.map(Ye=>Ye.user_id))||[])}catch(je){console.error("Error loading brokerage managers:",je)}},vr=async()=>{try{l(!0);const{data:je,error:Be}=await H.functions.invoke("get-brokerage-agents",{body:{brokerageId:t}});if(Be)throw Be;const Ye=je.agents||[];if(a(Ye),Ye.length>0){const vt=Ye.map(Rt=>Rt.id),{data:xt}=await H.from("agent_assistant_assignments").select("agent_id, assistant_id").in("agent_id",vt);if(xt&&xt.length>0){const Rt=xt.map(Qt=>Qt.assistant_id),{data:Zt}=await H.from("profiles").select("id, name, email").in("id",Rt),Vt={};for(const Qt of xt){const Es=Zt==null?void 0:Zt.find(ys=>ys.id===Qt.assistant_id);Es&&(Vt[Qt.agent_id]={name:Es.name||"",email:Es.email||""})}w(Vt)}else w({})}}catch(je){console.error("Error loading agents:",je),s({title:"Error",description:"Failed to load agents",variant:"destructive"})}finally{l(!1)}},Ct=async()=>{if(!L.email||!L.name||!L.password){s({title:"Error",description:"Please fill in all fields",variant:"destructive"});return}I(!0);try{const{data:{session:je}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/create-user",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.access_token}`},body:JSON.stringify({...L,brokerageId:t})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to create agent");s({title:"Success",description:`Agent ${L.email} created successfully`}),R({email:"",name:"",password:"",phone:""}),C(!1),vr()}catch(je){console.error("Error creating agent:",je),s({title:"Error",description:je.message||"Failed to create agent",variant:"destructive"})}finally{I(!1)}},As=async je=>{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:je})}),vt=await Ye.json();if(!Ye.ok)throw new Error(vt.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"})}},Us=async(je,Be)=>{try{const{error:Ye}=await H.functions.invoke("send-password-reset",{body:{email:je,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"})}},kr=je=>{V(je),U(!0)},ta=je=>{Ce(je),$e({name:je.name,phone:je.phone||"",email:je.email}),Ae(!0)},ka=async()=>{if(!Fe)return;if(!Me.name.trim()){s({title:"Error",description:"Name is required",variant:"destructive"});return}const je=Me.email.trim().toLowerCase()!==Fe.email.toLowerCase();Te(!0);try{if(je){if(!Me.email.trim())throw new Error("Email is required");me(!0);const{data:{session:Ye}}=await H.auth.getSession(),vt=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:Fe.id,newEmail:Me.email.trim(),brokerageId:t})}),xt=await vt.json();if(me(!1),!vt.ok)throw new Error(xt.error||"Failed to update email")}const{error:Be}=await H.from("profiles").update({name:Me.name.trim(),phone:Me.phone.trim()||null}).eq("id",Fe.id);if(Be)throw Be;s({title:"Success",description:"Agent profile updated successfully"}),Ae(!1),Ce(null),vr()}catch(Be){console.error("Error updating agent:",Be),s({title:"Error",description:Be.message||"Failed to update agent",variant:"destructive"})}finally{Te(!1),me(!1)}},Li=async()=>{if(!re){s({title:"Error",description:"Please select an agent to promote",variant:"destructive"});return}xe(!0);try{const{data:{session:je}}=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 ${je==null?void 0:je.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),le(""),Ds()}catch(je){console.error("Error adding brokerage manager:",je),s({title:"Error",description:je.message||"Failed to add brokerage manager",variant:"destructive"})}finally{xe(!1)}},Wa=async je=>{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:je,role:"brokerage_manager",action:"remove",brokerageId:t})}),vt=await Ye.json();if(!Ye.ok)throw new Error(vt.error||"Failed to remove brokerage manager");s({title:"Success",description:"Brokerage manager role removed"}),Ds()}catch(Be){console.error("Error removing brokerage manager:",Be),s({title:"Error",description:Be.message||"Failed to remove brokerage manager",variant:"destructive"})}},cr=je=>_e.includes(je),Qr=je=>{Qe(je),It(""),Je(!0)},Hr=async()=>{if(!(!He||!at)){if(at.length<6){s({title:"Error",description:"Password must be at least 6 characters",variant:"destructive"});return}hs(!0);try{const{data:{session:je}}=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 ${je==null?void 0:je.access_token}`},body:JSON.stringify({agentId:He.id,brokerageId:t,action:"set_password",newPassword:at})}),Ye=await Be.json();if(!Be.ok)throw new Error(Ye.error||"Failed to set password");s({title:"Success",description:`Password set for ${He.name}`}),Je(!1),Qe(null),It("")}catch(je){console.error("Error setting password:",je),s({title:"Error",description:je.message||"Failed to set password",variant:"destructive"})}finally{hs(!1)}}},ln=async je=>{ts(je.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:je.id,brokerageId:t,action:"claim_account"})}),vt=await Ye.json();if(!Ye.ok)throw new Error(vt.error||"Failed to claim account");s({title:"Success",description:`Account claimed for ${je.name}`}),vr()}catch(Be){console.error("Error claiming account:",Be),s({title:"Error",description:Be.message||"Failed to claim account",variant:"destructive"})}finally{ts(null)}},Zr=async()=>{if(B){J(!0);try{const{data:{session:je}}=await H.auth.getSession(),Be=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/remove-agent",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${je==null?void 0:je.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),vr()}catch(je){console.error("Error removing agent:",je),s({title:"Error",description:je.message||"Failed to remove agent",variant:"destructive"})}finally{J(!1)}}},yi=je=>{const Be=je.trim().split(" ");return Be.length>1?Be[Be.length-1].toLowerCase():je.toLowerCase()},pt=je=>{Ve===je?Se(et==="asc"?"desc":"asc"):(nt(je),Se("asc"))},ir=je=>Ve!==je?e.jsx(yd,{className:"ml-1 h-4 w-4"}):et==="asc"?e.jsx(Nu,{className:"ml-1 h-4 w-4"}):e.jsx(Hh,{className:"ml-1 h-4 w-4"}),Bn=n.filter(je=>{if(u==="active"&&!je.claimed||u==="pending"&&je.claimed)return!1;if(!i)return!0;const Be=i.toLowerCase();return je.name.toLowerCase().includes(Be)||je.email.toLowerCase().includes(Be)}),Cr=[...Bn].sort((je,Be)=>{if(!Ve)return 0;let Ye=0;return Ve==="name"?Ye=yi(je.name).localeCompare(yi(Be.name)):Ve==="status"&&(Ye=je.claimed===Be.claimed?0:je.claimed?-1:1),et==="asc"?Ye:-Ye});Bn.filter(je=>je.claimed&&!cr(je.id));const jr=je=>{g(Be=>{const Ye=new Set(Be);return Ye.has(je)?Ye.delete(je):Ye.add(je),Ye})},Xn=()=>{f.size===Cr.length?g(new Set):g(new Set(Cr.map(je=>je.id)))},Aa=()=>{g(new Set)},Pi=async()=>{const je=Array.from(f);if(je.length===0)return;_(!0);let Be=0,Ye=0;try{const{data:{session:vt}}=await H.auth.getSession();for(const xt of je)try{(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/resend-welcome-email",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${vt==null?void 0:vt.access_token}`},body:JSON.stringify({userId:xt})})).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"}),Aa()}catch(vt){console.error("Error bulk sending welcome emails:",vt),s({title:"Error",description:vt.message||"Failed to send welcome emails",variant:"destructive"})}finally{_(!1)}};return o?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Agents"}),e.jsx(xr,{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(Th,{className:"mr-2 h-4 w-4"}),"Add Brokerage Manager"]}),e.jsxs(K,{variant:"outline",onClick:()=>X(!0),children:[e.jsx(s1,{className:"mr-2 h-4 w-4"}),"Import CSV"]}),e.jsxs(K,{onClick:()=>C(!0),children:[e.jsx(rc,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]})}),e.jsxs(Re,{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(hn,{className:"absolute left-3 top-3 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search agents...",value:i,onChange:je=>c(je.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:u,onValueChange:je=>p(je),children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Qs,{placeholder:"Filter by status"})}),e.jsxs(Ks,{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:b,children:[e.jsx(Kh,{className:"mr-2 h-4 w-4"}),"Email Agents (",f.size,")"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:Pi,disabled:b,children:[e.jsx(dr,{className:"mr-2 h-4 w-4"}),b?"Sending...":"Resend Welcome Email"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:Aa,children:"Clear"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Lo,{checked:Cr.length>0&&f.size===Cr.length,onCheckedChange:Xn,"aria-label":"Select all"})}),e.jsx(kt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>pt("name"),children:["Name (Last)",ir("name")]})}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:e.jsxs(K,{variant:"ghost",size:"sm",className:"-ml-3 h-8 hover:bg-transparent",onClick:()=>pt("status"),children:["Status",ir("status")]})}),e.jsx(kt,{children:"Actions"})]})}),e.jsx(On,{children:Cr.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center text-muted-foreground",children:"No agents found"})}):Cr.map(je=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Lo,{checked:f.has(je.id),onCheckedChange:()=>jr(je.id),"aria-label":`Select ${je.name}`})}),e.jsx(dt,{className:"font-medium",children:je.name}),e.jsx(dt,{children:je.email}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[je.claimed?e.jsx(tt,{variant:"default",children:"Active"}):e.jsx(tt,{variant:"secondary",children:"Pending"}),cr(je.id)&&e.jsxs(tt,{variant:"outline",className:"border-primary text-primary",children:[e.jsx(SL,{className:"mr-1 h-3 w-3"}),"Manager"]}),j[je.id]&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:[e.jsx(mr,{className:"mr-1 h-3 w-3"}),"Asst: ",j[je.id].name||j[je.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:()=>{qe(je),Ge(!0)},title:"Send celebration",className:"text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50",children:e.jsx(tu,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ta(je),title:"Edit agent",children:e.jsx(Da,{className:"h-4 w-4"})}),!je.claimed&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>As(je.id),title:"Resend welcome email",children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>ln(je),title:"Claim account for agent",disabled:Yt===je.id,className:"text-green-600 hover:text-green-700 hover:bg-green-50",children:e.jsx(V_,{className:"h-4 w-4"})})]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Qr(je),title:"Set password",className:"text-blue-600 hover:text-blue-700 hover:bg-blue-50",children:e.jsx(Mh,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Us(je.email,je.name),title:"Send password reset email",children:e.jsx(J4,{className:"h-4 w-4"})}),cr(je.id)&&e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>Wa(je.id),title:"Remove manager role",className:"text-orange-500 hover:text-orange-600",children:e.jsx(Th,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>kr(je),className:"text-destructive hover:text-destructive",title:"Remove agent",children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},je.id))})]})})]})]}),e.jsx(xs,{open:N,onOpenChange:C,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:L.name,onChange:je=>R({...L,name:je.target.value}),placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:L.email,onChange:je=>R({...L,email:je.target.value}),placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone (optional)"}),e.jsx(ze,{id:"phone",type:"tel",value:L.phone,onChange:je=>R({...L,phone:je.target.value}),placeholder:"555-123-4567"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"password",children:"Temporary Password"}),e.jsx(ze,{id:"password",type:"password",value:L.password,onChange:je=>R({...L,password:je.target.value}),placeholder:"Temporary password"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:Ct,disabled:M,children:M?"Creating...":"Create Agent"})]})]})}),e.jsx(xs,{open:q,onOpenChange:U,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>U(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Zr,disabled:Y,children:Y?"Removing...":"Remove Agent"})]})]})}),e.jsx(Qet,{open:te,onOpenChange:X,fixedBrokerageId:t,onSuccess:vr}),e.jsx(xs,{open:ce,onOpenChange:ne,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Select Agent"}),e.jsxs(Bo,{open:we,onOpenChange:Ie,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":we,className:"w-full justify-between",children:[re?((Oo=n.find(je=>je.id===re))==null?void 0:Oo.name)+" ("+(($t=n.find(je=>je.id===re))==null?void 0:$t.email)+")":"Select an agent to promote...",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-full p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search by name or email..."}),e.jsxs(Ox,{className:"max-h-[200px]",children:[e.jsx(Rx,{children:"No eligible agents found."}),e.jsx(Fx,{children:n.filter(je=>!cr(je.id)).map(je=>e.jsxs(vp,{value:`${je.name} ${je.email}`,onSelect:()=>{le(je.id),Ie(!1)},children:[e.jsx(fa,{className:`mr-2 h-4 w-4 ${re===je.id?"opacity-100":"opacity-0"}`}),je.name," (",je.email,")"]},je.id))})]})]})})]}),n.filter(je=>!cr(je.id)).length===0&&e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"All agents are already brokerage managers."})]})}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(K,{onClick:Li,disabled:pe||!re,children:pe?"Adding...":"Add as Manager"})]})]})}),e.jsx(xs,{open:Ne,onOpenChange:Ae,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Edit Agent"}),e.jsxs(Wr,{children:["Update profile information for ",Fe==null?void 0:Fe.name]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"edit-name",children:"Name"}),e.jsx(ze,{id:"edit-name",value:Me.name,onChange:je=>$e({...Me,name:je.target.value}),placeholder:"Agent name"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"edit-email",children:"Email"}),e.jsx(ze,{id:"edit-email",type:"email",value:Me.email,onChange:je=>$e({...Me,email:je.target.value}),placeholder:"agent@example.com"}),Me.email.trim().toLowerCase()!==(Fe==null?void 0:Fe.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(ye,{htmlFor:"edit-phone",children:"Phone"}),e.jsx(ze,{id:"edit-phone",type:"tel",value:Me.phone,onChange:je=>$e({...Me,phone:je.target.value}),placeholder:"555-123-4567"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ae(!1),children:"Cancel"}),e.jsx(K,{onClick:ka,disabled:ct||ft,children:ft?"Updating email...":ct?"Saving...":"Save Changes"})]})]})}),lt&&e.jsx(Jet,{open:rt,onOpenChange:je=>{Ge(je),je||qe(null)},userId:lt.id,userName:lt.name}),e.jsx(xs,{open:Ze,onOpenChange:Je,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Set Password"}),e.jsxs(Wr,{children:["Set a new password for ",He==null?void 0:He.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(ye,{htmlFor:"new-password",children:"New Password"}),e.jsx(ze,{id:"new-password",type:"password",value:at,onChange:je=>It(je.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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Je(!1),children:"Cancel"}),e.jsx(K,{onClick:Hr,disabled:Ut||!at||at.length<6,children:Ut?"Setting...":"Set Password"})]})]})})]})},Bvs={academy_video:"Academy Video",template:"Template",toolbox:"Toolbox Resource",newsletter:"Newsletter",social_swag:"Social Swag",event:"Event"},$vs={view:"Viewed",click_canva:"Opened Canva",click_pdf:"Downloaded PDF",click_video:"Watched Video",click_link:"Clicked Link",register:"Registered"},qvs=t=>{switch(t){case"academy_video":return e.jsx(Cn,{className:"h-4 w-4"});case"template":return e.jsx(En,{className:"h-4 w-4"});case"toolbox":return e.jsx(En,{className:"h-4 w-4"});case"newsletter":return e.jsx(i1,{className:"h-4 w-4"});case"social_swag":return e.jsx(un,{className:"h-4 w-4"});case"event":return e.jsx(cn,{className:"h-4 w-4"});default:return e.jsx(an,{className:"h-4 w-4"})}},Uvs=({brokerageId:t})=>{const{toast:s}=qa(),[r,n]=k.useState([]),[a,o]=k.useState([]),[l,i]=k.useState([]),[c,u]=k.useState(!0),[p,f]=k.useState(null);k.useEffect(()=>{g()},[t]);const g=async()=>{try{u(!0);const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("brokerage_id",t);if(w)throw w;const N=j.map(Y=>Y.id),C=new Map(j.map(Y=>[Y.id,Y]));if(N.length===0){n([]),o([]),i([]);return}const{data:M,error:I}=await H.from("activity_logs").select("*").in("user_id",N).order("launched_at",{ascending:!1});if(I)throw I;const L=M.map(Y=>{var J,te;return{id:Y.id,user_id:Y.user_id,app_name:Y.app_name,launched_at:Y.launched_at,user_name:((J=C.get(Y.user_id))==null?void 0:J.name)||"Unknown",user_email:((te=C.get(Y.user_id))==null?void 0:te.email)||"Unknown"}});n(L);const{data:R,error:q}=await H.from("content_engagement_logs").select("*").in("user_id",N).order("created_at",{ascending:!1});if(q)throw q;const U=(R||[]).map(Y=>{var J,te;return{id:Y.id,user_id:Y.user_id,resource_type:Y.resource_type,resource_id:Y.resource_id,resource_title:Y.resource_title,action_type:Y.action_type,created_at:Y.created_at,user_name:((J=C.get(Y.user_id))==null?void 0:J.name)||"Unknown",user_email:((te=C.get(Y.user_id))==null?void 0:te.email)||"Unknown"}});o(U);const B=new Map;j.forEach(Y=>{B.set(Y.id,{user_id:Y.id,user_name:Y.name,user_email:Y.email,app_launches:0,content_views:0,last_activity:""})}),L.forEach(Y=>{const J=B.get(Y.user_id);J&&(J.app_launches++,(!J.last_activity||new Date(Y.launched_at)>new Date(J.last_activity))&&(J.last_activity=Y.launched_at))}),U.forEach(Y=>{const J=B.get(Y.user_id);J&&(J.content_views++,(!J.last_activity||new Date(Y.created_at)>new Date(J.last_activity))&&(J.last_activity=Y.created_at))});const V=Array.from(B.values()).filter(Y=>Y.app_launches>0||Y.content_views>0).sort((Y,J)=>new Date(J.last_activity).getTime()-new Date(Y.last_activity).getTime());i(V)}catch(j){console.error("Error loading activity:",j),s({title:"Error",description:"Failed to load activity logs",variant:"destructive"})}finally{u(!1)}},b=j=>r.filter(w=>w.user_id===j),_=j=>a.filter(w=>w.user_id===j);return c?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Agent Activity"}),e.jsx(xr,{children:"Track app usage and content engagement - click an agent for details"})]}),e.jsx(Re,{children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"App Launches"}),e.jsx(kt,{className:"text-center",children:"Content Views"}),e.jsx(kt,{children:"Last Active"})]})}),e.jsx(On,{children:l.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No activity yet"})}):l.map(j=>e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>f({id:j.user_id,name:j.user_name,email:j.user_email}),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:j.user_name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:j.user_email})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(rl,{className:"h-3 w-3"}),j.app_launches]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(En,{className:"h-3 w-3"}),j.content_views]})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:j.last_activity&&_d(new Date(j.last_activity),{addSuffix:!0})})]},j.user_id))})]})})})]}),e.jsx(xs,{open:!!p,onOpenChange:j=>!j&&f(null),children:e.jsxs(fs,{className:"max-w-3xl max-h-[80vh] overflow-hidden flex flex-col",children:[e.jsxs(_s,{children:[e.jsxs(bs,{children:[p==null?void 0:p.name,"'s Activity"]}),e.jsx(Wr,{children:p==null?void 0:p.email})]}),e.jsxs(ja,{defaultValue:"content",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2",children:[e.jsx(us,{value:"content",children:"Content Engagement"}),e.jsx(us,{value:"apps",children:"App Launches"})]}),e.jsx(ks,{value:"content",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Resource"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(On,{children:p&&_(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center text-muted-foreground",children:"No content engagement yet"})}):p&&_(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"max-w-[200px] truncate font-medium",children:j.resource_title}),e.jsx(dt,{children:e.jsxs(tt,{variant:"outline",className:"gap-1",children:[qvs(j.resource_type),Bvs[j.resource_type]||j.resource_type]})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm text-muted-foreground",children:$vs[j.action_type]||j.action_type})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:_d(new Date(j.created_at),{addSuffix:!0})})]},j.id))})]})})}),e.jsx(ks,{value:"apps",className:"flex-1 overflow-auto",children:e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"App"}),e.jsx(kt,{children:"Time"})]})}),e.jsx(On,{children:p&&b(p.id).length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:2,className:"text-center text-muted-foreground",children:"No app launches yet"})}):p&&b(p.id).map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:j.app_name})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:_d(new Date(j.launched_at),{addSuffix:!0})})]},j.id))})]})})})]})]})})]})},Vvs=({brokerageId:t})=>{const{toast:s}=qa(),[r,n]=k.useState({totalAgents:0,activeAgents:0,pendingAgents:0,totalLaunches:0,launchesThisWeek:0,launchesThisMonth:0}),[a,o]=k.useState(!0);k.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(L=>L.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:b}=await H.from("profiles").select("*",{count:"exact",head:!0}).eq("brokerage_id",t).not("last_login","is",null),_=b||0,j=p-_,{count:w}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u),N=new Date;N.setDate(N.getDate()-7);const{count:C}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",N.toISOString()),M=new Date;M.setMonth(M.getMonth()-1);const{count:I}=await H.from("activity_logs").select("*",{count:"exact",head:!0}).in("user_id",u).gte("launched_at",M.toISOString());n({totalAgents:p,activeAgents:_,pendingAgents:j,totalLaunches:w||0,launchesThisWeek:C||0,launchesThisMonth:I||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(Pe,{children:e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Agents"}),e.jsx(mr,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Active Agents"}),e.jsx(xi,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Pending Invites"}),e.jsx(mn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total App Launches"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Week"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"This Month"}),e.jsx(jh,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(Re,{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"})]})]})]})},Hvs=({brokerageId:t})=>{const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState({description:"",maxUses:""});k.useEffect(()=>{f()},[t]);const f=async()=>{try{const{data:N,error:C}=await H.from("invite_codes").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(C)throw C;r(N||[])}catch(N){console.error("Error loading invite codes:",N),he.error("Failed to load invite links")}finally{a(!1)}},g=()=>Math.random().toString(36).substring(2,8).toUpperCase(),b=async()=>{l(!0);try{const N=g(),{error:C}=await H.from("invite_codes").insert({code:N,description:u.description||null,max_uses:u.maxUses?parseInt(u.maxUses):null,brokerage_id:t,is_active:!0});if(C)throw C;he.success("Invite link created!"),c(!1),p({description:"",maxUses:""}),f()}catch(N){console.error("Error creating invite code:",N),he.error("Failed to create invite link")}finally{l(!1)}},_=async N=>{try{const{error:C}=await H.from("invite_codes").delete().eq("id",N);if(C)throw C;he.success("Invite link deleted"),r(s.filter(M=>M.id!==N))}catch(C){console.error("Error deleting invite code:",C),he.error("Failed to delete invite link")}},j=async(N,C)=>{try{const{error:M}=await H.from("invite_codes").update({is_active:!C}).eq("id",N);if(M)throw M;r(s.map(I=>I.id===N?{...I,is_active:!C}:I)),he.success(`Invite link ${C?"deactivated":"activated"}`)}catch(M){console.error("Error toggling invite code:",M),he.error("Failed to update invite link")}},w=N=>{const C=`${window.location.origin}/join?code=${N}`;navigator.clipboard.writeText(C),he.success("Link copied to clipboard!")};return n?e.jsx(Pe,{children:e.jsx(Re,{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(zo,{className:"h-5 w-5"}),"Agent Invite Links"]}),e.jsx(xr,{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(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"description",children:"Description (optional)"}),e.jsx(ze,{id:"description",placeholder:"e.g., New agent recruiting campaign",value:u.description,onChange:N=>p({...u,description:N.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"maxUses",children:"Max Uses (optional)"}),e.jsx(ze,{id:"maxUses",type:"number",placeholder:"Leave empty for unlimited",value:u.maxUses,onChange:N=>p({...u,maxUses:N.target.value})})]}),e.jsx(K,{onClick:b,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Invite Link"})]})]})]})]}),e.jsx(Re,{children:s.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(zo,{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(N=>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:N.code}),e.jsx(tt,{variant:N.is_active?"default":"secondary",children:N.is_active?"Active":"Inactive"})]}),N.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:N.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[N.uses_count," uses",N.max_uses&&` / ${N.max_uses} max`]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>w(N.code),title:"Copy link",children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>j(N.id,N.is_active),title:N.is_active?"Deactivate":"Activate",children:N.is_active?"Disable":"Enable"}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(N.id),className:"text-destructive hover:text-destructive",title:"Delete",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},N.id))})})]})},Wvs=({open:t,onOpenChange:s,referralCode:r,brokerageId:n,senderName:a,brokerageName:o,onInvitesSent:l})=>{const[i,c]=k.useState(""),[u,p]=k.useState([]),[f,g]=k.useState(""),[b,_]=k.useState(!1),j=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),w=()=>{const I=i.trim().toLowerCase();if(I&&j(I)&&!u.includes(I)){if(u.length>=10){he.error("Maximum 10 emails per invite");return}p([...u,I]),c("")}else I&&!j(I)?he.error("Please enter a valid email address"):u.includes(I)&&he.error("Email already added")},N=I=>{p(u.filter(L=>L!==I))},C=I=>{(I.key==="Enter"||I.key===",")&&(I.preventDefault(),w())},M=async()=>{if(u.length===0){he.error("Please add at least one email address");return}_(!0);try{const{data:I,error:L}=await H.functions.invoke("send-referral-invite",{body:{emails:u,personalMessage:f.trim()||void 0,referralCode:r,brokerageId:n,senderName:a,brokerageName:o}});if(L)throw L;I.successCount===I.totalCount?he.success(`${I.successCount} invite${I.successCount>1?"s":""} sent successfully!`):he.warning(`${I.successCount} of ${I.totalCount} invites sent. Some failed.`),p([]),g(""),s(!1),l==null||l()}catch(I){console.error("Error sending invites:",I),he.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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(dr,{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(No,{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(ye,{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:I=>c(I.target.value),onKeyDown:C,onBlur:w}),e.jsx(K,{type:"button",variant:"secondary",onClick:w,children:"Add"})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:u.map(I=>e.jsxs(tt,{variant:"secondary",className:"flex items-center gap-1 pr-1",children:[I,e.jsx("button",{type:"button",onClick:()=>N(I),className:"ml-1 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Or,{className:"h-3 w-3"})})]},I))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"message",children:"Personal Message (optional)"}),e.jsx(Er,{id:"message",placeholder:"Add a personal note that will appear at the top of the email...",value:f,onChange:I=>g(I.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(un,{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||b,children:b?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(Rn,{className:"h-4 w-4 mr-2"}),"Send ",u.length>0&&`(${u.length})`," Invite",u.length!==1?"s":""]})})]})]})})},Gvs=({brokerageId:t,refreshTrigger:s})=>{const[r,n]=k.useState([]),[a,o]=k.useState(!0);k.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(tt,{className:"bg-green-100 text-green-800 gap-1",children:[e.jsx(xi,{className:"h-3 w-3"}),"Signed Up"]});case"expired":return e.jsxs(tt,{variant:"outline",className:"text-muted-foreground gap-1",children:[e.jsx(xc,{className:"h-3 w-3"}),"Expired"]});default:return e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{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(dr,{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 ",ps(new Date(c.sent_at),"MMM d, yyyy")]})]}),i(c.status)]},c.id))]})},Kvs=()=>{const{brokerageId:t,user:s}=Rs(),[r,n]=k.useState(null),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState([]),[p,f]=k.useState(!0),[g,b]=k.useState(!1),[_,j]=k.useState(0);k.useEffect(()=>{t&&w()},[t]);const w=async()=>{try{const[R,q]=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})]);R.data&&o(R.data.name),q.data&&i(q.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(R){console.error("Error fetching referral data:",R)}finally{f(!1)}},N=()=>{const R=`https://dashboard.relevelup.com/?ref=${r}`;navigator.clipboard.writeText(R),he.success("Referral link copied to clipboard!")},C=c.filter(R=>R.status==="qualified").length,M=c.filter(R=>R.status==="pending").length,I=C*25,L=Math.max(0,Math.ceil((299-I)/25));return p?null:e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(No,{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:["$",I]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Monthly Savings"})]}),I>0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600",children:[e.jsx(xi,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm font-medium",children:"Active"})]})]}),L>0&&I<299&&e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Refer ",L," 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"})]}),I>=299&&e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(un,{className:"h-5 w-5"}),e.jsx("span",{className:"font-bold",children:"FREE Membership Unlocked!"})]})]})})]})}),e.jsxs(Re,{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:()=>b(!0),className:"w-full",size:"lg",children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Invite Broker Friends"]}),e.jsxs(K,{onClick:N,variant:"outline",className:"w-full",size:"lg",children:[e.jsx(gi,{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(wc,{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:["$",I]}),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(mr,{className:"h-5 w-5 mx-auto text-primary mb-1"}),e.jsx("p",{className:"text-2xl font-bold",children:C}),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(mn,{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(Gvs,{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(R=>{var q,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:((q=R.referred_brokerage)==null?void 0:q.name)||((U=R.referred_user)==null?void 0:U.email)||"Pending setup"}),e.jsxs(tt,{variant:R.status==="qualified"?"default":R.status==="pending"?"secondary":"destructive",className:R.status==="qualified"?"bg-green-600":"",children:[R.status==="qualified"&&e.jsx(xi,{className:"h-3 w-3 mr-1"}),R.status]})]},R.id)})]})]})]}),e.jsx(Wvs,{open:g,onOpenChange:b,referralCode:r||"",brokerageId:t||"",senderName:l||"A LevelUp Member",brokerageName:a,onInvitesSent:()=>j(R=>R+1)})]})},Zvs=({brokerageId:t})=>{const s=pr(),{teams:r,isLoading:n}=fC(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(R=>R.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(R=>({team_id:R.id,team_name:R.name,member_count:0,leader_name:null,leader_avatar:null,total_contacts:0,total_deals:0,total_videos:0}));const g=f.map(R=>R.user_id),b=f.filter(R=>R.role==="team_leader").map(R=>R.user_id),{data:_}=await H.from("profiles").select("id, name, avatar_url").in("id",b),j=new Map((_||[]).map(R=>[R.id,R])),{data:w}=await H.from("innercircle_contacts").select("owner_user_id").in("owner_user_id",g),{data:N}=await H.from("deal_pipeline").select("owner_user_id").in("owner_user_id",g),{data:C}=await H.from("agent_videos").select("owner_user_id").in("owner_user_id",g).eq("is_deleted",!1),M=new Map;(w||[]).forEach(R=>{M.set(R.owner_user_id,(M.get(R.owner_user_id)||0)+1)});const I=new Map;(N||[]).forEach(R=>{I.set(R.owner_user_id,(I.get(R.owner_user_id)||0)+1)});const L=new Map;return(C||[]).forEach(R=>{L.set(R.owner_user_id,(L.get(R.owner_user_id)||0)+1)}),r.map(R=>{const q=f.filter(X=>X.team_id===R.id),U=q.find(X=>X.role==="team_leader"),B=U?j.get(U.user_id):null,V=q.map(X=>X.user_id),Y=V.reduce((X,ce)=>X+(M.get(ce)||0),0),J=V.reduce((X,ce)=>X+(I.get(ce)||0),0),te=V.reduce((X,ce)=>X+(L.get(ce)||0),0);return{team_id:R.id,team_name:R.name,member_count:q.length,leader_name:(B==null?void 0:B.name)||null,leader_avatar:(B==null?void 0:B.avatar_url)||null,total_contacts:Y,total_deals:J,total_videos:te}})},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(Pe,{children:[e.jsx(Dt,{children:e.jsx(vs,{className:"h-5 w-32"})}),e.jsx(Re,{children:e.jsx(vs,{className:"h-24 w-full"})})]},p))});if(r.length===0)return e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"})," Teams"]}),e.jsx("p",{className:"text-2xl font-bold",children:r.length})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{className:"h-4 w-4"})," Total Members"]}),e.jsx("p",{className:"text-2xl font-bold",children:i})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Y4,{className:"h-4 w-4"})," Total Contacts"]}),e.jsx("p",{className:"text-2xl font-bold",children:c.toLocaleString()})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Wh,{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(Pe,{className:"hover:shadow-md transition-shadow",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:p.team_name}),e.jsxs(tt,{variant:"secondary",children:[p.member_count," members"]})]}),p.leader_name&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsxs(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:p.leader_avatar||""}),e.jsx(wn,{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(Im,{className:"h-3 w-3 text-amber-500"}),p.leader_name]})]})]}),e.jsx(Re,{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 →"})})]})},Yvs=()=>{const{user:t,isBrokerageManager:s,brokerageId:r,isAdmin:n,managedBrokerages:a,selectedBrokerageId:o,setSelectedBrokerageId:l}=Rs(),i=pr(),{toast:c}=qa(),[u,p]=k.useState(""),[f,g]=k.useState(!0),b=o||(a.length>0?a[0].id:r);k.useEffect(()=>{if(!t||!s&&!n){i("/dashboard");return}!o&&a.length>0&&l(a[0].id),b?_():a.length===0&&!r&&g(!1)},[t,s,n,b,i,a,o]);const _=async()=>{if(!b){g(!1);return}try{const{data:j,error:w}=await H.from("brokerages").select("name").eq("id",b).single();if(w)throw w;p(j.name)}catch(j){console.error("Error loading brokerage info:",j),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"})})}):b?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(Ys,{value:o||"",onValueChange:l,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(wa,{className:"mr-2 h-4 w-4"}),e.jsx(Qs,{placeholder:"Select brokerage"})]}),e.jsx(Ks,{children:a.map(j=>e.jsx(Mt,{value:j.id,children:j.name},j.id))})]})]}),e.jsxs(ja,{defaultValue:"agents",className:"space-y-4",children:[e.jsxs(ga,{className:"grid w-full grid-cols-4 md:grid-cols-8",children:[e.jsx(us,{value:"agents",children:"Agents"}),e.jsx(us,{value:"teams",children:"Teams"}),e.jsx(us,{value:"invite",children:"Invite Links"}),e.jsx(us,{value:"referrals",children:"Referrals"}),e.jsx(us,{value:"leaderboard",children:"Leaderboard"}),e.jsx(us,{value:"activity",children:"Activity"}),e.jsx(us,{value:"analytics",children:"Analytics"}),e.jsx(us,{value:"shares",children:"Shares"})]}),e.jsx(ks,{value:"agents",className:"space-y-4",children:e.jsx(zvs,{brokerageId:b})}),e.jsx(ks,{value:"teams",className:"space-y-4",children:e.jsx(Zvs,{brokerageId:b})}),e.jsx(ks,{value:"invite",className:"space-y-4",children:e.jsx(Hvs,{brokerageId:b})}),e.jsx(ks,{value:"referrals",className:"space-y-4",children:e.jsx(Kvs,{})}),e.jsx(ks,{value:"leaderboard",className:"space-y-4",children:e.jsx(xet,{brokerageId:b,title:`${u} Event Leaderboard`,showUserStats:!1})}),e.jsx(ks,{value:"activity",className:"space-y-4",children:e.jsx(Uvs,{brokerageId:b})}),e.jsx(ks,{value:"analytics",className:"space-y-4",children:e.jsx(Vvs,{brokerageId:b})}),e.jsx(ks,{value:"shares",className:"space-y-4",children:e.jsx(Mtt,{brokerageOnly:!0,brokerageId:b})})]})]})}):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(wa,{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 Xvs({brokerageId:t,canManage:s}){const{user:r}=Rs(),[n,a]=k.useState([]),[o,l]=k.useState(!0),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(""),[N,C]=k.useState(""),[M,I]=k.useState(!1),L=async()=>{try{const{data:V,error:Y}=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(Y)throw Y;const J=V;if(J&&J.length>0){const te=[...new Set(J.map(re=>re.created_by))],{data:X}=await H.from("profiles").select("id, name, avatar_url").in("id",te),ce=new Map((X==null?void 0:X.map(re=>[re.id,re]))||[]),ne=J.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)}};k.useEffect(()=>{L()},[t]);const R=()=>{w(""),C(""),I(!1),p(null)},q=V=>{V?(p(V),w(V.title),C(V.content),I(V.is_pinned)):R(),c(!0)},U=async()=>{if(!j.trim()||!N.trim()){he.error("Please fill in all fields");return}_(!0);try{if(u){const{error:V}=await H.from("brokerage_announcements").update({title:j.trim(),content:N.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null}).eq("id",u.id);if(V)throw V;he.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:j.trim(),content:N.trim(),is_pinned:M,pinned_at:M?new Date().toISOString():null});if(V)throw V;he.success("Announcement created")}c(!1),R(),L()}catch(V){console.error("Error saving announcement:",V),he.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;he.success("Announcement deleted"),L()}catch(V){console.error("Error deleting announcement:",V),he.error("Failed to delete announcement")}finally{g(null)}};return o?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Kh,{className:"h-5 w-5"}),"Announcements"]})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Kh,{className:"h-5 w-5 text-primary"}),"Announcements"]}),s&&e.jsxs(K,{size:"sm",onClick:()=>q(),className:"gap-1",children:[e.jsx(qs,{className:"h-4 w-4"}),"New"]})]}),e.jsx(Re,{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 Y,J,te,X;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(_n,{className:"h-5 w-5",children:[e.jsx(za,{src:((Y=V.author)==null?void 0:Y.avatar_url)||void 0}),e.jsx(wn,{className:"text-[10px]",children:((te=(J=V.author)==null?void 0:J.name)==null?void 0:te.charAt(0))||"?"})]}),e.jsx("span",{children:(X=V.author)==null?void 0:X.name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:ps(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:()=>q(V),children:e.jsx(Da,{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(_s,{children:e.jsx(bs,{children:u?"Edit Announcement":"New Announcement"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:j,onChange:V=>w(V.target.value),placeholder:"Announcement title..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"content",children:"Content"}),e.jsx(Er,{id:"content",value:N,onChange:V=>C(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($r,{id:"pinned",checked:M,onCheckedChange:I}),e.jsxs(ye,{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:b,children:b?"Saving...":u?"Update":"Create"})]})]})]})}),e.jsx(_c,{open:!!f,onOpenChange:()=>g(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Announcement"}),e.jsx(Jl,{children:"Are you sure you want to delete this announcement? This action cannot be undone."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function Qvs({brokerageId:t}){const[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(""),[i,c]=k.useState(new Set);k.useEffect(()=>{(async()=>{try{const{data:f,error:g}=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(g)throw g;if(r(f||[]),f&&f.length>0){const b=f.map(j=>j.id),{data:_}=await H.from("agent_assistant_assignments").select("agent_id").in("agent_id",b);_&&c(new Set(_.map(j=>j.agent_id)))}}catch(f){console.error("Error fetching agents:",f)}finally{a(!1)}})()},[t]);const u=s.filter(p=>{var f,g;return p.name.toLowerCase().includes(o.toLowerCase())||p.email.toLowerCase().includes(o.toLowerCase())||((f=p.title)==null?void 0:f.toLowerCase().includes(o.toLowerCase()))||((g=p.areas_served)==null?void 0:g.toLowerCase().includes(o.toLowerCase()))});return n?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Agent Roster"]})}),e.jsx(Re,{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(p=>e.jsx("div",{className:"animate-pulse",children:e.jsx("div",{className:"h-48 bg-muted rounded-lg"})},p))})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 space-y-0",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),"Agent Roster",e.jsxs("span",{className:"text-sm font-normal text-muted-foreground",children:["(",s.length,")"]})]}),e.jsxs("div",{className:"relative w-full sm:w-64",children:[e.jsx(hn,{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:o,onChange:p=>l(p.target.value),className:"pl-9"})]})]}),e.jsx(Re,{children:u.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:o?"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:u.map(p=>e.jsx(Jvs,{agent:p,hasAssistant:i.has(p.id)},p.id))})})]})}function Jvs({agent:t,hasAssistant:s}){const r=t.name.split(" ").map(n=>n[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(_n,{className:"h-20 w-20 mb-3 ring-2 ring-background shadow-md",children:[e.jsx(za,{src:t.avatar_url||void 0,alt:t.name}),e.jsx(wn,{className:"text-lg bg-primary/10 text-primary",children:r})]}),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(tt,{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(Ba,{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:[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(Un,{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(dr,{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(Cu,{className:"h-4 w-4"})})})]})]})}function e1s({brokerageId:t}){const[s,r]=k.useState([]),[n,a]=k.useState(!0);if(k.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(j=>j.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 b=new Map(c.map(j=>[j.id,j])),_=(f||[]).filter(j=>j.total_points>0).map(j=>{const w=b.get(j.user_id);return{user_id:j.user_id,total_points:j.total_points,name:(w==null?void 0:w.name)||"Unknown",avatar_url:(w==null?void 0:w.avatar_url)||null}});r(_)}catch(c){console.error("Error fetching leaderboard:",c)}finally{a(!1)}})()},[t]),n)return e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5"}),"Team Leaderboard"]})}),e.jsx(Re,{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(a1,{className:Pt("h-5 w-5",o(i))}):e.jsx("span",{className:"w-5 text-center text-sm text-muted-foreground",children:i});return e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-primary"}),"Team Leaderboard"]})}),e.jsx(Re,{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:Pt("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(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:i.avatar_url||void 0}),e.jsx(wn,{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=pr(),[r,n]=k.useState([]),[a,o]=k.useState(!0);k.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(j=>j.id),f=new Map(c.map(j=>[j.id,j])),{data:g,error:b}=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(b)throw b;const _=(g||[]).map(j=>({id:j.id,slug:j.slug,property_address:j.property_address,city:j.city,price:j.price,property_type:j.property_type,agent_id:j.agent_id,agent:f.get(j.agent_id)||null,photos:j.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(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-5 w-5"}),"Brokerage Listings"]})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-4",children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Sn,{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(Re,{children:[r.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Sn,{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(Sn,{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(an,{className:"h-3 w-3 ml-1"})]})]})]})}function s1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Rs(),n=pr(),[a,o]=k.useState(!0),[l,i]=k.useState(null),[c,u]=k.useState(""),[p,f]=k.useState(0),[g,b]=k.useState(!1),[_,j]=k.useState(!1);return k.useEffect(()=>{(async()=>{if(t)try{const{data:N}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(N!=null&&N.brokerage_id)){o(!1);return}i(N.brokerage_id);const{data:C}=await H.from("brokerages").select("name").eq("id",N.brokerage_id).maybeSingle();C&&u(C.name);const{count:M}=await H.from("profiles").select("id",{count:"exact",head:!0}).eq("brokerage_id",N.brokerage_id);if(f(M||0),s)b(!0),j(!0);else if(r){const{data:I}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",N.brokerage_id).maybeSingle();b(!!I),j(!!I)}}catch(N){console.error("Error fetching brokerage info:",N)}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(mr,{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(kh,{className:"h-4 w-4 mr-2"}),"Brokerage Content"]}),e.jsxs(K,{onClick:()=>n(`/mission-control/listings/new?brokerage=${l}`),children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Add Listing"]})]})]}),e.jsx(Xvs,{brokerageId:l,canManage:g}),e.jsx(Qvs,{brokerageId:l}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsx(e1s,{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(wa,{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 r1s(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 n1s(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 LFe={video:{icon:rl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:En,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:cl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:cn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:sc,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function a1s({item:t,canManage:s}){const[r,n]=k.useState(!1),[a,o]=k.useState(null),l=pLt(),i=pr(),c=LFe[t.content_type]||LFe.link,u=c.icon,p=k.useMemo(()=>t.thumbnail_url?t.thumbnail_url:t.content_type==="graphic"&&t.file_url?t.file_url:t.content_type==="video"?r1s(t.url):null,[t]);k.useEffect(()=>{p||!t.url||t.content_type!=="video"||!n1s(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}`)},b=async()=>{try{await l.mutateAsync(t.id),he.success("Content deleted")}catch{he.error("Failed to delete")}n(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{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(Re,{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(tt,{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(tt,{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:["📅 ",ps(new Date(t.event_date),"MMM d, yyyy · h:mm a")]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground mt-2",children:["Added ",ps(new Date(t.created_at),"MMM d, yyyy")]})]}),s&&e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,onClick:_=>_.stopPropagation(),children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsx(zd,{align:"end",children:e.jsxs(Ca,{onClick:_=>{_.stopPropagation(),n(!0)},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})})]})]})})]}),e.jsx(_c,{open:r,onOpenChange:n,children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Content"}),e.jsxs(Jl,{children:['Are you sure you want to delete "',t.title,'"? This cannot be undone.']})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:b,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function i1s(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 DFe=[{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 o1s({brokerageId:t,categories:s}){var fe;const{user:r}=Rs(),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState("📁"),[f,g]=k.useState(!1);k.useRef(null);const[b,_]=k.useState("video"),[j,w]=k.useState(""),[N,C]=k.useState(""),[M,I]=k.useState(""),[L,R]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,J]=k.useState(""),te=mLt(),X=fLt(t),ce=xLt(),ne=gLt(t),re=()=>{_("video"),w(""),C(""),I(""),R(""),U(""),V(""),J("")},le=async(we,Ie)=>{var Ae;const Ne=(Ae=we.target.files)==null?void 0:Ae[0];if(Ne){g(!0);try{const Fe=Ne.name.split(".").pop(),Ce=`${t}/${Date.now()}-${Math.random().toString(36).slice(2)}.${Fe}`,{error:Me}=await H.storage.from("brokerage-content").upload(Ce,Ne);if(Me)throw Me;const{data:{publicUrl:$e}}=H.storage.from("brokerage-content").getPublicUrl(Ce);Ie==="file"?(R($e),b==="graphic"&&!q&&U($e)):U($e),he.success("File uploaded")}catch(Fe){he.error(Fe.message||"Upload failed")}finally{g(!1)}}},pe=async()=>{if(!j.trim()){he.error("Title is required");return}if(r)try{await te.mutateAsync({brokerage_id:t,category_id:Y||null,content_type:b,title:j.trim(),description:N.trim()||null,url:M.trim()||null,file_url:L.trim()||null,thumbnail_url:q.trim()||null,event_date:B?new Date(B).toISOString():null,created_by:r.id}),he.success("Content added!"),re(),a(!1)}catch(we){he.error(we.message||"Failed to add content")}},xe=async()=>{if(i.trim())try{await X.mutateAsync({name:i.trim(),icon:u,sort_order:s.length}),c(""),p("📁"),he.success("Category created")}catch(we){he.error(we.message||"Failed to create category")}},_e=async()=>{try{await ne.mutateAsync(),he.success("Default categories created")}catch{he.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(_s,{children:e.jsx(bs,{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(ye,{children:"Content Type"}),e.jsxs(Ys,{value:b,onValueChange:_,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:DFe.map(we=>e.jsx(Mt,{value:we.value,children:we.label},we.value))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(fe=DFe.find(we=>we.value===b))==null?void 0:fe.hint})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Category"}),e.jsxs(Ys,{value:Y,onValueChange:J,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select category (optional)"})}),e.jsx(Ks,{children:s.map(we=>e.jsxs(Mt,{value:we.id,children:[we.icon," ",we.name]},we.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Title *"}),e.jsx(ze,{value:j,onChange:we=>w(we.target.value),placeholder:"Content title"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:N,onChange:we=>C(we.target.value),placeholder:"Brief description...",rows:2})]}),["video","link","graphic","event"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:b==="video"?"Video URL":b==="graphic"?"Canva / Image URL":b==="event"?"Event Link (Zoom, etc.)":"URL"}),e.jsx(ze,{value:M,onChange:we=>{const Ie=we.target.value;if(I(Ie),b==="video"&&!q){const Ne=i1s(Ie);Ne&&U(Ne)}},placeholder:"https://..."})]}),["pdf","graphic"].includes(b)&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:b==="pdf"?"Upload PDF":"Upload Image"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"file",accept:b==="pdf"?".pdf,.doc,.docx":"image/*",onChange:we=>le(we,"file"),disabled:f}),f&&e.jsx(ws,{className:"h-4 w-4 animate-spin"})]}),L&&e.jsx("p",{className:"text-xs text-green-600",children:"✓ File uploaded"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Thumbnail Image (optional)"}),e.jsx(ze,{type:"file",accept:"image/*",onChange:we=>le(we,"thumbnail"),disabled:f}),q&&e.jsxs("div",{className:"relative w-20 h-20 rounded overflow-hidden",children:[e.jsx("img",{src:q,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(Or,{className:"h-3 w-3"})})]})]}),b==="event"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Event Date & Time"}),e.jsx(ze,{type:"datetime-local",value:B,onChange:we=>V(we.target.value)})]}),e.jsxs(K,{onClick:pe,disabled:te.isPending||!j.trim(),className:"w-full",children:[te.isPending?e.jsx(ws,{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(Yo,{className:"h-4 w-4 mr-2"}),"Categories"]})}),e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{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:_e,disabled:ne.isPending,children:[ne.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Default Categories"]})]}),s.map(we=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg border",children:[e.jsxs("span",{className:"text-sm",children:[we.icon," ",we.name]}),!we.is_default&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:async()=>{await ce.mutateAsync(we.id),he.success("Category deleted")},children:e.jsx(Or,{className:"h-4 w-4"})})]},we.id)),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",children:[e.jsx(ze,{value:u,onChange:we=>p(we.target.value),className:"w-14 text-center",maxLength:2}),e.jsx(ze,{value:i,onChange:we=>c(we.target.value),placeholder:"New category name",className:"flex-1",onKeyDown:we=>we.key==="Enter"&&xe()}),e.jsx(K,{size:"sm",onClick:xe,disabled:!i.trim(),children:"Add"})]})]})]})]})]})}function l1s(){const{user:t,isAdmin:s,isBrokerageManager:r}=Rs(),[n,a]=k.useState(!0),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState("");k.useEffect(()=>{(async()=>{if(t)try{const{data:I}=await H.from("profiles").select("brokerage_id").eq("id",t.id).maybeSingle();if(!(I!=null&&I.brokerage_id)){a(!1);return}l(I.brokerage_id);const{data:L}=await H.from("brokerages").select("name").eq("id",I.brokerage_id).maybeSingle();if(L&&c(L.name),s)p(!0);else if(r){const{data:R}=await H.from("brokerage_manager_assignments").select("id").eq("user_id",t.id).eq("brokerage_id",I.brokerage_id).maybeSingle();p(!!R)}}catch(I){console.error("Error fetching brokerage info:",I)}finally{a(!1)}})()},[t,s,r]);const{data:j=[]}=dLt(o),{data:w=[],isLoading:N}=uLt(o,f),C=k.useMemo(()=>{if(!b.trim())return w;const M=b.toLowerCase();return w.filter(I=>{var L;return I.title.toLowerCase().includes(M)||((L=I.description)==null?void 0:L.toLowerCase().includes(M))||I.content_type.toLowerCase().includes(M)})},[w,b]);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(o1s,{brokerageId:o,categories:j}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(hn,{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:b,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"}),j.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))]})]}),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"})}):C.length===0?e.jsx(Pe,{className:"bg-muted/30 border-dashed",children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Lm,{className:"h-12 w-12 text-muted-foreground/50 mb-3"}),e.jsx("p",{className:"text-muted-foreground font-medium",children:b.trim()?"No matching content found":"No content yet"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:b.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:C.map(M=>e.jsx(a1s,{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(wa,{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 OFe={video:{icon:rl,label:"Video",color:"bg-red-500/10 text-red-600 dark:text-red-400"},pdf:{icon:En,label:"Document",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},link:{icon:cl,label:"Link",color:"bg-green-500/10 text-green-600 dark:text-green-400"},event:{icon:cn,label:"Event",color:"bg-purple-500/10 text-purple-600 dark:text-purple-400"},graphic:{icon:sc,label:"Graphic",color:"bg-amber-500/10 text-amber-600 dark:text-amber-400"}};function c1s(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 d1s(t){try{const s=new URL(t).hostname.replace("www.","");return["youtube.com","youtu.be","m.youtube.com"].includes(s)}catch{return!1}}function u1s(t){try{return new URL(t).hostname.includes("vimeo.com")}catch{return!1}}function h1s(t){try{const s=t.match(/vimeo\.com\/(\d+)/);if(s)return`https://player.vimeo.com/video/${s[1]}`}catch{}return null}function m1s(){const{contentId:t}=yo(),{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(wa,{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(Ei,{to:"/brokerage-content",children:"Back to Content"})})]})});const n=OFe[s.content_type]||OFe.link,a=n.icon,o=s.url||s.file_url,l=o&&d1s(o)?c1s(o):null,i=o&&u1s(o)?h1s(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(Ei,{to:"/brokerage-content",children:[e.jsx(ri,{className:"h-4 w-4"}),"Back to Content"]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tt,{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(tt,{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 ",ps(new Date(s.created_at),"MMMM d, yyyy")]})]}),e.jsx("h1",{className:"text-2xl font-bold text-foreground",children:s.title}),c&&e.jsx(Pe,{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(Pe,{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(Pe,{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(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"pt-6 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-md bg-primary/10",children:e.jsx(cn,{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:ps(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(Ci,{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(an,{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 p1s(){const t=pr(),[s,r]=k.useState(""),[n,a]=k.useState("grid"),{data:o,isLoading:l}=mt({queryKey:["newsletters"],queryFn:async()=>{const{data:M,error:I}=await H.from("newsletter_content").select("*").eq("is_published",!0).order("publish_date",{ascending:!1});if(I)throw I;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,I,L,R]=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:I.data||[],videos:L.data||[],drives:R.data||[]}}}),p=M=>(i==null?void 0:i.filter(I=>I.newsletter_id===M).length)||0,f=M=>(c==null?void 0:c.filter(I=>I.newsletter_id===M).length)||0,g=M=>{var I;return((I=u==null?void 0:u.canva)==null?void 0:I.filter(L=>L.newsletter_id===M).length)||0},b=M=>{var I;return((I=u==null?void 0:u.pdfs)==null?void 0:I.filter(L=>L.newsletter_id===M).length)||0},_=M=>{var I;return((I=u==null?void 0:u.videos)==null?void 0:I.filter(L=>L.newsletter_id===M).length)||0},j=M=>{var I;return((I=u==null?void 0:u.drives)==null?void 0:I.filter(L=>L.newsletter_id===M).length)||0},w=M=>g(M)+b(M)+_(M)+j(M),N=o==null?void 0:o.filter(M=>{var I;return M.title.toLowerCase().includes(s.toLowerCase())||((I=M.description)==null?void 0:I.toLowerCase().includes(s.toLowerCase()))}),C=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(hn,{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(Ch,{className:"h-4 w-4"})})]})]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[(N==null?void 0:N.length)||0," item",(N==null?void 0:N.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,I)=>e.jsx(Pe,{children:e.jsxs(Re,{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"})]})]})},I))}),!l&&(N==null?void 0:N.length)===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx(En,{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&&N&&N.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:N.map(M=>{const I=w(M.id),L=g(M.id),R=b(M.id),q=_(M.id);return n==="grid"?e.jsxs(Pe,{className:"group overflow-hidden hover:shadow-lg transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(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(En,{className:"h-16 w-16"})})}),e.jsxs(Re,{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(cn,{className:"h-3 w-3"}),ps(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,"")}),I>0&&e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[L>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(sc,{className:"h-3 w-3"})," ",L," Template",L>1?"s":""]}),R>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(Ci,{className:"h-3 w-3"})," ",R," PDF",R>1?"s":""]}),q>0&&e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1 font-normal",children:[e.jsx(rl,{className:"h-3 w-3"})," ",q," Video",q>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(eh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]},M.id):e.jsx(Pe,{className:"group overflow-hidden hover:shadow-md transition-all duration-200 cursor-pointer border-border/50",onClick:()=>C(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(En,{className:"h-10 w-10"})})}),e.jsxs(Re,{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(cn,{className:"h-3 w-3"}),ps(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:[I>0&&e.jsxs("span",{children:[I," resource",I>1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(eh,{className:"h-3 w-3"})," ",p(M.id)]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{className:"h-3 w-3"})," ",f(M.id)]})]})]})]})},M.id)})})]})})}function f1s({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(Pe,{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(Re,{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 x1s(){const{id:t}=yo(),s=pr(),{user:r}=Rs(),{toast:n}=qa(),a=es(),{trackEngagement:o}=UO(),[l,i]=k.useState(""),{data:c,isLoading:u}=mt({queryKey:["newsletter",t],queryFn:async()=>{const{data:L,error:R}=await H.from("newsletter_content").select("*").eq("id",t).single();if(R)throw R;return L},enabled:!!t});k.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:L}=await H.from("newsletter_drive_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:f}=mt({queryKey:["newsletter-pdfs",t],queryFn:async()=>{const{data:L}=await H.from("newsletter_pdfs").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:g}=mt({queryKey:["newsletter-videos",t],queryFn:async()=>{const{data:L}=await H.from("newsletter_videos").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:b}=mt({queryKey:["newsletter-canva-links",t],queryFn:async()=>{const{data:L}=await H.from("newsletter_canva_links").select("*").eq("newsletter_id",t).order("sort_order");return L||[]},enabled:!!t}),{data:_}=mt({queryKey:["newsletter-likes",t],queryFn:async()=>{const{data:L}=await H.from("newsletter_likes").select("*").eq("newsletter_id",t);return L||[]},enabled:!!t}),{data:j}=mt({queryKey:["newsletter-comments",t],queryFn:async()=>{const{data:L}=await H.from("newsletter_comments").select("*, profiles:user_id(name)").eq("newsletter_id",t).order("created_at",{ascending:!1});return L||[]},enabled:!!t}),w=_==null?void 0:_.some(L=>L.user_id===(r==null?void 0:r.id)),N=Lt({mutationFn:async()=>{w?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]})}}),C=Lt({mutationFn:async L=>{const{error:R}=await H.from("newsletter_comments").insert({newsletter_id:t,user_id:r==null?void 0:r.id,content:L});if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),i(""),n({title:"Comment added"})}}),M=Lt({mutationFn:async L=>{const{error:R}=await H.from("newsletter_comments").delete().eq("id",L);if(R)throw R},onSuccess:()=>{a.invalidateQueries({queryKey:["newsletter-comments",t]}),n({title:"Comment deleted"})}}),I=L=>{if(L.includes("player.mediadelivery.net")||L.includes("iframe.mediadelivery.net")){const R=L.match(/embed\/(\d+)\/([a-f0-9-]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://iframe.mediadelivery.net/embed/${R[1]}/${R[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(L.includes("youtube.com")||L.includes("youtu.be")){const R=L.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([^&\s]+)/);if(R)return e.jsx("div",{className:"relative w-full pt-[56.25%]",children:e.jsx("iframe",{src:`https://www.youtube.com/embed/${R[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:L,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 text-primary hover:underline",children:[e.jsx(rl,{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(ri,{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:ps(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(f1s,{rows:c.content_blocks||[]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(aE,{resourceType:"newsletter",resourceId:c.id,resourceTitle:c.title}),e.jsxs(K,{variant:w?"default":"outline",size:"sm",onClick:()=>N.mutate(),children:[e.jsx(ii,{className:`h-4 w-4 mr-1 ${w?"fill-current":""}`}),(_==null?void 0:_.length)||0," ",(_==null?void 0:_.length)===1?"Like":"Likes"]})]}),b&&b.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Canva Templates"})}),e.jsx(Re,{className:"space-y-2",children:b.map(L=>e.jsxs("a",{href:L.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(sc,{className:"h-5 w-5 text-purple-500"}),e.jsx("span",{className:"font-medium",children:L.title}),e.jsx(an,{className:"h-4 w-4 text-muted-foreground ml-auto"})]},L.id))})]}),p&&p.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Google Drive Files"})}),e.jsx(Re,{className:"space-y-2",children:p.map(L=>e.jsxs("a",{href:L.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(an,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:L.title})]},L.id))})]}),f&&f.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"PDF Downloads"})}),e.jsx(Re,{className:"space-y-2",children:f.map(L=>e.jsxs("a",{href:L.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(En,{className:"h-5 w-5 text-red-500"}),e.jsx("span",{className:"font-medium flex-1",children:L.name}),e.jsx(Ci,{className:"h-4 w-4 text-muted-foreground"})]},L.id))})]}),g&&g.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Videos"})}),e.jsx(Re,{className:"space-y-6",children:g.map(L=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"font-medium",children:L.title}),I(L.video_url)]},L.id))})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg",children:["Comments (",(j==null?void 0:j.length)||0,")"]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(Er,{placeholder:"Write a comment...",value:l,onChange:L=>i(L.target.value),className:"flex-1"}),e.jsx(K,{onClick:()=>l.trim()&&C.mutate(l),disabled:!l.trim()||C.isPending,children:e.jsx(Rn,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"space-y-4",children:j==null?void 0:j.map(L=>{var R,q,U;return e.jsxs("div",{className:"flex gap-3",children:[e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{children:((q=(R=L.profiles)==null?void 0:R.name)==null?void 0:q[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=L.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:ps(new Date(L.created_at),"MMM d, yyyy")}),L.user_id===(r==null?void 0:r.id)&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>M.mutate(L.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:L.content})]})]},L.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 g1s({rows:t,onChange:s}){const[r,n]=k.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 b=[...t];b[u]={...b[u],columns:b[u].columns.map((_,j)=>j===p?{..._,[f]:g}:_)},s(b)},i=async(u,p,f)=>{var _;const g=(_=f.target.files)==null?void 0:_[0];if(!g)return;const b=`${u}-${p}`;n(b);try{const j=`content-blocks/${Date.now()}-${g.name}`,{error:w}=await H.storage.from("newsletter-content").upload(j,g);if(!w){const{data:N}=H.storage.from("newsletter-content").getPublicUrl(j);l(u,p,"image_url",N.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(ye,{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(Pe,{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(Or,{className:"h-4 w-4"})}),e.jsxs(Re,{className:"p-4 pt-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ju,{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 b=`${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(Or,{className:"h-3 w-3"})})]}):e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",className:"hidden",id:`block-img-${b}`,onChange:_=>i(p,g,_)}),e.jsx(K,{type:"button",variant:"outline",size:"sm",className:"w-full text-xs h-8",disabled:r===b,asChild:!0,children:e.jsx("label",{htmlFor:`block-img-${b}`,className:"cursor-pointer",children:r===b?"Uploading...":e.jsxs(e.Fragment,{children:[e.jsx(fl,{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(Er,{placeholder:"Description",value:f.description,onChange:_=>l(p,g,"description",_.target.value),className:"text-sm min-h-[60px] resize-none"})]},g)})})]})]},p))]})}function y1s(){const{toast:t}=qa(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(null),[l,i]=k.useState({title:"",description:"",publish_date:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),[c,u]=k.useState(null),[p,f]=k.useState(null),[g,b]=k.useState([]),[_,j]=k.useState([]),[w,N]=k.useState([]),[C,M]=k.useState([]),[I,L]=k.useState([]),[R,q]=k.useState([]),[U,B]=k.useState(!1),{data:V,isLoading:Y}=mt({queryKey:["admin-newsletters"],queryFn:async()=>{const{data:Ne,error:Ae}=await H.from("newsletter_content").select("*").order("publish_date",{ascending:!1});if(Ae)throw Ae;return Ne}}),J=Lt({mutationFn:async Ne=>{const{data:Ae,error:Fe}=await H.from("newsletter_content").insert({title:Ne.title,description:Ne.description||null,preview_image_url:Ne.preview_image_url,publish_date:Ne.publish_date,is_published:Ne.is_published,content_blocks:Ne.content_blocks}).select().single();if(Fe)throw Fe;return Ae},onSuccess:async Ne=>{await ce(Ne.id),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter created successfully"}),Ne.is_published&&sVt(Ne.title,Ne.id),le()},onError:Ne=>{t({title:"Error creating newsletter",description:Ne.message,variant:"destructive"})}}),te=Lt({mutationFn:async Ne=>{const{error:Ae}=await H.from("newsletter_content").update({title:Ne.title,description:Ne.description||null,preview_image_url:Ne.preview_image_url,publish_date:Ne.publish_date,is_published:Ne.is_published,content_blocks:Ne.content_blocks}).eq("id",Ne.id);if(Ae)throw Ae;return Ne.id},onSuccess:async Ne=>{await ce(Ne),s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter updated successfully"}),le()},onError:Ne=>{t({title:"Error updating newsletter",description:Ne.message,variant:"destructive"})}}),X=Lt({mutationFn:async Ne=>{const{error:Ae}=await H.from("newsletter_content").delete().eq("id",Ne);if(Ae)throw Ae},onSuccess:()=>{s.invalidateQueries({queryKey:["admin-newsletters"]}),t({title:"Newsletter deleted successfully"})},onError:Ne=>{t({title:"Error deleting newsletter",description:Ne.message,variant:"destructive"})}}),ce=async Ne=>{await H.from("newsletter_drive_links").delete().eq("newsletter_id",Ne),await H.from("newsletter_pdfs").delete().eq("newsletter_id",Ne),await H.from("newsletter_videos").delete().eq("newsletter_id",Ne),await H.from("newsletter_canva_links").delete().eq("newsletter_id",Ne);for(const Ae of R){const Fe=`${Ne}/${Date.now()}-${Ae.file.name}`,{error:Ce}=await H.storage.from("newsletter-content").upload(Fe,Ae.file);if(!Ce){const{data:Me}=H.storage.from("newsletter-content").getPublicUrl(Fe);_.push({name:Ae.name,file_url:Me.publicUrl,file_size:Ae.file.size,sort_order:_.length})}}g.length>0&&await H.from("newsletter_drive_links").insert(g.map((Ae,Fe)=>({newsletter_id:Ne,title:Ae.title,drive_url:Ae.drive_url,sort_order:Fe}))),_.length>0&&await H.from("newsletter_pdfs").insert(_.map((Ae,Fe)=>({newsletter_id:Ne,name:Ae.name,file_url:Ae.file_url,file_size:Ae.file_size||null,sort_order:Fe}))),w.length>0&&await H.from("newsletter_videos").insert(w.map((Ae,Fe)=>({newsletter_id:Ne,title:Ae.title,video_url:Ae.video_url,sort_order:Fe}))),C.length>0&&await H.from("newsletter_canva_links").insert(C.map((Ae,Fe)=>({newsletter_id:Ne,title:Ae.title,canva_share_link:Ae.canva_share_link,sort_order:Fe})))},ne=async Ne=>{o(Ne),i({title:Ne.title,description:Ne.description||"",publish_date:ps(new Date(Ne.publish_date),"yyyy-MM-dd'T'HH:mm"),is_published:Ne.is_published}),f(Ne.preview_image_url),L(Ne.content_blocks||[]);const[Ae,Fe,Ce,Me]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Ne.id).order("sort_order")]);b(Ae.data||[]),j(Fe.data||[]),N(Ce.data||[]),M(Me.data||[]),q([]),n(!0)},re=async Ne=>{const[Ae,Fe,Ce,Me]=await Promise.all([H.from("newsletter_drive_links").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_pdfs").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_videos").select("*").eq("newsletter_id",Ne.id).order("sort_order"),H.from("newsletter_canva_links").select("*").eq("newsletter_id",Ne.id).order("sort_order")]);o(null),i({title:`${Ne.title} (Copy)`,description:Ne.description||"",publish_date:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),f(Ne.preview_image_url),L(Ne.content_blocks||[]),b((Ae.data||[]).map(({id:$e,...ct})=>ct)),j((Fe.data||[]).map(({id:$e,...ct})=>ct)),N((Ce.data||[]).map(({id:$e,...ct})=>ct)),M((Me.data||[]).map(({id:$e,...ct})=>ct)),q([]),n(!0)},le=()=>{n(!1),o(null),i({title:"",description:"",publish_date:ps(new Date,"yyyy-MM-dd'T'HH:mm"),is_published:!1}),u(null),f(null),b([]),j([]),N([]),M([]),L([]),q([])},pe=async Ne=>{var Fe;const Ae=(Fe=Ne.target.files)==null?void 0:Fe[0];Ae&&(u(Ae),f(URL.createObjectURL(Ae)))},xe=async()=>{if(!l.title){t({title:"Title is required",variant:"destructive"});return}B(!0);let Ne=p;if(c){const Ae=`previews/${Date.now()}-${c.name}`,{error:Fe}=await H.storage.from("newsletter-content").upload(Ae,c);if(!Fe){const{data:Ce}=H.storage.from("newsletter-content").getPublicUrl(Ae);Ne=Ce.publicUrl}}a?te.mutate({id:a.id,...l,preview_image_url:Ne,content_blocks:I}):J.mutate({...l,preview_image_url:Ne,content_blocks:I}),B(!1)},_e=()=>b([...g,{title:"",drive_url:"",sort_order:g.length}]),fe=()=>N([...w,{title:"",video_url:"",sort_order:w.length}]),we=()=>M([...C,{title:"",canva_share_link:"",sort_order:C.length}]),Ie=Ne=>{const Ae=Ne.target.files;if(!Ae)return;const Fe=Array.from(Ae).map(Ce=>({file:Ce,name:Ce.name.replace(/\.[^/.]+$/,"")}));q([...R,...Fe])};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(ah,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.length)||0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(V==null?void 0:V.filter(Ne=>Ne.is_published).length)||0})})]})]}),e.jsxs(xs,{open:r,onOpenChange:Ne=>!Ne&&le(),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(_s,{children:e.jsx(bs,{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(ye,{children:"Title *"}),e.jsx(ze,{value:l.title,onChange:Ne=>i({...l,title:Ne.target.value}),placeholder:"Newsletter title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Publish Date"}),e.jsx(ze,{type:"datetime-local",value:l.publish_date,onChange:Ne=>i({...l,publish_date:Ne.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:l.description,onChange:Ne=>i({...l,description:Ne}),placeholder:"Newsletter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Or,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:"image/*",onChange:pe,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(oi,{className:"mr-2 h-4 w-4"})," Upload Image"]})})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{checked:l.is_published,onCheckedChange:Ne=>i({...l,is_published:Ne})}),e.jsx(ye,{children:"Published"})]}),e.jsx(g1s,{rows:I,onChange:L}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Canva Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:we,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Canva Link"]})]}),C.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ne.title,onChange:Fe=>{const Ce=[...C];Ce[Ae].title=Fe.target.value,M(Ce)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Canva share link",value:Ne.canva_share_link,onChange:Fe=>{const Ce=[...C];Ce[Ae].canva_share_link=Fe.target.value,M(Ce)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>M(C.filter((Fe,Ce)=>Ce!==Ae)),children:e.jsx(Or,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Google Drive Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:_e,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Link"]})]}),g.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Link title",value:Ne.title,onChange:Fe=>{const Ce=[...g];Ce[Ae].title=Fe.target.value,b(Ce)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Google Drive URL",value:Ne.drive_url,onChange:Fe=>{const Ce=[...g];Ce[Ae].drive_url=Fe.target.value,b(Ce)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>b(g.filter((Fe,Ce)=>Ce!==Ae)),children:e.jsx(Or,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"PDF Files"}),e.jsxs("div",{children:[e.jsx(ze,{type:"file",accept:".pdf",multiple:!0,onChange:Ie,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(oi,{className:"mr-1 h-3 w-3"})," Upload PDF"]})})]})]}),_.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"flex-1 text-sm",children:Ne.name}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(_.filter((Fe,Ce)=>Ce!==Ae)),children:e.jsx(Or,{className:"h-4 w-4"})})]},`existing-${Ae}`)),R.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center bg-muted/50 p-2 rounded",children:[e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:Ne.name,onChange:Fe=>{const Ce=[...R];Ce[Ae].name=Fe.target.value,q(Ce)},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:()=>q(R.filter((Fe,Ce)=>Ce!==Ae)),children:e.jsx(Or,{className:"h-4 w-4"})})]},`pending-${Ae}`))]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-base font-medium",children:"Video Links"}),e.jsxs(K,{type:"button",variant:"outline",size:"sm",onClick:fe,children:[e.jsx(qs,{className:"mr-1 h-3 w-3"})," Add Video"]})]}),w.map((Ne,Ae)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(ze,{placeholder:"Video title",value:Ne.title,onChange:Fe=>{const Ce=[...w];Ce[Ae].title=Fe.target.value,N(Ce)},className:"w-1/3"}),e.jsx(ze,{placeholder:"Video URL",value:Ne.video_url,onChange:Fe=>{const Ce=[...w];Ce[Ae].video_url=Fe.target.value,N(Ce)},className:"flex-1"}),e.jsx(K,{type:"button",variant:"ghost",size:"icon",onClick:()=>N(w.filter((Fe,Ce)=>Ce!==Ae)),children:e.jsx(Or,{className:"h-4 w-4"})})]},Ae))]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsx(K,{variant:"outline",onClick:le,children:"Cancel"}),e.jsx(K,{onClick:xe,disabled:U||J.isPending||te.isPending,children:U?"Uploading...":a?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:Y?e.jsx(Ss,{children:e.jsx(dt,{colSpan:4,className:"text-center py-8",children:"Loading..."})}):(V==null?void 0:V.length)===0?e.jsx(Ss,{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(Ne=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ne.preview_image_url?e.jsx("img",{src:Ne.preview_image_url,alt:Ne.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(En,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Ne.title}),Ne.description&&e.jsx("div",{className:"text-sm text-muted-foreground line-clamp-1",children:Ne.description.replace(/<[^>]*>/g,"")})]})]})}),e.jsx(dt,{children:ps(new Date(Ne.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 ${Ne.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:Ne.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(Ne),title:"Edit",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>re(Ne),title:"Duplicate",children:e.jsx(gi,{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?")&&X.mutate(Ne.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},Ne.id))})]})})})]})})}const RFe={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 v1s(){const{user:t}=Rs(),{toast:s}=qa(),r=pr(),n=es(),[a,o]=k.useState(""),[l,i]=k.useState("popular"),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(!1),{data:w=[],isLoading:N}=mt({queryKey:["wishlist-items",l,_],queryFn:async()=>{let R=H.from("wishlist_items").select("*");_&&t&&(R=R.eq("user_id",t.id)),l==="latest"?R=R.order("created_at",{ascending:!1}):l==="popular"?R=R.order("vote_count",{ascending:!1}):l==="trending"&&(R=R.order("vote_count",{ascending:!1}));const{data:q,error:U}=await R;if(U)throw U;const B=[...new Set((q==null?void 0:q.map(ne=>ne.user_id))||[])],{data:V}=await H.from("profiles").select("id, name").in("id",B),Y=new Map((V==null?void 0:V.map(ne=>[ne.id,ne]))||[]);let J=[];if(t){const{data:ne}=await H.from("wishlist_votes").select("item_id").eq("user_id",t.id);J=(ne==null?void 0:ne.map(re=>re.item_id))||[]}const te=(q==null?void 0:q.map(ne=>ne.id))||[],{data:X}=await H.from("wishlist_comments").select("item_id").in("item_id",te),ce=new Map;return X==null||X.forEach(ne=>{ce.set(ne.item_id,(ce.get(ne.item_id)||0)+1)}),q==null?void 0:q.map(ne=>{const re=Y.get(ne.user_id),le=(re==null?void 0:re.name)||"Unknown";return{...ne,user_name:le,user_initials:le.split(" ").map(pe=>pe[0]).join("").toUpperCase().slice(0,2),has_voted:J.includes(ne.id),comment_count:ce.get(ne.id)||0}})}}),C=Lt({mutationFn:async({title:R,description:q})=>{const{error:U}=await H.from("wishlist_items").insert({user_id:t.id,title:R,description:q});if(U)throw U},onSuccess:()=>{n.invalidateQueries({queryKey:["wishlist-items"]}),u(!1),f(""),b(""),s({title:"Idea submitted!",description:"Your idea has been added to the wishlist."})},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),M=Lt({mutationFn:async({itemId:R,hasVoted:q})=>{if(q){const{error:U}=await H.from("wishlist_votes").delete().eq("item_id",R).eq("user_id",t.id);if(U)throw U;return{itemId:R,wasAdded:!1}}else{const{error:U}=await H.from("wishlist_votes").insert({item_id:R,user_id:t.id});if(U)throw U;return{itemId:R,wasAdded:!0}}},onSuccess:async R=>{if(n.invalidateQueries({queryKey:["wishlist-items"]}),R!=null&&R.wasAdded){const q=w.find(B=>B.id===R.itemId),U=((q==null?void 0:q.vote_count)||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:R.itemId,voteCount:U}}).catch(console.error)}},onError:R=>{s({title:"Error",description:R.message,variant:"destructive"})}}),I=w.filter(R=>R.title.toLowerCase().includes(a.toLowerCase())||R.description.toLowerCase().includes(a.toLowerCase())),L=()=>{if(!p.trim()||!g.trim()){s({title:"Error",description:"Please fill in both title and description.",variant:"destructive"});return}C.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(B_,{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(_s,{children:e.jsx(bs,{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(ye,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",placeholder:"Give your idea a clear title...",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",placeholder:"Describe your idea in detail. What problem does it solve? How would it help agents?",value:g,onChange:R=>b(R.target.value),rows:4})]}),e.jsx(K,{onClick:L,className:"w-full",disabled:C.isPending,children:C.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{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(hn,{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:R=>o(R.target.value),className:"pl-10"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ja,{value:l,onValueChange:R=>i(R),children:e.jsxs(ga,{children:[e.jsx(us,{value:"popular",children:"Most Popular"}),e.jsx(us,{value:"latest",children:"Latest"}),e.jsx(us,{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:()=>j(!_),children:_?"Show All Ideas":"My Ideas"})}),N?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):I.length===0?e.jsxs("div",{className:"text-center py-12 bg-muted/30 rounded-lg",children:[e.jsx(B_,{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:I.map(R=>e.jsx("div",{className:"bg-card border rounded-lg p-4 hover:shadow-md transition-shadow cursor-pointer",onClick:()=>r(`/wishlist/${R.id}`),children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("button",{onClick:q=>{q.stopPropagation(),M.mutate({itemId:R.id,hasVoted:R.has_voted||!1})},className:Pt("flex flex-col items-center justify-center min-w-[50px] py-2 px-3 rounded-lg border transition-colors",R.has_voted?"bg-primary/10 border-primary text-primary":"bg-muted/50 border-border hover:bg-muted"),children:[e.jsx(Nu,{className:Pt("h-4 w-4",R.has_voted&&"fill-current")}),e.jsx("span",{className:"text-sm font-semibold",children:R.vote_count})]}),e.jsx(_n,{className:"h-10 w-10 bg-primary/20",children:e.jsx(wn,{className:"bg-primary/20 text-primary text-sm font-medium",children:R.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:R.title}),e.jsx(tt,{className:Pt("text-xs",RFe[R.status].color),children:RFe[R.status].label})]}),e.jsx("p",{className:"text-muted-foreground text-sm line-clamp-2",children:R.description}),e.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:R.user_name}),e.jsx("span",{children:"•"}),e.jsx("span",{children:new Date(R.created_at).toLocaleDateString()})]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(io,{className:"h-4 w-4"}),e.jsx("span",{className:"text-sm",children:R.comment_count})]})]})},R.id))})]})})}const FFe={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 b1s(){const{itemId:t}=yo(),s=pr(),{user:r}=Rs(),{toast:n}=qa(),a=es(),[o,l]=k.useState(""),{data:i=!1}=mt({queryKey:["user-is-admin",r==null?void 0:r.id],queryFn:async()=>{if(!r)return!1;const{data:w,error:N}=await H.from("user_roles").select("role").eq("user_id",r.id).eq("role","admin").maybeSingle();return!N&&!!w},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["wishlist-item",t],queryFn:async()=>{const{data:w,error:N}=await H.from("wishlist_items").select("*").eq("id",t).single();if(N)throw N;const{data:C}=await H.from("profiles").select("name").eq("id",w.user_id).single();let M=!1;if(r){const{data:I}=await H.from("wishlist_votes").select("id").eq("item_id",t).eq("user_id",r.id).maybeSingle();M=!!I}return{...w,user_name:(C==null?void 0:C.name)||"Unknown",user_initials:((C==null?void 0:C.name)||"U").split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),has_voted:M}}}),{data:p=[],isLoading:f}=mt({queryKey:["wishlist-comments",t],queryFn:async()=>{const{data:w,error:N}=await H.from("wishlist_comments").select("*").eq("item_id",t).order("created_at",{ascending:!0});if(N)throw N;const C=[...new Set((w==null?void 0:w.map(L=>L.user_id))||[])],{data:M}=await H.from("profiles").select("id, name").in("id",C),I=new Map((M==null?void 0:M.map(L=>[L.id,L]))||[]);return w==null?void 0:w.map(L=>{const R=I.get(L.user_id),q=(R==null?void 0:R.name)||"Unknown";return{...L,user_name:q,user_initials:q.split(" ").map(U=>U[0]).join("").toUpperCase().slice(0,2)}})}}),g=Lt({mutationFn:async w=>{if(w){const{error:N}=await H.from("wishlist_votes").delete().eq("item_id",t).eq("user_id",r.id);if(N)throw N;return{wasAdded:!1}}else{const{error:N}=await H.from("wishlist_votes").insert({item_id:t,user_id:r.id});if(N)throw N;return{wasAdded:!0}}},onSuccess:async w=>{if(a.invalidateQueries({queryKey:["wishlist-item",t]}),a.invalidateQueries({queryKey:["wishlist-items"]}),w!=null&&w.wasAdded&&c){const N=(c.vote_count||0)+1;H.functions.invoke("wishlist-notify",{body:{itemId:t,voteCount:N}}).catch(console.error)}},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),b=Lt({mutationFn:async w=>{const{error:N}=await H.from("wishlist_comments").insert({item_id:t,user_id:r.id,content:w});if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),l(""),n({title:"Comment added!"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),_=Lt({mutationFn:async w=>{const{error:N}=await H.from("wishlist_comments").delete().eq("id",w);if(N)throw N},onSuccess:()=>{a.invalidateQueries({queryKey:["wishlist-comments",t]}),n({title:"Comment deleted"})},onError:w=>{n({title:"Error",description:w.message,variant:"destructive"})}}),j=()=>{o.trim()&&b.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(ri,{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:Pt("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(Nu,{className:Pt("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(tt,{className:Pt("text-xs",FFe[c.status].color),children:FFe[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(_n,{className:"h-6 w-6",children:e.jsx(wn,{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(Rle,{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:j,disabled:!o.trim()||b.isPending,size:"icon",className:"h-auto",children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"})})]}),f?e.jsx("div",{className:"space-y-4",children:[1,2].map(w=>e.jsx(vs,{className:"h-20 w-full"},w))}):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(w=>e.jsxs("div",{className:"flex gap-3 p-3 bg-muted/30 rounded-lg",children:[e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{className:"bg-primary/20 text-primary text-xs",children:w.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:w.user_name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(w.created_at).toLocaleDateString()})]}),e.jsx(Eke,{content:w.content,className:"text-sm text-foreground"})]}),(r==null?void 0:r.id)===w.user_id&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>_.mutate(w.id),children:e.jsx(Nr,{className:"h-4 w-4"})})]},w.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 zFe={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"}},BFe=["open","under_review","planned","in_progress","launched","declined"];function _1s(){const{toast:t}=qa(),s=pr(),r=es(),[n,a]=k.useState(""),[o,l]=k.useState("all"),[i,c]=k.useState(!1),[u,p]=k.useState(null),{data:f=[],isLoading:g}=mt({queryKey:["admin-wishlist-items"],queryFn:async()=>{const{data:N,error:C}=await H.from("wishlist_items").select("*").order("vote_count",{ascending:!1});if(C)throw C;const M=[...new Set((N==null?void 0:N.map(B=>B.user_id))||[])],{data:I}=await H.from("profiles").select("id, name, email").in("id",M),L=new Map((I==null?void 0:I.map(B=>[B.id,B]))||[]),R=(N==null?void 0:N.map(B=>B.id))||[],{data:q}=await H.from("wishlist_comments").select("item_id").in("item_id",R),U=new Map;return q==null||q.forEach(B=>{U.set(B.item_id,(U.get(B.item_id)||0)+1)}),N==null?void 0:N.map(B=>{const V=L.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}})}}),b=Lt({mutationFn:async({itemId:N,status:C})=>{const{error:M}=await H.from("wishlist_items").update({status:C}).eq("id",N);if(M)throw M},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),t({title:"Status updated!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),_=Lt({mutationFn:async N=>{const{error:C}=await H.from("wishlist_items").delete().eq("id",N);if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-wishlist-items"]}),c(!1),p(null),t({title:"Item deleted!"})},onError:N=>{t({title:"Error",description:N.message,variant:"destructive"})}}),j=f.filter(N=>{const C=N.title.toLowerCase().includes(n.toLowerCase())||N.description.toLowerCase().includes(n.toLowerCase())||N.user_name.toLowerCase().includes(n.toLowerCase()),M=o==="all"||N.status===o;return C&&M}),w={total:f.length,open:f.filter(N=>N.status==="open").length,inProgress:f.filter(N=>N.status==="in_progress").length,launched:f.filter(N=>N.status==="launched").length,highVotes:f.filter(N=>N.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(ri,{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:w.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:w.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:w.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:w.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:w.highVotes})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(hn,{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:N=>a(N.target.value),className:"pl-10"})]}),e.jsxs(Ys,{value:o,onValueChange:N=>l(N),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Filter by status"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),BFe.map(N=>e.jsx(Mt,{value:N,children:zFe[N].label},N))]})]})]}),g?e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(N=>e.jsx(vs,{className:"h-16 w-full"},N))}):e.jsx("div",{className:"bg-card border rounded-lg overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[60px]",children:"Votes"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Submitted By"}),e.jsx(kt,{className:"hidden sm:table-cell",children:"Comments"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-[100px]",children:"Actions"})]})}),e.jsx(On,{children:j.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8 text-muted-foreground",children:"No items found"})}):j.map(N=>e.jsxs(Ss,{className:Pt(N.vote_count>=10&&"bg-primary/5"),children:[e.jsx(dt,{children:e.jsx(tt,{variant:N.vote_count>=10?"default":"secondary",children:N.vote_count})}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium line-clamp-1",children:N.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:N.description})]})}),e.jsx(dt,{className:"hidden md:table-cell",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-sm",children:N.user_name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:N.user_email})]})}),e.jsx(dt,{className:"hidden sm:table-cell",children:N.comment_count}),e.jsx(dt,{children:e.jsxs(Ys,{value:N.status,onValueChange:C=>b.mutate({itemId:N.id,status:C}),children:[e.jsx(Gs,{className:"w-[140px] h-8",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:BFe.map(C=>e.jsx(Mt,{value:C,children:zFe[C].label},C))})]})}),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/${N.id}`,"_blank"),children:e.jsx(an,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>{p(N.id),c(!0)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})})]},N.id))})]})}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Deleting..."]}):"Delete"})]})]})})]})})}function w1s(){const{user:t}=Rs(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState(""),[N,C]=k.useState(""),[M,I]=k.useState(""),[L,R]=k.useState(""),[q,U]=k.useState(!1),[B,V]=k.useState(""),[Y,J]=k.useState("once"),[te,X]=k.useState([]),[ce,ne]=k.useState([]),[re,le]=k.useState(!1),[pe,xe]=k.useState(!1),[_e,fe]=k.useState([]),[we,Ie]=k.useState({total:0,dismissed:0});k.useEffect(()=>{Ne()},[]);const Ne=async()=>{const{data:Ze,error:Je}=await H.from("levelup_briefs").select("*").order("created_at",{ascending:!1});Je?(he.error("Failed to fetch briefs"),console.error(Je)):r(Ze||[]),a(!1)},Ae=()=>{_(""),w(""),C(""),I(""),R(""),U(!1),V(new Date().toISOString().slice(0,16)),J("once"),X([]),ne([]),c(null)},Fe=()=>{Ae(),l(!0)},Ce=async Ze=>{c(Ze),_(Ze.title),w(Ze.description||""),C(Ze.video_url||""),I(Ze.graphic_url||""),R(Ze.graphic_link_url||""),U(Ze.is_published),V(Ze.publish_date.slice(0,16)),J(Ze.show_frequency);const{data:Je}=await H.from("levelup_brief_links").select("*").eq("brief_id",Ze.id).order("sort_order");X((Je==null?void 0:Je.map(Qe=>({title:Qe.title,url:Qe.url})))||[]);const{data:He}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(He){const Qe=[];for(const at of He){const{data:It}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",at.id).order("sort_order");Qe.push({question:at.question,poll_type:at.poll_type,options:(It==null?void 0:It.map(Ut=>Ut.option_text))||[]})}ne(Qe)}l(!0)},Me=async Ze=>{var He;const Je=(He=Ze.target.files)==null?void 0:He[0];if(Je){le(!0);try{const Qe=await H.functions.invoke("bunny-upload",{body:{action:"create",title:Je.name.replace(/\.[^/.]+$/,"")}});if(Qe.error)throw Qe.error;const{videoId:at,libraryId:It}=Qe.data,Ut=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:at}});if(Ut.error)throw Ut.error;const{uploadUrl:hs,apiKey:Yt}=Ut.data,ts=new XMLHttpRequest;await new Promise((vr,Ct)=>{ts.upload.addEventListener("progress",As=>{if(As.lengthComputable){const Us=Math.round(As.loaded/As.total*100);console.log("Upload progress:",Us)}}),ts.addEventListener("load",()=>{ts.status>=200&&ts.status<300?vr():Ct(new Error(`Upload failed with status ${ts.status}`))}),ts.addEventListener("error",()=>Ct(new Error("Upload failed"))),ts.open("PUT",hs),ts.setRequestHeader("AccessKey",Yt),ts.send(Je)});const Ds=`https://player.mediadelivery.net/embed/${It}/${at}`;C(Ds),he.success("Video uploaded successfully! It may take a few minutes to process.")}catch(Qe){console.error("Upload error:",Qe),he.error("Failed to upload video")}finally{le(!1)}}},$e=async()=>{if(!b.trim()){he.error("Title is required");return}try{let Ze;if(i){const{error:Je}=await H.from("levelup_briefs").update({title:b,description:j||null,video_url:N||null,graphic_url:M||null,graphic_link_url:L||null,is_published:q,publish_date:B,show_frequency:Y}).eq("id",i.id);if(Je)throw Je;Ze=i.id,await H.from("levelup_brief_links").delete().eq("brief_id",Ze);const{data:He}=await H.from("levelup_brief_polls").select("id").eq("brief_id",Ze);if(He)for(const Qe of He)await H.from("levelup_brief_poll_options").delete().eq("poll_id",Qe.id);await H.from("levelup_brief_polls").delete().eq("brief_id",Ze)}else{const{data:Je,error:He}=await H.from("levelup_briefs").insert({title:b,description:j||null,video_url:N||null,graphic_url:M||null,graphic_link_url:L||null,is_published:q,publish_date:B,show_frequency:Y,created_by:t==null?void 0:t.id}).select().single();if(He)throw He;Ze=Je.id}if(te.length>0){const Je=te.map((He,Qe)=>({brief_id:Ze,title:He.title,url:He.url,sort_order:Qe}));await H.from("levelup_brief_links").insert(Je)}for(let Je=0;Je0){const It=He.options.map((Ut,hs)=>({poll_id:Qe.id,option_text:Ut,sort_order:hs}));await H.from("levelup_brief_poll_options").insert(It)}}he.success(i?"Brief updated":"Brief created"),l(!1),Ae(),Ne()}catch(Ze){console.error("Error saving brief:",Ze),he.error("Failed to save brief")}},ct=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;he.success("Brief deleted"),Ne()}catch(Je){console.error("Error deleting brief:",Je),he.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:He}=await H.from("levelup_brief_views").select("*",{count:"exact",head:!0}).eq("brief_id",Ze.id).not("dismissed_at","is",null);Ie({total:Je||0,dismissed:He||0});const{data:Qe}=await H.from("levelup_brief_polls").select("*").eq("brief_id",Ze.id).order("sort_order");if(Qe){const at=[];for(const It of Qe){const{data:Ut}=await H.from("levelup_brief_poll_options").select("*").eq("poll_id",It.id).order("sort_order"),{data:hs}=await H.from("levelup_brief_poll_responses").select("option_id, user_id").eq("poll_id",It.id),Yt=[...new Set((hs==null?void 0:hs.map(As=>As.user_id))||[])];let ts={};if(Yt.length>0){const{data:As}=await H.from("profiles").select("id, name, email").in("id",Yt);As&&As.forEach(Us=>{ts[Us.id]=Us.name||Us.email||"Unknown"})}const Ds=(hs||[]).map(As=>({optionId:As.option_id,userName:ts[As.user_id]||"Unknown",userId:As.user_id})),vr={};let Ct=0;Ut&&Ut.forEach(As=>{const Us=(hs==null?void 0:hs.filter(kr=>kr.option_id===As.id).length)||0;vr[As.id]=Us,Ct+=Us}),at.push({...It,options:Ut||[],results:vr,respondents:Ds,totalResponses:It.poll_type==="single"?new Set(hs==null?void 0:hs.map(As=>As.user_id)).size:Ct})}fe(at)}p(!0)},ft=()=>{X([...te,{title:"",url:""}])},me=(Ze,Je,He)=>{const Qe=[...te];Qe[Ze][Je]=He,X(Qe)},Ve=Ze=>{X(te.filter((Je,He)=>He!==Ze))},nt=()=>{ne([...ce,{question:"",poll_type:"single",options:["",""]}])},et=(Ze,Je)=>{const He=[...ce];He[Ze].question=Je,ne(He)},Se=(Ze,Je)=>{const He=[...ce];He[Ze].poll_type=Je,ne(He)},rt=Ze=>{const Je=[...ce];Je[Ze].options.push(""),ne(Je)},Ge=(Ze,Je,He)=>{const Qe=[...ce];Qe[Ze].options[Je]=He,ne(Qe)},lt=(Ze,Je)=>{const He=[...ce];He[Ze].options=He[Ze].options.filter((Qe,at)=>at!==Je),ne(He)},qe=Ze=>{ne(ce.filter((Je,He)=>He!==Ze))};return e.jsxs(Ts,{title:"The LevelUp Brief",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{title:"The LevelUp Brief",description:"Create engaging popup briefs for your agents",children:e.jsxs(K,{onClick:Fe,children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create Brief"]})}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Frequency"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading..."})}):s.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No briefs created yet"})}):s.map(Ze=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ze.title}),e.jsx(dt,{children:e.jsx(tt,{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:ps(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(Ro,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ce(Ze),children:e.jsx(dd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>ct(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(_s,{children:e.jsx(bs,{children:i?"Edit Brief":"Create New Brief"})}),e.jsxs(ja,{defaultValue:"content",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-4",children:[e.jsx(us,{value:"content",children:"Content"}),e.jsx(us,{value:"media",children:"Media"}),e.jsx(us,{value:"links",children:"Links"}),e.jsx(us,{value:"polls",children:"Polls"})]}),e.jsxs(ks,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Title *"}),e.jsx(ze,{value:b,onChange:Ze=>_(Ze.target.value),placeholder:"What's happening at LevelUp..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:j,onChange:Ze=>w(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(ye,{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(ye,{children:"Show Frequency"}),e.jsxs(Ys,{value:Y,onValueChange:J,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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($r,{checked:q,onCheckedChange:U}),e.jsx(ye,{children:"Publish immediately"})]})]}),e.jsxs(ks,{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(ye,{children:"Upload Video to Bunny.net"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"video/*",onChange:Me,disabled:re})}),re&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Or paste embed URL"}),e.jsx(ze,{value:N,onChange:Ze=>C(Ze.target.value),placeholder:"https://iframe.mediadelivery.net/embed/..."})]}),N&&e.jsx("div",{className:"aspect-video rounded-lg overflow-hidden bg-muted",children:e.jsx("iframe",{src:N,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(ye,{children:"Upload Image"}),e.jsx("div",{className:"flex gap-2",children:e.jsx(ze,{type:"file",accept:"image/*",onChange:async Ze=>{var He;const Je=(He=Ze.target.files)==null?void 0:He[0];if(Je){xe(!0);try{const Qe=Je.name.split(".").pop(),at=`brief-graphics/${Date.now()}.${Qe}`,{error:It}=await H.storage.from("banner-images").upload(at,Je,{upsert:!0});if(It)throw It;const{data:Ut}=H.storage.from("banner-images").getPublicUrl(at);I(Ut.publicUrl),he.success("Image uploaded!")}catch(Qe){console.error(Qe),he.error("Failed to upload image")}finally{xe(!1)}}},disabled:pe})}),pe&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Uploading..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Or paste Image URL"}),e.jsx(ze,{value:M,onChange:Ze=>I(Ze.target.value),placeholder:"https://example.com/image.png"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Click-through Link (optional)"}),e.jsx(ze,{value:L,onChange:Ze=>R(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(ks,{value:"links",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ye,{children:"Quick Links"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ft,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Link"]})]}),te.map((Ze,Je)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsx(ze,{value:Ze.title,onChange:He=>me(Je,"title",He.target.value),placeholder:"Link title",className:"flex-1"}),e.jsx(ze,{value:Ze.url,onChange:He=>me(Je,"url",He.target.value),placeholder:"https://...",className:"flex-[2]"}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Ve(Je),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},Je)),te.length===0&&e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No links added yet"})]}),e.jsxs(ks,{value:"polls",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(ye,{children:"Polls"}),e.jsxs(K,{variant:"outline",size:"sm",onClick:nt,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add Poll"]})]}),ce.map((Ze,Je)=>e.jsx(Pe,{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:He=>et(Je,He.target.value),placeholder:"Poll question...",className:"flex-1 mr-2"}),e.jsxs(Ys,{value:Ze.poll_type,onValueChange:He=>Se(Je,He),children:[e.jsx(Gs,{className:"w-32",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"single",children:"Single"}),e.jsx(Mt,{value:"multi",children:"Multi-select"})]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>qe(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((He,Qe)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:He,onChange:at=>Ge(Je,Qe,at.target.value),placeholder:`Option ${Qe+1}`}),Ze.options.length>2&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>lt(Je,Qe),children:e.jsx(Nr,{className:"h-4 w-4 text-muted-foreground"})})]},Qe)),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:$e,children:i?"Update Brief":"Create Brief"})]})]})}),e.jsx(xs,{open:u,onOpenChange:p,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(bs,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Views"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:we.total})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Dismissed"})}),e.jsx(Re,{children:e.jsx("p",{className:"text-2xl font-bold",children:we.dismissed})})]})]}),_e.length>0?e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:"Poll Results"}),_e.map(Ze=>e.jsxs(Pe,{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 He=Ze.results[Je.id]||0,Qe=Ze.totalResponses>0?Math.round(He/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:[He," (",Qe,"%)"]})]}),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:`${Qe}%`}})}),He>0&&e.jsx("div",{className:"flex flex-wrap gap-1 pt-1",children:(Ze.respondents||[]).filter(at=>at.optionId===Je.id).map((at,It)=>e.jsx(tt,{variant:"secondary",className:"text-xs font-normal",children:at.userName},It))})]},Je.id)})})]},Ze.id))]}):e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No polls in this brief"})]})]})})]})}const j1s=()=>{const{user:t}=Rs(),{toast:s}=qa(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),[u,p]=k.useState(null),[f,g]=k.useState(""),{data:b=[],isLoading:_}=mt({queryKey:["additional-services-admin"],queryFn:async()=>{const{data:L,error:R}=await H.from("additional_services").select("*").order("publish_date",{ascending:!1});if(R)throw R;return L}}),j=Lt({mutationFn:async L=>{let R=L.existingImageUrl;if(L.image){const U=L.image.name.split(".").pop(),B=`${Date.now()}-${Math.random().toString(36).substring(7)}.${U}`,{error:V}=await H.storage.from("service-images").upload(B,L.image);if(V)throw V;const{data:Y}=H.storage.from("service-images").getPublicUrl(B);R=Y.publicUrl}const q={name:L.item.name,description:L.item.description||null,preview_image_url:R,signup_link_url:L.item.signup_link_url,publish_date:L.item.publish_date?new Date(L.item.publish_date).toISOString():new Date().toISOString(),is_published:L.item.is_published,created_by:t==null?void 0:t.id};if(L.itemId){const{error:U}=await H.from("additional_services").update(q).eq("id",L.itemId);if(U)throw U}else{const{error:U}=await H.from("additional_services").insert(q);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),N()},onError:L=>{s({title:"Error saving service",description:L.message,variant:"destructive"})}}),w=Lt({mutationFn:async L=>{const{error:R}=await H.from("additional_services").delete().eq("id",L);if(R)throw R},onSuccess:()=>{r.invalidateQueries({queryKey:["additional-services-admin"]}),r.invalidateQueries({queryKey:["additional-services"]}),s({title:"Service deleted"})},onError:L=>{s({title:"Error deleting service",description:L.message,variant:"destructive"})}}),N=()=>{c({name:"",description:"",signup_link_url:"",publish_date:new Date().toISOString().split("T")[0],is_published:!1}),p(null),g(""),l(null)},C=L=>{l(L),c({name:L.name,description:L.description||"",signup_link_url:L.signup_link_url,publish_date:L.publish_date?new Date(L.publish_date).toISOString().split("T")[0]:new Date().toISOString().split("T")[0],is_published:L.is_published}),g(L.preview_image_url||""),a(!0)},M=L=>{var q;const R=(q=L.target.files)==null?void 0:q[0];R&&(p(R),g(URL.createObjectURL(R)))},I=L=>{if(L.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}j.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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Services"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.length})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Published"})}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:b.filter(L=>L.is_published).length})})]})]}),e.jsxs(xs,{open:n,onOpenChange:L=>{a(L),L||N()},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(_s,{children:e.jsx(bs,{children:o?"Edit Service":"Add New Service"})}),e.jsxs("form",{onSubmit:I,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name *"}),e.jsx(ze,{id:"name",value:i.name,onChange:L=>c({...i,name:L.target.value}),placeholder:"Enter service name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(hy,{content:i.description,onChange:L=>c({...i,description:L}),placeholder:"Enter description",minHeight:"120px"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"signup_link_url",children:"Signup Link URL *"}),e.jsx(ze,{id:"signup_link_url",type:"url",value:i.signup_link_url,onChange:L=>c({...i,signup_link_url:L.target.value}),placeholder:"https://example.com/signup"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"publish_date",children:"Publish Date"}),e.jsx(ze,{id:"publish_date",type:"date",value:i.publish_date,onChange:L=>c({...i,publish_date:L.target.value})})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx($r,{id:"is_published",checked:i.is_published,onCheckedChange:L=>c({...i,is_published:L})}),e.jsx(ye,{htmlFor:"is_published",children:"Published"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(Or,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-4 text-center",children:[e.jsx(fl,{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:j.isPending,children:j.isPending?"Saving...":o?"Update":"Create"})]})]})]})]})]}),e.jsx(Pe,{children:e.jsx(Re,{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"})}):b.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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-16",children:"Preview"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Signup Link"}),e.jsx(kt,{children:"Publish Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:b.map(L=>e.jsxs(Ss,{children:[e.jsx(dt,{children:L.preview_image_url?e.jsx("img",{src:L.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(fl,{className:"h-5 w-5 text-muted-foreground"})})}),e.jsx(dt,{className:"font-medium",children:L.name}),e.jsx(dt,{children:e.jsxs("a",{href:L.signup_link_url,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline flex items-center gap-1",children:[e.jsx(an,{className:"h-3 w-3"}),"Link"]})}),e.jsx(dt,{children:new Date(L.publish_date).toLocaleDateString()}),e.jsx(dt,{children:e.jsx(tt,{variant:L.is_published?"default":"secondary",children:L.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:()=>C(L),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this service?")&&w.mutate(L.id)},children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},L.id))})]})})})]})})};function N1s(){const{toast:t}=qa(),[s,r]=k.useState([]),[n,a]=k.useState(!0),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""});k.useEffect(()=>{f()},[]);const f=async()=>{try{const{data:w,error:N}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"list"}});if(N)throw N;r(w.coupons||[])}catch(w){console.error("Error fetching coupons:",w),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 w={action:"create",name:u.name,duration:u.duration,promotion_code:u.promotionCode.trim()||void 0};u.discountType==="percent"?w.percent_off=parseFloat(u.percentOff):(w.amount_off=Math.round(parseFloat(u.amountOff)*100),w.currency="usd"),u.duration==="repeating"&&(w.duration_in_months=parseInt(u.durationInMonths));const{data:N,error:C}=await H.functions.invoke("stripe-manage-coupons",{body:w});if(C)throw C;t({title:"Success",description:"Coupon created successfully"}),c(!1),p({name:"",promotionCode:"",discountType:"percent",percentOff:"",amountOff:"",duration:"once",durationInMonths:""}),f()}catch(w){console.error("Error creating coupon:",w),t({title:"Error",description:w.message||"Failed to create coupon",variant:"destructive"})}finally{l(!1)}},b=async w=>{if(confirm("Are you sure you want to delete this coupon?"))try{const{error:N}=await H.functions.invoke("stripe-manage-coupons",{body:{action:"delete",couponId:w}});if(N)throw N;t({title:"Success",description:"Coupon deleted successfully"}),f()}catch(N){console.error("Error deleting coupon:",N),t({title:"Error",description:N.message||"Failed to delete coupon",variant:"destructive"})}},_=w=>w.percent_off?`${w.percent_off}% off`:w.amount_off?`$${(w.amount_off/100).toFixed(2)} off`:"N/A",j=w=>{switch(w.duration){case"once":return"Once";case"forever":return"Forever";case"repeating":return`${w.duration_in_months} months`;default:return w.duration}};return e.jsx(Ts,{title:"Subscription Discounts",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{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(_s,{children:[e.jsx(bs,{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(ye,{children:"Promotion Code (what users will type)"}),e.jsx(ze,{placeholder:"e.g., BROKERAGE50",value:u.promotionCode,onChange:w=>p({...u,promotionCode:w.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(ye,{children:"Coupon Name (internal label)"}),e.jsx(ze,{placeholder:"e.g., 50% Off Brokerage Launch",value:u.name,onChange:w=>p({...u,name:w.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Discount Type"}),e.jsxs(Ys,{value:u.discountType,onValueChange:w=>{const N=w==="amount"&&u.duration==="forever"?"once":u.duration;p({...u,discountType:w,duration:N})},children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"percent",children:e.jsxs("span",{className:"flex items-center",children:[e.jsx(OM,{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(wc,{className:"mr-2 h-4 w-4"}),"Fixed Amount Off"]})})]})]})]}),u.discountType==="percent"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Percent Off"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"1",max:"100",placeholder:"20",value:u.percentOff,onChange:w=>p({...u,percentOff:w.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(ye,{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:w=>p({...u,amountOff:w.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Duration"}),e.jsxs(Ys,{value:u.duration,onValueChange:w=>p({...u,duration:w}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Number of Months"}),e.jsx(ze,{type:"number",min:"1",placeholder:"3",value:u.durationInMonths,onChange:w=>p({...u,durationInMonths:w.target.value})})]}),e.jsx(K,{onClick:g,disabled:o,className:"w-full",children:o?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Coupon"})]})]})]})}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Active Coupons"}),e.jsx(xr,{children:"Share coupon codes with users to give them discounts on subscriptions"})]}),e.jsx(Re,{children:n?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Promo Code"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Discount"}),e.jsx(kt,{children:"Duration"}),e.jsx(kt,{children:"Redemptions"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:s.map(w=>{var N;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono font-medium",children:((N=w.promotion_codes)==null?void 0:N.length)>0?w.promotion_codes.join(", "):e.jsx("span",{className:"text-muted-foreground text-xs",children:"No promo code"})}),e.jsx(dt,{children:w.name||"-"}),e.jsx(dt,{children:_(w)}),e.jsx(dt,{children:j(w)}),e.jsx(dt,{children:w.times_redeemed}),e.jsx(dt,{children:e.jsx(tt,{variant:w.valid?"default":"secondary",children:w.valid?"Active":"Inactive"})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(w.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})})]},w.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"How to Use Coupons"})}),e.jsxs(Re,{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 cye={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 k1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState(null),{data:l,isLoading:i,refetch:c}=mt({queryKey:["admin-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("profiles").select(` *, brokerages:brokerage_id (id, name) `).order("created_at",{ascending:!1});if(j)throw j;return _}}),{data:u}=mt({queryKey:["admin-brokerages-subscriptions"],queryFn:async()=>{const{data:_,error:j}=await H.from("brokerages").select("*").order("name");if(j)throw j;return await Promise.all((_||[]).map(async N=>{const{data:C}=await H.from("profiles").select("id, name, email, subscription_status, subscription_product_id").eq("brokerage_id",N.id),{data:M}=await H.from("user_roles").select("user_id").eq("role","brokerage_manager"),I=(M==null?void 0:M.map(q=>q.user_id))||[],L=(C==null?void 0:C.filter(q=>I.includes(q.id)))||[],R=(C==null?void 0:C.length)||0;return{...N,managers:L,agentCount:R}}))}}),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 j=cye[_.subscription_product_id];return{status:(j==null?void 0:j.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 w,N;if(!(((w=_.name)==null?void 0:w.toLowerCase().includes(t.toLowerCase()))||((N=_.email)==null?void 0:N.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},b=_=>{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(ah,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{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(Pe,{className:"border-green-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Cx,{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(Pe,{className:"border-blue-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{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(Pe,{className:"border-purple-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Im,{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(Pe,{className:"border-orange-500/50",children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wa,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(V_,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wa,{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(ja,{defaultValue:"users",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"users",children:"All Users"}),e.jsx(us,{value:"brokerages",children:"Brokerages"})]}),e.jsxs(ks,{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(hn,{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(Ys,{value:r,onValueChange:_=>n(_),children:[e.jsx(Gs,{className:"w-[200px]",children:e.jsx(Qs,{placeholder:"Filter by status"})}),e.jsxs(Ks,{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(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"User"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Plan"}),e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{children:"End Date"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:i?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center py-8",children:"Loading subscriptions..."})}):(f==null?void 0:f.length)===0?e.jsx(Ss,{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 N,C;const j=p(_),w=cye[_.subscription_product_id];return e.jsxs(Ss,{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(tt,{variant:j.variant,children:j.badge})}),e.jsx(dt,{children:e.jsx("span",{className:"text-sm",children:_.is_grandfathered?"Legacy Access":_.brokerage_id&&!_.subscription_product_id?"Brokerage Subscription":(w==null?void 0:w.name)||j.status})}),e.jsx(dt,{children:(N=_.brokerages)!=null&&N.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:ps(new Date(_.subscription_end_date),"MMM d, yyyy")}):_.trial_expires_at?e.jsxs("span",{className:"text-sm text-blue-600",children:["Trial: ",ps(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:()=>b(_.stripe_customer_id),children:e.jsx(an,{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(_s,{children:[e.jsx(bs,{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(tt,{variant:j.variant,className:"mt-1",children:j.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":(w==null?void 0:w.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:((C=_.brokerages)==null?void 0:C.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:ps(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:ps(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:()=>b(_.stripe_customer_id),children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"View in Stripe Dashboard"]})]})]})]})]})})]},_.id)})})]})})})]}),e.jsx(ks,{value:"brokerages",className:"space-y-4",children:e.jsx("div",{className:"grid gap-4",children:u==null?void 0:u.map(_=>{var w,N;const j=(w=_.managers)==null?void 0:w.some(C=>C.subscription_status==="active"&&(C.subscription_product_id==="prod_Tc08MupgoVySDG"||C.subscription_product_id==="prod_Tc09N1tJ4RrAFn"));return e.jsxs(Pe,{children:[e.jsx(Dt,{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(wa,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:_.name}),e.jsxs(xr,{children:[_.agentCount," agents"]})]})]}),e.jsx(tt,{variant:j?"default":"outline",children:j?"Active Subscription":"No Active Subscription"})]})}),e.jsx(Re,{children:((N=_.managers)==null?void 0:N.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(C=>{const M=cye[C.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:C.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.email})]}),e.jsx("div",{className:"text-right",children:M?e.jsxs("div",{children:[e.jsx(tt,{variant:"default",children:M.name}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:M.price})]}):e.jsx(tt,{variant:"outline",children:"No Subscription"})})]},C.id)})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No managers assigned"})})]},_.id)})})})]})]})})}function S1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(""),[l,i]=k.useState("all"),[c,u]=k.useState({total:0,qualified:0,pending:0,cancelled:0,totalDiscounts:0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:_,error:j}=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(j)throw j;s(_||[]);const w=(_==null?void 0:_.filter(M=>M.status==="qualified").length)||0,N=(_==null?void 0:_.filter(M=>M.status==="pending").length)||0,C=(_==null?void 0:_.filter(M=>M.status==="cancelled").length)||0;u({total:(_==null?void 0:_.length)||0,qualified:w,pending:N,cancelled:C,totalDiscounts:w*25})}catch(_){console.error("Error fetching referrals:",_),he.error("Failed to load referrals")}finally{n(!1)}},f=async()=>{try{he.loading("Processing qualifications...");const{error:_}=await H.functions.invoke("process-referral-qualifications");if(_)throw _;he.dismiss(),he.success("Qualifications processed successfully"),p()}catch(_){he.dismiss(),console.error("Error processing qualifications:",_),he.error("Failed to process qualifications")}},g=t.filter(_=>{var N,C,M,I,L,R;const j=((C=(N=_.referrer_brokerage)==null?void 0:N.name)==null?void 0:C.toLowerCase().includes(a.toLowerCase()))||((I=(M=_.referred_brokerage)==null?void 0:M.name)==null?void 0:I.toLowerCase().includes(a.toLowerCase()))||((R=(L=_.referred_user)==null?void 0:L.email)==null?void 0:R.toLowerCase().includes(a.toLowerCase())),w=l==="all"||_.status===l;return j&&w}),b=_=>{switch(_){case"qualified":return e.jsxs(tt,{className:"bg-green-100 text-green-800",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),"Qualified"]});case"pending":return e.jsxs(tt,{variant:"secondary",children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Pending"]});case"cancelled":return e.jsxs(tt,{variant:"destructive",children:[e.jsx(xc,{className:"h-3 w-3 mr-1"}),"Cancelled"]});default:return e.jsx(tt,{children:_})}};return e.jsx(Ts,{title:"Referral Program",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xi,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mn,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xc,{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(Pe,{children:e.jsx(Re,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wc,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"All Referrals"}),e.jsx(xr,{children:"View and manage all referral relationships"})]}),e.jsxs(Re,{children:[e.jsxs("div",{className:"flex gap-4 mb-4",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(hn,{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(Ys,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Filter by status"})}),e.jsxs(Ks,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Referrer"}),e.jsx(kt,{children:"Referred"}),e.jsx(kt,{children:"Signup Date"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Qualified Date"}),e.jsx(kt,{children:"Discount"})]})}),e.jsx(On,{children:g.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No referrals found"})}):g.map(_=>{var j,w,N,C;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:((j=_.referrer_brokerage)==null?void 0:j.name)||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{children:((w=_.referred_brokerage)==null?void 0:w.name)||((N=_.referred_user)==null?void 0:N.name)||"Pending setup"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(C=_.referred_user)==null?void 0:C.email})]})}),e.jsx(dt,{children:ps(new Date(_.signup_date),"MMM d, yyyy")}),e.jsx(dt,{children:b(_.status)}),e.jsx(dt,{children:_.qualified_date?ps(new Date(_.qualified_date),"MMM d, yyyy"):"-"}),e.jsx(dt,{children:_.discount_applied?e.jsx(tt,{variant:"outline",className:"text-green-600",children:"$25/mo applied"}):e.jsx("span",{className:"text-muted-foreground",children:"-"})})]},_.id)})})]})]})]})]})})}const dye=[{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"}],C1s=[{value:"brokerage_manager",label:"Brokerage Manager"},{value:"agent",label:"Agent"}];function M1s(){const[t,s]=k.useState([]),[r,n]=k.useState(!0),[a,o]=k.useState(!1),[l,i]=k.useState(null),[c,u]=k.useState({title:"",description:"",action_type:"view_template",target_role:"agent",is_active:!0});k.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:C,error:M}=await H.from("onboarding_checklist_items").select("*").order("target_role").order("sort_order");if(M)throw M;s(C||[])}catch(C){console.error("Error fetching checklist items:",C),he.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=C=>{i(C),u({title:C.title,description:C.description||"",action_type:C.action_type,target_role:C.target_role,is_active:C.is_active}),o(!0)},b=async()=>{if(!c.title.trim()){he.error("Title is required");return}try{if(l){const{error:C}=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(C)throw C;he.success("Checklist item updated")}else{const C=t.filter(I=>I.target_role===c.target_role).reduce((I,L)=>Math.max(I,L.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:C+1});if(M)throw M;he.success("Checklist item created")}o(!1),p()}catch(C){console.error("Error saving checklist item:",C),he.error("Failed to save checklist item")}},_=async C=>{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",C);if(M)throw M;he.success("Checklist item deleted"),p()}catch(M){console.error("Error deleting checklist item:",M),he.error("Failed to delete checklist item")}},j=async C=>{try{const{error:M}=await H.from("onboarding_checklist_items").update({is_active:!C.is_active}).eq("id",C.id);if(M)throw M;he.success(C.is_active?"Item deactivated":"Item activated"),p()}catch(M){console.error("Error toggling item:",M),he.error("Failed to update item")}},w=t.filter(C=>C.target_role==="brokerage_manager"),N=t.filter(C=>C.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(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tt,{variant:"secondary",children:"Brokerage Manager"}),"Checklist Items"]})}),e.jsx(Re,{children:w.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for brokerage managers"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:w.map((C,M)=>{var I;return e.jsxs(Ss,{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:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:((I=dye.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(dt,{children:e.jsx($r,{checked:C.is_active,onCheckedChange:()=>j(C)})}),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(C),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(C.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(tt,{variant:"secondary",children:"Agent"}),"Checklist Items"]})}),e.jsx(Re,{children:N.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-4",children:"No checklist items for agents"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:N.map((C,M)=>{var I;return e.jsxs(Ss,{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:C.title}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-1",children:C.description})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",children:((I=dye.find(L=>L.value===C.action_type))==null?void 0:I.label)||C.action_type})}),e.jsx(dt,{children:e.jsx($r,{checked:C.is_active,onCheckedChange:()=>j(C)})}),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(C),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(C.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},C.id)})})]})})]})]}),e.jsx(xs,{open:a,onOpenChange:o,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{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(ye,{htmlFor:"title",children:"Title *"}),e.jsx(ze,{id:"title",value:c.title,onChange:C=>u({...c,title:C.target.value}),placeholder:"e.g., Watch your first academy video"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:c.description,onChange:C=>u({...c,description:C.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(ye,{children:"Target Role"}),e.jsxs(Ys,{value:c.target_role,onValueChange:C=>u({...c,target_role:C}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:C1s.map(C=>e.jsx(Mt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Action Type"}),e.jsxs(Ys,{value:c.action_type,onValueChange:C=>u({...c,action_type:C}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:dye.map(C=>e.jsx(Mt,{value:C.value,children:C.label},C.value))})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"is_active",checked:c.is_active,onCheckedChange:C=>u({...c,is_active:C})}),e.jsx(ye,{htmlFor:"is_active",children:"Active"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(K,{onClick:b,children:l?"Save Changes":"Create Item"})]})]})})]})}function T1s(){const[t,s]=k.useState(""),[r,n]=k.useState("all"),[a,o]=k.useState("name"),[l,i]=k.useState("asc"),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(""),{data:w}=mt({queryKey:["admin-brokerages"],queryFn:async()=>{const{data:V,error:Y}=await H.from("brokerages").select("id, name").order("name");if(Y)throw Y;return V}}),N=async V=>{let J=[],te=0,X=!0;for(;X;){const{data:ce,error:ne}=await V(te,te+1e3-1);if(ne)throw ne;ce&&ce.length>0?(J=[...J,...ce],te+=1e3,X=ce.length===1e3):X=!1}return J},{data:C,isLoading:M}=mt({queryKey:["admin-agent-os-user-stats"],queryFn:async()=>{const V=await N((Ce,Me)=>H.from("profiles").select("id, name, email, brokerage_id, created_at").range(Ce,Me)),{data:Y}=await H.from("brokerages").select("id, name"),J=new Map((Y==null?void 0:Y.map(Ce=>[Ce.id,Ce.name]))||[]),[{data:te},{data:X},{data:ce},{data:ne},{data:re},{data:le},{data:pe}]=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")]),xe=new Map;te==null||te.forEach(Ce=>xe.set(Ce.owner_user_id,Ce.contact_count));const _e=new Map;X==null||X.forEach(Ce=>_e.set(Ce.owner_user_id,Ce.video_count));const fe=new Map;ce==null||ce.forEach(Ce=>fe.set(Ce.owner_user_id,Ce.popby_count));const we=new Map;ne==null||ne.forEach(Ce=>we.set(Ce.agent_id,Ce.listing_count));const Ie=new Map;re==null||re.forEach(Ce=>Ie.set(Ce.owner_user_id,Ce.deal_count));const Ne=new Map;le==null||le.forEach(Ce=>Ne.set(Ce.owner_user_id,{total:Ce.portal_count,active:Ce.active_portal_count}));const Ae=new Map;return pe==null||pe.forEach(Ce=>Ae.set(Ce.owner_user_id,{total:Ce.card_count,sent:Ce.sent_card_count,views:Ce.total_card_views})),V.map(Ce=>{const Me=Ne.get(Ce.id),$e=Ae.get(Ce.id);return{id:Ce.id,name:Ce.name||"Unknown",email:Ce.email||"",brokerage_id:Ce.brokerage_id,brokerage_name:Ce.brokerage_id&&J.get(Ce.brokerage_id)||null,contact_count:xe.get(Ce.id)||0,video_count:_e.get(Ce.id)||0,popby_count:fe.get(Ce.id)||0,listing_count:we.get(Ce.id)||0,deal_count:Ie.get(Ce.id)||0,portal_count:(Me==null?void 0:Me.total)||0,active_portal_count:(Me==null?void 0:Me.active)||0,card_count:($e==null?void 0:$e.total)||0,sent_card_count:($e==null?void 0:$e.sent)||0,total_card_views:($e==null?void 0:$e.views)||0,created_at:Ce.created_at}})}}),I=k.useMemo(()=>{if(!C)return[];let V=C.filter(Y=>{const J=t.toLowerCase(),te=!t||Y.name.toLowerCase().includes(J)||Y.email.toLowerCase().includes(J),X=r==="all"||r==="none"&&!Y.brokerage_id||Y.brokerage_id===r,ce=parseInt(c)||0,ne=parseInt(p)||0,re=parseInt(g)||0,le=parseInt(_)||0,pe=Y.contact_count>=ce&&Y.video_count>=ne&&Y.popby_count>=re&&Y.listing_count>=le;return te&&X&&pe});return V.sort((Y,J)=>{let te=0;return a==="name"?te=Y.name.localeCompare(J.name):te=Y[a]-J[a],l==="asc"?te:-te}),V},[C,t,r,a,l,c,p,g,_]),L=V=>{a===V?i(l==="asc"?"desc":"asc"):(o(V),i("desc"))},R=()=>{const V=["Name","Email","Brokerage","Contacts","Videos","Popbys","Listings","Deals","Portals (Active)","Cards Created","Cards Sent","Card Views"],Y=I.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]),J=[V.join(","),...Y.map(ne=>ne.map(re=>`"${re}"`).join(","))].join(` `),te=new Blob([J],{type:"text/csv"}),X=URL.createObjectURL(te),ce=document.createElement("a");ce.href=X,ce.download=`agent-os-user-stats-${new Date().toISOString().split("T")[0]}.csv`,ce.click(),URL.revokeObjectURL(X)},q=k.useMemo(()=>I.length?I.reduce((V,Y)=>({contacts:V.contacts+Y.contact_count,videos:V.videos+Y.video_count,popbys:V.popbys+Y.popby_count,listings:V.listings+Y.listing_count,deals:V.deals+Y.deal_count,portals:V.portals+Y.portal_count,activePortals:V.activePortals+Y.active_portal_count,cards:V.cards+Y.card_count,sentCards:V.sentCards+Y.sent_card_count,cardViews:V.cardViews+Y.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},[I]),U=k.useMemo(()=>I.length?{portals:I.filter(V=>V.portal_count>0).length,cards:I.filter(V=>V.card_count>0).length}:{portals:0,cards:0},[I]),B=({field:V,children:Y})=>e.jsx(kt,{className:"cursor-pointer hover:bg-muted/50 select-none",onClick:()=>L(V),children:e.jsxs("div",{className:"flex items-center gap-1",children:[Y,e.jsx(yd,{className:`h-3 w-3 ${a===V?"text-primary":"text-muted-foreground"}`})]})});return e.jsx(F1,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(Pe,{className:"border-blue-500/20 bg-gradient-to-br from-blue-500/5 to-transparent",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(t1,{className:"h-4 w-4 text-blue-500"}),"Client Portals"]})}),e.jsx(Re,{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:q.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:q.activePortals}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Active Portals"})]})]})})]}),e.jsxs(Pe,{className:"border-violet-500/20 bg-gradient-to-br from-violet-500/5 to-transparent",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(dr,{className:"h-4 w-4 text-violet-500"}),"Card Studio"]})}),e.jsx(Re,{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:q.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:q.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:q.cardViews}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Total Views"})]})]})})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"User Activity Analytics"]}),e.jsx(xr,{children:"View all users and their Agent OS usage metrics"})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:R,children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Export CSV"]})]})}),e.jsxs(Re,{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(hn,{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(Ys,{value:r,onValueChange:n,children:[e.jsxs(Gs,{children:[e.jsx(wa,{className:"h-4 w-4 mr-2 text-muted-foreground"}),e.jsx(Qs,{placeholder:"Brokerage"})]}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Brokerages"}),e.jsx(Mt,{value:"none",children:"No Brokerage"}),w==null?void 0:w.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=>b(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:I.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:q.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:q.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:q.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:q.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:q.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:q.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:q.cards.toLocaleString()}),e.jsx("div",{className:"text-muted-foreground",children:"Cards"})]})]}),M?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(B,{field:"name",children:"Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{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(t1,{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(dr,{className:"h-3 w-3 text-violet-500"}),"Cards"]})})]})}),e.jsx(On,{children:I.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No users found matching your filters"})}):I.map(V=>e.jsxs(Ss,{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(tt,{variant:"secondary",children:V.brokerage_name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.contact_count>0?"default":"outline",children:V.contact_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.video_count>0?"default":"outline",children:V.video_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.popby_count>0?"default":"outline",children:V.popby_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.listing_count>0?"default":"outline",children:V.listing_count})}),e.jsx(dt,{children:e.jsx(tt,{variant:V.deal_count>0?"default":"outline",children:V.deal_count})}),e.jsx(dt,{children:V.portal_count>0?e.jsxs(Oc,{children:[e.jsx(Rc,{children:e.jsxs(tt,{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(gc,{children:[e.jsxs("p",{children:[V.portal_count," total portals"]}),e.jsxs("p",{children:[V.active_portal_count," currently active"]})]})]}):e.jsx(tt,{variant:"outline",children:"0"})}),e.jsx(dt,{children:V.card_count>0?e.jsxs(Oc,{children:[e.jsx(Rc,{children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(tt,{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(Rn,{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(qn,{className:"h-3 w-3"}),V.total_card_views]})]})}),e.jsxs(gc,{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(tt,{variant:"outline",children:"0"})})]},V.id))})]})})]})]})]})})}function A1s(){qa(),es();const[t,s]=k.useState("user-analytics"),{data:r}=mt({queryKey:["admin-feature-flags"],queryFn:async()=>{const{data:b,error:_}=await H.from("feature_flags").select("*").order("key");if(_)throw _;return b}}),{data:n,isLoading:a}=mt({queryKey:["admin-relationship-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("relationship_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:o,isLoading:l}=mt({queryKey:["admin-action-types"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_types").select("*").order("sort_order");if(_)throw _;return b}}),{data:i,isLoading:c}=mt({queryKey:["admin-action-scripts"],queryFn:async()=>{const{data:b,error:_}=await H.from("action_scripts").select("*, action_type:action_types(*)");if(_)throw _;return b}}),{data:u,isLoading:p}=mt({queryKey:["admin-touchpoint-plans"],queryFn:async()=>{const{data:b,error:_}=await H.from("touchpoint_plans").select("*").order("name");if(_)throw _;return b}}),{data:f,isLoading:g}=mt({queryKey:["admin-popby-items"],queryFn:async()=>{const{data:b,error:_}=await H.from("popby_items").select("*").is("owner_user_id",null).order("name");if(_)throw _;return b}});return e.jsx(Ts,{title:"Agent OS Control Center",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{title:"Agent OS Control Center",description:"Manage InnerCircle settings, scripts, and touchpoint plans"}),e.jsxs(ja,{value:t,onValueChange:s,children:[e.jsxs(ga,{className:"grid w-full grid-cols-9",children:[e.jsxs(us,{value:"user-analytics",className:"gap-2",children:[e.jsx(Ro,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Users"})]}),e.jsxs(us,{value:"relationship-types",className:"gap-2",children:[e.jsx(mr,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Relationships"})]}),e.jsxs(us,{value:"action-types",className:"gap-2",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Actions"})]}),e.jsxs(us,{value:"scripts",className:"gap-2",children:[e.jsx(En,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Scripts"})]}),e.jsxs(us,{value:"video-scripts",className:"gap-2",children:[e.jsx(xu,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Video Scripts"})]}),e.jsxs(us,{value:"plans",className:"gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Plans"})]}),e.jsxs(us,{value:"popbys",className:"gap-2",children:[e.jsx(No,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Popbys"})]}),e.jsxs(us,{value:"settings",className:"gap-2",children:[e.jsx(Yo,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Settings"})]}),e.jsxs(us,{value:"feature-flags",className:"gap-2",children:[e.jsx(r1,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Flags"})]})]}),e.jsx(ks,{value:"user-analytics",className:"mt-6",children:e.jsx(T1s,{})}),e.jsx(ks,{value:"relationship-types",className:"mt-6",children:e.jsx(E1s,{types:n||[],isLoading:a})}),e.jsx(ks,{value:"action-types",className:"mt-6",children:e.jsx(P1s,{types:o||[],isLoading:l})}),e.jsx(ks,{value:"scripts",className:"mt-6",children:e.jsx(I1s,{scripts:i||[],actionTypes:o||[],isLoading:c})}),e.jsx(ks,{value:"video-scripts",className:"mt-6",children:e.jsx(R1s,{})}),e.jsx(ks,{value:"plans",className:"mt-6",children:e.jsx(L1s,{plans:u||[],actionTypes:o||[],scripts:i||[],isLoading:p})}),e.jsx(ks,{value:"popbys",className:"mt-6",children:e.jsx(O1s,{items:f||[],isLoading:g})}),e.jsx(ks,{value:"settings",className:"mt-6",children:e.jsx(F1s,{})}),e.jsx(ks,{value:"feature-flags",className:"mt-6",children:e.jsx(D1s,{flags:r||[]})})]})]})})}function E1s({types:t,isLoading:s}){const{toast:r}=qa(),n=es(),[a,o]=k.useState(null),[l,i]=k.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Relationship Types"}),e.jsx(xr,{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(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-12"}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:t.map(p=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx(Ju,{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($r,{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(Da,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ye,{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(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function P1s({types:t,isLoading:s}){const{toast:r}=qa(),n=es(),[a,o]=k.useState(null),[l,i]=k.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Action Types"}),e.jsx(xr,{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(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Color"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:t.map(p=>e.jsxs(Ss,{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($r,{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(Da,{className:"h-4 w-4"})})})]},p.id))})]})}),e.jsx(xs,{open:l,onOpenChange:i,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||""})]}),e.jsxs("div",{children:[e.jsx(ye,{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(ye,{htmlFor:"color",children:"Color"}),e.jsx(ze,{id:"color",name:"color",type:"color",defaultValue:(a==null?void 0:a.color)||"#6366f1"})]})]}),e.jsxs(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function I1s({scripts:t,actionTypes:s,isLoading:r}){const{toast:n}=qa(),a=es(),[o,l]=k.useState(null),[i,c]=k.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Script Library"}),e.jsx(xr,{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(Re,{children:r?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Action Type"}),e.jsx(kt,{children:"Tone"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:t.map(f=>{var g;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:f.title}),e.jsx(dt,{children:e.jsx(tt,{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(tt,{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(Da,{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(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{htmlFor:"action_type_id",children:"Action Type"}),e.jsxs(Ys,{name:"action_type_id",defaultValue:o==null?void 0:o.action_type_id,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select action type"})}),e.jsx(Ks,{children:s.map(f=>e.jsx(Mt,{value:f.id,children:f.name},f.id))})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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(ye,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Er,{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(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function L1s({plans:t,actionTypes:s,scripts:r,isLoading:n}){const{toast:a}=qa(),o=es(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(null),[g,b]=k.useState(!1),[_,j]=k.useState(null),[w,N]=k.useState(null),{data:C}=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"})}}),I=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"})}}),L=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]})}}),R=Lt({mutationFn:async B=>{const{data:V,error:Y}=await H.from("action_scripts").insert([{...B,active:!0}]).select().single();if(Y)throw Y;return V},onSuccess:async B=>{o.invalidateQueries({queryKey:["admin-action-scripts"]}),_&&await I.mutateAsync({id:_.itemId,plan_id:p,month_number:_.month,action_type_id:_.actionTypeId,default_script_id:B.id}),b(!1),j(null),a({title:"Script created and assigned"})},onError:B=>{a({title:"Error",description:B.message,variant:"destructive"})}}),q=(B,V,Y)=>{j({month:B,actionTypeId:V,itemId:Y}),b(!0)},U=B=>r.find(V=>V.id===B);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Touchpoint Plans"}),e.jsx(xr,{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(Re,{children:n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{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(Pe,{className:`cursor-pointer transition-colors ${p===B.id?"border-primary":""}`,onClick:()=>f(B.id),children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:B.name}),e.jsx(K,{variant:"ghost",size:"icon",onClick:V=>{V.stopPropagation(),i(B),u(!0)},children:e.jsx(Da,{className:"h-4 w-4"})})]})}),e.jsxs(Re,{children:[e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:B.description}),e.jsx(tt,{variant:B.active?"default":"secondary",className:"mt-2",children:B.active?"Active":"Inactive"})]})]},B.id))})})]}),p&&e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Plan Schedule"}),e.jsx(xr,{children:"Configure the monthly touchpoint schedule. Select an action type for each month, then assign or create a script."})]}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-3",children:Array.from({length:12},(B,V)=>V+1).map(B=>{const V=C==null?void 0:C.find(te=>te.month_number===B),Y=V!=null&&V.default_script_id?U(V.default_script_id):null,J=r.filter(te=>te.action_type_id===(V==null?void 0:V.action_type_id)&&te.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(Ys,{value:(V==null?void 0:V.action_type_id)||"none",onValueChange:te=>{te==="none"&&V?L.mutate(V.id):te!=="none"&&I.mutate({id:V==null?void 0:V.id,plan_id:p,month_number:B,action_type_id:te,default_script_id:null})},children:[e.jsx(Gs,{className:"w-40",children:e.jsx(Qs,{placeholder:"No action"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No action"}),s.filter(te=>te.active).map(te=>e.jsx(Mt,{value:te.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[te.color&&e.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:te.color}}),te.name]})},te.id))]})]}),V&&e.jsxs(e.Fragment,{children:[e.jsxs(Ys,{value:V.default_script_id||"none",onValueChange:te=>{N(null),I.mutate({id:V.id,default_script_id:te==="none"?null:te})},children:[e.jsx(Gs,{className:"w-56",children:e.jsx(Qs,{placeholder:"Select script"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No default script"}),J.map(te=>e.jsxs(Mt,{value:te.id,children:[te.title," ",te.tone&&`(${te.tone})`]},te.id))]})]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>q(B,V.action_type_id,V.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"}),"New Script"]}),Y&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N((w==null?void 0:w.id)===Y.id?null:Y),children:(w==null?void 0:w.id)===Y.id?"Hide":"Preview"})]})]}),w&&(V==null?void 0:V.default_script_id)===w.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(tt,{variant:"outline",children:w.title}),w.tone&&e.jsx(tt,{variant:"secondary",children:w.tone})]}),e.jsx("p",{className:"text-muted-foreground whitespace-pre-wrap",children:w.script_body})]})]},B)})})})]}),e.jsx(xs,{open:c,onOpenChange:u,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(l==null?void 0:l.description)||"",rows:3})]})]}),e.jsxs(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})}),e.jsx(xs,{open:g,onOpenChange:b,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(bs,{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);R.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(ye,{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(ye,{htmlFor:"script_tone",children:"Tone"}),e.jsx(ze,{id:"script_tone",name:"tone",placeholder:"e.g., Friendly, Professional"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_body",children:"Script Body"}),e.jsx(Er,{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(zn,{className:"mt-4",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:R.isPending,children:[R.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Create & Assign"]})]})]})]})})]})}function D1s({flags:t}){const{toast:s}=qa(),r=es(),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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Feature Flags"}),e.jsx(xr,{children:"Control which features are enabled for members"})]}),e.jsx(Re,{children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Flag"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Notes"}),e.jsx(kt,{children:"Last Updated"})]})}),e.jsx(On,{children:t.map(a=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono text-sm",children:a.key}),e.jsx(dt,{children:e.jsx($r,{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 O1s({items:t,isLoading:s}){const{toast:r}=qa(),n=es(),[a,o]=k.useState(null),[l,i]=k.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Popby Ideas"}),e.jsx(xr,{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(Re,{children:s?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{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(No,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:t.map(f=>e.jsxs(Ss,{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($r,{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(Da,{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(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",name:"description",defaultValue:(a==null?void 0:a.description)||"",placeholder:"Brief description of the popby idea..."})]})]}),e.jsxs(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function R1s(){var b;const{toast:t}=qa(),s=es(),[r,n]=k.useState(null),[a,o]=k.useState(!1),{data:l,isLoading:i}=mt({queryKey:["admin-video-script-categories"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_script_categories").select("*").order("sort_order");if(j)throw j;return _}}),{data:c,isLoading:u}=mt({queryKey:["admin-video-scripts"],queryFn:async()=>{const{data:_,error:j}=await H.from("video_scripts").select("*, category:video_script_categories(*)").order("title");if(j)throw j;return _}}),p=Lt({mutationFn:async _=>{var j,w;if(_.id){const{error:N}=await H.from("video_scripts").update({title:_.title,script_text:_.script_text,category_id:_.category_id,tags:((j=_.tags)==null?void 0:j.split(",").map(C=>C.trim()).filter(Boolean))||[]}).eq("id",_.id);if(N)throw N}else{const{error:N}=await H.from("video_scripts").insert([{title:_.title,script_text:_.script_text,category_id:_.category_id||null,tags:((w=_.tags)==null?void 0:w.split(",").map(C=>C.trim()).filter(Boolean))||[]}]);if(N)throw N}},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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Video Scripts"}),e.jsx(xr,{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(Re,{children:u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Title"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"w-24",children:"Actions"})]})}),e.jsx(On,{children:c==null?void 0:c.map(_=>{var j;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:_.title}),e.jsx(dt,{className:"text-muted-foreground",children:((j=_.category)==null?void 0:j.name)||"Uncategorized"}),e.jsx(dt,{children:e.jsx($r,{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(Da,{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(_s,{children:e.jsxs(bs,{children:[r?"Edit":"Add"," Video Script"]})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault();const j=new FormData(_.currentTarget);p.mutate({id:r==null?void 0:r.id,title:j.get("title"),script_text:j.get("script_text"),category_id:j.get("category_id")||null,tags:j.get("tags")})},children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{htmlFor:"category_id",children:"Category"}),e.jsxs(Ys,{name:"category_id",defaultValue:(r==null?void 0:r.category_id)||"",children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsx(Ks,{children:l==null?void 0:l.map(_=>e.jsx(Mt,{value:_.id,children:_.name},_.id))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script_text",children:"Script Text"}),e.jsx(Er,{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(ye,{htmlFor:"tags",children:"Tags (comma-separated)"}),e.jsx(ze,{id:"tags",name:"tags",defaultValue:((b=r==null?void 0:r.tags)==null?void 0:b.join(", "))||"",placeholder:"birthday, follow-up, thank-you"})]})]}),e.jsxs(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save"]})]})]})]})})]})}function F1s(){const{toast:t}=qa(),[s,r]=k.useState(""),[n,a]=k.useState(!0),[o,l]=k.useState(!1);k.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(Pe,{children:e.jsx(Re,{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})})}):e.jsx("div",{className:"space-y-6",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ba,{className:"h-5 w-5"}),"Popby Map Settings"]}),e.jsx(xr,{children:"Configure the map feature for popbys"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Token"]}),s&&e.jsx(tt,{variant:"secondary",className:"ml-2",children:"Token configured"})]})]})})}const z1s=()=>{const[t,s]=k.useState(""),[r,n]=k.useState("grid"),a=pr(),{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(hn,{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(Ch,{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(Pe,{children:e.jsxs(Re,{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(Pe,{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(un,{className:"h-8 w-8"})})}),e.jsxs(Re,{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:bde(c.description)})]})]},c.id))})]})})},B1s=()=>{const{serviceId:t}=yo(),s=pr(),{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(ri,{className:"h-4 w-4"}),"Back to Services"]}),e.jsx(Pe,{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(un,{className:"h-16 w-16"})})})}),e.jsx(Pe,{children:e.jsxs(Re,{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(cn,{className:"h-4 w-4 mr-1"}),"Published ",ps(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(an,{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(ri,{className:"h-4 w-4 mr-2"}),"Back to Services"]})]})})},oI=[{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 $1s(){const[t,s]=k.useState(oI[0].id),r=oI.find(n=>n.id===t)||oI[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(bM,{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(Ys,{value:t,onValueChange:s,children:[e.jsx(Gs,{className:"w-full",children:e.jsx(Qs,{placeholder:"Select a tool"})}),e.jsx(Ks,{children:oI.map(n=>e.jsx(Mt,{value:n.id,children:n.name},n.id))})]})}),e.jsx("div",{className:"hidden md:block",children:e.jsx(ja,{value:t,onValueChange:s,className:"w-full",children:e.jsx(ga,{className:"w-full flex-wrap h-auto gap-1 bg-muted p-1",children:oI.map(n=>e.jsx(us,{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 $Fe="agent-os-onboarding-completed",$z=[{icon:p0,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:Fm,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:mr,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:Dd,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:No,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:Ro,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"]}],q1s=()=>{const[t,s]=k.useState(!1),[r,n]=k.useState(0),[a,o]=k.useState(!1);k.useEffect(()=>{if(!localStorage.getItem($Fe)){const _=setTimeout(()=>s(!0),500);return()=>clearTimeout(_)}},[]);const l=()=>{r<$z.length-1?(o(!0),setTimeout(()=>{n(r+1),o(!1)},150)):c()},i=()=>{c()},c=()=>{localStorage.setItem($Fe,"true"),s(!1)},u=$z[r],p=u.icon,f=r===$z.length-1,g=b=>{b||c(),s(b)};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(un,{className:"h-3 w-3"}),"Beta"]})]}),e.jsxs("div",{className:"p-6 pt-4",children:[e.jsxs(_s,{className:"text-center sm:text-center pb-2",children:[e.jsx(bs,{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((b,_)=>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(fa,{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:b})]},_))}),e.jsx("div",{className:"flex justify-center gap-2 py-4",children:$z.map((b,_)=>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}=Rs();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})},V1s=()=>{const t=es(),{user:s}=Rs();return Lt({mutationFn:async({contactId:r,days:n})=>{if(!(s!=null&&s.id))throw new Error("Not authenticated");const a=Tl(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"]}),vn({title:"Touch snoozed!",description:"Contact has been snoozed."})},onError:r=>{vn({title:"Error snoozing contact",description:r.message,variant:"destructive"})}})},H1s=()=>{const t=es();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"]}),vn({title:"Snooze cancelled"})},onError:s=>{vn({title:"Error cancelling snooze",description:s.message,variant:"destructive"})}})},W1s=[{label:"1 week",days:7},{label:"2 weeks",days:14},{label:"1 month",days:30}];function Bhe({open:t,onOpenChange:s,contactId:r,contactName:n}){const[a,o]=k.useState(null),l=V1s(),i=async()=>{a&&(await l.mutateAsync({contactId:r,days:a}),o(null),s(!1))},c=u=>ps(Tl(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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(mn,{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:W1s.map(u=>e.jsxs("button",{type:"button",onClick:()=>o(u.days),className:Pt("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(cn,{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 G1s={Crown:Im,FileText:En,Users:mr,Globe:Su,Star:Jn,Phone:Un,MessageSquare:io,PenTool:$_,Video:Cn,Gift:No};function K1s({actions:t,onMarkComplete:s,onViewScript:r,isLoading:n,buildSmsLink:a,buildEmailLink:o,onGmailCompose:l}){const i=pr(),[c,u]=k.useState("name"),[p,f]=k.useState("asc"),[g,b]=k.useState(null),[_,j]=k.useState(""),w=L=>{c===L?f(R=>R==="asc"?"desc":"asc"):(u(L),f("asc"))},N=k.useMemo(()=>[...t].sort((L,R)=>{var U,B;let q=0;switch(c){case"name":{const V=`${L.contact.first_name} ${L.contact.last_name||""}`.toLowerCase(),Y=`${R.contact.first_name} ${R.contact.last_name||""}`.toLowerCase();q=V.localeCompare(Y);break}case"relationship_type":q=(L.relationshipTypeName||"").localeCompare(R.relationshipTypeName||"");break;case"action_type":q=(((U=L.actionType)==null?void 0:U.name)||"").localeCompare(((B=R.actionType)==null?void 0:B.name)||"");break;case"last_touch":q=(L.monthNumber||0)-(R.monthNumber||0);break}return p==="asc"?q:-q}),[t,c,p]),C=L=>G1s[L||"Phone"]||Un,M=({field:L,children:R})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>w(L),children:[R,c===L?p==="asc"?e.jsx(Nu,{className:"ml-2 h-4 w-4"}):e.jsx(Hh,{className:"ml-2 h-4 w-4"}):e.jsx(yd,{className:"ml-2 h-4 w-4 opacity-50"})]}),I=(L,R,q)=>{b(L),j(`${R} ${q||""}`.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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[180px]",children:e.jsx(M,{field:"name",children:"Contact"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(M,{field:"relationship_type",children:"Type"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(M,{field:"action_type",children:"Action"})}),e.jsx(kt,{className:"w-[130px]",children:"Phone"}),e.jsx(kt,{className:"w-[200px]",children:"Quick Actions"})]})}),e.jsx(On,{children:N.map((L,R)=>{var J,te,X,ce,ne,re;const q=L.isSpecialDate,U=L.specialDateType,B=q?U==="birthday"?Sh:Sn:C(((J=L.actionType)==null?void 0:J.icon)||null),V=L.contact.phone,Y=L.contact.email;return e.jsxs(Ss,{className:Pt("hover:bg-muted/50 transition-colors",q&&U==="birthday"&&"bg-pink-50/50 dark:bg-pink-950/20",q&&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/${L.contact.id}`),className:"truncate max-w-[160px] text-left hover:text-primary hover:underline transition-colors",children:[L.contact.first_name," ",L.contact.last_name]})})}),e.jsx(dt,{children:L.relationshipTypeName?e.jsx(tt,{variant:"secondary",className:"text-xs",children:L.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:q?e.jsx(tt,{className:Pt("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(Sh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sn,{className:"h-3 w-3"})," Anniversary"]})}):e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(B,{className:"h-3 w-3"}),(te=L.actionType)==null?void 0:te.name]})})}),e.jsx(dt,{children:V?e.jsx("span",{className:"text-sm font-mono",children:L.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:${L.contact.phone}`,className:"p-1.5 rounded bg-primary/10 hover:bg-primary/20 text-primary transition-colors",title:"Call",children:e.jsx(Un,{className:"h-3.5 w-3.5"})}),V&&e.jsx("a",{href:a(L.contact.phone,(X=L.script)==null?void 0:X.script_body,L.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(io,{className:"h-3.5 w-3.5"})}),Y&&(l?e.jsx("button",{onClick:()=>l({id:L.contact.id,first_name:L.contact.first_name,last_name:L.contact.last_name,email:L.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(dr,{className:"h-3.5 w-3.5"})}):e.jsx("a",{href:o(L.contact.email,(ce=L.script)==null?void 0:ce.script_body,(ne=L.script)==null?void 0:ne.email_subject,(re=L.actionType)==null?void 0:re.name,L.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(dr,{className:"h-3.5 w-3.5"})})),q&&e.jsxs("button",{onClick:()=>{const le=`${L.contact.first_name}${L.contact.last_name?" "+L.contact.last_name:""}`,pe=U==="birthday"?"birthday":"home_anniversary",xe=new URLSearchParams({cardType:pe,contactId:L.contact.id,name:le,...L.contact.address?{address:L.contact.address}:{},...U==="anniversary"&&L.contact.home_anniversary?{date:L.contact.home_anniversary}:{}});i(`/mission-control/card-studio?${xe.toString()}`)},className:Pt("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(dr,{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:()=>I(L.contact.id,L.contact.first_name,L.contact.last_name),title:"Snooze",children:e.jsx(Dm,{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 le;return s(L.contact.id,L.actionType.id,(le=L.script)==null?void 0:le.id)},disabled:n,children:[e.jsx(la,{className:"h-3.5 w-3.5 mr-1"}),"Done"]})]})})]},`${L.contact.id}-${R}`)})})]})}),e.jsx(Bhe,{open:!!g,onOpenChange:L=>!L&&b(null),contactId:g||"",contactName:_})]})}function $0(){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 Z1s({onSelect:t}){const[s,r]=k.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(ws,{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(ll,{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(ws,{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(Gi,{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(tt,{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(xa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]},c.id))})]})}function eSe(){var a;const{user:t}=Rs(),{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[{data:o,error:l},{data:i,error:c}]=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()]);if(l)throw l;if(c)throw c;return{reply_to_email:((u=o==null?void 0:o.reply_to_email)==null?void 0:u.trim())||((p=i==null?void 0:i.email)==null?void 0:p.trim())||null,display_name:((f=o==null?void 0:o.display_name)==null?void 0:f.trim())||((g=i==null?void 0:i.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 Y1s=5*1024*1024,kv=50,X1s=["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 Q1s(t){return t<1024?t+" B":t<1024*1024?(t/1024).toFixed(1)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function J1s(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 Lb(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 jE({open:t,onOpenChange:s,contact:r,bulkContacts:n,defaultSubject:a="",defaultBody:o="",gmailEmail:l,onSendComplete:i}){const{user:c}=Rs(),u=es(),{isReady:p,settings:f}=eSe(),g=!!n&&n.length>0,b=g&&p,_=g?n:r?[r]:[],j=_[0],w=g?Math.ceil(_.length/kv):1,N=g&&_.length>kv,[C,M]=k.useState((j==null?void 0:j.email)||""),[I,L]=k.useState(a),[R,q]=k.useState(o),[U,B]=k.useState(!1),[V,Y]=k.useState(!1),[J,te]=k.useState([]),[X,ce]=k.useState(a),[ne,re]=k.useState(o),[le,pe]=k.useState("composing"),[xe,_e]=k.useState(0),[fe,we]=k.useState(0),[Ie,Ne]=k.useState(0),[Ae,Fe]=k.useState(0),Ce=k.useRef(!1),[Me,$e]=k.useState(null);k.useEffect(()=>{t&&(M((j==null?void 0:j.email)||""),ce(a),re(o),L(Lb(a,j||{first_name:""})),q(Lb(o,j||{first_name:""})),Y(!a&&!o),te([]),pe("composing"),_e(0),we(0),Ne(0),Fe(0),Ce.current=!1,$e(null))},[t,j,a,o]);const ct=async Je=>{const He=Je.target.files;if(!He)return;const Qe=J.reduce((It,Ut)=>It+Ut.size,0),at=[];for(const It of Array.from(He)){if(!X1s.includes(It.type)){he.error(`${It.name}: Unsupported file type`);continue}if(Qe+It.size>Y1s){he.error("Total attachments exceed 5MB limit");break}try{const Ut=await J1s(It);at.push({name:It.name,type:It.type,size:It.size,data:Ut})}catch{he.error(`Failed to read ${It.name}`)}}te(It=>[...It,...at]),Je.target.value=""},Te=Je=>{te(He=>He.filter((Qe,at)=>at!==Je))},ft=Je=>{ce(Je.subject),re(Je.body),L(Lb(Je.subject,j||{first_name:""})),q(Lb(Je.body,j||{first_name:""})),Y(!1)},me=Je=>Je.split(/\n\n+/).map(He=>`

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

`).join(""),Ve=async Je=>{const He=Lb(X,Je),Qe=Lb(ne,Je),at=me(Qe);try{if(b){const It=(f==null?void 0:f.display_name)||"ReLevelUp",Ut=`${It.toLowerCase().replace(/[^a-z]/g,".")}@send.relevelup.com`,hs=`${It} <${Ut}>`,{data:Yt,error:ts}=await H.functions.invoke("ses-send-campaign",{body:{action:"test_send",to:Je.email,from_email:hs,subject:He,body_html:at,reply_to:(f==null?void 0:f.reply_to_email)||void 0}});if(ts)throw ts;if(!(Yt!=null&&Yt.success))throw new Error((Yt==null?void 0:Yt.error)||"Failed to send")}else{const{data:It,error:Ut}=await H.functions.invoke("gmail-send",{body:{to:Je.email,subject:He,body:at,contactId:Je.id,attachments:J.map(({name:hs,type:Yt,data:ts})=>({name:hs,type:Yt,data:ts}))}});if(Ut)throw Ut;if(!(It!=null&&It.success))throw new Error((It==null?void 0:It.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:He,source:b?"ses_bulk":"sphere_gaps"}),!0}catch(It){return console.error("Send error:",It),he.error("Failed to send to "+Je.first_name+": "+(It instanceof Error?It.message:"Unknown error")),!1}},nt=()=>{const Je=xe*kv;return _.slice(Je,Je+kv)},et=async()=>{if(!I||!R){he.error("Please fill in subject and message");return}const Je=nt();B(!0),pe("sending");let He=0,Qe=0;for(let It=0;ItsetTimeout(hs,150));we(It=>It+He),Ne(It=>It+Qe),B(!1),u.invalidateQueries({queryKey:["bulk-email-sends"]}),xe>=w-1||Ce.current?pe("all_done"):pe("batch_complete")},Se=async()=>{if(!I||!R){he.error("Please fill in subject and message");return}if(!g){B(!0);const Je=await Ve(j);B(!1),Je&&(u.invalidateQueries({queryKey:["bulk-email-sends"]}),he.success("Email sent successfully!"),s(!1),i==null||i());return}await et()},rt=async()=>{_e(Je=>Je+1),Fe(0),await new Promise(Je=>setTimeout(Je,50)),await et()};k.useEffect(()=>{},[xe]);const Ge=()=>{if(U){Ce.current=!0;return}s(!1),i==null||i()},lt=xe*kv,qe=Math.min(lt+kv,_.length),Ze=g&&_.length>0?Math.round((fe+Ie)/_.length*100):0;return e.jsx(xs,{open:t,onOpenChange:Ge,children:e.jsxs(fs,{className:"sm:max-w-[600px] max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:`h-5 w-5 ${b?"text-orange-500":"text-red-500"}`}),g?`Send to ${_.length} Contacts`:"Compose Email"]}),b?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&&le==="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."]})]}),le==="sending"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(ws,{className:"h-8 w-8 animate-spin mx-auto text-primary"}),e.jsxs("p",{className:"font-medium",children:["Sending batch ",xe+1," of ",w,"..."]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Ae," of ",nt().length," in this batch"]})]}),e.jsx(Bi,{value:Ae/nt().length*100,className:"h-2"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Overall: ",fe+Ie," / ",_.length]}),e.jsxs("span",{children:[fe," sent • ",Ie," failed"]})]}),e.jsx(K,{variant:"outline",size:"sm",className:"w-full",onClick:()=>{Ce.current=!0},children:"Stop Sending"})]}),le==="batch_complete"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(la,{className:"h-8 w-8 text-emerald-500 mx-auto"}),e.jsxs("p",{className:"font-medium",children:["Batch ",xe+1," Complete!"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[fe," sent, ",Ie," failed so far"]})]}),e.jsx(Bi,{value:Ze,className:"h-2"}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[_.length-fe-Ie," contacts remaining (",w-xe-1," batches left)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:Ge,children:"Done for Now"}),e.jsxs(K,{className:"flex-1 gap-2",onClick:rt,children:[e.jsx(Rn,{className:"h-4 w-4"}),"Send Next ",Math.min(kv,_.length-qe)," Contacts"]})]})]}),le==="all_done"&&e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx(la,{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:[fe," emails sent successfully",Ie>0&&e.jsxs("span",{className:"text-destructive",children:[" • ",Ie," failed"]})]})]}),e.jsx(K,{className:"w-full",onClick:Ge,children:"Close"})]}),le==="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(En,{className:"h-4 w-4"})," Choose a Template"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Y(!1),className:"h-7 px-2 text-xs",children:[e.jsx(Or,{className:"h-3 w-3 mr-1"})," Write from scratch"]})]}),e.jsx(Z1s,{onSelect:ft})]}):e.jsxs(K,{variant:"outline",size:"sm",className:"gap-2",onClick:()=>Y(!0),children:[e.jsx(En,{className:"h-4 w-4"}),"Browse Templates"]}),e.jsx(sl,{}),!g&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"gmail-to",children:"To"}),e.jsx(ze,{id:"gmail-to",value:C,onChange:Je=>M(Je.target.value),placeholder:"recipient@example.com"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"gmail-subject",children:"Subject"}),e.jsx(ze,{id:"gmail-subject",value:I,onChange:Je=>{L(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(ye,{htmlFor:"gmail-body",children:"Message"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(tt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Je=>Je+"{{first_name}}"),re(Je=>Je+"{{first_name}}")},children:"{{first_name}}"}),e.jsx(tt,{variant:"outline",className:"text-[10px] cursor-pointer hover:bg-accent",onClick:()=>{q(Je=>Je+"{{last_name}}"),re(Je=>Je+"{{last_name}}")},children:"{{last_name}}"})]})]}),e.jsx(Er,{id:"gmail-body",value:R,onChange:Je=>{q(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(iS,{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:ct})]}),J.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:J.map((Je,He)=>e.jsxs(tt,{variant:"secondary",className:"gap-1.5 pl-2 pr-1 py-1",children:[e.jsx(iS,{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:["(",Q1s(Je.size),")"]}),e.jsx("button",{type:"button",onClick:()=>Te(He),className:"ml-0.5 rounded-full p-0.5 hover:bg-muted",children:e.jsx(Or,{className:"h-3 w-3"})})]},He))})]}),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:()=>{$e(_[0]||null),pe("reviewing")},disabled:!I||!R,className:"gap-2",children:["Review Emails",e.jsx(fi,{className:"h-4 w-4"})]}):e.jsxs(K,{onClick:Se,disabled:U||!I||!R,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"}),U?"Sending...":"Send Email"]})]})]}),le==="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."]}),N&&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 ",w," batches of up to ",kv,". You'll confirm before each batch."]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{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 ${(Me==null?void 0:Me.id)===Je.id?"bg-primary/10 text-primary font-medium":"text-muted-foreground hover:bg-accent hover:text-foreground"}`,onClick:()=>$e(Je),children:[Je.first_name," ",Je.last_name," — ",Je.email]},Je.id))})]}),Me&&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(dr,{className:"h-3.5 w-3.5"}),"Preview for ",Me.first_name," ",Me.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:"})," ",Me.email]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Subject:"})," ",Lb(X,Me)]})]}),e.jsx(sl,{}),e.jsx("div",{className:"text-sm whitespace-pre-wrap bg-background rounded p-2.5 max-h-40 overflow-y-auto border",children:Lb(ne,Me)})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>{pe("composing"),$e(null)},children:[e.jsx(ri,{className:"h-4 w-4 mr-1"}),"Back to Edit"]}),e.jsxs(K,{onClick:Se,disabled:U,className:"gap-2",children:[U?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"}),N?`Send First ${kv}`:`Send to ${_.length}`]})]})]})]})})}function ebs(){const t=pr(),{data:s}=Wm(),{data:r}=FO(),n=bNe(),{isGmailConnected:a,gmailEmail:o}=$0(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(new Set),g=Bm(new Date),b=Tl(g,30),_=I=>{if(!I)return null;const L=I.split(/[-/T]/);if(L.length<3)return null;const R=parseInt(L[1],10)-1,q=parseInt(L[2],10);return isNaN(R)||isNaN(q)?null:new Date(g.getFullYear(),R,q)},j=k.useMemo(()=>{if(!s)return[];const I=[];for(const L of s){if(L.birthday){const R=_(L.birthday);R&&(Sl(R,g)||RS(R,g)&&FS(R,b))&&I.push({contact:L,type:"birthday",date:R,daysUntil:hf(R,g),dateStr:L.birthday})}if(L.home_anniversary){const R=_(L.home_anniversary);R&&(Sl(R,g)||RS(R,g)&&FS(R,b))&&I.push({contact:L,type:"anniversary",date:R,daysUntil:hf(R,g),dateStr:L.home_anniversary})}}return I.sort((L,R)=>L.daysUntil-R.daysUntil),I},[s]),w=async I=>{const L=(r==null?void 0:r.find(R=>R.name==="Call"))||(r==null?void 0:r[0]);if(L)try{await n.mutateAsync({contactId:I.contact.id,actionTypeId:L.id,notes:`${I.type==="birthday"?"Birthday":"Home Anniversary"} outreach`}),f(R=>new Set(R).add(`${I.contact.id}-${I.type}`)),vn({title:"Touch logged!",description:`Logged outreach for ${I.contact.first_name}`})}catch{vn({title:"Error",description:"Failed to log touch",variant:"destructive"})}},N=I=>{const L=`${I.contact.first_name}${I.contact.last_name?" "+I.contact.last_name:""}`,R=I.type==="birthday"?"birthday":"home_anniversary",q=new URLSearchParams({cardType:R,contactId:I.contact.id,name:L,...I.contact.address?{address:I.contact.address}:{},...I.type==="anniversary"&&I.dateStr?{date:I.dateStr}:{}});t(`/mission-control/card-studio?${q.toString()}`)},C=I=>I===0?"Today!":I===1?"Tomorrow":`${I} days`,M=I=>I===0?"bg-red-500/15 text-red-600 dark:text-red-400 border-red-500/30":I<=3?"bg-amber-500/15 text-amber-600 dark:text-amber-400 border-amber-500/30":I<=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(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Dd,{className:"h-5 w-5 text-primary"}),"Upcoming Milestones",e.jsx(tt,{variant:"secondary",className:"text-xs font-normal",children:"Next 30 days"})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[j.length," event",j.length!==1?"s":""]})]})}),e.jsxs(Re,{className:"space-y-2",children:[j.length===0&&e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Sh,{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."})]}),j.map((I,L)=>{var B,V;const R=`${I.contact.id}-${I.type}`,q=p.has(R),U=`${((B=I.contact.first_name)==null?void 0:B[0])||""}${((V=I.contact.last_name)==null?void 0:V[0])||""}`.toUpperCase();return e.jsxs("div",{className:Pt("p-3 rounded-lg border transition-colors",I.daysUntil===0&&I.type==="birthday"?"bg-pink-500/10 border-pink-500/30 dark:bg-pink-900/20 dark:border-pink-800/40":I.daysUntil===0&&I.type==="anniversary"?"bg-blue-500/10 border-blue-500/30 dark:bg-blue-900/20 dark:border-blue-800/40":I.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(_n,{className:Pt("h-10 w-10",I.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(wn,{className:Pt("text-xs font-medium",I.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:I.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:[I.contact.first_name," ",I.contact.last_name||""]}),e.jsx(tt,{variant:"outline",className:Pt("text-[10px] shrink-0 whitespace-nowrap",M(I.daysUntil)),children:C(I.daysUntil)})]}),e.jsxs("div",{className:Pt("text-xs flex items-center gap-1.5 mt-0.5",I.type==="birthday"?"text-pink-600/80 dark:text-pink-400/80":"text-blue-600/80 dark:text-blue-400/80"),children:[I.type==="birthday"?e.jsxs(e.Fragment,{children:[e.jsx(Sh,{className:"h-3 w-3"})," Birthday"]}):e.jsxs(e.Fragment,{children:[e.jsx(Sn,{className:"h-3 w-3"})," Home Anniversary"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ps(I.date,"MMM d")})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 mt-2 pl-[52px]",children:[I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Call",asChild:!0,children:e.jsx("a",{href:`tel:${I.contact.phone}`,children:e.jsx(Un,{className:"h-3.5 w-3.5"})})}),I.contact.phone&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Text",asChild:!0,children:e.jsx("a",{href:`sms:${I.contact.phone}`,children:e.jsx(io,{className:"h-3.5 w-3.5"})})}),I.contact.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Email",onClick:()=>{a?(i({id:I.contact.id,first_name:I.contact.first_name,last_name:I.contact.last_name,email:I.contact.email}),u(!0)):window.location.href=`mailto:${I.contact.email}`},children:e.jsx(dr,{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=${I.contact.id}`),children:e.jsx(Cn,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{variant:"ghost",size:"sm",className:Pt("h-7 px-2 gap-1 text-xs",I.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 ${I.type==="birthday"?"birthday":"anniversary"} card`,onClick:()=>N(I),children:[e.jsx(un,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Card"})]}),e.jsx(K,{variant:"ghost",size:"icon",className:Pt("h-7 w-7",q&&"text-green-600"),title:"Log a touch",disabled:q||n.isPending,onClick:()=>w(I),children:e.jsx(la,{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/${I.contact.id}`),children:e.jsx(qn,{className:"h-3.5 w-3.5"})})]})]},`${R}-${L}`)})]})]}),a&&l&&e.jsx(jE,{open:c,onOpenChange:u,contact:l,gmailEmail:o})]})}const tbs={property_view:{label:"Viewed Listing",icon:qn,color:"text-blue-500",bgColor:"bg-blue-500/10",borderColor:"border-blue-200 dark:border-blue-800"},new_lead:{label:"New Lead",icon:rc,color:"text-emerald-500",bgColor:"bg-emerald-500/10",borderColor:"border-emerald-200 dark:border-emerald-800"},saved_listing:{label:"Saved Listing",icon:ii,color:"text-rose-500",bgColor:"bg-rose-500/10",borderColor:"border-rose-200 dark:border-rose-800"}};function sbs(){const{user:t}=Rs(),s=pr(),[r,n]=k.useState("all"),[a,o]=k.useState(new Set),{data:l,isLoading:i}=mt({queryKey:["lead-site-activity",t==null?void 0:t.id],queryFn:async()=>{const{data:b,error:_}=await H.rpc("get_lead_site_activity",{_user_id:t.id});if(_)throw _;return b},enabled:!!t,refetchInterval:6e4});if(i||!(l!=null&&l.has_site))return null;const c=(l.activities||[]).filter(b=>!a.has(`${b.activity_type}-${b.occurred_at}-${b.visitor_name}`)),u=r==="all"?c:c.filter(b=>b.activity_type===r),p={all:c.length,property_view:c.filter(b=>b.activity_type==="property_view").length,new_lead:c.filter(b=>b.activity_type==="new_lead").length,saved_listing:c.filter(b=>b.activity_type==="saved_listing").length},f=b=>{o(_=>new Set(_).add(`${b.activity_type}-${b.occurred_at}-${b.visitor_name}`))};if(c.length===0)return e.jsxs("section",{className:"space-y-3",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(Su,{className:"h-5 w-5 text-primary"})}),e.jsx("h2",{className:"text-lg font-semibold",children:"Website Activity"})]}),e.jsxs("div",{className:"rounded-xl border bg-card p-6 text-center",children:[e.jsx(jh,{className:"h-8 w-8 text-muted-foreground mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No website activity in the last 30 days."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Visitor engagement will appear here as leads interact with your site."})]})]});const g=[{key:"all",label:"All Activity"},{key:"new_lead",label:"New Leads",icon:rc},{key:"property_view",label:"Viewed Listings",icon:qn},{key:"saved_listing",label:"Saved",icon:ii}];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(Su,{className:"h-5 w-5 text-primary"})}),e.jsx("div",{children:e.jsxs("h2",{className:"text-lg font-semibold flex items-center gap-2",children:["Website Activity",e.jsxs(tt,{variant:"secondary",className:"text-xs font-normal",children:[e.jsx(jh,{className:"h-3 w-3 mr-1"}),c.length," new"]})]})})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Last 30 days"})]}),e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:g.map(b=>e.jsxs("button",{onClick:()=>n(b.key),className:` flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium border transition-all whitespace-nowrap ${r===b.key?"bg-primary text-primary-foreground border-primary":"bg-card border-border hover:bg-accent text-muted-foreground"} `,children:[b.icon&&e.jsx(b.icon,{className:"h-3.5 w-3.5"}),b.label,p[b.key]>0&&e.jsx("span",{className:`text-xs ${r===b.key?"opacity-80":""}`,children:p[b.key]})]},b.key))}),e.jsx("div",{className:"w-full overflow-x-auto scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent pb-1",children:e.jsx("div",{className:"flex gap-3 pb-3",style:{width:"max-content"},children:u.slice(0,20).map((b,_)=>{const j=tbs[b.activity_type],w=j.icon,N=_d(new Date(b.occurred_at),{addSuffix:!0});return e.jsxs(Pe,{className:`min-w-[280px] max-w-[320px] flex-shrink-0 border ${j.borderColor} hover:shadow-md transition-shadow relative group`,children:[e.jsx("button",{onClick:()=>f(b),className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity p-1 rounded-full hover:bg-muted",children:e.jsx(Or,{className:"h-3.5 w-3.5 text-muted-foreground"})}),e.jsxs(Re,{className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-start justify-between pr-4",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-sm truncate text-primary cursor-pointer hover:underline",onClick:()=>{b.contact_id?s(`/mission-control/contacts/${b.contact_id}`):b.visitor_name&&s(`/mission-control/contacts?search=${encodeURIComponent(b.visitor_name)}`)},children:b.visitor_name||"Anonymous Visitor"}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[e.jsxs(tt,{variant:"outline",className:`text-[10px] ${j.color} border-current/20`,children:[e.jsx(w,{className:"h-3 w-3 mr-1"}),j.label]}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:N})]})]})}),b.activity_type==="property_view"&&b.mls_number&&e.jsxs("div",{className:`text-xs px-2.5 py-1.5 rounded-md ${j.bgColor}`,children:["MLS# ",b.mls_number]}),b.activity_type==="saved_listing"&&b.mls_number&&e.jsxs("div",{className:`text-xs px-2.5 py-1.5 rounded-md ${j.bgColor} flex items-center gap-1.5`,children:[e.jsx(ii,{className:"h-3 w-3 text-rose-500 fill-rose-500"}),"Saved MLS# ",b.mls_number]}),b.activity_type==="new_lead"&&e.jsxs("div",{className:`text-xs px-2.5 py-1.5 rounded-md ${j.bgColor} space-y-0.5`,children:[b.lead_type&&e.jsx("span",{className:"capitalize font-medium",children:b.lead_type.replace(/_/g," ")}),b.message&&e.jsx("p",{className:"text-muted-foreground line-clamp-2",children:b.message})]}),e.jsxs("div",{className:"flex items-center gap-1 pt-1 border-t",children:[b.visitor_email&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-primary hover:text-primary",onClick:()=>window.location.href=`mailto:${b.visitor_email}`,children:[e.jsx(dr,{className:"h-3.5 w-3.5 mr-1"}),"Email"]}),b.visitor_phone&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-primary hover:text-primary",onClick:()=>window.location.href=`tel:${b.visitor_phone}`,children:[e.jsx(Un,{className:"h-3.5 w-3.5 mr-1"}),"Call"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-primary hover:text-primary",onClick:()=>window.location.href=`sms:${b.visitor_phone}`,children:[e.jsx(io,{className:"h-3.5 w-3.5 mr-1"}),"Text"]})]}),b.contact_id&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-7 text-xs ml-auto",onClick:()=>s(`/mission-control/contacts/${b.contact_id}`),children:["View",e.jsx(xa,{className:"h-3.5 w-3.5 ml-0.5"})]})]})]})]},`${b.activity_type}-${b.occurred_at}-${_}`)})})})]})}const qFe={Crown:Im,FileText:En,Users:mr,Globe:Su,Star:Jn,Phone:Un,MessageSquare:io,PenTool:$_,Video:Cn,Gift:No},rbs={"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 nbs(){var Ge,lt,qe,Ze,Je,He;const t=pr(),{user:s}=Rs(),{data:r}=Ux(),{data:n}=qYe(),{data:a}=Wm(),{data:o}=FO(),{data:l}=GYe(),i=lLt(),c=_Ne(),u=iLt(90),p=bNe(),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),[N,C]=k.useState(""),[M,I]=k.useState(!1),[L,R]=k.useState(""),[q,U]=k.useState(Woe()),[B,V]=k.useState("cards"),[Y,J]=k.useState(!1),[te,X]=k.useState(null),[ce,ne]=k.useState(null),[re,le]=k.useState(""),{isGmailConnected:pe,gmailEmail:xe}=$0(),_e=()=>{const Qe=parseInt(L,10);if(isNaN(Qe)||Qe<1){vn({title:"Invalid goal",description:"Please enter a number greater than 0",variant:"destructive"});return}U(Qe),WYe(Qe),I(!1),vn({title:"Goal updated",description:`Weekly touch goal set to ${Qe}`})},fe=()=>{R(q.toString()),I(!0)};k.useEffect(()=>{(async()=>{if(!(s!=null&&s.id))return;const{data:at}=await H.from("profiles").select("name").eq("id",s.id).single();at!=null&&at.name&&C(at.name.split(" ")[0])})()},[s==null?void 0:s.id]),k.useEffect(()=>{i.mutate()},[]);const we=Bm(new Date),Ie=Tl(we,7),Ne=Qe=>{if(!Qe)return null;const at=Qe.split(/[-/T]/);if(at.length<3)return null;const It=parseInt(at[1],10)-1,Ut=parseInt(at[2],10);return isNaN(It)||isNaN(Ut)?null:new Date(we.getFullYear(),It,Ut)},Ae=(a==null?void 0:a.filter(Qe=>{const at=Ne(Qe.birthday),It=Ne(Qe.home_anniversary);return at&&Sl(at,we)||It&&Sl(It,we)}))||[];a!=null&&a.filter(Qe=>{if(!Qe.birthday&&!Qe.home_anniversary)return!1;const at=It=>{if(!It)return!1;const Ut=Ne(It);return Ut?RS(Ut,we)&&FS(Ut,Ie):!1};return at(Qe.birthday)||at(Qe.home_anniversary)}).slice(0,5);const Fe=[],Ce=(o==null?void 0:o.find(Qe=>Qe.name==="Call"))||(o==null?void 0:o[0]);for(const Qe of Ae){const at=Ne(Qe.birthday),It=Ne(Qe.home_anniversary),Ut=at&&Sl(at,we),hs=It&&Sl(It,we);Ut&&Fe.push({contact:Qe,actionType:Ce||{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:((qe=(lt=(Ge=Qe.tags)==null?void 0:Ge[0])==null?void 0:lt.relationship_type)==null?void 0:qe.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"birthday"}),hs&&Fe.push({contact:Qe,actionType:Ce||{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:((He=(Je=(Ze=Qe.tags)==null?void 0:Ze[0])==null?void 0:Je.relationship_type)==null?void 0:He.name)||"",monthNumber:0,isSpecialDate:!0,specialDateType:"anniversary"})}const $e=l!==void 0?l||[]:(a==null?void 0:a.slice(0,5).map((Qe,at)=>{var Ut,hs,Yt;const It=o==null?void 0:o[at%((o==null?void 0:o.length)||1)];return It?{contact:Qe,actionType:It,planName:"Quick Touch",relationshipTypeName:((Yt=(hs=(Ut=Qe.tags)==null?void 0:Ut[0])==null?void 0:hs.relationship_type)==null?void 0:Yt.name)||"",monthNumber:0}:null}).filter(Boolean))||[],ct=[...Fe,...$e],Te=async(Qe,at,It)=>{await p.mutateAsync({contactId:Qe,actionTypeId:at,scriptUsedId:It}),w(!1),_(null)},ft=Qe=>{Qe.script?(_(Qe),w(!0)):Te(Qe.contact.id,Qe.actionType.id)},me=Qe=>qFe[Qe||"Phone"]||Un,Ve=Qe=>qFe[Qe||"Users"]||mr,nt=(Qe,at)=>Qe.replace(/\{\{FirstName\}\}/g,at.first_name).replace(/\{\{LastName\}\}/g,at.last_name||"").replace(/\{\{AgentName\}\}/g,N||"there"),et=(Qe,at)=>({Call:`Thinking of you, ${at}!`,Text:`Quick hello, ${at}`,Email:`Checking in, ${at}`,"Handwritten Note":`A note for ${at}`,Video:`Video message for ${at}`,Gift:`Something special for you, ${at}`})[Qe]||`Hello ${at}!`,Se=(Qe,at,It)=>{const Ut=`sms:${Qe}`;if(at&&It){const hs=nt(at,It);return`${Ut}?body=${encodeURIComponent(hs)}`}return Ut},rt=(Qe,at,It,Ut,hs)=>{const Yt=`mailto:${Qe}`,ts=[];if(hs){const Ds=It||et(Ut||"Email",hs.first_name);if(ts.push(`subject=${encodeURIComponent(Ds)}`),at){const vr=nt(at,hs);ts.push(`body=${encodeURIComponent(vr)}`)}}return ts.length>0?`${Yt}?${ts.join("&")}`:Yt};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(sbs,{}),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(Qe=>Qe.active).map(Qe=>{const at=Ve(Qe.icon),It=(n==null?void 0:n[Qe.id])||0,Ut=f===Qe.id,hs=rbs[Qe.name]||"bg-secondary text-secondary-foreground";return e.jsxs("button",{onClick:()=>{Ut?(g(null),t("/mission-control/contacts")):(g(Qe.id),t(`/mission-control/contacts?type=${Qe.id}`))},className:` flex items-center gap-2 px-4 py-3 rounded-lg border transition-all ${Ut?hs:"bg-card hover:bg-accent"} `,children:[e.jsx(at,{className:"h-5 w-5"}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"font-medium",children:Qe.name}),e.jsxs("div",{className:`text-sm ${Ut?"opacity-90":"text-muted-foreground"}`,children:[It," Contacts"]})]})]},Qe.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(xu,{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(xa,{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(tt,{variant:"outline",className:"gap-1",children:[e.jsx(un,{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(Ch,{className:"h-4 w-4"})})]})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:ct.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(K1s,{actions:ct,onMarkComplete:Te,onViewScript:ft,isLoading:p.isPending,buildSmsLink:Se,buildEmailLink:rt,onGmailCompose:pe?Qe=>{X(Qe),J(!0)}:void 0}):e.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[ct.map((Qe,at)=>{var Ct,As,Us,kr,ta,ka,Li;const It=Qe.isSpecialDate,Ut=Qe.specialDateType,hs=It?Ut==="birthday"?Sh:Sn:me(((Ct=Qe.actionType)==null?void 0:Ct.icon)||null),Yt=Qe.contact.phone,ts=Qe.contact.email,Ds=It?Ut==="birthday"?"#EC4899":"#8B5CF6":((As=Qe.actionType)==null?void 0:As.color)||"#3B82F6",vr=It?Ut==="birthday"?"🎂 Birthday Today!":"🏠 Home Anniversary!":(Us=Qe.actionType)==null?void 0:Us.name;return e.jsxs("div",{className:`flex-shrink-0 w-[260px] border rounded-lg overflow-hidden ${It?"ring-2 ring-offset-2":""}`,style:It?{"--tw-ring-color":Ds}:void 0,children:[e.jsxs("div",{className:"p-3 text-white flex items-center gap-2",style:{backgroundColor:Ds},children:[e.jsx(hs,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:vr})]}),e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>t(`/mission-control/contacts/${Qe.contact.id}`),className:"font-medium text-sm hover:text-primary hover:underline transition-colors text-left",children:[Qe.contact.first_name," ",Qe.contact.last_name]}),e.jsxs("div",{className:"flex gap-1.5",children:[Yt&&e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:`tel:${Qe.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(Un,{className:"h-3 w-3"}),"Call"]}),e.jsxs("a",{href:Se(Qe.contact.phone,(kr=Qe.script)==null?void 0:kr.script_body,Qe.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(io,{className:"h-3 w-3"}),"Text"]})]}),ts&&(pe?e.jsxs("button",{onClick:()=>{X({id:Qe.contact.id,first_name:Qe.contact.first_name,last_name:Qe.contact.last_name,email:Qe.contact.email}),J(!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(dr,{className:"h-3 w-3"}),"Email"]}):e.jsxs("a",{href:rt(Qe.contact.email,(ta=Qe.script)==null?void 0:ta.script_body,(ka=Qe.script)==null?void 0:ka.email_subject,(Li=Qe.actionType)==null?void 0:Li.name,Qe.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(dr,{className:"h-3 w-3"}),"Email"]}))]}),It&&e.jsxs("button",{onClick:()=>{const Wa=`${Qe.contact.first_name}${Qe.contact.last_name?" "+Qe.contact.last_name:""}`,cr=Ut==="birthday"?"birthday":"home_anniversary",Qr=new URLSearchParams({cardType:cr,contactId:Qe.contact.id,name:Wa,...Qe.contact.address?{address:Qe.contact.address}:{},...Ut==="anniversary"&&Qe.contact.home_anniversary?{date:Qe.contact.home_anniversary}:{}});t(`/mission-control/card-studio?${Qr.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(dr,{className:"h-3 w-3"}),"Send ",Ut==="birthday"?"Birthday":"Anniversary"," Card"]}),!Yt&&!ts&&e.jsx("p",{className:"text-xs text-muted-foreground italic",children:"No contact info"}),e.jsxs("div",{className:"flex gap-1 flex-wrap",children:[Qe.relationshipTypeName&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:Qe.relationshipTypeName}),Qe.monthNumber>0&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:["Month ",Qe.monthNumber]})]}),Qe.script&&e.jsx(K,{size:"sm",variant:"outline",className:"w-full",onClick:()=>ft(Qe),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(Qe.contact.id),le(`${Qe.contact.first_name} ${Qe.contact.last_name||""}`.trim())},children:[e.jsx(Dm,{className:"h-3.5 w-3.5"}),"Snooze"]}),e.jsx(K,{size:"sm",className:"flex-1",onClick:()=>{var Wa;return Te(Qe.contact.id,Qe.actionType.id,(Wa=Qe.script)==null?void 0:Wa.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]},Qe.contact.id+at)}),e.jsx("div",{className:"flex-shrink-0 w-[100px] border rounded-lg flex items-center justify-center",children:e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{variant:"ghost",className:"h-full w-full",children:[e.jsx(px,{className:"h-5 w-5 mr-2"}),"More"]})}),e.jsx(zd,{children:e.jsx(Ca,{onClick:()=>t("/mission-control/contacts"),children:"View all contacts"})})]})})]})})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"text-lg",children:"Momentum"}),e.jsxs(xs,{open:M,onOpenChange:I,children:[e.jsx(qi,{asChild:!0,children:e.jsx("button",{onClick:fe,className:"p-0.5 rounded hover:bg-muted transition-colors","aria-label":"Edit weekly goal",children:e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground hover:text-primary"})})}),e.jsxs(fs,{className:"sm:max-w-[360px]",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"weekly-goal-ic",children:"Weekly touch goal"}),e.jsx(ze,{id:"weekly-goal-ic",type:"number",min:"1",value:L,onChange:Qe=>R(Qe.target.value),placeholder:"20",onKeyDown:Qe=>{Qe.key==="Enter"&&_e()}})]}),e.jsx(K,{onClick:_e,className:"w-full",children:"Save Goal"})]})]})]})]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(Bi,{value:Math.min(c.actionsThisWeek/q*100,100),className:"h-3 w-full max-w-full"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Qu,{className:"h-5 w-5 text-orange-500"}),e.jsxs("span",{className:"font-medium",children:[c.actionsThisWeek," / ",q]}),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(mn,{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(xa,{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(lXe,{}),e.jsx(ebs,{})]})]}),e.jsx(xs,{open:j,onOpenChange:w,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{className:"flex items-center gap-2",children:b&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:b.actionType.color||"#3B82F6"}}),b.actionType.name," Script"]})})}),b&&b.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:[b.contact.first_name," ",b.contact.last_name]})]}),e.jsx("div",{className:"bg-muted p-4 rounded-lg",children:e.jsx("p",{className:"whitespace-pre-wrap",children:nt(b.script.script_body,b.contact)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>w(!1),children:"Close"}),e.jsx(K,{className:"flex-1",onClick:()=>{var Qe;return Te(b.contact.id,b.actionType.id,(Qe=b.script)==null?void 0:Qe.id)},disabled:p.isPending,children:"Mark Complete"})]})]})]})}),e.jsx(q1s,{})]}),pe&&te&&e.jsx(jE,{open:Y,onOpenChange:J,contact:te,gmailEmail:xe}),e.jsx(Bhe,{open:!!ce,onOpenChange:Qe=>!Qe&&ne(null),contactId:ce||"",contactName:re})]})}var bat="Toggle",tSe=k.forwardRef((t,s)=>{const{pressed:r,defaultPressed:n,onPressedChange:a,...o}=t,[l,i]=rh({prop:r,onChange:a,defaultProp:n??!1,caller:bat});return e.jsx(sn.button,{type:"button","aria-pressed":l,"data-state":l?"on":"off","data-disabled":t.disabled?"":void 0,...o,ref:s,onClick:Ir(t.onClick,()=>{t.disabled||i(!l)})})});tSe.displayName=bat;var _at=tSe,Bw="ToggleGroup",[wat]=nd(Bw,[Cw]),jat=Cw(),sSe=ht.forwardRef((t,s)=>{const{type:r,...n}=t;if(r==="single"){const a=n;return e.jsx(abs,{...a,ref:s})}if(r==="multiple"){const a=n;return e.jsx(ibs,{...a,ref:s})}throw new Error(`Missing prop \`type\` expected on \`${Bw}\``)});sSe.displayName=Bw;var[Nat,kat]=wat(Bw),abs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=rh({prop:r,defaultProp:n??"",onChange:a,caller:Bw});return e.jsx(Nat,{scope:t.__scopeToggleGroup,type:"single",value:ht.useMemo(()=>l?[l]:[],[l]),onItemActivate:i,onItemDeactivate:ht.useCallback(()=>i(""),[i]),children:e.jsx(Sat,{...o,ref:s})})}),ibs=ht.forwardRef((t,s)=>{const{value:r,defaultValue:n,onValueChange:a=()=>{},...o}=t,[l,i]=rh({prop:r,defaultProp:n??[],onChange:a,caller:Bw}),c=ht.useCallback(p=>i((f=[])=>[...f,p]),[i]),u=ht.useCallback(p=>i((f=[])=>f.filter(g=>g!==p)),[i]);return e.jsx(Nat,{scope:t.__scopeToggleGroup,type:"multiple",value:l,onItemActivate:c,onItemDeactivate:u,children:e.jsx(Sat,{...o,ref:s})})});sSe.displayName=Bw;var[obs,lbs]=wat(Bw),Sat=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,disabled:n=!1,rovingFocus:a=!0,orientation:o,dir:l,loop:i=!0,...c}=t,u=jat(r),p=Sw(l),f={role:"group",dir:p,...c};return e.jsx(obs,{scope:r,rovingFocus:a,disabled:n,children:a?e.jsx(Ede,{asChild:!0,...u,orientation:o,dir:p,loop:i,children:e.jsx(sn.div,{...f,ref:s})}):e.jsx(sn.div,{...f,ref:s})})}),Vce="ToggleGroupItem",Cat=ht.forwardRef((t,s)=>{const r=kat(Vce,t.__scopeToggleGroup),n=lbs(Vce,t.__scopeToggleGroup),a=jat(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(Pde,{asChild:!0,...a,focusable:!l,active:o,ref:c,children:e.jsx(UFe,{...i,ref:s})}):e.jsx(UFe,{...i,ref:s})});Cat.displayName=Vce;var UFe=ht.forwardRef((t,s)=>{const{__scopeToggleGroup:r,value:n,...a}=t,o=kat(Vce,r),l={role:"radio","aria-checked":t.pressed,"aria-pressed":void 0},i=o.type==="single"?l:void 0;return e.jsx(tSe,{...i,...a,ref:s,onPressedChange:c=>{c?o.onItemActivate(n):o.onItemDeactivate(n)}})}),Mat=sSe,Tat=Cat;const Aat=lC("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"}}),cbs=k.forwardRef(({className:t,variant:s,size:r,...n},a)=>e.jsx(_at,{ref:a,className:Pt(Aat({variant:s,size:r,className:t})),...n}));cbs.displayName=_at.displayName;const Eat=k.createContext({size:"default",variant:"default"}),Pat=k.forwardRef(({className:t,variant:s,size:r,children:n,...a},o)=>e.jsx(Mat,{ref:o,className:Pt("flex items-center justify-center gap-1",t),...a,children:e.jsx(Eat.Provider,{value:{variant:s,size:r},children:n})}));Pat.displayName=Mat.displayName;const Iat=k.forwardRef(({className:t,children:s,variant:r,size:n,...a},o)=>{const l=k.useContext(Eat);return e.jsx(Tat,{ref:o,className:Pt(Aat({variant:l.variant||r,size:l.size||n}),t),...a,children:s})});Iat.displayName=Tat.displayName;const dbs=[{value:"bidirectional",label:"Two-Way",icon:yd,tooltip:"Sync contacts in both directions"},{value:"push_only",label:"Push Only",icon:Nu,tooltip:"Only push Agent OS → BoldTrail"},{value:"pull_only",label:"Pull Only",icon:Hh,tooltip:"Only pull BoldTrail → Agent OS"}];function D_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(Pat,{type:"single",value:t,onValueChange:a=>{a&&s(a)},className:"justify-start",children:dbs.map(a=>e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsxs(Iat,{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(gc,{children:a.tooltip})]},a.value))})]})}function ubs(){const t=es(),[s,r]=k.useState(!1),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(0),j=k.useRef(!1),{data:w}=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}}),N=(w==null?void 0:w.sync_direction)||"bidirectional",C=u??N,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=>{he.error(B.message||"Failed to generate sync preview")}}),I=Lt({mutationFn:async()=>{j.current=!1,g("Initializing sync..."),_(5);const{data:B,error:V}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:C}});if(V)throw V;if(B!=null&&B.error)throw new Error(B.error);const Y=B;let J=Y.sync_log_id,te=Y.next_phase,X=Y.next_offset;const ce=Y.push_total||0,ne=Y.pull_total||0,re=Y.update_total||0,le=ce+ne+re;let pe=0,xe=0,_e=0;for(;te!=="finalize"&&!j.current;){te==="push"?(g(`Pushing contacts to BoldTrail... (${pe}/${ce})`),_(le>0?pe/le*90:0)):te==="pull"?(g(`Pulling contacts from BoldTrail... (${xe}/${ne})`),_(le>0?(ce+xe)/le*90:0)):te==="update"&&(g(`Updating existing contacts... (${_e}/${re})`),_(le>0?(ce+ne+_e)/le*90:0));const{data:Ie,error:Ne}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:te,offset:X,sync_log_id:J,sync_direction:C}});if(Ne)throw Ne;if(Ie!=null&&Ie.error)throw new Error(Ie.error);const Ae=Ie;pe+=Ae.chunk_pushed||0,xe+=Ae.chunk_pulled||0,_e+=Ae.chunk_updated||0,Ae.progress&&g(Ae.progress),te=Ae.next_phase,X=Ae.next_offset}g("Finalizing sync..."),_(95);const{data:fe,error:we}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:J,sync_direction:C}});if(we)throw we;return _(100),fe},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`];he.success(`Sync complete! ${V.join(", ")}.`)},onError:B=>{g(null),_(0),he.error(B.message||"Sync failed")}});if(!(w!=null&&w.connected))return null;const L=C==="pull_only"?0:(n==null?void 0:n.to_push)??0,R=C==="push_only"?0:(n==null?void 0:n.to_pull)??0,q=(n==null?void 0:n.to_update)??0,U=L>0||R>0||q>0;return e.jsxs(e.Fragment,{children:[e.jsxs(Oc,{children:[e.jsx(Rc,{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(yd,{className:"h-4 w-4 text-emerald-600"})})}),e.jsx(gc,{children:"Sync with BoldTrail"})]}),e.jsx(xs,{open:s,onOpenChange:B=>{I.isPending||r(B)},children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(yd,{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(D_e,{value:C,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 ${C==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:L}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Nu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${C==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:R}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Hh,{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:q}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(RM,{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(mr,{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"]}),q>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(RM,{className:"h-3 w-3 inline mr-1"}),q," contacts have missing fields that will be filled from the other system"]}),L>0&&e.jsxs(gf,{open:o,onOpenChange:l,children:[e.jsx(yf,{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(Nu,{className:"h-3 w-3 text-emerald-600"}),L," contacts to push to BoldTrail"]}),e.jsx(To,{className:`h-3 w-3 transition-transform ${o?"rotate-180":""}`})]})}),e.jsx(vf,{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"]})]})})]}),R>0&&e.jsxs(gf,{open:i,onOpenChange:c,children:[e.jsx(yf,{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(Hh,{className:"h-3 w-3 text-blue-600"}),R," contacts to pull from BoldTrail"]}),e.jsx(To,{className:`h-3 w-3 transition-transform ${i?"rotate-180":""}`})]})}),e.jsx(vf,{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&&!I.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."}),I.isPending&&e.jsxs("div",{className:"space-y-2 py-2",children:[e.jsx(Bi,{value:b||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:I.isPending,children:"Cancel"}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending||!U,className:"gap-2",children:[I.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(yd,{className:"h-4 w-4"}),I.isPending?"Syncing...":"Sync Now"]})]})]})]})})]})}const hbs=()=>{const{user:t}=Rs();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})},$he=t=>{const{user:s}=Rs();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})},rSe=()=>{const{user:t}=Rs();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})},Lat=()=>{const{user:t}=Rs();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})},mbs=()=>{const{data:t}=Wm(),{data:s}=Ux(),{data:r}=$he(),{data:n}=Lat(),{data:a}=rSe(),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=Bm(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 w=p.tags.map(N=>l.get(N.relationship_type_id)).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}const g=o.get(p.id)||null,b=g?iy(c,Bm(new Date(g))):null,_=b===null||b>=f,j=_&&b!==null?b-f:0;return{...p,lastPopby:g,daysSinceLastPopby:b,frequencyDays:f,isDue:_,daysOverdue:j}}).sort((p,f)=>f.daysOverdue-p.daysOverdue)},Dat=()=>mbs().filter(s=>s.isDue),pbs=()=>{const t=es(),{user:s}=Rs();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"]}),vn({title:"Popby item created!"})},onError:r=>{vn({title:"Error creating popby item",description:r.message,variant:"destructive"})}})},fbs=()=>{const t=es(),{user:s}=Rs();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"]}),vn({title:"Popby logged!"})},onError:r=>{vn({title:"Error logging popby",description:r.message,variant:"destructive"})}})},xbs=()=>{const t=es(),{user:s}=Rs();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"]}),vn({title:"Frequency updated!"})},onError:r=>{vn({title:"Error updating frequency",description:r.message,variant:"destructive"})}})},gbs=()=>{const{data:t}=$he(30),s=Dat(),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 ybs(){const{user:t}=Rs();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 Oat(t){const{data:s}=ybs(),{data:r}=Lat(),{data:n}=rSe(),{data:a}=U1s();return k.useMemo(()=>{const o=a==null?void 0:a.find(w=>w.contact_id===t.id),l=o?new Date(o.snoozed_until):null,i=Bm(new Date);if(l&&!FS(l,i))return{nextTouchDate:l,daysUntil:iy(l,i),status:"snoozed",frequencyDays:90,lastTouchDate:null,snoozedUntil:l};const u=((s==null?void 0:s.filter(w=>w.contact_id===t.id))||[]).sort((w,N)=>new Date(N.completed_at).getTime()-new Date(w.completed_at).getTime())[0],p=u?new Date(u.completed_at):null;let f=90;const g=r==null?void 0:r.find(w=>w.contact_id===t.id&&w.is_active);if(g)f=g.frequency_days;else if(t.tags&&t.tags.length>0){const w=t.tags.map(N=>{const C=n==null?void 0:n.find(M=>M.relationship_type_id===N.relationship_type_id);return C==null?void 0:C.frequency_days}).filter(N=>N!==void 0);w.length>0&&(f=Math.min(...w))}if(!p)return{nextTouchDate:null,daysUntil:null,status:"never-touched",frequencyDays:f,lastTouchDate:null,snoozedUntil:null};const b=Tl(Bm(p),f),_=iy(b,i);let j;return _<0?j="overdue":_<=7?j="due-soon":j="on-track",{nextTouchDate:b,daysUntil:_,status:j,frequencyDays:f,lastTouchDate:p,snoozedUntil:null}},[t,s,r,n,a])}function O_e({contact:t}){const s=Oat(t),n=(()=>{switch(s.status){case"overdue":return{variant:"destructive",icon:Nl,text:`${Math.abs(s.daysUntil)} days overdue`,className:""};case"due-soon":return{variant:"secondary",icon:mn,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:la,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:Dm,text:`Snoozed until ${ps(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:cn,text:"Never touched",className:"border-dashed"}}})(),a=n.icon;return e.jsxs(tt,{variant:n.variant,className:Pt("gap-1",n.className),children:[e.jsx(a,{className:"h-3 w-3"}),n.text]})}function vbs({contact:t,onLogTouch:s,onSnooze:r}){const n=Oat(t),a=H1s(),[o,l]=k.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(Nl,{className:"h-5 w-5 text-destructive"});case"due-soon":return e.jsx(mn,{className:"h-5 w-5 text-amber-600 dark:text-amber-400"});case"on-track":return e.jsx(la,{className:"h-5 w-5 text-emerald-600 dark:text-emerald-400"});case"snoozed":return e.jsx(Dm,{className:"h-5 w-5 text-slate-600 dark:text-slate-400"});case"never-touched":return e.jsx(cn,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(cn,{className:"h-4 w-4"}),"Next Touch"]})}),e.jsxs(Re,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[c(),e.jsx("span",{className:Pt("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:"})," ",ps(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:"})," ",ps(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:"})," ",ps(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(Or,{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(Dm,{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(Bhe,{open:o,onOpenChange:l,contactId:t.id,contactName:`${t.first_name} ${t.last_name||""}`.trim()})]})}const uye=768;function NE(){const[t,s]=k.useState(void 0);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${uye-1}px)`),n=()=>{s(window.innerWidthr.removeEventListener("change",n)},[]),!!t}function bbs(){const{user:t}=Rs(),{hasLeadSite:s,leadSite:r}=yue(),{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 _bs={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"}},wbs={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 g8({score:t,showScore:s=!1,showTooltip:r=!0,size:n="sm",className:a}){const o=_bs[t.status],l=wbs[n],i=e.jsxs("div",{className:Pt("inline-flex items-center rounded-full font-medium",o.bgLightClass,o.textClass,l.badge,l.text,a),children:[e.jsx("span",{className:Pt("rounded-full",o.bgClass,l.dot)}),s?e.jsx("span",{children:t.score}):e.jsx("span",{children:o.label})]});return r?e.jsx(F1,{children:e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:i}),e.jsx(gc,{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:Pt("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}],qz=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]},Nbs=({open:t,onOpenChange:s,relationshipTypes:r,onSuccess:n})=>{const{user:a}=Rs(),{toast:o}=qa(),l=k.useRef(null),[i,c]=k.useState("upload"),[u,p]=k.useState([]),[f,g]=k.useState([]),[b,_]=k.useState({}),[j,w]=k.useState([]),[N,C]=k.useState([]),[M,I]=k.useState(!1),[L,R]=k.useState(null),q=()=>{c("upload"),p([]),g([]),_({}),w([]),C([]),R(null),l.current&&(l.current.value="")},U=()=>{q(),s(!1)},B=xe=>{const _e=xe.split(` `).map(Ne=>Ne.trim()).filter(Ne=>Ne);if(_e.length===0)return{headers:[],data:[]};const fe=Ne=>{const Ae=[];let Fe="",Ce=!1;for(let Me=0;Me{var we;const _e=(we=xe.target.files)==null?void 0:we[0];if(!_e)return;const fe=new FileReader;fe.onload=Ie=>{var Me;const Ne=(Me=Ie.target)==null?void 0:Me.result,{headers:Ae,data:Fe}=B(Ne);if(Ae.length===0){o({title:"No data found",description:"The CSV file appears to be empty.",variant:"destructive"});return}p(Ae),g(Fe);const Ce={};Ae.forEach($e=>{const ct=$e.toLowerCase().replace(/[_\s-]/g,"");ct.includes("firstname")||ct==="first"?Ce.first_name=$e:ct.includes("lastname")||ct==="last"?Ce.last_name=$e:ct.includes("spouse")&&ct.includes("email")?Ce.spouse_email=$e:ct.includes("spouse")||ct.includes("partner")?Ce.spouse_name=$e:ct.includes("email")?Ce.email=$e:ct.includes("phone")||ct.includes("mobile")||ct.includes("cell")?Ce.phone=$e:ct.includes("address")||ct.includes("street")?Ce.address=$e:ct==="city"?Ce.city=$e:ct==="state"||ct==="province"?Ce.state=$e:ct==="zip"||ct==="zipcode"||ct==="postalcode"?Ce.zip=$e:ct.includes("company")||ct.includes("organization")||ct.includes("business")?Ce.company_name=$e:ct.includes("jobtitle")||ct.includes("title")&&!ct.includes("spouse")?Ce.job_title=$e:ct.includes("birthday")||ct.includes("dob")||ct.includes("birthdate")?Ce.birthday=$e:ct.includes("anniversary")||ct.includes("homeanniversary")?Ce.home_anniversary=$e:(ct.includes("notes")||ct.includes("comment"))&&(Ce.notes=$e)}),_(Ce),c("mapping")},fe.readAsText(_e)},Y=(xe,_e)=>{_(fe=>{if(_e==="none"){const{[xe]:we,...Ie}=fe;return Ie}return{...fe,[xe]:_e}})},J=xe=>{w(_e=>_e.includes(xe)?_e.filter(fe=>fe!==xe):[..._e,xe])},te=async()=>{if(!(a!=null&&a.id))return;const{data:xe}=await H.from("innercircle_contacts").select("id, email, phone").eq("owner_user_id",a.id),_e=new Set((xe||[]).filter(Ie=>Ie.email).map(Ie=>Ie.email.toLowerCase())),fe=new Set((xe||[]).filter(Ie=>Ie.phone).map(Ie=>Ie.phone.replace(/[^0-9]/g,""))),we=f.map(Ie=>{const Ne=ct=>{const Te=b[ct];if(!Te)return"";const ft=u.indexOf(Te);return ft>=0?(Ie[ft]||"").trim():""},Ae=Ne("first_name"),Fe=Ne("email"),Ce=Ne("phone"),Me=Ae.length>0,$e=!!(Fe&&_e.has(Fe.toLowerCase())||Ce&&fe.has(Ce.replace(/[^0-9]/g,"")));return{first_name:Ae,last_name:Ne("last_name"),email:Fe,phone:Ce,address:Ne("address"),city:Ne("city"),state:Ne("state"),zip:Ne("zip"),spouse_name:Ne("spouse_name"),spouse_email:Ne("spouse_email"),company_name:Ne("company_name"),job_title:Ne("job_title"),birthday:Ne("birthday"),home_anniversary:Ne("home_anniversary"),notes:Ne("notes"),isValid:Me,isDuplicate:$e,error:Me?void 0:"First name is required"}});C(we),c("preview")},X=xe=>{const _e=xe.trim().split(/\s+/);return{first_name:_e[0],last_name:_e.length>1?_e.slice(1).join(" "):null}},ce=async()=>{if(!(a!=null&&a.id))return;const xe=N.filter(Ie=>Ie.isValid);if(xe.length===0){o({title:"No valid contacts",description:"There are no valid contacts to import.",variant:"destructive"});return}I(!0);let _e=0,fe=0,we=0;try{for(const Ie of xe)try{let Ne=null;if(Ie.email){const{data:Ce}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ie.email).maybeSingle();Ne=Ce}if(!Ne&&Ie.phone){const Ce=Ie.phone.replace(/[^0-9]/g,""),{data:Me}=await H.from("innercircle_contacts").select("id, phone").eq("owner_user_id",a.id).not("phone","is",null);if(Me){const $e=Me.find(ct=>ct.phone&&ct.phone.replace(/[^0-9]/g,"")===Ce);$e&&(Ne={id:$e.id})}}const Ae={owner_user_id:a.id,first_name:Ie.first_name,last_name:Ie.last_name||null,email:Ie.email||null,phone:Ie.phone||null,address:Ie.address||null,city:Ie.city||null,state:Ie.state||null,zip:Ie.zip||null,spouse_name:Ie.spouse_name||null,spouse_email:Ie.spouse_email||null,company_name:Ie.company_name||null,job_title:Ie.job_title||null,birthday:qz(Ie.birthday),home_anniversary:qz(Ie.home_anniversary),notes:Ie.notes||null};let Fe=null;if(Ne){const{data:Ce}=await H.from("innercircle_contacts").select("*").eq("id",Ne.id).single();if(Ce){const Me={},$e=["last_name","email","phone","address","city","state","zip","spouse_name","spouse_email","company_name","job_title","birthday","home_anniversary","notes"];for(const ct of $e){const Te=Ce[ct],ft=Ae[ct];(!Te||Te==="")&&ft&&(Me[ct]=ft)}Object.keys(Me).length>0&&await H.from("innercircle_contacts").update(Me).eq("id",Ne.id)}Fe=Ne.id,fe++}else{const{data:Ce,error:Me}=await H.from("innercircle_contacts").insert(Ae).select("id").single();Me?(console.error("Insert error for contact:",Ie.first_name,Me),we++):Ce?(Fe=Ce.id,j.length>0&&await H.from("innercircle_contact_tags").insert(j.map($e=>({contact_id:Ce.id,relationship_type_id:$e}))),_e++):we++}if(Fe&&Ie.spouse_name){const Ce=X(Ie.spouse_name);let Me=null;if(Ie.spouse_email){const{data:ct}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("email",Ie.spouse_email).maybeSingle();Me=ct}if(!Me){const{data:ct}=await H.from("innercircle_contacts").select("id").eq("owner_user_id",a.id).eq("first_name",Ce.first_name).eq("last_name",Ce.last_name||Ie.last_name||"").maybeSingle();Me=ct}let $e=null;if(Me){$e=Me.id;const ct=qz(Ie.home_anniversary);ct&&await H.from("innercircle_contacts").update({home_anniversary:ct}).eq("id",Me.id).is("home_anniversary",null)}else{const{data:ct}=await H.from("innercircle_contacts").insert({owner_user_id:a.id,first_name:Ce.first_name,last_name:Ce.last_name||Ie.last_name||null,email:Ie.spouse_email||null,address:Ie.address||null,city:Ie.city||null,state:Ie.state||null,zip:Ie.zip||null,home_anniversary:qz(Ie.home_anniversary),spouse_name:`${Ie.first_name}${Ie.last_name?" "+Ie.last_name:""}`,spouse_email:Ie.email||null,notes:`Spouse of ${Ie.first_name} ${Ie.last_name||""} (imported via CSV)`.trim()}).select("id").single();ct&&($e=ct.id,_e++)}$e&&(await H.from("innercircle_contacts").update({spouse_contact_id:$e}).eq("id",Fe),await H.from("innercircle_contacts").update({spouse_contact_id:Fe}).eq("id",$e))}}catch(Ne){console.error("Error importing contact:",Ne),we++}R({created:_e,updated:fe,failed:we}),c("result"),(_e>0||fe>0)&&n(),o({title:"Import Complete",description:`${_e} created, ${fe} updated${we>0?`, ${we} failed`:""}.`})}catch(Ie){console.error("Import error:",Ie),o({title:"Import Failed",description:Ie.message||"Failed to import contacts",variant:"destructive"})}finally{I(!1)}},ne=N.filter(xe=>xe.isValid).length,re=N.filter(xe=>!xe.isValid).length,le=N.filter(xe=>xe.isValid&&xe.isDuplicate).length,pe=ne-le;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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(s1,{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(oi,{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 xe;return(xe=l.current)==null?void 0:xe.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 xe=`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`,_e=new Blob([xe],{type:"text/csv"}),fe=URL.createObjectURL(_e),we=document.createElement("a");we.href=fe,we.download="contact_import_template.csv",we.click(),URL.revokeObjectURL(fe)},children:[e.jsx(Ci,{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(ye,{className:"text-base font-medium",children:"Map CSV Columns to Contact Fields"}),e.jsx("div",{className:"grid gap-3",children:jbs.map(xe=>e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(ye,{className:"w-40 text-sm",children:[xe.label,xe.required&&e.jsx("span",{className:"text-destructive ml-1",children:"*"})]}),e.jsxs(Ys,{value:b[xe.key]||"none",onValueChange:_e=>Y(xe.key,_e),children:[e.jsx(Gs,{className:"w-48",children:e.jsx(Qs,{placeholder:"Select column..."})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"-- Not mapped --"}),u.map(_e=>e.jsx(Mt,{value:_e,children:_e},_e))]})]})]},xe.key))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{className:"text-base font-medium",children:"Apply Relationship Types (optional)"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.map(xe=>e.jsx(tt,{variant:j.includes(xe.id)?"default":"outline",className:"cursor-pointer",onClick:()=>J(xe.id),children:xe.name},xe.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(la,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{children:[pe," new"]})]}),le>0&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Nl,{className:"h-4 w-4"}),e.jsxs("span",{children:[le," existing (will merge gaps)"]})]}),re>0&&e.jsxs("div",{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nl,{className:"h-4 w-4"}),e.jsxs("span",{children:[re," invalid"]})]})]}),le>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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/30",children:[e.jsx(kt,{children:"First Name"}),e.jsx(kt,{children:"Last Name"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Phone"}),e.jsx(kt,{children:"Status"})]})}),e.jsx(On,{children:N.slice(0,100).map((xe,_e)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:xe.first_name}),e.jsx(dt,{children:xe.last_name}),e.jsx(dt,{children:xe.email}),e.jsx(dt,{children:xe.phone}),e.jsx(dt,{children:xe.isValid?xe.isDuplicate?e.jsx(tt,{variant:"outline",className:"bg-accent text-accent-foreground",children:"Merge"}):e.jsx(tt,{variant:"secondary",className:"bg-primary/10 text-primary",children:"New"}):e.jsx(tt,{variant:"destructive",children:xe.error||"Invalid"})})]},_e))})]}),N.length>100&&e.jsxs("p",{className:"text-sm text-muted-foreground text-center py-2",children:["Showing first 100 of ",N.length," contacts"]})]})]}),i==="result"&&L&&e.jsxs("div",{className:"space-y-4 py-4 text-center",children:[e.jsx(la,{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:[L.created," created, ",L.updated," merged"]}),L.failed>0&&e.jsxs("p",{className:"text-destructive",children:[L.failed," failed to import"]})]}),e.jsxs(zn,{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:q,children:"Back"}),e.jsx(K,{onClick:te,disabled:!b.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(ws,{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 kbs(){return"contacts"in navigator&&"ContactsManager"in window}function Sbs(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 b=f.substring(f.indexOf(":")+1).split(";");l=(b[0]||"").trim(),o=(b[1]||"").trim()}if((f.startsWith("FN:")||f.startsWith("FN;"))&&!o){const b=f.substring(f.indexOf(":")+1).trim().split(" ");o=b[0]||"",l=b.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 Cbs({open:t,onOpenChange:s,onComplete:r}){const{user:n}=Rs(),{data:a}=Wm(),o=vue(),l=k.useRef(null),[i,c]=k.useState("choose"),[u,p]=k.useState([]),[f,g]=k.useState(new Set),[b,_]=k.useState(0),[j,w]=k.useState(0),N=kbs(),C=k.useCallback(Y=>{if(!a)return Y;const J=new Set(a.filter(X=>X.email).map(X=>X.email.toLowerCase())),te=new Set(a.filter(X=>X.phone).map(X=>X.phone.replace(/\D/g,"")));return Y.map(X=>{var re,le;const ce=(re=X.email)==null?void 0:re.toLowerCase(),ne=(le=X.phone)==null?void 0:le.replace(/\D/g,"");return ce&&J.has(ce)?{...X,isDuplicate:!0,duplicateField:"email"}:ne&&ne.length>=7&&te.has(ne)?{...X,isDuplicate:!0,duplicateField:"phone"}:X})},[a]),M=async()=>{try{const Y=["name","email","tel","address"],J=await navigator.contacts.select(Y,{multiple:!0});if(!J||J.length===0)return;const te=J.map(ne=>{var pe,xe,_e,fe;const le=(((pe=ne.name)==null?void 0:pe[0])||"").split(" ");return{first_name:le[0]||"",last_name:le.slice(1).join(" "),email:((xe=ne.email)==null?void 0:xe[0])||"",phone:((_e=ne.tel)==null?void 0:_e[0])||"",address:(fe=ne.address)!=null&&fe[0]?[ne.address[0].streetAddress,ne.address[0].city,ne.address[0].region,ne.address[0].postalCode].filter(Boolean).join(", "):""}}),X=C(te);p(X);const ce=new Set;X.forEach((ne,re)=>{ne.isDuplicate||ce.add(re)}),g(ce),c("preview")}catch(Y){console.error("Contact Picker error:",Y),vn({title:"Could not access contacts",description:"Please try the file upload option instead.",variant:"destructive"})}},I=Y=>{var X;const J=(X=Y.target.files)==null?void 0:X[0];if(!J)return;const te=new FileReader;te.onload=ce=>{var xe;const ne=(xe=ce.target)==null?void 0:xe.result,re=Sbs(ne);if(re.length===0){vn({title:"No contacts found",description:"The file didn't contain any valid contacts.",variant:"destructive"});return}const le=C(re);p(le);const pe=new Set;le.forEach((_e,fe)=>{_e.isDuplicate||pe.add(fe)}),g(pe),c("preview")},te.readAsText(J),l.current&&(l.current.value="")},L=async()=>{const Y=u.filter((te,X)=>f.has(X));if(Y.length===0)return;c("importing");let J=0;for(const te of Y)try{await o.mutateAsync({first_name:te.first_name,last_name:te.last_name||void 0,email:te.email||void 0,phone:te.phone||void 0,address:te.address||void 0}),J++,w(Math.round(J/Y.length*100))}catch(X){console.error(`Failed to import ${te.first_name} ${te.last_name}:`,X)}_(J),c("done")},R=Y=>{g(J=>{const te=new Set(J);return te.has(Y)?te.delete(Y):te.add(Y),te})},q=()=>{f.size===u.length?g(new Set):g(new Set(u.map((Y,J)=>J)))},U=Y=>{Y||(c("choose"),p([]),g(new Set),_(0),w(0),i==="done"&&r()),s(Y)},B=u.filter(Y=>Y.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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(u1,{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:[N&&e.jsxs(K,{onClick:M,className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(u1,{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:[N&&e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),N&&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:N?"outline":"default",onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},className:"w-full h-auto py-4 flex flex-col items-center gap-2",children:[e.jsx(oi,{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:N?"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:I,className:"hidden"}),!N&&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:q,children:f.size===u.length?"Deselect All":"Select All"})]}),e.jsx(Gi,{className:"h-[350px] rounded-md border",children:e.jsx("div",{className:"divide-y",children:u.map((Y,J)=>e.jsxs("div",{className:`flex items-start gap-3 p-3 cursor-pointer hover:bg-accent/50 transition-colors ${Y.isDuplicate?"opacity-60":""}`,onClick:()=>R(J),children:[e.jsx(Lo,{checked:f.has(J),onCheckedChange:()=>R(J),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:[Y.first_name," ",Y.last_name]}),Y.isDuplicate&&e.jsxs(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0 bg-amber-500/10 text-amber-600 border-amber-200",children:["Exists (",Y.duplicateField,")"]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5 mt-0.5",children:[Y.phone&&e.jsx("div",{children:Y.phone}),Y.email&&e.jsx("div",{className:"truncate",children:Y.email})]})]})]},J))})}),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:L,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(ws,{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:[j,"% 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:`${j}%`}})})]}),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(fa,{className:"h-6 w-6 text-emerald-600"})}),e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[b," contact",b!==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 qhe(){const t=li();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 Mbs(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 nSe(){const t=es(),s=li();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 Tbs(){const t=es();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 Abs(){const t=es();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 Rat(){const t=es();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 Ebs(){const t=es();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 Pbs(){const t=li();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 Ibs({selectedIds:t,contacts:s,onClearSelection:r,onSendToLeadPond:n,showLeadPondAction:a,onTransfer:o,showTransferAction:l}){const i=pr(),{data:c}=Ux(),u=vNe(),p=es(),{isGmailConnected:f}=$0(),{isReady:g}=eSe(),{data:b}=qhe(),_=nSe(),j=Rat(),[w,N]=k.useState(!1),[C,M]=k.useState(!1),[I,L]=k.useState(!1),[R,q]=k.useState(""),U=t.size;if(U===0)return null;const B=async ne=>{N(!0);try{const le=Array.from(t).map(xe=>({contact_id:xe,relationship_type_id:ne})),{error:pe}=await H.from("innercircle_contact_tags").upsert(le,{onConflict:"contact_id,relationship_type_id",ignoreDuplicates:!0});if(pe)throw pe;p.invalidateQueries({queryKey:["innercircle-contacts"]}),p.invalidateQueries({queryKey:["innercircle-contact-counts"]}),vn({title:`Assigned type to ${U} contacts`}),r()}catch(re){vn({title:"Error assigning type",description:re.message,variant:"destructive"})}finally{N(!1)}},V=async ne=>{N(!0);try{const re=Array.from(t);for(const le of re)try{await j.mutateAsync({contactId:le,tagId:ne})}catch{}p.invalidateQueries({queryKey:["all-contact-custom-tags"]}),vn({title:`Tagged ${U} contacts`}),L(!1),q("")}catch(re){vn({title:"Error adding tags",description:re.message,variant:"destructive"})}finally{N(!1)}},Y=async()=>{if(R.trim()){N(!0);try{const ne=await _.mutateAsync({name:R.trim()});await V(ne.id)}catch(ne){vn({title:"Error creating tag",description:ne.message,variant:"destructive"}),N(!1)}}},J=(b==null?void 0:b.filter(ne=>ne.name.toLowerCase().includes(R.toLowerCase())))||[],te=b==null?void 0:b.find(ne=>ne.name.toLowerCase()===R.trim().toLowerCase()),X=()=>{const ne=s.filter(we=>t.has(we.id)),re=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Notes","Relationship Types"],le=ne.map(we=>{var Ie;return[we.first_name,we.last_name||"",we.email||"",we.phone||"",we.address||"",we.birthday||"",we.home_anniversary||"",we.notes||"",((Ie=we.tags)==null?void 0:Ie.map(Ne=>{var Ae;return(Ae=Ne.relationship_type)==null?void 0:Ae.name}).join("; "))||""]}),pe=[re.join(","),...le.map(we=>we.map(Ie=>`"${(Ie||"").replace(/"/g,'""')}"`).join(","))].join(` `),xe=new Blob([pe],{type:"text/csv"}),_e=URL.createObjectURL(xe),fe=document.createElement("a");fe.href=_e,fe.download=`contacts-export-${new Date().toISOString().slice(0,10)}.csv`,fe.click(),URL.revokeObjectURL(_e),vn({title:`Exported ${U} contacts`})},ce=async()=>{if(confirm(`Are you sure you want to delete ${U} contacts? This cannot be undone.`)){N(!0);try{const ne=Array.from(t);for(const re of ne)await u.mutateAsync(re);r()}catch(ne){vn({title:"Error deleting contacts",description:ne.message,variant:"destructive"})}finally{N(!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(tt,{variant:"secondary",className:"font-semibold",children:[U," selected"]}),e.jsxs(Ys,{onValueChange:B,disabled:w,children:[e.jsx(Gs,{className:"w-[180px] h-8",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Om,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm",children:"Assign Type"})]})}),e.jsx(Ks,{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(Bo,{open:I,onOpenChange:L,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",disabled:w,children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"}),"Add Tag"]})}),e.jsxs(Do,{className:"w-56 p-2",align:"start",children:[e.jsx(ze,{placeholder:"Search or create tag...",value:R,onChange:ne=>q(ne.target.value),onKeyDown:ne=>{ne.key==="Enter"&&R.trim()&&!te?(ne.preventDefault(),Y()):ne.key==="Enter"&&te&&(ne.preventDefault(),V(te.id))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[J.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)),R.trim()&&!te&&e.jsxs("button",{onClick:Y,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 "',R.trim(),'"']}),J.length===0&&!R.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:w,children:[e.jsx(dr,{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:w,children:[e.jsx(Kh,{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:w,children:[e.jsx(Zg,{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:w,children:[e.jsx(Jv,{className:"h-3.5 w-3.5 mr-1"}),"Transfer"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:X,disabled:w,children:[e.jsx(Ci,{className:"h-3.5 w-3.5 mr-1"}),"Export"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,disabled:w,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(Or,{className:"h-3.5 w-3.5 mr-1"}),"Clear"]})]}),e.jsx(jE,{open:C,onOpenChange:M,bulkContacts:Array.from(t).map(ne=>{const re=s.find(le=>le.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 VFe({contact:t,onEdit:s,onDelete:r,onSnooze:n,onSendToLeadPond:a,showLeadPondAction:o,onTransfer:l,showTransferAction:i}){const c=pr(),{isReady:u}=eSe(),p=`${t.first_name} ${t.last_name||""}`.trim();return e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:f=>f.stopPropagation(),children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",onClick:f=>f.stopPropagation(),children:[e.jsxs(Ca,{onClick:()=>c(`/mission-control/contacts/${t.id}?tab=activity&action=log`),children:[e.jsx(Un,{className:"h-4 w-4 mr-2"}),"Log Touch"]}),e.jsxs(Ca,{onClick:()=>c(`/mission-control/video?contactId=${t.id}`),children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Send Video"]}),e.jsxs(Ca,{onClick:()=>c(`/mission-control/popbys?contactId=${t.id}`),children:[e.jsx(Ba,{className:"h-4 w-4 mr-2"}),"Schedule Pop-by"]}),u&&t.email&&e.jsxs(Ca,{onClick:()=>c(`/admin/email-campaigns/new?contactIds=${t.id}`),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Mass Email"]}),e.jsxs(Ca,{onClick:()=>n(t.id,p),children:[e.jsx(Dm,{className:"h-4 w-4 mr-2"}),"Snooze"]}),o&&a&&e.jsxs(Ca,{onClick:()=>a(t.id),children:[e.jsx(Zg,{className:"h-4 w-4 mr-2"}),"Send to Lead Pond"]}),i&&l&&e.jsxs(Ca,{onClick:()=>l(t.id),children:[e.jsx(Jv,{className:"h-4 w-4 mr-2"}),"Transfer to Team Member"]}),e.jsxs(Ca,{onClick:()=>s(t),children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ca,{onClick:()=>r(t.id),className:"text-destructive focus:text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})}function Lbs(){const{user:t}=Rs();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 Dbs(){const t=es(),{user:s}=Rs();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"]}),vn({title:"Smart filter saved"})},onError:r=>{vn({title:"Error saving smart filter",description:r.message,variant:"destructive"})}})}function Obs(){const t=es();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"]}),vn({title:"Smart filter deleted"})}})}function Rbs({currentFilters:t,currentSortBy:s,onApplySmartList:r}){const{data:n}=Lbs(),a=Dbs(),o=Obs(),[l,i]=k.useState(!1),[c,u]=k.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(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"gap-1.5",children:[e.jsx(Yg,{className:"h-3.5 w-3.5"}),"Smart Filters",n&&n.length>0&&e.jsx(tt,{variant:"secondary",className:"h-5 px-1.5 text-[10px]",children:n.length}),e.jsx(To,{className:"h-3.5 w-3.5"})]})}),e.jsxs(zd,{align:"start",className:"w-56",children:[n&&n.length>0?e.jsxs(e.Fragment,{children:[n.map(g=>e.jsxs(Ca,{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:b=>{b.stopPropagation(),o.mutate(g.id)},children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]},g.id)),e.jsx(lw,{})]}):e.jsx(Ca,{disabled:!0,className:"text-muted-foreground text-xs",children:"No saved filters yet"}),p&&e.jsxs(Ca,{onClick:()=>i(!0),children:[e.jsx(GI,{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(_s,{children:e.jsx(bs,{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 CI(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 WFe({birthday:t,homeAnniversary:s,className:r,contactId:n,contactName:a,contactAddress:o}){const l=pr(),i=HFe(t,"birthday",7),c=HFe(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:Pt("flex flex-wrap gap-1",r),children:[i&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(tt,{variant:"secondary",className:Pt("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(dr,{className:"h-2.5 w-2.5"}),"Send Card"]})]}),c&&e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(tt,{variant:"secondary",className:Pt("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(dr,{className:"h-2.5 w-2.5"}),"Send Card"]})]})]})}function GFe({deal:t}){if(!t||!t.stage)return null;const{stage:s}=t;return e.jsxs(tt,{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 Fbs(){const t=li();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 zbs({contactId:t,compact:s=!1}){const{data:r}=qhe(),{data:n}=Mbs(t),a=nSe(),o=Rat(),l=Ebs(),[i,c]=k.useState(!1),[u,p]=k.useState(""),f=k.useRef(null),g=new Set((n==null?void 0:n.map(N=>N.tag_id))||[]),b=(r==null?void 0:r.filter(N=>N.name.toLowerCase().includes(u.toLowerCase())))||[],_=r==null?void 0:r.find(N=>N.name.toLowerCase()===u.trim().toLowerCase()),j=async N=>{g.has(N.id)?await l.mutateAsync({contactId:t,tagId:N.id}):await o.mutateAsync({contactId:t,tagId:N.id})},w=async()=>{if(!(!u.trim()||_))try{const N=await a.mutateAsync({name:u.trim()});await o.mutateAsync({contactId:t,tagId:N.id}),p("")}catch{}};return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[n==null?void 0:n.map(N=>{var C,M,I;return e.jsxs(tt,{variant:"outline",className:"text-xs gap-1 pr-1",style:{borderColor:((C=N.tag)==null?void 0:C.color)||"#6366F1",color:((M=N.tag)==null?void 0:M.color)||"#6366F1"},children:[e.jsx(Om,{className:"h-2.5 w-2.5"}),(I=N.tag)==null?void 0:I.name,e.jsx("button",{onClick:L=>{L.stopPropagation(),l.mutate({contactId:t,tagId:N.tag_id})},className:"ml-0.5 rounded-full hover:bg-accent p-0.5",children:e.jsx(Or,{className:"h-2.5 w-2.5"})})]},N.id)}),e.jsxs(Bo,{open:i,onOpenChange:c,children:[e.jsx($o,{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:N=>N.stopPropagation(),children:[e.jsx(qs,{className:"h-3 w-3"}),!s&&e.jsx("span",{className:"ml-1",children:"Tag"})]})}),e.jsxs(Do,{className:"w-56 p-2",align:"start",onClick:N=>N.stopPropagation(),children:[e.jsx(ze,{ref:f,placeholder:"Search or create tag...",value:u,onChange:N=>p(N.target.value),onKeyDown:N=>{N.key==="Enter"&&u.trim()&&!_?(N.preventDefault(),w()):N.key==="Enter"&&_&&!g.has(_.id)&&(N.preventDefault(),j(_))},className:"h-8 text-sm mb-2"}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto space-y-0.5",children:[b.map(N=>e.jsxs("button",{onClick:()=>j(N),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:N.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:N.name}),g.has(N.id)&&e.jsx(fa,{className:"h-3.5 w-3.5 text-primary shrink-0"})]},N.id)),u.trim()&&!_&&e.jsxs("button",{onClick:w,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(),'"']}),b.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 KFe({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(tt,{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 Uz=["#6366F1","#8B5CF6","#EC4899","#EF4444","#F97316","#F59E0B","#10B981","#14B8A6","#06B6D4","#3B82F6","#6B7280","#1F2937"];function Bbs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=qhe(),a=nSe(),o=Abs(),l=Tbs(),[i,c]=k.useState(""),[u,p]=k.useState(Uz[0]),[f,g]=k.useState(null),[b,_]=k.useState(""),[j,w]=k.useState(""),N=async()=>{if(i.trim())try{await a.mutateAsync({name:i.trim(),color:u}),c(""),p(Uz[0]),vn({title:"Tag created"})}catch(L){vn({title:"Error",description:L.message,variant:"destructive"})}},C=async L=>{if(b.trim())try{await o.mutateAsync({id:L,name:b.trim(),color:j}),g(null),vn({title:"Tag updated"})}catch(R){vn({title:"Error",description:R.message,variant:"destructive"})}},M=async(L,R)=>{if(confirm(`Delete tag "${R}"? It will be removed from all contacts.`))try{await l.mutateAsync(L),vn({title:"Tag deleted"})}catch(q){vn({title:"Error",description:q.message,variant:"destructive"})}},I=L=>{g(L.id),_(L.name),w(L.color)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{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:L=>c(L.target.value),onKeyDown:L=>L.key==="Enter"&&N(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:N,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:Uz.map(L=>e.jsx("button",{onClick:()=>p(L),className:`h-6 w-6 rounded-full border-2 transition-transform ${u===L?"border-foreground scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:L}},L))})]}),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(L=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:f===L.id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:Uz.map(R=>e.jsx("button",{onClick:()=>w(R),className:`h-5 w-5 rounded-full border-2 ${j===R?"border-foreground":"border-transparent"}`,style:{backgroundColor:R}},R))}),e.jsx(ze,{value:b,onChange:R=>_(R.target.value),onKeyDown:R=>R.key==="Enter"&&C(L.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:()=>C(L.id),children:e.jsx(fa,{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(Or,{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:L.color}}),e.jsx("span",{className:"flex-1 text-sm",children:L.name}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 transition-opacity",onClick:()=>I(L),children:e.jsx(Da,{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(L.id,L.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})},L.id))]})]})})}function $bs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=tE(),a=wNe(),o=VLt(),l=HLt(),[i,c]=k.useState(""),[u,p]=k.useState(null),[f,g]=k.useState(""),b=async()=>{if(i.trim())try{await a.mutateAsync(i.trim()),c("")}catch(N){he.error(N.message||"Failed to add lead source")}},_=async N=>{if(f.trim())try{await o.mutateAsync({id:N,name:f.trim()}),p(null)}catch(C){he.error(C.message||"Failed to update")}},j=async(N,C)=>{if(confirm(`Remove lead source "${C}"? Contacts using it will keep the label but it won't appear in new dropdowns.`))try{await l.mutateAsync(N)}catch(M){he.error(M.message||"Failed to remove")}},w=N=>{p(N.id),g(N.name)};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Manage Lead Sources"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{placeholder:"New lead source name...",value:i,onChange:N=>c(N.target.value),onKeyDown:N=>N.key==="Enter"&&b(),className:"flex-1 h-9"}),e.jsxs(K,{size:"sm",onClick:b,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(N=>e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg hover:bg-accent/50 group",children:u===N.id?e.jsxs(e.Fragment,{children:[e.jsx(ze,{value:f,onChange:C=>g(C.target.value),onKeyDown:C=>C.key==="Enter"&&_(N.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:()=>_(N.id),children:e.jsx(fa,{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(Or,{className:"h-4 w-4"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1 text-sm",children:N.name}),N.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:()=>w(N),children:e.jsx(Da,{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:()=>j(N.id,N.name),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),!N.owner_user_id&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default"})]})},N.id))]})]})})}function Fat({value:t,onChange:s,label:r="Lead Source"}){const{data:n}=tE(),a=wNe(),[o,l]=k.useState(!1),[i,c]=k.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(ye,{children:r}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Ys,{value:t||"_none",onValueChange:p=>s(p==="_none"?"":p),children:[e.jsx(Gs,{className:"flex-1",children:e.jsx(Qs,{placeholder:"Select lead source"})}),e.jsxs(Ks,{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(Or,{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 R_e({contactId:t,currentSpouseContactId:s,currentSpouseName:r,currentSpouseEmail:n,onLink:a,onUnlink:o,isEditing:l}){const i=pr(),[c,u]=k.useState(!1),[p,f]=k.useState(""),{data:g}=mt({queryKey:["innercircle-contact-spouse",s],queryFn:async()=>{const{data:_,error:j}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone, birthday").eq("id",s).maybeSingle();if(j)throw j;return _},enabled:!!s}),{data:b}=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:j,error:w}=await _;if(w)throw w;return j},enabled:c});if(s&&g){const _=`${g.first_name} ${g.last_name||""}`.trim();return e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{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(to,{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(uS,{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(fi,{className:"h-3.5 w-3.5"})})]})]})}return!s&&(r||n)?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{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(to,{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(Bo,{open:c,onOpenChange:u,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",size:"sm",className:"shrink-0 h-7 px-2",children:[e.jsx(cl,{className:"h-3.5 w-3.5 mr-1"}),"Link Contact"]})}),e.jsx(Do,{className:"w-72 p-2",align:"end",children:e.jsx(ZFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),u(!1),f("")}})})]})]})]}):l?e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Spouse / Partner"}),e.jsxs(Bo,{open:c,onOpenChange:u,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full justify-start text-muted-foreground font-normal h-10",children:[e.jsx(cl,{className:"h-4 w-4 mr-2"}),"Link an existing contact as spouse..."]})}),e.jsx(Do,{className:"w-72 p-2",align:"start",children:e.jsx(ZFe,{search:p,setSearch:f,results:b,onSelect:_=>{a(_),u(!1),f("")}})})]})]}):null}function ZFe({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(hn,{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(Gi,{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 qbs(){var yi;const t=pr(),[s]=qc(),{user:r}=Rs(),n=NE(),a=es(),o=s.get("type"),l=s.get("filter")??s.get("status"),i=s.get("new")==="true",{contactsWithScores:c,isLoading:u}=wue(),{activeContactIds:p,hasLeadSite:f}=bbs(),{data:g}=Ux(),{data:b}=Fbs(),{data:_}=qhe(),{data:j}=Pbs(),[w,N]=k.useState(new Set),[C,M]=k.useState("any"),I=vue(),L=yNe(),R=vNe(),q=UYe(),[U,B]=k.useState(""),[V,Y]=k.useState(o||"all"),[J,te]=k.useState(l||"all"),[X,ce]=k.useState("date-added"),[ne,re]=k.useState(i),[le,pe]=k.useState(null),[xe,_e]=k.useState(!1),[fe,we]=k.useState(!1),[Ie,Ne]=k.useState(null),[Ae,Fe]=k.useState(""),[Ce,Me]=k.useState(new Set),[$e,ct]=k.useState(!1),[Te,ft]=k.useState(1),[me,Ve]=k.useState(50),[nt,et]=k.useState("my"),[Se,rt]=k.useState(!1),[Ge,lt]=k.useState(!1),{data:qe}=Bx(),{addToLeadPond:Ze}=ett(qe==null?void 0:qe.teamId),Je=!!((yi=qe==null?void 0:qe.team)!=null&&yi.lead_pond_enabled&&(qe!=null&&qe.teamId)),He=!!(qe!=null&&qe.teamId),[Qe,at]=k.useState([]),[It,Ut]=k.useState(!1),hs=pt=>{at([pt]),Ut(!0)},Yt=pt=>{at(pt),Ut(!0)},ts=pt=>{qe!=null&&qe.teamId&&Ze.mutate({contact_id:pt,team_id:qe.teamId})},Ds=pt=>{qe!=null&&qe.teamId&&pt.forEach(ir=>{Ze.mutate({contact_id:ir,team_id:qe.teamId})})},vr=k.useCallback(pt=>{ct(!1),Me(ir=>{const Bn=new Set(ir);return Bn.has(pt)?Bn.delete(pt):Bn.add(pt),Bn})},[]);k.useEffect(()=>{if(!(r!=null&&r.id))return;const pt=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(pt)}},[a,r==null?void 0:r.id]),k.useEffect(()=>{l&&te(l)},[l]);const[Ct,As]=k.useState({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]});k.useEffect(()=>{i&&re(!0)},[i]),k.useEffect(()=>{var pt;le&&As({first_name:le.first_name||"",last_name:le.last_name||"",email:le.email||"",phone:le.phone||"",address:le.address||"",city:le.city||"",state:le.state||"",zip_code:le.zip_code||"",birthday:le.birthday||"",home_anniversary:le.home_anniversary||"",spouse_name:le.spouse_name||"",spouse_email:le.spouse_email||"",lead_source_id:le.lead_source_id||"",notes:le.notes||"",tagIds:((pt=le.tags)==null?void 0:pt.map(ir=>ir.relationship_type_id))||[]})},[le]);const Us=k.useMemo(()=>{if(!c)return[];let pt=c.filter(ir=>{var Xn,Aa,Pi;const Bn=U===""||`${ir.first_name} ${ir.last_name}`.toLowerCase().includes(U.toLowerCase())||((Xn=ir.email)==null?void 0:Xn.toLowerCase().includes(U.toLowerCase()))||((Aa=ir.phone)==null?void 0:Aa.includes(U)),Cr=V==="all"||((Pi=ir.tags)==null?void 0:Pi.some(Oo=>Oo.relationship_type_id===V)),jr=w.size===0||(()=>{const Oo=(j==null?void 0:j.filter($t=>$t.contact_id===ir.id).map($t=>$t.tag_id))||[];return C==="any"?Oo.some($t=>w.has($t)):Array.from(w).every($t=>Oo.includes($t))})();return Bn&&Cr&&jr});return J==="not-touched-90"?pt=pt.filter(ir=>{const Bn=ir.relationshipScore.daysSinceTouch;return Bn===null||Bn>90}):J==="at-risk"?pt=pt.filter(ir=>ir.relationshipScore.status==="at-risk"):J==="cooling"?pt=pt.filter(ir=>ir.relationshipScore.status==="cooling"):J==="warm"?pt=pt.filter(ir=>ir.relationshipScore.status==="warm"):J==="has-deal"?pt=pt.filter(ir=>b&&b[ir.id]):J==="no-deal"?pt=pt.filter(ir=>!b||!b[ir.id]):J==="open-house"?pt=pt.filter(ir=>{var Cr;return(((Cr=ir.lead_source_ref)==null?void 0:Cr.name)||ir.lead_source)==="Open House"}):J==="website-active"&&(pt=pt.filter(ir=>p.has(ir.id))),pt=[...pt].sort((ir,Bn)=>{switch(X){case"important-dates":{const Cr=CI(ir.birthday),jr=CI(Bn.birthday),Xn=CI(ir.home_anniversary),Aa=CI(Bn.home_anniversary),Pi=[Cr,Xn].filter($t=>$t!==null).sort(($t,je)=>($t??1/0)-(je??1/0))[0]??1/0,Oo=[jr,Aa].filter($t=>$t!==null).sort(($t,je)=>($t??1/0)-(je??1/0))[0]??1/0;return Pi-Oo}case"last-touched":{const Cr=ir.relationshipScore.lastTouchDate,jr=Bn.relationshipScore.lastTouchDate;return!Cr&&!jr?0:Cr?jr?new Date(Cr).getTime()-new Date(jr).getTime():1:-1}case"next-touch":{const Cr=ir.relationshipScore.daysSinceTouch,jr=Bn.relationshipScore.daysSinceTouch;return Cr===null&&jr===null?0:Cr===null?-1:jr===null?1:jr-Cr}case"score":return ir.relationshipScore.score-Bn.relationshipScore.score;case"date-added":{const Cr=ir.created_at,jr=Bn.created_at;return!Cr&&!jr?0:Cr?jr?new Date(jr).getTime()-new Date(Cr).getTime():-1:1}case"name":default:{const Cr=`${ir.first_name||""} ${ir.last_name||""}`.toLowerCase(),jr=`${Bn.first_name||""} ${Bn.last_name||""}`.toLowerCase();return Cr.localeCompare(jr)}}}),pt},[c,U,V,w,C,J,X,b,j,p]),kr=Us.length,ta=Math.max(1,Math.ceil(kr/me)),ka=Math.min(Te,ta),Li=k.useMemo(()=>{const pt=(ka-1)*me;return Us.slice(pt,pt+me)},[Us,ka,me]);k.useEffect(()=>{ft(1)},[U,V,w,C,J,X]);const Wa=k.useCallback(()=>{ct(!1),Me(pt=>pt.size>0?new Set:new Set(Li.map(ir=>ir.id)))},[Li]),cr=k.useCallback(()=>{ct(!0),Me(new Set(Us.map(pt=>pt.id)))},[Us]),Qr=k.useCallback((pt,ir)=>{B(pt.search||""),Y(pt.type||"all"),te(pt.status||"all"),ce(ir||"name")},[]),Hr=()=>{As({first_name:"",last_name:"",email:"",phone:"",address:"",city:"",state:"",zip_code:"",birthday:"",home_anniversary:"",spouse_name:"",spouse_email:"",lead_source_id:"",notes:"",tagIds:[]})},ln=async pt=>{pt.preventDefault();const ir={...Ct,lead_source_id:Ct.lead_source_id||null};le?(await L.mutateAsync({id:le.id,...ir}),pe(null)):(await I.mutateAsync(ir),re(!1)),Hr()},Zr=async pt=>{confirm("Are you sure you want to delete this contact?")&&await R.mutateAsync(pt)};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"})]}),qe&&e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsx("button",{onClick:()=>et("my"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${nt==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Contacts"}),(qe.team.contact_visibility==="full_team"||qe.team.contact_visibility==="leader_only"&&qe.role==="team_leader")&&e.jsxs("button",{onClick:()=>et("team"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${nt==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),"Team"]}),qe.team.lead_pond_enabled&&e.jsxs("button",{onClick:()=>et("lead-pond"),className:`px-3 py-1.5 rounded-md text-sm font-medium transition-colors flex items-center gap-1.5 ${nt==="lead-pond"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Zg,{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(ll,{className:"h-4 w-4 mr-1"}),"Back"]})}),nt==="team"?e.jsx(Pke,{}):nt==="lead-pond"&&qe?e.jsx(Ike,{teamId:qe.teamId}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{children:e.jsx(Re,{className:"p-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:pt=>B(pt.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:()=>_e(!0),className:"shrink-0",children:[e.jsx(oi,{className:"h-4 w-4 mr-1"}),"Import CSV"]}),e.jsxs(K,{variant:"outline",onClick:()=>we(!0),className:"shrink-0",children:[e.jsx(u1,{className:"h-4 w-4 mr-1"}),"Import from Phone"]}),e.jsx(ubs,{})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(Ys,{value:V,onValueChange:Y,children:[e.jsx(Gs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Qs,{placeholder:"Filter by type"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),g==null?void 0:g.filter(pt=>pt.active).map(pt=>e.jsx(Mt,{value:pt.id,children:pt.name},pt.id))]})]}),_&&_.length>0&&e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"h-9 justify-start text-sm",children:[e.jsx(Om,{className:"h-3.5 w-3.5 mr-1.5 shrink-0 text-muted-foreground"}),w.size===0?"Filter by Tags":`${w.size} tag${w.size>1?"s":""}`]})}),e.jsx(Do,{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 ${C==="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 ${C==="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(pt=>{const ir=w.has(pt.id);return e.jsxs("button",{onClick:()=>{N(Bn=>{const Cr=new Set(Bn);return Cr.has(pt.id)?Cr.delete(pt.id):Cr.add(pt.id),Cr})},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(Lo,{checked:ir,className:"pointer-events-none"}),e.jsx("div",{className:"h-2.5 w-2.5 rounded-full shrink-0",style:{backgroundColor:pt.color}}),e.jsx("span",{className:"flex-1 text-left truncate",children:pt.name})]},pt.id)})}),w.size>0&&e.jsx(K,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>N(new Set),children:"Clear tags"})]})})]}),e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",title:"Settings",children:e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})})}),e.jsxs(zd,{align:"end",children:[e.jsxs(Ca,{onClick:()=>rt(!0),children:[e.jsx(Om,{className:"h-4 w-4 mr-2"}),"Manage Tags"]}),e.jsxs(Ca,{onClick:()=>lt(!0),children:[e.jsx(Zg,{className:"h-4 w-4 mr-2"}),"Manage Lead Sources"]})]})]}),e.jsxs(Ys,{value:J,onValueChange:te,children:[e.jsx(Gs,{className:"w-[145px] h-9 text-sm",children:e.jsx(Qs,{placeholder:"Filter by status"})}),e.jsxs(Ks,{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(Ys,{value:X,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(yd,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx(Qs,{placeholder:"Sort by"})]})}),e.jsxs(Ks,{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(Rbs,{currentFilters:{search:U,type:V,status:J},currentSortBy:X,onApplySmartList:Qr})]})]})})}),e.jsx(Ibs,{selectedIds:Ce,contacts:Us,onClearSelection:()=>{Me(new Set),ct(!1)},showLeadPondAction:Je,onSendToLeadPond:Ds,showTransferAction:He,onTransfer:Yt}),Ce.size>0&&Ce.size===Li.length&&!$e&&kr>me&&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 ",Li.length," contacts on this page are selected."]}),e.jsxs(K,{variant:"link",size:"sm",className:"h-auto p-0 font-semibold",onClick:cr,children:["Select all ",kr.toLocaleString()," matching contacts"]})]}),$e&&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 ",kr.toLocaleString()," matching contacts are selected.",e.jsx(K,{variant:"link",size:"sm",className:"h-auto p-0",onClick:()=>{Me(new Set),ct(!1)},children:"Clear selection"})]}),n?e.jsx("div",{className:"space-y-3",children:u?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:"Loading contacts..."}):Us.length===0?e.jsx(Pe,{className:"p-6 text-center text-muted-foreground",children:U||V!=="all"||J!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"}):Li.map(pt=>{var Bn,Cr,jr;const{relationshipScore:ir}=pt;return e.jsx(Pe,{className:"cursor-pointer hover:bg-accent/50 transition-colors",onClick:()=>{const Xn=new URLSearchParams;U&&Xn.set("search",U),V!=="all"&&Xn.set("type",V),J!=="all"&&Xn.set("filter",J);const Aa=Xn.toString();t(`/mission-control/contacts/${pt.id}${Aa?`?${Aa}`:""}`)},children:e.jsx(Re,{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:[pt.first_name," ",pt.last_name]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground shrink-0"})]}),e.jsxs("div",{className:"space-y-1 text-sm mb-3",children:[pt.email&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(dr,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:pt.email})]}),pt.phone&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Un,{className:"h-3.5 w-3.5 shrink-0"}),e.jsx("span",{children:pt.phone})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1 mb-2",children:[e.jsx(g8,{score:ir,size:"sm"}),e.jsx(O_e,{contact:pt}),(((Bn=pt.lead_source_ref)==null?void 0:Bn.name)||pt.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs gap-1 border-primary/30 text-primary",children:((Cr=pt.lead_source_ref)==null?void 0:Cr.name)||pt.lead_source}),(jr=pt.tags)==null?void 0:jr.map(Xn=>{var Aa;return e.jsx(tt,{variant:"secondary",className:"text-xs",children:(Aa=Xn.relationship_type)==null?void 0:Aa.name},Xn.id)}),e.jsx(KFe,{contactId:pt.id,tags:j==null?void 0:j.filter(Xn=>Xn.contact_id===pt.id)}),e.jsx(GFe,{deal:b==null?void 0:b[pt.id]})]}),e.jsx(WFe,{birthday:pt.birthday,homeAnniversary:pt.home_anniversary,className:"mb-2",contactId:pt.id,contactName:`${pt.first_name}${pt.last_name?" "+pt.last_name:""}`,contactAddress:[pt.address,pt.city,pt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),ps(new Date(ir.lastTouchDate),"MMM d")]}):e.jsx("span",{className:"italic",children:"Never contacted"}),pt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),ps(Il(pt.birthday),"MMM d")]}),pt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),ps(Il(pt.home_anniversary),"MMM d")]}),pt.created_at&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(qs,{className:"h-3 w-3"}),"Added ",ps(new Date(pt.created_at),"MMM d, yyyy")]})]})]}),e.jsx("div",{className:"ml-2",onClick:Xn=>Xn.stopPropagation(),children:e.jsx(VFe,{contact:pt,onEdit:pe,onDelete:Zr,onSnooze:(Xn,Aa)=>{Ne(Xn),Fe(Aa)},showLeadPondAction:Je,onSendToLeadPond:ts,showTransferAction:He,onTransfer:hs})})]})})},pt.id)})}):e.jsx(Pe,{children:e.jsx(Re,{className:"p-0 overflow-x-auto",children:e.jsxs(Ln,{className:"min-w-[800px]",children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Lo,{checked:Li.length>0&&Li.every(pt=>Ce.has(pt.id)),onCheckedChange:()=>Wa()})}),e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Score"}),e.jsx(kt,{children:"Contact Info"}),e.jsx(kt,{children:"Types / Pipeline"}),e.jsx(kt,{children:"Last Contact"}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>ce(X==="date-added"?"name":"date-added"),children:e.jsxs("div",{className:"flex items-center gap-1",children:["Date Added",X==="date-added"&&e.jsx(yd,{className:"h-3 w-3"})]})}),e.jsx(kt,{children:"Important Dates"}),e.jsx(kt,{className:"w-[50px]",children:"Actions"})]})}),e.jsx(On,{children:u?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8",children:"Loading contacts..."})}):Us.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:U||V!=="all"||J!=="all"?"No contacts match your search":"No contacts yet. Add your first contact!"})}):Li.map(pt=>{var Cr,jr,Xn;const{relationshipScore:ir}=pt,Bn=b==null?void 0:b[pt.id];return e.jsxs(Ss,{className:`cursor-pointer hover:bg-accent/50 ${Ce.has(pt.id)?"bg-accent/30":""}`,onClick:()=>{const Aa=new URLSearchParams;U&&Aa.set("search",U),V!=="all"&&Aa.set("type",V),J!=="all"&&Aa.set("status",J);const Pi=Aa.toString();t(`/mission-control/contacts/${pt.id}${Pi?`?${Pi}`:""}`)},children:[e.jsx(dt,{onClick:Aa=>Aa.stopPropagation(),children:e.jsx(Lo,{checked:Ce.has(pt.id),onCheckedChange:()=>vr(pt.id)})}),e.jsxs(dt,{className:"font-medium",children:[pt.first_name," ",pt.last_name]}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(g8,{score:ir,size:"sm"}),e.jsx(O_e,{contact:pt})]})}),e.jsx(dt,{children:e.jsx(g8,{score:ir,size:"sm",showScore:!0})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1 text-sm",children:[pt.email&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(dr,{className:"h-3 w-3"}),pt.email]}),pt.phone&&e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(Un,{className:"h-3 w-3"}),pt.phone]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(((Cr=pt.lead_source_ref)==null?void 0:Cr.name)||pt.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((jr=pt.lead_source_ref)==null?void 0:jr.name)||pt.lead_source}),(Xn=pt.tags)==null?void 0:Xn.map(Aa=>{var Pi;return e.jsx(tt,{variant:"secondary",className:"text-xs",children:(Pi=Aa.relationship_type)==null?void 0:Pi.name},Aa.id)}),e.jsx(KFe,{contactId:pt.id,tags:j==null?void 0:j.filter(Aa=>Aa.contact_id===pt.id)}),e.jsx(GFe,{deal:Bn})]})}),e.jsx(dt,{children:e.jsx("div",{className:"text-sm",children:ir.lastTouchDate?e.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground",children:[e.jsx(mn,{className:"h-3 w-3"}),ps(new Date(ir.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:pt.created_at?ps(new Date(pt.created_at),"MMM d, yyyy"):"—"})}),e.jsx(dt,{children:e.jsxs("div",{className:"space-y-1",children:[e.jsx(WFe,{birthday:pt.birthday,homeAnniversary:pt.home_anniversary,contactId:pt.id,contactName:`${pt.first_name}${pt.last_name?" "+pt.last_name:""}`,contactAddress:[pt.address,pt.city,pt.state].filter(Boolean).join(", ")}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[pt.birthday&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),ps(Il(pt.birthday),"MMM d")]}),pt.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),ps(Il(pt.home_anniversary),"MMM d")]})]})]})}),e.jsx(dt,{children:e.jsx(VFe,{contact:pt,onEdit:pe,onDelete:Zr,onSnooze:(Aa,Pi)=>{Ne(Aa),Fe(Pi)},showLeadPondAction:Je,onSendToLeadPond:ts,showTransferAction:He,onTransfer:hs})})]},pt.id)})})]})})}),kr>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 ",(ka-1)*me+1,"–",Math.min(ka*me,kr)," of ",kr.toLocaleString()," contacts"]}),e.jsxs(Ys,{value:String(me),onValueChange:pt=>{Ve(Number(pt)),ft(1)},children:[e.jsx(Gs,{className:"w-[80px] h-8",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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:ka<=1,onClick:()=>ft(1),children:"First"}),e.jsx(K,{variant:"outline",size:"sm",disabled:ka<=1,onClick:()=>ft(pt=>pt-1),children:e.jsx(ll,{className:"h-4 w-4"})}),e.jsxs("span",{className:"px-3 text-sm font-medium",children:["Page ",ka," of ",ta]}),e.jsx(K,{variant:"outline",size:"sm",disabled:ka>=ta,onClick:()=>ft(pt=>pt+1),children:e.jsx(xa,{className:"h-4 w-4"})}),e.jsx(K,{variant:"outline",size:"sm",disabled:ka>=ta,onClick:()=>ft(ta),children:"Last"})]})]}),e.jsx(xs,{open:ne||!!le,onOpenChange:pt=>{pt||(re(!1),pe(null),Hr())},children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{children:le?"Edit Contact":"Add Contact"})}),e.jsxs("form",{onSubmit:ln,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"first_name",children:"First Name *"}),e.jsx(ze,{id:"first_name",value:Ct.first_name,onChange:pt=>As({...Ct,first_name:pt.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:Ct.last_name,onChange:pt=>As({...Ct,last_name:pt.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:Ct.email,onChange:pt=>As({...Ct,email:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:Ct.phone,onChange:pt=>As({...Ct,phone:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"address",children:"Address"}),e.jsx(ze,{id:"address",value:Ct.address,onChange:pt=>As({...Ct,address:pt.target.value}),placeholder:"Street address"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:Ct.city,onChange:pt=>As({...Ct,city:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:Ct.state,onChange:pt=>As({...Ct,state:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"zip_code",children:"Zip"}),e.jsx(ze,{id:"zip_code",value:Ct.zip_code,onChange:pt=>As({...Ct,zip_code:pt.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:Ct.birthday,onChange:pt=>As({...Ct,birthday:pt.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:Ct.home_anniversary,onChange:pt=>As({...Ct,home_anniversary:pt.target.value})})]})]}),le&&e.jsx(R_e,{contactId:le.id,currentSpouseContactId:(le==null?void 0:le.spouse_contact_id)||null,currentSpouseName:(le==null?void 0:le.spouse_name)||null,currentSpouseEmail:(le==null?void 0:le.spouse_email)||null,onLink:pt=>q.mutate({contactId:le.id,spouseContactId:pt}),onUnlink:()=>q.mutate({contactId:le.id,spouseContactId:null}),isEditing:!0}),e.jsx(Fat,{value:Ct.lead_source_id,onChange:pt=>As({...Ct,lead_source_id:pt})}),e.jsxs("div",{children:[e.jsx(ye,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:g==null?void 0:g.filter(pt=>pt.active).map(pt=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Lo,{checked:Ct.tagIds.includes(pt.id),onCheckedChange:ir=>{As(ir?{...Ct,tagIds:[...Ct.tagIds,pt.id]}:{...Ct,tagIds:Ct.tagIds.filter(Bn=>Bn!==pt.id)})}}),e.jsx("span",{className:"text-sm",children:pt.name})]},pt.id))})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:Ct.notes,onChange:pt=>As({...Ct,notes:pt.target.value}),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{type:"button",variant:"outline",onClick:()=>{re(!1),pe(null),Hr()},children:"Cancel"}),e.jsxs(K,{type:"submit",disabled:I.isPending||L.isPending,children:[le?"Update":"Create"," Contact"]})]})]})]})}),e.jsx(Nbs,{open:xe,onOpenChange:_e,relationshipTypes:(g==null?void 0:g.filter(pt=>pt.active))||[],onSuccess:()=>{_e(!1)}}),e.jsx(Cbs,{open:fe,onOpenChange:we,onComplete:()=>we(!1)}),e.jsx(Bhe,{open:!!Ie,onOpenChange:pt=>{pt||Ne(null)},contactId:Ie||"",contactName:Ae}),e.jsx(Bbs,{open:Se,onOpenChange:rt}),e.jsx($bs,{open:Ge,onOpenChange:lt}),e.jsx(ttt,{open:It,onOpenChange:Ut,contactIds:Qe,contactNames:Qe.map(pt=>{const ir=Us.find(Bn=>Bn.id===pt);return ir?`${ir.first_name} ${ir.last_name||""}`.trim():""}),onComplete:()=>{at([]),Me(new Set),ct(!1)}})]})]})})}function Ubs(){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 Vbs(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 Hbs(){const{user:t}=Rs();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 Wbs(){const{user:t}=Rs(),s=es();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 Gbs(t){const{user:s}=Rs();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 Kbs(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 _C(){const{user:t}=Rs(),s=es();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 Zbs(){const t=es();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 Ybs(){const t=es();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 Uhe(){const{user:t}=Rs();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 zat(){const{data:t,isLoading:s}=Uhe(),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 hR(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 mR(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 bA(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 Xbs(){const{user:t}=Rs(),s=es();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 Qbs(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 Jbs(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 aSe(){const t=li(),s=es();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 pR(){const t=es();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 e_s(){const t=es();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 t_s(){const t=es();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 s_s(){const t=es();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 Bat(){const t=es();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 r_s(){const t=li();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 n_s(){const t=li(),s=es();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 a_s(){const t=es();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 i_s(){const t=es();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 v1(t){const s=window.location.hostname;return s==="localhost"||s.includes("lovable.app")?`${window.location.origin}/portal/${t}`:`https://clients.relevelup.com/${t}`}function o_s({contactId:t}){const s=pr(),r=es(),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(null),j=pR(),w=Bat(),{data:N,isLoading:C}=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(te=>te.id),{data:Y,error:J}=await H.from("client_portals").select("*").in("deal_id",V).is("archived_at",null);if(J)throw J;return(Y||[]).map(te=>({...te,deal:U.find(X=>X.id===te.deal_id)}))},enabled:!!t}),M=(N==null?void 0:N.map(U=>U.id))||[],{data:I}=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(Y=>{V[Y.portal_id]||(V[Y.portal_id]=Y)}),V},enabled:M.length>0}),L=U=>{navigator.clipboard.writeText(v1(U)),a(U),he.success("Portal link copied!"),setTimeout(()=>a(null),2e3)},R=async U=>{u.trim()&&(await w.mutateAsync({portal_id:U,title:u,content:f||void 0}),c(!1),p(""),g(""),r.invalidateQueries({queryKey:["contact-portal-updates"]}),he.success("Portal update posted!"))},q=async()=>{b&&(await j.mutateAsync({id:b.id,welcome_message:b.welcome_message,next_step_text:b.next_step_text,is_enabled:b.is_enabled,show_post_close_tips:b.show_post_close_tips,review_url:b.review_url}),l(!1),_(null),r.invalidateQueries({queryKey:["contact-portals",t]}),he.success("Portal settings updated!"))};return C||!N||N.length===0?null:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Su,{className:"h-4 w-4"}),"Client Portal"]})}),e.jsx(Re,{className:"space-y-3",children:N.map(U=>{var J,te,X;const B=((J=U.stage_mapping)==null?void 0:J.length)>0?U.stage_mapping:Qje(((te=U.deal)==null?void 0:te.deal_type)||"buyer"),V=B==null?void 0:B[U.current_stage_index??0],Y=I==null?void 0:I[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:((X=U.deal)==null?void 0:X.deal_name)||"Portal"}),V&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Stage: ",V.label||V.name]})]}),e.jsx(tt,{variant:U.is_enabled?"default":"secondary",className:"text-[10px] flex-shrink-0",children:U.is_enabled?"Active":"Disabled"})]}),Y&&e.jsxs("div",{className:"bg-muted/50 rounded-md p-2",children:[e.jsx("p",{className:"text-xs font-medium truncate",children:Y.title}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:ps(new Date(Y.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:()=>L(U.slug),children:[n===U.slug?e.jsx(fa,{className:"h-3 w-3 mr-1"}):e.jsx(gi,{className:"h-3 w-3 mr-1"}),"Copy Link"]}),e.jsxs(K,{variant:"outline",size:"sm",className:"h-7 text-xs",onClick:()=>window.open(v1(U.slug),"_blank"),children:[e.jsx(an,{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(io,{className:"h-3 w-3 mr-1"}),"Post Update"]})}),e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(ze,{value:u,onChange:ce=>p(ce.target.value),placeholder:"e.g. Inspection completed!"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Details (optional)"}),e.jsx(Er,{value:f,onChange:ce=>g(ce.target.value),placeholder:"Add more details...",rows:3})]}),e.jsxs(K,{onClick:()=>R(U.id),disabled:!u.trim()||w.isPending,className:"w-full",children:[e.jsx(Rn,{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(Yo,{className:"h-3 w-3 mr-1"}),"Settings"]})}),e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Portal Settings"})}),b&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Portal Enabled"}),e.jsx($r,{checked:b.is_enabled,onCheckedChange:ce=>_({...b,is_enabled:ce})})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Welcome Message"}),e.jsx(Er,{value:b.welcome_message||"",onChange:ce=>_({...b,welcome_message:ce.target.value}),placeholder:"Welcome to your home journey!",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Next Step"}),e.jsx(ze,{value:b.next_step_text||"",onChange:ce=>_({...b,next_step_text:ce.target.value}),placeholder:"What your client should do next..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Review URL"}),e.jsx(ze,{value:b.review_url||"",onChange:ce=>_({...b,review_url:ce.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Show Post-Close Tips"}),e.jsx($r,{checked:b.show_post_close_tips,onCheckedChange:ce=>_({...b,show_post_close_tips:ce})})]}),e.jsx(sl,{}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:q,disabled:j.isPending,className:"flex-1",children:"Save Settings"}),e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/pipeline?deal=${U.deal_id}`),children:[e.jsx(fi,{className:"h-4 w-4 mr-1"}),"Full Settings"]})]})]})]})]})]}),N.length>1&&e.jsx(sl,{})]},U.id)})})]})}function l_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(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{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(qn,{className:"h-4 w-4 text-primary"})}),"Property Activity",e.jsxs(tt,{variant:"secondary",className:"text-xs ml-auto",children:[n.length," ",n.length===1?"property":"properties"]})]})}),e.jsx(Re,{className:"pt-0",children:e.jsx("div",{className:"space-y-1",children:n.map(l=>{const i=o(l);return e.jsxs("a",{href:i||"#",target:"_blank",rel:"noopener noreferrer",onClick:c=>{i||c.preventDefault()},className:"group flex items-center gap-3 p-2.5 rounded-lg hover:bg-muted/60 transition-colors",children:[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(Sn,{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.jsxs("span",{className:"font-medium text-sm",children:["MLS# ",l.mls_number]})}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(mn,{className:"h-3 w-3"}),e.jsx("span",{title:ps(new Date(l.viewed_at),"PPp"),children:_d(new Date(l.viewed_at),{addSuffix:!0})})]})]}),i&&e.jsx(an,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity"})]},l.mls_number)})})})]})}const c_s=["Single Family","Condo","Townhouse","Multi-Family","Land","Commercial"];function YFe({value:t,onChange:s,onAdd:r,suggestions:n,placeholder:a,icon:o}){const[l,i]=k.useState(!1),c=k.useRef(null),u=k.useRef(null);k.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(To,{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(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),f]},f))})]})}function d_s({contactId:t,contactName:s}){var U,B,V;const{user:r}=Rs(),{hasLeadSite:n}=yue(),a=es(),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState(""),{data:f}=mt({queryKey:["agent-lead-site-config",r==null?void 0:r.id],queryFn:async()=>{const{data:Y,error:J}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(J||!Y)return{cities:[],zipCodes:[]};const te=Y.theme_config||{},X=Array.isArray(te.searchCities)?te.searchCities:[];Y.mls_market_area&&!X.includes(Y.mls_market_area)&&X.unshift(Y.mls_market_area);const ce=Array.isArray(te.searchZipCodes)?te.searchZipCodes:[];return{cities:X,zipCodes:ce}},enabled:!!r}),{data:g,isLoading:b}=mt({queryKey:["contact-property-alert",t],queryFn:async()=>{const{data:Y,error:J}=await H.from("contact_property_alerts").select("*").eq("contact_id",t).maybeSingle();if(J)throw J;return Y},enabled:!!t&&!!r}),[_,j]=k.useState({}),w=()=>{j({is_active:(g==null?void 0:g.is_active)??!0,min_price:(g==null?void 0:g.min_price)??null,max_price:(g==null?void 0:g.max_price)??null,min_beds:(g==null?void 0:g.min_beds)??null,min_baths:(g==null?void 0:g.min_baths)??null,min_sqft:(g==null?void 0:g.min_sqft)??null,max_sqft:(g==null?void 0:g.max_sqft)??null,cities:(g==null?void 0:g.cities)??[],zip_codes:(g==null?void 0:g.zip_codes)??[],property_types:(g==null?void 0:g.property_types)??[],frequency:(g==null?void 0:g.frequency)??"daily"}),l(!0)},N=Lt({mutationFn:async()=>{const Y={contact_id:t,owner_user_id:r.id,is_active:_.is_active??!0,min_price:_.min_price||null,max_price:_.max_price||null,min_beds:_.min_beds||null,min_baths:_.min_baths||null,min_sqft:_.min_sqft||null,max_sqft:_.max_sqft||null,cities:_.cities||[],zip_codes:_.zip_codes||[],property_types:_.property_types||[],frequency:_.frequency||"daily"};if(g!=null&&g.id){const{error:J}=await H.from("contact_property_alerts").update(Y).eq("id",g.id);if(J)throw J}else{const{error:J}=await H.from("contact_property_alerts").insert(Y);if(J)throw J}},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),he.success("Property alert saved!")},onError:Y=>{he.error(Y.message||"Failed to save alert")}}),C=Lt({mutationFn:async()=>{if(!(g!=null&&g.id))return;const{error:Y}=await H.from("contact_property_alerts").delete().eq("id",g.id);if(Y)throw Y},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-property-alert",t]}),l(!1),he.success("Property alert removed")}}),M=Y=>{var te;const J=Y.trim();J&&!((te=_.cities)!=null&&te.includes(J))&&j(X=>({...X,cities:[...X.cities||[],J]})),c("")},I=Y=>{var te;const J=Y.trim();J&&!((te=_.zip_codes)!=null&&te.includes(J))&&j(X=>({...X,zip_codes:[...X.zip_codes||[],J]})),p("")},L=Y=>{j(J=>{const te=J.property_types||[];return{...J,property_types:te.includes(Y)?te.filter(X=>X!==Y):[...te,Y]}})};if(!n||b)return null;if(g&&!o)return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx("div",{className:`h-7 w-7 rounded-lg flex items-center justify-center ${g.is_active?"bg-green-500/10":"bg-muted"}`,children:g.is_active?e.jsx(Pm,{className:"h-4 w-4 text-green-600"}):e.jsx(e1,{className:"h-4 w-4 text-muted-foreground"})}),"Property Alerts",e.jsxs(tt,{variant:g.is_active?"default":"secondary",className:"text-xs ml-auto",children:[g.is_active?"Active":"Paused"," · ",g.frequency]})]})}),e.jsxs(Re,{className:"pt-0 space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-xs",children:[g.min_price||g.max_price?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(wc,{className:"h-3 w-3"}),g.min_price?`$${(g.min_price/1e3).toFixed(0)}k`:"$0"," - ",g.max_price?`$${(g.max_price/1e3).toFixed(0)}k`:"Any"]}):null,g.min_beds?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(H4,{className:"h-3 w-3"}),g.min_beds,"+ beds"]}):null,g.min_baths?e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Nh,{className:"h-3 w-3"}),g.min_baths,"+ baths"]}):null,(U=g.cities)==null?void 0:U.map(Y=>e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Ba,{className:"h-3 w-3"}),Y]},Y)),(B=g.zip_codes)==null?void 0:B.map(Y=>e.jsx(tt,{variant:"outline",children:Y},Y)),(V=g.property_types)==null?void 0:V.map(Y=>e.jsx(tt,{variant:"outline",children:Y},Y))]}),g.last_sent_at&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Last sent: ",new Date(g.last_sent_at).toLocaleDateString()]}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,className:"w-full",children:"Edit Alert"})]})]});const R=((f==null?void 0:f.cities)||[]).filter(Y=>{var J;return!((J=_.cities)!=null&&J.includes(Y))}),q=((f==null?void 0:f.zipCodes)||[]).filter(Y=>{var J;return!((J=_.zip_codes)!=null&&J.includes(Y))});return o?e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Pm,{className:"h-4 w-4 text-primary"}),g?"Edit":"Setup"," Property Alert for ",s]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Alert Active"}),e.jsx($r,{checked:_.is_active??!0,onCheckedChange:Y=>j(J=>({...J,is_active:Y}))})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(wc,{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:_.min_price??"",onChange:Y=>j(J=>({...J,min_price:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max price",value:_.max_price??"",onChange:Y=>j(J=>({...J,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(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(H4,{className:"h-3.5 w-3.5"})," Min Beds"]}),e.jsxs(Ys,{value:_.min_beds?String(_.min_beds):"any",onValueChange:Y=>j(J=>({...J,min_beds:Y==="any"?null:Number(Y)})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Any"})}),e.jsxs(Ks,{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(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Nh,{className:"h-3.5 w-3.5"})," Min Baths"]}),e.jsxs(Ys,{value:_.min_baths?String(_.min_baths):"any",onValueChange:Y=>j(J=>({...J,min_baths:Y==="any"?null:Number(Y)})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Any"})}),e.jsxs(Ks,{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(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(d1,{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:_.min_sqft??"",onChange:Y=>j(J=>({...J,min_sqft:Y.target.value?Number(Y.target.value):null}))}),e.jsx(ze,{type:"number",placeholder:"Max sqft",value:_.max_sqft??"",onChange:Y=>j(J=>({...J,max_sqft:Y.target.value?Number(Y.target.value):null}))})]})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ba,{className:"h-3.5 w-3.5"})," Cities"]}),e.jsx(YFe,{value:i,onChange:c,onAdd:M,suggestions:R,placeholder:"Type to search cities..."}),_.cities&&_.cities.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.cities.map(Y=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(J=>{var te;return{...J,cities:(te=J.cities)==null?void 0:te.filter(X=>X!==Y)}}),children:e.jsx(Or,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"mb-1.5",children:"Zip Codes"}),e.jsx(YFe,{value:u,onChange:p,onAdd:I,suggestions:q,placeholder:"Type to search zip codes...",icon:e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:"#"})}),_.zip_codes&&_.zip_codes.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:_.zip_codes.map(Y=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[Y,e.jsx("button",{onClick:()=>j(J=>{var te;return{...J,zip_codes:(te=J.zip_codes)==null?void 0:te.filter(X=>X!==Y)}}),children:e.jsx(Or,{className:"h-3 w-3"})})]},Y))})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Sn,{className:"h-3.5 w-3.5"})," Property Types"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:c_s.map(Y=>{var J;return e.jsx(tt,{variant:(J=_.property_types)!=null&&J.includes(Y)?"default":"outline",className:"cursor-pointer",onClick:()=>L(Y),children:Y},Y)})})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"mb-1.5",children:"Frequency"}),e.jsxs(Ys,{value:_.frequency||"daily",onValueChange:Y=>j(J=>({...J,frequency:Y})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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:()=>N.mutate(),disabled:N.isPending,className:"flex-1",children:[N.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(ed,{className:"h-4 w-4 mr-1"}),"Save Alert"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),g&&e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>C.mutate(),disabled:C.isPending,children:e.jsx(Or,{className:"h-4 w-4"})})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{className:"p-4",children:e.jsxs("button",{onClick:w,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(Pm,{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 u_s({contactId:t,contactName:s}){var X;const{user:r}=Rs(),{hasLeadSite:n}=yue(),a=es(),[o,l]=k.useState(!1),[i,c]=k.useState(""),[u,p]=k.useState([]),[f,g]=k.useState(!1),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,C]=k.useState(""),M=k.useRef(null),I=k.useRef(null),{data:L}=mt({queryKey:["agent-lead-site-cities",r==null?void 0:r.id],queryFn:async()=>{const{data:ce,error:ne}=await H.from("lead_sites").select("theme_config, mls_market_area").eq("agent_id",r==null?void 0:r.id).eq("is_active",!0).maybeSingle();if(ne||!ce)return[];const re=ce.theme_config||{},le=Array.isArray(re.searchCities)?re.searchCities:[];return ce.mls_market_area&&!le.includes(ce.mls_market_area)&&le.unshift(ce.mls_market_area),le},enabled:!!r}),{data:R,isLoading:q}=mt({queryKey:["contact-market-report",t],queryFn:async()=>{const{data:ce,error:ne}=await H.from("innercircle_contacts").select("market_report_enabled, market_report_cities").eq("id",t).single();if(ne)throw ne;return ce},enabled:!!t&&!!r});k.useEffect(()=>{const ce=ne=>{I.current&&!I.current.contains(ne.target)&&M.current&&!M.current.contains(ne.target)&&_(!1)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const U=()=>{g((R==null?void 0:R.market_report_enabled)??!1),p((R==null?void 0:R.market_report_cities)??[]),l(!0)},B=ce=>{const ne=(ce||i).trim();ne&&!u.includes(ne)&&p([...u,ne]),c(""),_(!1)},V=(L||[]).filter(ce=>!u.includes(ce)&&ce.toLowerCase().includes(i.toLowerCase())),Y=Lt({mutationFn:async()=>{const{data:ce,error:ne}=await H.functions.invoke("send-market-report",{body:{action:"preview",agentId:r==null?void 0:r.id,cities:(R==null?void 0:R.market_report_cities)??[]}});if(ne)throw new Error(ne.message||"Failed to generate preview");if(ce&&!ce.ok&&ce.error)throw new Error(ce.error);return ce},onSuccess:ce=>{C(ce.html),w(!0)},onError:ce=>{he.error(ce.message||"Failed to generate preview")}}),J=Lt({mutationFn:async()=>{const{data:ce,error:ne}=await H.functions.invoke("send-market-report",{body:{action:"send",agentId:r==null?void 0:r.id,cities:(R==null?void 0:R.market_report_cities)??[],contactIds:[t]}});if(ne)throw new Error(ne.message||"Failed to send report");if(ce&&!ce.ok&&ce.error)throw new Error(ce.error);return ce},onSuccess:()=>{he.success(`Market report sent to ${s}!`)},onError:ce=>{he.error(ce.message||"Failed to send report")}}),te=Lt({mutationFn:async()=>{const{error:ce}=await H.from("innercircle_contacts").update({market_report_enabled:f,market_report_cities:u}).eq("id",t);if(ce)throw ce},onSuccess:()=>{a.invalidateQueries({queryKey:["contact-market-report",t]}),l(!1),he.success(f?"Monthly market report enabled!":"Market report disabled")},onError:ce=>{he.error(ce.message||"Failed to save")}});return!n||q?null:R!=null&&R.market_report_enabled&&!o?e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{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(Ro,{className:"h-4 w-4 text-primary"})}),"Monthly Market Report",e.jsx(tt,{variant:"default",className:"text-xs ml-auto",children:"Active"})]})}),e.jsxs(Re,{className:"pt-0 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 text-xs",children:((X=R.market_report_cities)==null?void 0:X.length)>0?R.market_report_cities.map(ce=>e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Ba,{className:"h-3 w-3"}),ce]},ce)):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(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(qn,{className:"h-4 w-4 mr-1"}),"Preview"]}),e.jsxs(K,{variant:"default",size:"sm",onClick:()=>J.mutate(),disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4 mr-1"}),"Send Now"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,children:"Edit"})]}),e.jsx(xs,{open:j,onOpenChange:w,children:e.jsxs(fs,{className:"max-w-3xl max-h-[85vh] overflow-hidden flex flex-col",children:[e.jsx(_s,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Ro,{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:N}})}),e.jsxs("div",{className:"flex gap-2 pt-4 border-t",children:[e.jsxs(K,{onClick:()=>{w(!1),J.mutate()},disabled:J.isPending,className:"flex-1",children:[J.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4 mr-1"}),"Send to ",s]}),e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Close"})]})]})})]})]}):o?e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ro,{className:"h-4 w-4 text-primary"}),"Market Report for ",s]})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Send Monthly Report"}),e.jsx($r,{checked:f,onCheckedChange:g})]}),f&&e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1 mb-1.5",children:[e.jsx(Ba,{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:M,value:i,onChange:ce=>{c(ce.target.value),_(!0)},onFocus:()=>_(!0),placeholder:"Type to search cities...",onKeyDown:ce=>{ce.key==="Enter"&&(ce.preventDefault(),V.length>0?B(V[0]):B())}}),e.jsx(To,{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:()=>B(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),b&&V.length>0&&e.jsx("div",{ref:I,className:"absolute z-50 mt-1 w-full max-h-60 overflow-y-auto rounded-md border bg-popover shadow-md",children:V.map(ce=>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:()=>B(ce),children:[e.jsx(Ba,{className:"h-3 w-3 text-muted-foreground flex-shrink-0"}),ce]},ce))})]}),u.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1 mt-2",children:u.map(ce=>e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[ce,e.jsx("button",{onClick:()=>p(u.filter(ne=>ne!==ce)),children:e.jsx(Or,{className:"h-3 w-3"})})]},ce))})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(K,{onClick:()=>te.mutate(),disabled:te.isPending,className:"flex-1",children:[te.isPending?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(ed,{className:"h-4 w-4 mr-1"}),"Save"]}),e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})]}):e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{className:"p-4",children:e.jsxs("button",{onClick:U,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(Ro,{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 h_s({videoId:t}){var l;const{data:s,isLoading:r,error:n}=Kbs(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(Gu,{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 m_s({contactId:t}){const s=pr(),[r,n]=k.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 b=g==="done"?"todo":"done";await H.from("deal_tasks").update({status:b,completed_at:b==="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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(fa,{className:"h-4 w-4"}),"Tasks",u.length>0&&e.jsx(tt,{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(Re,{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:ps(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(p_s,{contactId:t,open:r,onOpenChange:f=>{n(f),f||i()}})]})}function p_s({contactId:t,open:s,onOpenChange:r}){const[n,a]=k.useState(""),[o,l]=k.useState("medium"),[i,c]=k.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?ps(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(_s,{children:e.jsx(bs,{children:"Add Task"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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(ye,{children:"Due Date"}),e.jsx(ze,{type:"date",value:i?ps(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 f_s({contactId:t}){const s=pr(),{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Wh,{className:"h-4 w-4"}),"Linked Deals"]})}),e.jsx(Re,{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(tt,{variant:"outline",className:"text-[10px] capitalize",children:a.deal_type}),o&&e.jsxs(tt,{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(fi,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors flex-shrink-0"})]})},a.id)})})]})}function x_s(){var Ge,lt,qe,Ze,Je;const{contactId:t}=yo(),s=pr(),[r]=qc(),n=r.get("search")||"",a=r.get("type")||"all",o=r.get("status")||"all",{data:l,isLoading:i}=ZIt(t||""),{data:c}=Ux(),{data:u}=FO(),{data:p}=zO(3650),{data:f}=$he(365),{data:g}=Qbs(t),{contactsWithScores:b}=wue(),_=yNe(),j=vNe(),w=bNe(),N=UYe(),[C,M]=k.useState(!1),[I,L]=k.useState({}),[R,q]=k.useState(!1),[U,B]=k.useState(null),[V,Y]=k.useState(""),[J,te]=k.useState(void 0),[X,ce]=k.useState(""),[ne,re]=k.useState(null),[le,pe]=k.useState(!1),[xe,_e]=k.useState(null),{isGmailConnected:fe,gmailEmail:we}=$0(),{data:Ie}=mt({queryKey:["gmail-sent-emails",t],queryFn:async()=>{const{data:He,error:Qe}=await H.from("gmail_sent_emails").select("*").eq("contact_id",t).order("sent_at",{ascending:!1});if(Qe)throw Qe;return He},enabled:!!t}),Ne=He=>{if(!He)return null;const Qe=He.match(/Video ID:\s*([a-f0-9-]+)/i);return Qe?Qe[1]:null},Ae=k.useMemo(()=>{if(!b)return[];let He=b.filter(Qe=>{var Ut,hs,Yt;const at=n===""||`${Qe.first_name} ${Qe.last_name}`.toLowerCase().includes(n.toLowerCase())||((Ut=Qe.email)==null?void 0:Ut.toLowerCase().includes(n.toLowerCase()))||((hs=Qe.phone)==null?void 0:hs.includes(n)),It=a==="all"||((Yt=Qe.tags)==null?void 0:Yt.some(ts=>ts.relationship_type_id===a));return at&&It});return o==="not-touched-90"?He=He.filter(Qe=>{const at=Qe.relationshipScore.daysSinceTouch;return at===null||at>90}):o==="at-risk"?He=He.filter(Qe=>Qe.relationshipScore.status==="at-risk"):o==="cooling"?He=He.filter(Qe=>Qe.relationshipScore.status==="cooling"):o==="warm"&&(He=He.filter(Qe=>Qe.relationshipScore.status==="warm")),He.map(Qe=>Qe.id)},[b,n,a,o]),Fe=Ae.indexOf(t||""),Ce=Fe>0?Ae[Fe-1]:null,Me=Fe1&&Fe!==-1,ct=He=>{const Qe=new URLSearchParams;n&&Qe.set("search",n),a!=="all"&&Qe.set("type",a),o!=="all"&&Qe.set("status",o);const at=Qe.toString();return`/mission-control/contacts/${He}${at?`?${at}`:""}`},Te=k.useMemo(()=>{const He=((p==null?void 0:p.filter(at=>at.contact_id===t))||[]).map(at=>{var Yt,ts,Ds;const It=Ne(at.notes);let Ut=((Yt=at.action_type)==null?void 0:Yt.name)||"Touch",hs=at.notes;if(Ut==="Other"&&((ts=at.notes)!=null&&ts.startsWith("["))){const vr=at.notes.indexOf("]");vr>0&&(Ut=at.notes.substring(1,vr),hs=at.notes.substring(vr+1).replace(/^\s*—\s*/,"").trim()||null)}return{id:at.id,type:"touch",completed_at:at.completed_at,name:Ut,color:((Ds=at.action_type)==null?void 0:Ds.color)||"#3B82F6",notes:hs,videoId:It}}),Qe=((f==null?void 0:f.filter(at=>at.contact_id===t))||[]).map(at=>({id:at.id,type:"popby",completed_at:at.completed_at,name:"Pop-by",color:"#F97316",notes:at.notes,videoId:null}));return[...He,...Qe].sort((at,It)=>new Date(It.completed_at).getTime()-new Date(at.completed_at).getTime())},[p,f,t]),ft=()=>{var He;l&&(L({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:((He=l.tags)==null?void 0:He.map(Qe=>Qe.relationship_type_id))||[]}),M(!0))},me=async()=>{await _.mutateAsync({id:t,...I,lead_source_id:I.lead_source_id||null}),M(!1)},Ve=async()=>{confirm("Are you sure you want to delete this contact?")&&(await j.mutateAsync(t),s("/mission-control/contacts"))},et=((Ge=u==null?void 0:u.find(He=>He.id===U))==null?void 0:Ge.name)==="Other",Se=async()=>{if(!U||et&&!X.trim())return;const He=J?new Date(J.getFullYear(),J.getMonth(),J.getDate(),12,0,0).toISOString():void 0,Qe=et?`[${X.trim()}]${V?" — "+V:""}`:V;await w.mutateAsync({contactId:t,actionTypeId:U,notes:Qe,completedAt:He}),q(!1),B(null),Y(""),te(void 0),ce("")},rt=(He,Qe)=>{fe&&l?(_e({email:He,name:Qe||`${l.first_name} ${l.last_name||""}`.trim()}),pe(!0)):window.location.href=`mailto:${He}`};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(ll,{className:"h-4 w-4 mr-1"}),"Back to Contacts"]}),$e&&e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Ce&&s(ct(Ce)),disabled:!Ce,className:"px-2",children:[e.jsx(ll,{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:[Fe+1," of ",Ae.length]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>Me&&s(ct(Me)),disabled:!Me,className:"px-2",children:[e.jsx("span",{className:"sr-only sm:not-sr-only sm:mr-1",children:"Next"}),e.jsx(xa,{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(dr,{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:R,onOpenChange:q,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(_s,{children:e.jsx(bs,{children:"Log an Action"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Action Type"}),e.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:u==null?void 0:u.filter(He=>He.active).map(He=>e.jsxs("button",{onClick:()=>B(He.id),className:` p-3 rounded-lg border text-left transition-all ${U===He.id?"border-primary bg-primary/10":"hover:bg-accent"} `,children:[e.jsx("div",{className:"font-medium",children:He.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:He.description})]},He.id))}),et&&e.jsxs("div",{className:"mt-3",children:[e.jsx(ye,{htmlFor:"custom-action-name",children:"What did you do?"}),e.jsx(ze,{id:"custom-action-name",value:X,onChange:He=>ce(He.target.value),placeholder:"e.g. Met a client for lunch, Dropped off a gift...",className:"mt-1"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Date (optional — backdate if needed)"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal mt-2",!J&&"text-muted-foreground"),children:[e.jsx(cn,{className:"h-4 w-4 mr-2"}),J?ps(J,"PPP"):"Today (default)"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:J,onSelect:te,disabled:He=>He>new Date,initialFocus:!0,className:Pt("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"action-notes",children:"Notes (optional)"}),e.jsx(Er,{id:"action-notes",value:V,onChange:He=>Y(He.target.value),placeholder:"Add any notes about this interaction...",rows:3})]}),e.jsxs(K,{onClick:Se,disabled:!U||et&&!X.trim()||w.isPending,className:"w-full",children:[e.jsx(fa,{className:"h-4 w-4 mr-1"}),"Complete Action"]})]})]})]}),e.jsxs(K,{variant:"outline",onClick:ft,children:[e.jsx(dd,{className:"h-4 w-4 mr-1"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:Ve,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||""]}),(((lt=l.lead_source_ref)==null?void 0:lt.name)||l.lead_source)&&e.jsx(tt,{variant:"outline",className:"text-xs border-primary/30 text-primary",children:((qe=l.lead_source_ref)==null?void 0:qe.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(dr,{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(Un,{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(O_e,{contact:l}),(Ze=l.tags)==null?void 0:Ze.map(He=>{const Qe=c==null?void 0:c.find(at=>at.id===He.relationship_type_id);return Qe?e.jsx(tt,{variant:"secondary",className:"text-xs",children:Qe.name},He.id):null})]}),e.jsx("div",{className:"mt-2",children:e.jsx(zbs,{contactId:t})})]})}),e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"md:col-span-2",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Contact Information"})}),e.jsx(Re,{children:C?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(ye,{htmlFor:"first_name",children:"First Name"}),e.jsx(ze,{id:"first_name",value:I.first_name,onChange:He=>L({...I,first_name:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"last_name",children:"Last Name"}),e.jsx(ze,{id:"last_name",value:I.last_name,onChange:He=>L({...I,last_name:He.target.value})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"email",children:"Email"}),e.jsx(ze,{id:"email",type:"email",value:I.email,onChange:He=>L({...I,email:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"phone",children:"Phone"}),e.jsx(ze,{id:"phone",value:I.phone,onChange:He=>L({...I,phone:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"address",children:"Street Address"}),e.jsx(ze,{id:"address",value:I.address,onChange:He=>L({...I,address:He.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(ye,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:I.city,onChange:He=>L({...I,city:He.target.value}),placeholder:"City"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:I.state,onChange:He=>L({...I,state:He.target.value}),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"zip_code",children:"Zip Code"}),e.jsx(ze,{id:"zip_code",value:I.zip_code,onChange:He=>L({...I,zip_code:He.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(ye,{htmlFor:"birthday",children:"Birthday"}),e.jsx(ze,{id:"birthday",type:"date",value:I.birthday,onChange:He=>L({...I,birthday:He.target.value})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"home_anniversary",children:"Home Anniversary"}),e.jsx(ze,{id:"home_anniversary",type:"date",value:I.home_anniversary,onChange:He=>L({...I,home_anniversary:He.target.value})})]})]}),e.jsx(sl,{}),e.jsx(R_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:He=>N.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>N.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(ye,{htmlFor:"company_name",children:"Company"}),e.jsx(ze,{id:"company_name",value:I.company_name,onChange:He=>L({...I,company_name:He.target.value}),placeholder:"Enter company name"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"job_title",children:"Job Title"}),e.jsx(ze,{id:"job_title",value:I.job_title,onChange:He=>L({...I,job_title:He.target.value}),placeholder:"Enter job title"})]})]}),e.jsx(Fat,{value:I.lead_source_id||"",onChange:He=>L({...I,lead_source_id:He})}),e.jsxs("div",{children:[e.jsx(ye,{children:"Relationship Types"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:c==null?void 0:c.filter(He=>He.active).map(He=>{var Qe;return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx(Lo,{checked:(Qe=I.tagIds)==null?void 0:Qe.includes(He.id),onCheckedChange:at=>{var It;L(at?{...I,tagIds:[...I.tagIds||[],He.id]}:{...I,tagIds:(It=I.tagIds)==null?void 0:It.filter(Ut=>Ut!==He.id)})}}),e.jsx("span",{className:"text-sm",children:He.name})]},He.id)})})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:I.notes,onChange:He=>L({...I,notes:He.target.value}),rows:4})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{onClick:me,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(cn,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:"Last Contacted:"})," ",ps(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(dr,{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(Un,{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(Ba,{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(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Birthday: ",ps(Il(l.birthday),"MMMM d")]})]}),l.home_anniversary&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Home Anniversary: ",ps(Il(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: ",ps(new Date(l.created_at),"MMMM d, yyyy")]})]})]}),e.jsx(sl,{}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(R_e,{contactId:t,currentSpouseContactId:(l==null?void 0:l.spouse_contact_id)||null,currentSpouseName:l.spouse_name||null,currentSpouseEmail:l.spouse_email||null,onLink:He=>N.mutate({contactId:t,spouseContactId:He}),onUnlink:()=>N.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(wa,{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(sl,{}),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(He=>{var Qe;return e.jsx(tt,{variant:"secondary",children:(Qe=He.relationship_type)==null?void 0:Qe.name},He.id)}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"No relationship types assigned"})})]}),l.notes&&e.jsxs(e.Fragment,{children:[e.jsx(sl,{}),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(vbs,{contact:l,onLogTouch:()=>q(!0)}),e.jsx(f_s,{contactId:t}),e.jsx(o_s,{contactId:t}),e.jsx(l_s,{contactId:t}),e.jsx(d_s,{contactId:t,contactName:l.first_name}),e.jsx(u_s,{contactId:t,contactName:l.first_name}),e.jsx(m_s,{contactId:t}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Activity Log"})}),e.jsx(Re,{children:Te.length>0?e.jsx("div",{className:"space-y-4",children:Te.map(He=>{var Qe;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:He.color},children:He.type==="popby"?e.jsx(No,{className:"h-4 w-4"}):(Qe=He.name)==null?void 0:Qe.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:He.name}),He.videoId&&e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>re(He.videoId),children:[e.jsx(rl,{className:"h-3 w-3 mr-1"}),"Preview"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ps(new Date(He.completed_at),"MMM d, yyyy h:mm a")}),He.notes&&!He.videoId&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:He.notes})]})]},He.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(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(io,{className:"h-5 w-5 text-primary"}),"Video Replies"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:g.map(He=>{var Qe,at;return e.jsxs("div",{className:"flex items-start gap-3 pb-3 border-b last:border-0",children:[(Qe=He.video)!=null&&Qe.thumbnail_url?e.jsx("img",{src:He.video.thumbnail_url,alt:He.video.title||"Video",className:"h-12 w-16 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>re(He.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(He.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: ",((at=He.video)==null?void 0:at.title)||"Untitled Video"]}),e.jsxs(K,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs flex-shrink-0",onClick:()=>re(He.video_id),children:[e.jsx(rl,{className:"h-3 w-3 mr-1"}),"Watch"]})]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ps(new Date(He.created_at),"MMM d, yyyy h:mm a")}),He.message&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-1 line-clamp-2",children:['"',He.message,'"']})]})]},He.id)})})})]}),Ie&&Ie.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Rn,{className:"h-5 w-5 text-sky-500"}),"Sent Emails"]})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:Ie.map(He=>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(dr,{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:He.subject}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["To: ",He.to_email," · ",ps(new Date(He.sent_at),"MMM d, yyyy h:mm a")]})]}),e.jsx(xa,{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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-5 w-5 text-sky-500"}),He.subject]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["To: ",He.to_email," · ",ps(new Date(He.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:He.body,className:"w-full h-[400px] border-0",sandbox:"",title:`Email: ${He.subject}`})})]})]},He.id))})})]})]}),e.jsx(xs,{open:!!ne,onOpenChange:He=>!He&&re(null),children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Video Preview"})}),ne&&e.jsx(h_s,{videoId:ne})]})})]})]})}),fe&&l&&xe&&e.jsx(jE,{open:le,onOpenChange:pe,contact:{id:l.id,first_name:l.first_name,last_name:l.last_name,email:xe.email},gmailEmail:we})]}):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 XFe={Crown:Im,FileText:En,Users:mr,Globe:Su,Star:Jn,Phone:Un,MessageSquare:io,PenTool:$_,Video:Cn,Gift:No},hye=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function g_s(){var Je,He;const t=pr(),{user:s}=Rs(),{data:r}=Ux(),{data:n}=XIt(),{data:a}=nLt(),{data:o}=qYe(),{data:l}=FO(),{data:i}=YIt(),c=aLt(),u=QIt(),p=eLt(),f=tLt(),g=sLt(),b=rLt(),_=JIt(),[j,w]=k.useState(null),[N,C]=k.useState(!1),[M,I]=k.useState(null),[L,R]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState([]),[Y,J]=k.useState(null),[te,X]=k.useState(null),[ce,ne]=k.useState(!1),[re,le]=k.useState(""),[pe,xe]=k.useState(""),[_e,fe]=k.useState(""),[we,Ie]=k.useState(""),Ne=(Qe,at)=>a==null?void 0:a.some(It=>It.plan_id===Qe&&It.relationship_type_id===at&&It.active),Ae=Qe=>a==null?void 0:a.find(at=>at.relationship_type_id===Qe&&at.active),Fe=async(Qe,at)=>{const It=Ne(Qe,at);await c.mutateAsync({planId:Qe,relationshipTypeId:at,active:!It})},Ce=(n==null?void 0:n.filter(Qe=>Qe.active&&!Qe.owner_user_id))||[],Me=(n==null?void 0:n.filter(Qe=>Qe.owner_user_id===(s==null?void 0:s.id)))||[],$e=r==null?void 0:r.find(Qe=>Qe.id===j),ct=j?Ae(j):null,Te=n==null?void 0:n.find(Qe=>Qe.id===(ct==null?void 0:ct.plan_id)),ft=async()=>{if(!L.trim())return;const Qe=await u.mutateAsync({name:L,description:q});Qe&&B.length>0&&await g.mutateAsync({planId:Qe.id,items:B}),nt()},me=async()=>{!L.trim()||!M||(await p.mutateAsync({id:M,name:L,description:q}),await g.mutateAsync({planId:M,items:B}),nt())},Ve=Qe=>{var at;I(Qe.id),R(Qe.name),U(Qe.description||""),V(((at=Qe.items)==null?void 0:at.map(It=>({month_number:It.month_number,action_type_id:It.action_type_id,default_script_id:It.default_script_id||void 0,notes:It.notes||void 0})))||[]),C(!0)},nt=()=>{C(!1),I(null),R(""),U(""),V([])},et=(Qe,at)=>{X(at)},Se=(Qe,at,It)=>{V(Ut=>[...Ut.filter(Yt=>Yt.month_number!==Qe),{month_number:Qe,action_type_id:at,default_script_id:It}]),J(null),X(null)},rt=Qe=>{V(at=>at.filter(It=>It.month_number!==Qe))},Ge=async()=>{if(!re.trim()||!pe.trim()||!te)return;const Qe=await b.mutateAsync({actionTypeId:te,title:re,scriptBody:pe,emailSubject:_e||void 0,tone:we||void 0});Qe&&Y!==null&&Se(Y,te,Qe.id),ne(!1),le(""),xe(""),fe(""),Ie("")},lt=te?i==null?void 0:i.filter(Qe=>Qe.action_type_id===te&&Qe.active):[],qe=Qe=>XFe[Qe||"Phone"]||Un,Ze=Qe=>XFe[Qe||"Users"]||mr;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(ll,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsxs(K,{onClick:()=>C(!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(Qe=>Qe.active).map(Qe=>{const at=Ze(Qe.icon),It=(o==null?void 0:o[Qe.id])||0,Ut=Ae(Qe.id),hs=n==null?void 0:n.find(ts=>ts.id===(Ut==null?void 0:Ut.plan_id)),Yt=j===Qe.id;return e.jsxs("button",{onClick:()=>w(Qe.id),className:` w-full flex items-center gap-3 p-4 rounded-lg border text-left transition-all ${Yt?"border-primary bg-primary/5 ring-2 ring-primary":"hover:bg-accent"} `,children:[e.jsx(at,{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:Qe.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[It," contacts"]})]}),hs?e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"}),hs.name.split(" ")[0]]}):e.jsx(tt,{variant:"outline",className:"text-xs text-muted-foreground",children:"No plan"})]},Qe.id)})]}),e.jsx("div",{className:"lg:col-span-2",children:j&&$e?e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[(()=>{const Qe=Ze($e.icon);return e.jsx(Qe,{className:"h-5 w-5"})})(),$e.name," Touchpoint Plan"]}),e.jsxs(xr,{children:["Choose a plan for your ",$e.name," contacts"]})]}),e.jsxs(Re,{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(xi,{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:()=>Fe(Te.id,j),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(cn,{className:"h-4 w-4"}),"12-Month Schedule"]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 gap-2",children:hye.map((Qe,at)=>{var Yt,ts;const It=((Yt=Te.items)==null?void 0:Yt.filter(Ds=>Ds.month_number===at+1))||[],Ut=(ts=It[0])==null?void 0:ts.action_type,hs=Ut?qe(Ut.icon):null;return e.jsxs("div",{className:` p-2 rounded border text-center ${It.length>0?"bg-primary/10 border-primary":"bg-muted"} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:Qe}),hs&&e.jsx(hs,{className:"h-4 w-4 mx-auto mt-1",style:{color:(Ut==null?void 0:Ut.color)||"#3B82F6"}})]},at)})})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium mb-3",children:Te?"Switch to a Different Plan":"Choose a Plan"}),Ce.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"}),Ce.map(Qe=>{var It;const at=(Te==null?void 0:Te.id)===Qe.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${at?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Qe.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((It=Qe.items)==null?void 0:It.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 Ut=`${Qe.name} (Copy)`;_.mutate({sourcePlanId:Qe.id,newName:Ut})},children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:at?"outline":"default",disabled:at||c.isPending,onClick:()=>Fe(Qe.id,j),children:at?"Active":"Use This"})]})]},Qe.id)})]}),Me.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"My Custom Plans"}),Me.map(Qe=>{var It;const at=(Te==null?void 0:Te.id)===Qe.id;return e.jsxs("div",{className:` flex items-center justify-between p-3 rounded-lg border ${at?"opacity-50":"hover:bg-accent"} `,children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Qe.name}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[((It=Qe.items)==null?void 0:It.length)||0," touchpoints/year"]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",title:"Edit plan",onClick:()=>Ve(Qe),children:e.jsx(Qy,{className:"h-4 w-4"})}),e.jsx(K,{size:"sm",variant:"ghost",title:"Delete plan",onClick:()=>f.mutate(Qe.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})}),e.jsx(K,{size:"sm",variant:at?"outline":"default",disabled:at||c.isPending,onClick:()=>Fe(Qe.id,j),children:at?"Active":"Use This"})]})]},Qe.id)})]}),Ce.length===0&&Me.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(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(cn,{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(Pe,{className:"bg-muted/50",children:e.jsx(Re,{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:N,onOpenChange:Qe=>{Qe?C(!0):nt()},children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{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(ye,{htmlFor:"plan-name",children:"Plan Name"}),e.jsx(ze,{id:"plan-name",value:L,onChange:Qe=>R(Qe.target.value),placeholder:"e.g., My VIP Plan"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"plan-description",children:"Description (optional)"}),e.jsx(Er,{id:"plan-description",value:q,onChange:Qe=>U(Qe.target.value),placeholder:"Describe your plan...",rows:2})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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:hye.map((Qe,at)=>{const It=at+1,Ut=B.find(ts=>ts.month_number===It),hs=Ut?l==null?void 0:l.find(ts=>ts.id===Ut.action_type_id):null,Yt=hs?qe(hs.icon):null;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>J(Y===It?null:It),className:` w-full p-3 rounded-lg border text-center transition-all ${Ut?"bg-primary/10 border-primary":"bg-muted hover:bg-accent"} ${Y===It?"ring-2 ring-primary":""} `,children:[e.jsx("div",{className:"text-xs text-muted-foreground font-medium",children:Qe}),Yt?e.jsx(Yt,{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"})]}),Ut&&e.jsx("button",{type:"button",onClick:ts=>{ts.stopPropagation(),rt(It)},className:"absolute -top-1 -right-1 p-1 bg-destructive text-destructive-foreground rounded-full",children:e.jsx(Or,{className:"h-3 w-3"})})]},at)})}),Y!==null&&!te&&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 ",hye[Y-1],":"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:l==null?void 0:l.filter(Qe=>Qe.active).map(Qe=>{const at=qe(Qe.icon);return e.jsxs("button",{type:"button",onClick:()=>et(Y,Qe.id),className:"flex items-center gap-2 px-3 py-2 rounded-lg border bg-background hover:bg-accent transition-colors",children:[e.jsx(at,{className:"h-4 w-4",style:{color:Qe.color||"#3B82F6"}}),e.jsx("span",{className:"text-sm",children:Qe.name})]},Qe.id)})})]}),Y!==null&&te&&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:()=>X(null),children:[e.jsx(ll,{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:()=>Se(Y,te),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"})]})}),lt==null?void 0:lt.map(Qe=>e.jsx("button",{type:"button",onClick:()=>Se(Y,te,Qe.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:Qe.title}),Qe.tone&&e.jsx(tt,{variant:"secondary",className:"text-xs mt-1",children:Qe.tone}),e.jsxs("div",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:[Qe.script_body.substring(0,100),"..."]})]})},Qe.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(zn,{children:[e.jsx(K,{variant:"outline",onClick:nt,children:"Cancel"}),e.jsxs(K,{onClick:M?me:ft,disabled:!L.trim()||u.isPending||p.isPending,children:[e.jsx(ed,{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(_s,{children:e.jsx(bs,{children:"Create Custom Script"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-title",children:"Script Title"}),e.jsx(ze,{id:"script-title",value:re,onChange:Qe=>le(Qe.target.value),placeholder:"e.g., Friendly Check-in Call"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-tone",children:"Tone (optional)"}),e.jsxs(Ys,{value:we,onValueChange:Ie,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select tone..."})}),e.jsxs(Ks,{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"})]})]})]}),((He=(Je=l==null?void 0:l.find(Qe=>Qe.id===te))==null?void 0:Je.name)==null?void 0:He.toLowerCase().includes("email"))&&e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-email-subject",children:"Email Subject"}),e.jsx(ze,{id:"script-email-subject",value:_e,onChange:Qe=>fe(Qe.target.value),placeholder:"e.g., Quick Hello!"})]}),e.jsxs("div",{children:[e.jsx(ye,{htmlFor:"script-body",children:"Script Content"}),e.jsx(Er,{id:"script-body",value:pe,onChange:Qe=>xe(Qe.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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsxs(K,{onClick:Ge,disabled:!re.trim()||!pe.trim()||b.isPending,children:[e.jsx(ed,{className:"h-4 w-4 mr-2"}),"Create & Use Script"]})]})]})})]})}const y_s="0dde5abb-0005-4c8c-a471-30d0cbc9e280",v_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 b_s(){const t=pr(),s=Dat(),{data:r}=hbs(),{data:n}=Ux(),{data:a}=rSe(),{data:o}=$he(90),{data:l}=Wm(),i=gbs(),c=fbs(),u=pbs(),p=xbs(),{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",y_s).order("publish_date",{ascending:!1});if(ne)throw ne;const{data:re}=await H.from("template_likes").select("template_id"),{data:le}=await H.from("template_comments").select("template_id"),pe=new Map;re==null||re.forEach(_e=>{pe.set(_e.template_id,(pe.get(_e.template_id)||0)+1)});const xe=new Map;return le==null||le.forEach(_e=>{xe.set(_e.template_id,(xe.get(_e.template_id)||0)+1)}),(ce||[]).map(_e=>({..._e,likesCount:pe.get(_e.id)||0,commentsCount:xe.get(_e.id)||0}))}}),b=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},[j,w]=k.useState(null),[N,C]=k.useState(!1),[M,I]=k.useState(!1),[L,R]=k.useState(!1),[q,U]=k.useState({popby_item_id:"",notes:""}),[B,V]=k.useState({name:"",description:""}),Y=async()=>{j&&(await c.mutateAsync({contact_id:j.id,popby_item_id:q.popby_item_id||void 0,notes:q.notes||void 0}),C(!1),w(null),U({popby_item_id:"",notes:""}))},J=async()=>{B.name.trim()&&(await u.mutateAsync({name:B.name.trim(),description:B.description.trim()||void 0}),R(!1),V({name:"",description:""}))},te=async(ce,ne)=>{await p.mutateAsync({relationship_type_id:ce,frequency_days:parseInt(ne)})},X=ce=>{var re;const ne=a==null?void 0:a.find(le=>le.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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Ba,{className:"h-4 w-4 mr-2"}),"View Map"]}),e.jsxs(K,{variant:"outline",onClick:()=>I(!0),children:[e.jsx(Yo,{className:"h-4 w-4 mr-2"}),"Frequency Settings"]}),e.jsxs(K,{variant:"outline",onClick:()=>R(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Popby Idea"]})]}),e.jsxs(ja,{defaultValue:"due",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"due",children:"Due for Popby"}),e.jsx(us,{value:"activity",children:"Recent Activity"}),e.jsx(us,{value:"library",children:"Popby Library"}),e.jsx(us,{value:"templates",children:"Popby Templates"})]}),e.jsx(ks,{value:"due",className:"space-y-4 mt-4",children:!s||s.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(No,{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(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(Re,{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(tt,{variant:"destructive",className:"text-xs",children:[ce.daysOverdue,"+ days overdue"]}),ce.daysSinceLastPopby===null&&e.jsx(tt,{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(Ba,{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: ",ps(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(Un,{className:"h-4 w-4"})})}),e.jsxs(K,{size:"sm",onClick:()=>{w(ce),C(!0)},children:[e.jsx(xi,{className:"h-4 w-4 mr-1"}),"Log Popby"]})]})]})})},ce.id))})}),e.jsx(ks,{value:"activity",className:"space-y-4 mt-4",children:!o||o.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(mn,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Recent Popby Log"})}),e.jsx(Re,{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(No,{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:b(ce.contact_id)}),_(ce.popby_item_id)&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:_(ce.popby_item_id)})]}),e.jsx("div",{className:"text-sm text-muted-foreground",children:ps(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(ks,{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(Pe,{children:e.jsx(Re,{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(No,{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(tt,{variant:"secondary",className:"mt-2 text-xs",children:"Shared"})]})]})})},ce.id)),e.jsx(Pe,{className:"border-dashed cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>R(!0),children:e.jsx(Re,{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(ks,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{className:"p-8 text-center text-muted-foreground",children:[e.jsx(Cl,{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(Pe,{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(Re,{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:bde(ce.description)}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-3",children:e.jsx(tt,{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(eh,{className:"h-3.5 w-3.5"}),ce.likesCount]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(zc,{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(an,{className:"h-4 w-4"}),"View Template"]})]})]},ce.id))})]})]}),e.jsx(xs,{open:N,onOpenChange:C,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsxs(bs,{children:["Log Popby for ",j==null?void 0:j.first_name," ",j==null?void 0:j.last_name]})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Popby Item (optional)"}),e.jsxs(Ys,{value:q.popby_item_id,onValueChange:ce=>U(ne=>({...ne,popby_item_id:ce})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a popby item..."})}),e.jsx(Ks,{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(ye,{children:"Notes (optional)"}),e.jsx(Er,{placeholder:"Any notes about this popby...",value:q.notes,onChange:ce=>U(ne=>({...ne,notes:ce.target.value}))})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),children:"Cancel"}),e.jsx(K,{onClick:Y,disabled:c.isPending,children:"Log Popby"})]})]})}),e.jsx(xs,{open:M,onOpenChange:I,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{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(ye,{className:"font-medium",children:ce.name}),e.jsxs(Ys,{value:X(ce.id),onValueChange:ne=>te(ce.id,ne),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:v_s.map(ne=>e.jsx(Mt,{value:ne.value,children:ne.label},ne.value))})]})]},ce.id))]}),e.jsx(zn,{children:e.jsx(K,{onClick:()=>I(!1),children:"Done"})})]})}),e.jsx(xs,{open:L,onOpenChange:R,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Add Popby Idea"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{children:"Description"}),e.jsx(Er,{placeholder:"Optional description...",value:B.description,onChange:ce=>V(ne=>({...ne,description:ce.target.value}))})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{onClick:J,disabled:!B.name.trim()||u.isPending,children:"Add Item"})]})]})})]})})}const __s=hC({property_address:pc().min(1,"Property address is required"),city:pc().optional(),state:pc().optional(),zip:pc().optional(),transaction_type:AGe(["buyer","seller"]),close_date:pc().min(1,"Close date is required"),sale_price:UL().min(0,"Sale price must be positive"),commission_amount:UL().optional(),lead_source_id:pc().optional(),client_type_id:pc().optional(),contact_id:pc().optional(),notes:pc().optional(),is_win:YCt()});function $at({open:t,onOpenChange:s,transaction:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(!1),[u,p]=k.useState(""),f=bue(),g=WLt(),{data:b}=tE(),{data:_}=Ux(),{data:j}=Wm(),w=vue(),N=wNe(),{data:C}=_ue(),M=(C==null?void 0:C.show_commission)??!0,I=due({resolver:uue(__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}});k.useEffect(()=>{r?I.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}):I.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,I]);const L=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)},R=async()=>{if(!o.trim())return;const[B,...V]=o.trim().split(" "),Y=V.join(" ")||null,J=await w.mutateAsync({first_name:B,last_name:Y,tagIds:[]});J&&(I.setValue("contact_id",J.id),l(""),c(!1),a(!1))},q=async()=>{if(!u.trim())return;const B=await N.mutateAsync(u.trim());B&&(I.setValue("lead_source_id",B.id),p(""))},U=j==null?void 0:j.find(B=>B.id===I.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(_s,{children:e.jsx(bs,{children:r?"Edit Transaction":"Add Transaction"})}),e.jsx(Gi,{className:"max-h-[70vh] pr-4",children:e.jsx(hue,{...I,children:e.jsxs("form",{onSubmit:I.handleSubmit(L),className:"space-y-4",children:[e.jsx(Wc,{control:I.control,name:"property_address",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Property Address *"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"123 Main St",...B})}),e.jsx(km,{})]})}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsx(Wc,{control:I.control,name:"city",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"City"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"City",...B})})]})}),e.jsx(Wc,{control:I.control,name:"state",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"State"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"TX",...B})})]})}),e.jsx(Wc,{control:I.control,name:"zip",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Zip"}),e.jsx(Pc,{children:e.jsx(ze,{placeholder:"75001",...B})})]})})]}),e.jsx(Wc,{control:I.control,name:"transaction_type",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Transaction Type *"}),e.jsxs(Ys,{onValueChange:B.onChange,value:B.value,children:[e.jsx(Pc,{children:e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select type"})})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"buyer",children:"Buyer"}),e.jsx(Mt,{value:"seller",children:"Seller"})]})]}),e.jsx(km,{})]})}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsx(Wc,{control:I.control,name:"close_date",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Close Date *"}),e.jsx(Pc,{children:e.jsx(ze,{type:"date",...B})}),e.jsx(km,{})]})}),e.jsx(Wc,{control:I.control,name:"sale_price",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Sale Price *"}),e.jsx(Pc,{children:e.jsx(ze,{type:"number",placeholder:"0",...B,onChange:V=>B.onChange(Number(V.target.value))})}),e.jsx(km,{})]})})]}),M&&e.jsx(Wc,{control:I.control,name:"commission_amount",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Commission"}),e.jsx(Pc,{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(Wc,{control:I.control,name:"lead_source_id",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Lead Source"}),e.jsxs(Ys,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Pc,{children:e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select source"})})}),e.jsx(Ks,{children:b==null?void 0:b.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:q,disabled:!u.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsx(Wc,{control:I.control,name:"client_type_id",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Client Type"}),e.jsxs(Ys,{onValueChange:B.onChange,value:B.value||"",children:[e.jsx(Pc,{children:e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select client type"})})}),e.jsx(Ks,{children:_==null?void 0:_.map(V=>e.jsx(Mt,{value:V.id,children:V.name},V.id))})]})]})}),e.jsx(Wc,{control:I.control,name:"contact_id",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Client Contact"}),e.jsxs(Bo,{open:n,onOpenChange:a,children:[e.jsx($o,{asChild:!0,children:e.jsx(Pc,{children:e.jsxs(K,{variant:"outline",role:"combobox",className:Pt("w-full justify-between",!B.value&&"text-muted-foreground"),children:[U?`${U.first_name} ${U.last_name||""}`.trim():"Select contact",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})})}),e.jsxs(Do,{className:"w-full p-0",align:"start",children:[e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{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(Fx,{children:j==null?void 0:j.map(V=>e.jsxs(vp,{value:`${V.first_name} ${V.last_name||""}`,onSelect:()=>{B.onChange(V.id),a(!1)},children:[e.jsx(fa,{className:Pt("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:R,disabled:!o.trim()||w.isPending,children:"Add Contact"}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{c(!1),l("")},children:"Cancel"})]})]})]})]})]})}),e.jsx(Wc,{control:I.control,name:"notes",render:({field:B})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Notes"}),e.jsx(Pc,{children:e.jsx(Er,{placeholder:"Any notes about this transaction...",...B})})]})}),e.jsx(Wc,{control:I.control,name:"is_win",render:({field:B})=>e.jsxs(Ac,{className:"flex items-center justify-between rounded-lg border p-3",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(Ec,{children:"Mark as Win 🏆"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Highlight this as a notable success"})]}),e.jsx(Pc,{children:e.jsx($r,{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 iSe({transactions:t,showCommission:s,isLoading:r,agentNameMap:n,readOnly:a}){const[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(""),[f,g]=k.useState("all"),[b,_]=k.useState("all"),[j,w]=k.useState("all"),[N,C]=k.useState(!1),M=GLt(),I=bue(),{data:L}=tE(),{data:R}=Ux(),q=NE(),U=Y=>{const{id:J,created_at:te,updated_at:X,lead_source:ce,client_type:ne,contact:re,...le}=Y;I.mutate(le)},B=()=>{i&&(M.mutate(i),c(null))},V=t.filter(Y=>{var re,le,pe,xe;const J=u===""||Y.property_address.toLowerCase().includes(u.toLowerCase())||((le=(re=Y.contact)==null?void 0:re.first_name)==null?void 0:le.toLowerCase().includes(u.toLowerCase()))||((xe=(pe=Y.contact)==null?void 0:pe.last_name)==null?void 0:xe.toLowerCase().includes(u.toLowerCase())),te=f==="all"||Y.transaction_type===f,X=b==="all"||Y.lead_source_id===b,ce=j==="all"||Y.client_type_id===j,ne=!N||Y.is_win;return J&&te&&X&&ce&&ne});return r?e.jsx(Pe,{children:e.jsx(Re,{className:"p-6 space-y-4",children:[1,2,3].map(Y=>e.jsx(vs,{className:"h-16 w-full"},Y))})}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(zt,{children:["Transactions (",V.length,")"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx(hn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search...",value:u,onChange:Y=>p(Y.target.value),className:"pl-8 w-[150px]"})]}),e.jsxs(Ys,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-[100px]",children:e.jsx(Qs,{placeholder:"Type"})}),e.jsxs(Ks,{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(Ys,{value:b,onValueChange:_,children:[e.jsx(Gs,{className:"w-[130px]",children:e.jsx(Qs,{placeholder:"Lead Source"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Sources"}),L==null?void 0:L.map(Y=>e.jsx(Mt,{value:Y.id,children:Y.name},Y.id))]})]}),e.jsxs(K,{variant:N?"default":"outline",size:"sm",onClick:()=>C(!N),children:[e.jsx(bc,{className:"h-4 w-4 mr-1"}),"Wins"]})]})]})}),e.jsx(Re,{children:V.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No transactions found"}):q?e.jsx("div",{className:"space-y-3",children:V.map(Y=>e.jsxs(Pe,{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:Y.property_address}),Y.is_win&&e.jsx(bc,{className:"h-4 w-4 text-yellow-500 flex-shrink-0"})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]}),e.jsx(tt,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.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: "}),AAe(Y.close_date)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Price: "}),Gl(Y.sale_price)]}),s&&Y.commission_amount&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Commission: "}),Gl(Y.commission_amount)]}),Y.lead_source&&e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground",children:"Source: "}),Y.lead_source.name]}),Y.contact&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Client: "}),Y.contact.first_name," ",Y.contact.last_name]}),n&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Agent: "}),n[Y.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(Y),children:e.jsx(dd,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>U(Y),children:e.jsx(gi,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(Y.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})]},Y.id))}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[n&&e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Property"}),e.jsx(kt,{children:"Type"}),e.jsx(kt,{children:"Close Date"}),e.jsx(kt,{children:"Sale Price"}),s&&e.jsx(kt,{children:"Commission"}),e.jsx(kt,{children:"Lead Source"}),e.jsx(kt,{children:"Client"}),!a&&e.jsx(kt,{className:"w-[50px]"})]})}),e.jsx(On,{children:V.map(Y=>{var J;return e.jsxs(Ss,{children:[n&&e.jsx(dt,{className:"font-medium text-sm",children:n[Y.owner_user_id]||"Unknown"}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[Y.is_win&&e.jsx(bc,{className:"h-4 w-4 text-yellow-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:Y.property_address}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Y.city,Y.state?`, ${Y.state}`:""]})]})]})}),e.jsx(dt,{children:e.jsx(tt,{variant:Y.transaction_type==="buyer"?"default":"secondary",children:Y.transaction_type})}),e.jsx(dt,{children:AAe(Y.close_date)}),e.jsx(dt,{children:Gl(Y.sale_price)}),s&&e.jsx(dt,{children:Y.commission_amount?Gl(Y.commission_amount):"-"}),e.jsx(dt,{children:((J=Y.lead_source)==null?void 0:J.name)||"-"}),e.jsx(dt,{children:Y.contact?`${Y.contact.first_name} ${Y.contact.last_name||""}`.trim():"-"}),!a&&e.jsx(dt,{children:e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",children:[e.jsxs(Ca,{onClick:()=>l(Y),children:[e.jsx(dd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsxs(Ca,{onClick:()=>U(Y),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Duplicate"]}),e.jsxs(Ca,{onClick:()=>c(Y.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},Y.id)})})]})})})]}),e.jsx($at,{open:!!o,onOpenChange:Y=>!Y&&l(null),transaction:o||void 0}),e.jsx(_c,{open:!!i,onOpenChange:Y=>!Y&&c(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Transaction?"}),e.jsx(Jl,{children:"This action cannot be undone. This will permanently delete this transaction."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:B,className:"bg-destructive text-destructive-foreground",children:"Delete"})]})]})})]})}function qat({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,b)=>{if(!b||b===0)return null;const _=Math.min(g/b*100,100),j=Math.max(b-g,0),w=l>0?j/l:0,N=o/12*100,C=_>=N?"ahead":_>=N*.8?"on-track":"behind";return{percent:_,remaining:j,pace:w,status:C}},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(tt,{className:"bg-green-500 text-white",children:[e.jsx(Ol,{className:"h-3 w-3 mr-1"}),"Ahead"]});case"on-track":return e.jsxs(tt,{variant:"secondary",children:[e.jsx(m0,{className:"h-3 w-3 mr-1"}),"On Track"]});case"behind":return e.jsxs(tt,{variant:"destructive",children:[e.jsx(cS,{className:"h-3 w-3 mr-1"}),"Behind"]});default:return null}};return!t.transactions_goal&&!t.volume_goal&&!t.gci_goal?null:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rm,{className:"h-5 w-5 text-primary"}),e.jsxs(zt,{children:[r," Goals Progress"]})]})}),e.jsx(Re,{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:[Gl(s.totalVolume,!0)," of ",Gl(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 ",Gl(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:[Gl(s.totalCommission,!0)," of ",Gl(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 ",Gl(p.pace,!0),"/month"]})]})]})})]})}const w_s={light:"",dark:".dark"},Uat=k.createContext(null);function Vat(){const t=k.useContext(Uat);if(!t)throw new Error("useChart must be used within a ");return t}const Hat=k.forwardRef(({id:t,className:s,children:r,config:n,...a},o)=>{const l=k.useId(),i=`chart-${t||l.replace(/:/g,"")}`;return e.jsx(Uat.Provider,{value:{config:n},children:e.jsxs("div",{"data-chart":i,ref:o,className:Pt("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(nT,{children:r})]})})});Hat.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(w_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},Wat=k.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},b)=>{const{config:_}=Vat(),j=k.useMemo(()=>{var L;if(a||!(s!=null&&s.length))return null;const[N]=s,C=`${g||N.dataKey||N.name||"value"}`,M=F_e(_,N,C),I=!g&&typeof l=="string"?((L=_[l])==null?void 0:L.label)||l:M==null?void 0:M.label;return i?e.jsx("div",{className:Pt("font-medium",c),children:i(I,s)}):I?e.jsx("div",{className:Pt("font-medium",c),children:I}):null},[l,i,s,a,c,_,g]);if(!t||!(s!=null&&s.length))return null;const w=s.length===1&&n!=="dot";return e.jsxs("div",{ref:b,className:Pt("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:[w?null:j,e.jsx("div",{className:"grid gap-1.5",children:s.map((N,C)=>{const M=`${f||N.name||N.dataKey||"value"}`,I=F_e(_,N,M),L=p||N.payload.fill||N.color;return e.jsx("div",{className:Pt("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&&(N==null?void 0:N.value)!==void 0&&N.name?u(N.value,N.name,N,C,N.payload):e.jsxs(e.Fragment,{children:[I!=null&&I.icon?e.jsx(I.icon,{}):!o&&e.jsx("div",{className:Pt("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":w&&n==="dashed"}),style:{"--color-bg":L,"--color-border":L}}),e.jsxs("div",{className:Pt("flex flex-1 justify-between leading-none",w?"items-end":"items-center"),children:[e.jsxs("div",{className:"grid gap-1.5",children:[w?j:null,e.jsx("span",{className:"text-muted-foreground",children:(I==null?void 0:I.label)||N.name})]}),N.value&&e.jsx("span",{className:"font-mono font-medium tabular-nums text-foreground",children:N.value.toLocaleString()})]})]})},N.dataKey)})})]})});Wat.displayName="ChartTooltip";const N_s=k.forwardRef(({className:t,hideIcon:s=!1,payload:r,verticalAlign:n="bottom",nameKey:a},o)=>{const{config:l}=Vat();return r!=null&&r.length?e.jsx("div",{ref:o,className:Pt("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=F_e(l,i,c);return e.jsxs("div",{className:Pt("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});N_s.displayName="ChartLegend";function F_e(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 Vz=["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 oSe({stats:t,year:s}){const r=t.transactionsByMonth.some(a=>a.count>0),n=t.leadSourceBreakdown.length>0;return!r&&!n?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{className:"overflow-hidden",children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Transactions by Month"})}),e.jsx(Re,{className:"overflow-hidden",children:e.jsx(Hat,{config:{count:{label:"Transactions",color:"hsl(var(--primary))"}},className:"h-[250px]",children:e.jsx(nT,{width:"100%",height:"100%",children:e.jsxs(xat,{data:t.transactionsByMonth,margin:{top:5,right:10,left:0,bottom:5},children:[e.jsx(Jnt,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(eC,{dataKey:"month",tick:{fontSize:11},className:"fill-muted-foreground",interval:0}),e.jsx(tC,{allowDecimals:!1,tick:{fontSize:12},className:"fill-muted-foreground",width:30}),e.jsx(up,{content:e.jsx(Wat,{})}),e.jsx(P1,{dataKey:"count",fill:"hsl(var(--primary))",radius:[4,4,0,0],name:"Transactions"})]})})})})]}),n&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{children:[e.jsx("div",{className:"h-[250px]",children:e.jsx(nT,{width:"100%",height:"100%",children:e.jsxs(gat,{children:[e.jsx(B0,{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(nR,{fill:Vz[o%Vz.length]},`cell-${o}`))}),e.jsx(up,{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:Vz[o%Vz.length]}}),e.jsx("span",{className:"text-muted-foreground",children:a.name})]},a.name))})]})]})]})}function k_s(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=xje(s,n,new Date);if(Mve(a))return ps(a,"yyyy-MM-dd")}catch{}try{const n=new Date(s);if(Mve(n))return ps(n,"yyyy-MM-dd")}catch{}return null}const S_s=["property_address","city","state","zip","transaction_type","close_date","sale_price","commission_amount","lead_source","client_type","is_win","notes"];function C_s({open:t,onOpenChange:s}){const[r,n]=k.useState([]),[a,o]=k.useState(!1),[l,i]=k.useState(0),{data:c}=tE(),{data:u}=Ux(),p=bue(),f=()=>{const N=S_s.join(","),C=["123 Main St","Dallas","TX","75001","buyer","2024-06-15","450000","13500","Referral","Past Client","yes","Great transaction!"].join(","),M=`${N} ${C}`,I=new Blob([M],{type:"text/csv"}),L=URL.createObjectURL(I),R=document.createElement("a");R.href=L,R.download="transaction-import-template.csv",R.click(),URL.revokeObjectURL(L)},g=N=>{const C=N.split(` `).filter(I=>I.trim());if(C.length<2)return[];const M=C[0].split(",").map(I=>I.trim().toLowerCase().replace(/['"]/g,""));return C.slice(1).map((I,L)=>{var re,le,pe,xe;const R=[];let q="",U=!1;for(const _e of I)_e==='"'?U=!U:_e===","&&!U?(R.push(q.trim()),q=""):q+=_e;R.push(q.trim());const B=_e=>{var we;const fe=M.indexOf(_e);return fe>=0?(we=R[fe])==null?void 0:we.replace(/^["']|["']$/g,"").trim():""},V=(re=B("transaction_type"))==null?void 0:re.toLowerCase(),Y=(le=B("sale_price"))==null?void 0:le.replace(/[$,]/g,""),J=(pe=B("commission_amount"))==null?void 0:pe.replace(/[$,]/g,""),te=(xe=B("is_win"))==null?void 0:xe.toLowerCase(),X=B("close_date"),ce=k_s(X);let ne;return B("property_address")?["buyer","seller"].includes(V)?ce?(!Y||isNaN(Number(Y)))&&(ne="Invalid sale price"):ne=`Invalid date format: "${X}" - 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(Y)||0,commission_amount:J?Number(J):null,lead_source_name:B("lead_source"),client_type_name:B("client_type"),is_win:["yes","true","1"].includes(te),notes:B("notes"),error:ne}})},b=N=>{var I;const C=(I=N.target.files)==null?void 0:I[0];if(!C)return;const M=new FileReader;M.onload=L=>{var U;const R=(U=L.target)==null?void 0:U.result,q=g(R);n(q)},M.readAsText(C)},_=async()=>{const N=r.filter(I=>!I.error);if(N.length===0){he.error("No valid transactions to import");return}o(!0),i(0);let C=0,M=0;for(let I=0;IU.name.toLowerCase()===L.lead_source_name.toLowerCase()),q=u==null?void 0:u.find(U=>U.name.toLowerCase()===L.client_type_name.toLowerCase());await p.mutateAsync({property_address:L.property_address,city:L.city||null,state:L.state||null,zip:L.zip||null,transaction_type:L.transaction_type,close_date:L.close_date,sale_price:L.sale_price,commission_amount:L.commission_amount,lead_source_id:(R==null?void 0:R.id)||null,client_type_id:(q==null?void 0:q.id)||null,contact_id:null,notes:L.notes||null,is_win:L.is_win}),C++}catch(R){M++,console.error("Failed to import transaction:",R)}i(Math.round((I+1)/N.length*100))}o(!1),C>0&&he.success(`Imported ${C} transaction${C>1?"s":""}`),M>0&&he.error(`Failed to import ${M} transaction${M>1?"s":""}`),n([]),s(!1)},j=r.filter(N=>!N.error).length,w=r.filter(N=>N.error).length;return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh]",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(Ci,{className:"h-4 w-4 mr-2"}),"Template"]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"csv-file",children:"Upload CSV File"}),e.jsx(ze,{id:"csv-file",type:"file",accept:".csv",onChange:b})]}),r.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(tt,{variant:"outline",children:[r.length," rows found"]}),j>0&&e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(fa,{className:"h-3 w-3 mr-1"}),j," valid"]}),w>0&&e.jsxs(tt,{variant:"destructive",children:[e.jsx(Nl,{className:"h-3 w-3 mr-1"}),w," errors"]})]}),e.jsx(Gi,{className:"h-[200px] border rounded-lg",children:e.jsxs("div",{className:"p-2 space-y-2",children:[r.slice(0,10).map((N,C)=>e.jsxs("div",{className:`p-2 rounded text-sm ${N.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:N.property_address||"(no address)"}),e.jsx(tt,{variant:N.transaction_type==="buyer"?"default":"secondary",children:N.transaction_type})]}),e.jsxs("div",{className:"text-muted-foreground",children:[N.close_date," • $",N.sale_price.toLocaleString()]}),N.error&&e.jsx(Mke,{variant:"destructive",className:"mt-1 py-1",children:e.jsx(Tke,{className:"text-xs",children:N.error})})]},C)),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:j===0||a,children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Import ",j," Transaction",j!==1?"s":""]})]})]})]})})}const M_s=hC({transactions_goal:UL().min(0).optional(),volume_goal:UL().min(0).optional(),gci_goal:UL().min(0).optional()});function T_s({open:t,onOpenChange:s,year:r,existingGoals:n}){const a=KLt(),{data:o}=_ue(),l=(o==null?void 0:o.show_commission)??!0,i=due({resolver:uue(M_s),defaultValues:{transactions_goal:void 0,volume_goal:void 0,gci_goal:void 0}});k.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(_s,{children:[e.jsxs(bs,{children:[r," Goals"]}),e.jsx(Wr,{children:"Set your annual targets to track your progress throughout the year."})]}),e.jsx(hue,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),className:"space-y-4",children:[e.jsx(Wc,{control:i.control,name:"transactions_goal",render:({field:u})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Transactions Goal"}),e.jsx(Pc,{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(bie,{children:"Total number of deals you want to close"}),e.jsx(km,{})]})}),e.jsx(Wc,{control:i.control,name:"volume_goal",render:({field:u})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"Volume Goal ($)"}),e.jsx(Pc,{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(bie,{children:"Total sales volume you want to achieve"}),e.jsx(km,{})]})}),l&&e.jsx(Wc,{control:i.control,name:"gci_goal",render:({field:u})=>e.jsxs(Ac,{children:[e.jsx(Ec,{children:"GCI Goal ($)"}),e.jsx(Pc,{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(bie,{children:"Gross commission income target"}),e.jsx(km,{})]})}),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 lSe({transactions:t,isLoading:s}){const r=k.useRef(null),n=k.useRef(null),a=k.useRef([]),o=k.useRef(null),{isAdmin:l}=Rs(),[i,c]=k.useState(""),[u,p]=k.useState(!0),[f,g]=k.useState(0),[b,_]=k.useState(!1),j=t.filter(N=>N.latitude!=null&&N.longitude!=null),w=t.filter(N=>N.latitude==null||N.longitude==null);return k.useEffect(()=>{(async()=>{p(!0);try{const{data:C}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();C!=null&&C.value&&c(C.value)}catch(C){console.error("Error fetching mapbox token:",C)}p(!1)})()},[]),k.useEffect(()=>{if(!i||w.length===0||b)return;(async()=>{var M;_(!0);let C=0;for(const I of w){const L=[I.property_address,I.city,I.state,I.zip].filter(Boolean).join(", ");if(L)try{const q=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(L)}.json?access_token=${i}&limit=1`)).json();if((M=q.features)!=null&&M[0]){const[U,B]=q.features[0].center;await H.from("scorecard_transactions").update({latitude:B,longitude:U}).eq("id",I.id),I.latitude=B,I.longitude=U,C++}}catch(R){console.error("Geocode error:",R)}}g(C),_(!1)})()},[i,t]),k.useEffect(()=>{if(!r.current||!i||n.current)return;xl.accessToken=i;const N=t.filter(I=>I.latitude!=null&&I.longitude!=null);let C=[-98.5795,39.8283],M=4;if(N.length>0){const I=N.reduce((R,q)=>R+q.longitude,0)/N.length,L=N.reduce((R,q)=>R+q.latitude,0)/N.length;C=[I,L],M=N.length===1?12:10}return n.current=new xl.Map({container:r.current,style:"mapbox://styles/mapbox/light-v11",zoom:M,center:C}),n.current.addControl(new xl.NavigationControl,"top-right"),()=>{var I;(I=n.current)==null||I.remove(),n.current=null}},[i]),k.useEffect(()=>{var C;if(!n.current||!i)return;a.current.forEach(M=>M.remove()),a.current=[],(C=o.current)==null||C.remove();const N=t.filter(M=>M.latitude!=null&&M.longitude!=null);if(N.forEach(M=>{var B;const I=M.transaction_type==="buyer",L=I?"#3B82F6":"#10B981",R=document.createElement("div");R.className="cursor-pointer",R.innerHTML=`
${I?'':''}
`;const q=new xl.Popup({offset:25,closeButton:!0}).setHTML(`
${M.property_address}
${M.city?`
${M.city}${M.state?", "+M.state:""} ${M.zip||""}
`:""}
${I?"Buyer":"Seller"} $${Number(M.sale_price).toLocaleString()}
Closed: ${Il(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 xl.Marker(R).setLngLat([M.longitude,M.latitude]).setPopup(q).addTo(n.current);a.current.push(U)}),N.length>1){const M=new xl.LngLatBounds;N.forEach(I=>M.extend([I.longitude,I.latitude])),n.current.fitBounds(M,{padding:60,maxZoom:13})}else N.length===1&&n.current.flyTo({center:[N[0].longitude,N[0].latitude],zoom:12})},[t,i,b]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Ba,{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:[j.length," of ",t.length," mapped",b&&" · Geocoding..."]})]}),e.jsx("div",{ref:r,className:"w-full h-[55vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[50vh] text-center gap-3",children:[e.jsx(Nl,{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 Gat=()=>{const{data:t}=Bx();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"})},A_s=t=>{const{data:s}=Bx(),{data:r}=Gat();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 E_s(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 P_s(t,s){return t?t.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2):s[0].toUpperCase()}function I_s({year:t}){var g;const{data:s,isLoading:r}=Gat(),{data:n,isLoading:a}=A_s(t),o=pr(),l=r||a,{aggregate:i,memberStats:c,topPerformer:u,agentNameMap:p,teamChartStats:f}=k.useMemo(()=>{if(!s||!n)return{aggregate:null,memberStats:[],topPerformer:null,agentNameMap:{},teamChartStats:null};const b=s.map(V=>E_s(V,n));b.sort((V,Y)=>Y.totalVolume-V.totalVolume);const _={};s.forEach(V=>{_[V.id]=V.name||V.email});const j=n.length,w=n.reduce((V,Y)=>V+Number(Y.sale_price),0),N=n.reduce((V,Y)=>V+(Number(Y.commission_amount)||0),0),C=n.filter(V=>V.transaction_type==="buyer").length,M=n.filter(V=>V.transaction_type==="seller").length,I={};n.forEach(V=>{var J;const Y=((J=V.lead_source)==null?void 0:J.name)||"Unknown";I[Y]=(I[Y]||0)+1});const L=Object.entries(I).sort((V,Y)=>Y[1]-V[1])[0],R={};n.forEach(V=>{const Y=Il(V.close_date).toLocaleString("default",{month:"short"});R[Y]=(R[Y]||0)+1});const U=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"].map(V=>({month:V,count:R[V]||0})),B=Object.entries(I).map(([V,Y])=>({name:V,count:Y})).sort((V,Y)=>Y.count-V.count);return{aggregate:{totalTxns:j,buyerCount:C,sellerCount:M,totalVolume:w,avgPrice:j>0?w/j:0,totalGCI:N,topSource:L?{name:L[0],count:L[1]}:null,memberCount:s.length},memberStats:b,topPerformer:b[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(b=>e.jsx(vs,{className:"h-24"},b))}),e.jsx(vs,{className:"h-64"})]}):!i||c.length===0?e.jsx(Pe,{className:"py-12",children:e.jsxs(Re,{className:"text-center space-y-2",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(wc,{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:Gl(i.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ol,{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:Gl(i.avgPrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(wc,{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:Gl(i.totalGCI,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bc,{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(Pe,{className:"border-primary/30 bg-primary/5",children:e.jsxs(Re,{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(xo,{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:Gl(u.totalVolume,!0)})]})]})}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Member Performance"})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Transactions"}),e.jsx(kt,{className:"text-center",children:"B / S"}),e.jsx(kt,{className:"text-right",children:"Volume"}),e.jsx(kt,{className:"text-right",children:"Avg Price"}),e.jsx(kt,{className:"text-right",children:"GCI"}),e.jsx(kt,{className:"text-right"})]})}),e.jsx(On,{children:c.map((b,_)=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative",children:[_===0&&b.totalTransactions>0&&e.jsx(xo,{className:"absolute -top-2 -right-2 h-3.5 w-3.5 text-amber-500"}),e.jsxs(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:b.member.avatar_url||void 0}),e.jsx(wn,{className:"text-xs",children:P_s(b.member.name,b.member.email)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:b.member.name||b.member.email}),b.member.name&&e.jsx("p",{className:"text-xs text-muted-foreground",children:b.member.email})]})]})}),e.jsx(dt,{className:"text-center font-semibold",children:b.totalTransactions}),e.jsxs(dt,{className:"text-center text-sm",children:[b.buyerCount," / ",b.sellerCount]}),e.jsx(dt,{className:"text-right font-medium",children:Gl(b.totalVolume,!0)}),e.jsx(dt,{className:"text-right text-sm",children:Gl(b.averagePrice,!0)}),e.jsx(dt,{className:"text-right font-medium",children:Gl(b.totalGCI,!0)}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>o(`/mission-control/scorecard/${b.member.id}`),children:e.jsx(qn,{className:"h-4 w-4"})})})]},b.member.id))})]})})})]}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"transactions",children:[e.jsx(Ch,{className:"h-4 w-4 mr-1"}),"All Transactions"]}),e.jsxs(us,{value:"charts",children:[e.jsx(Ro,{className:"h-4 w-4 mr-1"}),"Charts"]}),e.jsxs(us,{value:"map",children:[e.jsx(Ba,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ks,{value:"transactions",children:e.jsx(iSe,{transactions:n||[],showCommission:!0,isLoading:a,agentNameMap:p,readOnly:!0})}),e.jsx(ks,{value:"charts",children:f&&e.jsx(oSe,{stats:f,year:t})}),e.jsx(ks,{value:"map",children:e.jsx(lSe,{transactions:n||[],isLoading:a})})]})]})}const Kat=new Date().getFullYear(),QFe=Array.from({length:10},(t,s)=>Kat-s);function L_s(){var B;const[t,s]=k.useState(Kat),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[p,f]=k.useState("my"),{data:g}=Bx(),b=(g==null?void 0:g.role)==="team_leader",{data:_,isLoading:j}=jNe(t),{yearStats:w,lifetimeStats:N,showCommission:C}=oXe(t),{data:M,isLoading:I}=iXe(t),{data:L}=_ue(),R=ZLt(),q=()=>{if(!_||_.length===0)return;const V=["Property Address","City","State","Zip","Transaction Type","Close Date","Sale Price",...C?["Commission"]:[],"Lead Source","Client Type","Contact Name","Is Win","Notes"],Y=_.map(ne=>{var re,le;return[ne.property_address,ne.city||"",ne.state||"",ne.zip||"",ne.transaction_type,ne.close_date,ne.sale_price,...C?[ne.commission_amount||""]:[],((re=ne.lead_source)==null?void 0:re.name)||"",((le=ne.client_type)==null?void 0:le.name)||"",ne.contact?`${ne.contact.first_name} ${ne.contact.last_name||""}`.trim():"",ne.is_win?"Yes":"No",ne.notes||""]}),J=[V,...Y].map(ne=>ne.map(re=>`"${String(re).replace(/"/g,'""')}"`).join(",")).join(` `),te=new Blob([J],{type:"text/csv"}),X=URL.createObjectURL(te),ce=document.createElement("a");ce.href=X,ce.download=`transactions-${t}.csv`,ce.click(),URL.revokeObjectURL(X)},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"})]}),b&&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(mr,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),p==="team"&&b?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(Ys,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:QFe.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]})]}),e.jsx(I_s,{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(Ys,{value:String(t),onValueChange:V=>s(Number(V)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:QFe.map(V=>e.jsx(Mt,{value:String(V),children:V},V))})]}),e.jsx(K,{variant:"outline",size:"icon",onClick:()=>u(!c),children:e.jsx(Yo,{className:"h-4 w-4"})})]})]}),c&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-lg",children:"Settings"})}),e.jsx(Re,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(ye,{children:"Show Commission"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Display commission fields and include in stats"})]}),e.jsx($r,{checked:(L==null?void 0:L.show_commission)??!0,onCheckedChange:V=>R.mutate({show_commission:V})})]})})]}),U&&!j?e.jsx(Pe,{className:"py-12",children:e.jsxs(Re,{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(Ro,{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(oi,{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(Ci,{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(Rm,{className:"h-4 w-4 mr-2"}),"Set Goals"]}),e.jsxs(K,{variant:"outline",onClick:()=>o(!0),children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Import"]}),e.jsxs(K,{variant:"outline",onClick:q,disabled:U,children:[e.jsx(Ci,{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(Ci,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Transactions"})]}),e.jsx("p",{className:"text-2xl font-bold",children:w.totalTransactions}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[N.totalTransactions," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{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:[w.buyerCount,"/",w.sellerCount]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"B/S split"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(wc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Gl(w.totalVolume,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Gl(N.totalVolume,!0)," lifetime"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ol,{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:Gl(w.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bc,{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=w.topLeadSource)==null?void 0:B.name)||"-"}),w.topLeadSource&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[w.topLeadSource.count," deals"]})]})}),C&&e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(wc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"GCI"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Gl(w.totalCommission,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Gl(N.totalCommission,!0)," lifetime"]})]})}),C&&w.totalNetToAgent>0&&w.totalNetToAgent!==w.totalCommission&&e.jsx(Pe,{children:e.jsxs(Re,{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(wc,{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:Gl(w.totalNetToAgent,!0)}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Gl(N.totalNetToAgent,!0)," lifetime"]})]})})]}),M&&e.jsx(qat,{goals:M,stats:w,year:t,showCommission:C}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"transactions",children:"Transactions"}),e.jsx(us,{value:"charts",children:"Charts"}),e.jsxs(us,{value:"map",children:[e.jsx(Ba,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ks,{value:"transactions",children:e.jsx(iSe,{transactions:_||[],showCommission:C,isLoading:j})}),e.jsx(ks,{value:"charts",children:e.jsx(oSe,{stats:w,year:t})}),e.jsx(ks,{value:"map",children:e.jsx(lSe,{transactions:_||[],isLoading:j})})]})]})]})]}),e.jsx($at,{open:r,onOpenChange:n}),e.jsx(C_s,{open:a,onOpenChange:o}),e.jsx(T_s,{open:l,onOpenChange:i,year:t,existingGoals:M})]})}function Zat({open:t,onOpenChange:s,listingId:r,listingSlug:n,listingTitle:a}){const{user:o}=Rs(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(!1);k.useEffect(()=>{(async()=>{if(!(!t||!o)){u(!0);try{const{data:w,error:N}=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(N)throw N;if(w&&w.share_token)i(w);else if(w&&!w.share_token){const{data:C,error:M}=await H.from("listing_shares").update({share_type:"referral_link"}).eq("id",w.id).select("id, share_token, click_count, lead_count").single();if(M)throw M;i(C)}else{const{data:C,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(C)}}catch(w){console.error("Error creating share link:",w),he.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}`:"",b=async()=>{try{await navigator.clipboard.writeText(g),f(!0),he.success("Link copied to clipboard!"),setTimeout(()=>f(!1),2e3)}catch{he.error("Failed to copy link")}},_=j=>{const w=encodeURIComponent(g),N=encodeURIComponent(`Check out this listing: ${a}`);switch(j){case"email":window.open(`mailto:?subject=${N}&body=${w}`);break;case"text":window.open(`sms:?body=${N}%20${w}`);break;case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${w}`,"_blank");break}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(un,{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(ye,{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:b,disabled:c||!g,variant:p?"default":"outline",children:p?e.jsx(fa,{className:"h-4 w-4"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(dr,{className:"h-4 w-4 mr-2"}),"Email"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("text"),disabled:c,children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:()=>_("facebook"),disabled:c,children:[e.jsx(ku,{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(ye,{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(qn,{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(mr,{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 D_s={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},O_s={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},R_s={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function Hz({listing:t,onClick:s,onEdit:r,onDelete:n,showActions:a}){var j,w;const{user:o}=Rs(),{data:l}=eXe(t.id),i=JYe(),[c,u]=k.useState(!1),p=N=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(N),f=((j=t.photos)==null?void 0:j.find(N=>N.is_primary))||((w=t.photos)==null?void 0:w[0]),g=(o==null?void 0:o.id)===t.agent_id,b=async N=>{N.stopPropagation();try{const C=await i.mutateAsync(t.id);he.success(C.saved?"Listing saved!":"Listing removed from saved")}catch{he.error("Failed to save listing")}},_=N=>{if(N.stopPropagation(),o)u(!0);else{const C=`https://listings.relevelup.com/${t.slug||t.id}`;navigator.clipboard.writeText(C),he.success("Link copied to clipboard!")}};return e.jsxs(Pe,{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(x0,{className:"h-12 w-12"})}),e.jsx(tt,{className:`absolute top-2 left-2 ${D_s[t.status]} text-white border-0`,children:O_s[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:b,children:e.jsx(ii,{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(bd,{className:"h-4 w-4"}):e.jsx(un,{className:"h-4 w-4 text-amber-500"})})]})]}),e.jsx(Zat,{open:c,onOpenChange:u,listingId:t.id,listingSlug:t.slug||null,listingTitle:t.property_address||`${t.city}, ${t.state}`}),e.jsxs(Re,{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(tt,{variant:"outline",className:"text-xs",children:[e.jsx(mr,{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(Ba,{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(Np,{className:"h-4 w-4"}),t.bedrooms," bd"]}),t.bathrooms&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nh,{className:"h-4 w-4"}),t.bathrooms," ba"]}),t.square_footage&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(x0,{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(tt,{variant:"secondary",className:"text-xs",children:R_s[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(qn,{className:"h-3 w-3"}),t.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bd,{className:"h-3 w-3"}),t.share_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ii,{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:N=>{N.stopPropagation(),r()},children:[e.jsx(dd,{className:"h-4 w-4 mr-2"}),"Edit"]}),n&&e.jsx(K,{variant:"destructive",size:"sm",onClick:N=>{N.stopPropagation(),n()},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})]})}const F_s=[{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"}],z_s=[{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 B_s({filters:t,onFiltersChange:s,onClose:r}){const n=()=>{s({sortBy:"newest"})};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between pb-3",children:[e.jsx(zt,{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(Or,{className:"h-4 w-4"})})]})]}),e.jsxs(Re,{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(ye,{children:"Status"}),e.jsxs(Ys,{value:t.status||"all",onValueChange:a=>s({...t,status:a==="all"?void 0:a}),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"All statuses"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Statuses"}),F_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Type"}),e.jsxs(Ys,{value:t.propertyType||"all",onValueChange:a=>s({...t,propertyType:a==="all"?void 0:a}),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"All types"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Types"}),z_s.map(a=>e.jsx(Mt,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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(ye,{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(ye,{children:"Open to Referrals Only"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Show only listings accepting buyer referrals"})]}),e.jsx($r,{checked:t.openToReferrals||!1,onCheckedChange:a=>s({...t,openToReferrals:a||void 0})})]})]})]})}function $_s({leaderboard:t}){const s=n=>{switch(n){case 0:return e.jsx(xo,{className:"h-5 w-5 text-amber-500"});case 1:return e.jsx(a1,{className:"h-5 w-5 text-gray-400"});case 2:return e.jsx(bc,{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(tt,{variant:l===0?"default":"secondary",children:[o.count," ",a]})]},o.agentId))});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(xo,{className:"h-5 w-5 text-amber-500"}),"Community Badges"]})}),e.jsx(Re,{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(bd,{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(Sn,{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(a1,{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(xo,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Community Leaderboard"})}),e.jsx(Re,{children:e.jsxs(ja,{defaultValue:"sharers",children:[e.jsxs(ga,{className:"w-full",children:[e.jsxs(us,{value:"sharers",className:"flex-1",children:[e.jsx(bd,{className:"h-4 w-4 mr-2"}),"Top Sharers"]}),e.jsxs(us,{value:"listers",className:"flex-1",children:[e.jsx(Sn,{className:"h-4 w-4 mr-2"}),"Top Contributors"]})]}),e.jsx(ks,{value:"sharers",className:"mt-4",children:r(t==null?void 0:t.topSharers,"shares")}),e.jsx(ks,{value:"listers",className:"mt-4",children:r(t==null?void 0:t.topListers,"listings")})]})})]})]})}const JFe={coming_soon:"#F59E0B",active:"#10B981",price_improvement:"#8B5CF6",under_contract:"#3B82F6",sold:"#A855F7"},e7e={coming_soon:"Coming Soon",active:"Active",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"};function q_s(t){return t>=1e6?`$${(t/1e6).toFixed(1)}M`:`$${(t/1e3).toFixed(0)}K`}function U_s({listings:t,isLoading:s}){const r=pr(),n=k.useRef(null),a=k.useRef(null),o=k.useRef([]),{isAdmin:l}=Rs(),[i,c]=k.useState(""),[u,p]=k.useState(!0),[f,g]=k.useState(!1),b=t.filter(j=>j.latitude!=null&&j.longitude!=null),_=t.filter(j=>(j.latitude==null||j.longitude==null)&&(j.property_address||j.city));return k.useEffect(()=>{(async()=>{p(!0);try{const{data:w}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();w!=null&&w.value&&c(w.value)}catch(w){console.error("Error fetching mapbox token:",w)}p(!1)})()},[]),k.useEffect(()=>{if(!i||_.length===0||f)return;(async()=>{var w;g(!0);for(const N of _){const C=[N.property_address,N.city,N.state].filter(Boolean).join(", ");if(C)try{const I=await(await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(C)}.json?access_token=${i}&limit=1`)).json();if((w=I.features)!=null&&w[0]){const[L,R]=I.features[0].center;await H.from("listings").update({latitude:R,longitude:L}).eq("id",N.id),N.latitude=R,N.longitude=L}}catch(M){console.error("Geocode error:",M)}}g(!1)})()},[i,t]),k.useEffect(()=>{if(!n.current||!i||a.current)return;xl.accessToken=i;const j=t.filter(C=>C.latitude!=null&&C.longitude!=null);let w=[-98.5795,39.8283],N=4;if(j.length>0){const C=j.reduce((I,L)=>I+L.longitude,0)/j.length,M=j.reduce((I,L)=>I+L.latitude,0)/j.length;w=[C,M],N=j.length===1?12:10}return a.current=new xl.Map({container:n.current,style:"mapbox://styles/mapbox/light-v11",zoom:N,center:w}),a.current.addControl(new xl.NavigationControl,"top-right"),()=>{var C;(C=a.current)==null||C.remove(),a.current=null}},[i]),k.useEffect(()=>{if(!a.current||!i)return;o.current.forEach(w=>w.remove()),o.current=[];const j=t.filter(w=>w.latitude!=null&&w.longitude!=null);if(j.forEach(w=>{var R,q,U;const N=JFe[w.status]||"#10B981",C=((R=w.photos)==null?void 0:R.find(B=>B.is_primary))||((q=w.photos)==null?void 0:q[0]),M=document.createElement("div");M.className="cursor-pointer",M.innerHTML=`
`;const I=new xl.Popup({offset:25,closeButton:!0,maxWidth:"280px"}).setHTML(`
${C!=null&&C.photo_url?``:""}
${q_s(w.price)}
${w.property_address||""}
${w.city}, ${w.state}
${e7e[w.status]||w.status} ${w.bedrooms?`${w.bedrooms} bed`:""} ${w.bathrooms?`${w.bathrooms} bath`:""}
${(U=w.agent)!=null&&U.name?`
Listed by ${w.agent.name}
`:""}
Click to view details →
`),L=new xl.Marker(M).setLngLat([w.longitude,w.latitude]).setPopup(I).addTo(a.current);o.current.push(L)}),j.length>1){const w=new xl.LngLatBounds;j.forEach(N=>w.extend([N.longitude,N.latitude])),a.current.fitBounds(w,{padding:60,maxZoom:13})}else j.length===1&&a.current.flyTo({center:[j[0].longitude,j[0].latitude],zoom:12})},[t,i,f]),k.useEffect(()=>(window.__navigateToListing__=j=>{r(`/mission-control/listings/${j}`)},()=>{delete window.__navigateToListing__}),[r]),u||s?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Ba,{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(JFe).map(([j,w])=>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:w}}),e.jsx("span",{className:"text-xs",children:e7e[j]})]},j)),e.jsxs("span",{className:"text-muted-foreground ml-auto text-xs",children:[b.length," of ",t.length," mapped",f&&" · Geocoding..."]})]}),e.jsx("div",{ref:n,className:"w-full h-[60vh] rounded-lg shadow-lg border"})]}):e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center h-[60vh] text-center gap-3",children:[e.jsx(Nl,{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 V_s(){var B,V,Y,J,te,X,ce,ne;const t=pr(),{brokerageId:s}=Rs(),{data:r,isLoading:n}=KYe(),[a,o]=k.useState("feed"),[l,i]=k.useState(!1),[c,u]=k.useState(""),[p,f]=k.useState({sortBy:"newest"}),{data:g,isLoading:b}=ZYe({...p,city:c||p.city}),{data:_,isLoading:j}=ELt(),{data:w,isLoading:N}=YYe(),{data:C,isLoading:M}=DLt(),{data:I,isLoading:L}=FLt(),{data:R}=RLt(),q=QYe(),U=async re=>{if(confirm("Are you sure you want to delete this listing? This action cannot be undone."))try{await q.mutateAsync(re),he.success("Listing deleted successfully")}catch{he.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(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-primary/10 rounded-lg",children:e.jsx(Sn,{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(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-pink-500/10 rounded-lg",children:e.jsx(ii,{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(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-emerald-500/10 rounded-lg",children:e.jsx(G4,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(w==null?void 0:w.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"My Listings"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4 flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-sky-500/10 rounded-lg",children:e.jsx(mr,{className:"h-5 w-5 text-sky-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:(((B=C==null?void 0:C.sent)==null?void 0:B.length)||0)+(((V=C==null?void 0:C.received)==null?void 0:V.length)||0)}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Referrals"})]})]})})]}),e.jsxs(ja,{value:a,onValueChange:o,children:[e.jsxs(ga,{className:"w-full justify-start overflow-x-auto",children:[e.jsx(us,{value:"feed",children:"Community Feed"}),s&&e.jsx(us,{value:"brokerage",children:"Brokerage"}),e.jsx(us,{value:"my-listings",children:"My Listings"}),e.jsx(us,{value:"saved",children:"Saved"}),e.jsx(us,{value:"referrals",children:"Referrals"}),e.jsx(us,{value:"map",children:"Map"}),e.jsx(us,{value:"leaderboard",children:"Leaderboard"})]}),e.jsxs(ks,{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(hn,{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(Ys,{value:p.sortBy,onValueChange:re=>f({...p,sortBy:re}),children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Sort by"})}),e.jsxs(Ks,{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(Yg,{className:"h-4 w-4 mr-2"}),"Filters"]})]}),l&&e.jsx(B_s,{filters:p,onFiltersChange:f,onClose:()=>i(!1)}),b?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(6)].map((re,le)=>e.jsxs(Pe,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Re,{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"})]})]},le))}):(g==null?void 0:g.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Sn,{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(Hz,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.id))})]}),e.jsx(ks,{value:"my-listings",className:"space-y-4",children:N?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,le)=>e.jsxs(Pe,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Re,{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"})]})]},le))}):(w==null?void 0:w.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(G4,{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:w==null?void 0:w.map(re=>e.jsx(Hz,{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(ks,{value:"saved",className:"space-y-4",children:j?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,le)=>e.jsxs(Pe,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Re,{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"})]})]},le))}):(_==null?void 0:_.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(ii,{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(Hz,{listing:re.listing,onClick:()=>t(`/mission-control/listings/${re.listing.id}`)},re.id))})}),e.jsx(ks,{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(bd,{className:"h-4 w-4"}),"Referrals Sent (",((Y=C==null?void 0:C.sent)==null?void 0:Y.length)||0,")"]}),((J=C==null?void 0:C.sent)==null?void 0:J.length)===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center text-muted-foreground",children:"No referrals sent yet"})}):e.jsx("div",{className:"space-y-3",children:(te=C==null?void 0:C.sent)==null?void 0:te.map(re=>{var le,pe;return e.jsx(Pe,{children:e.jsx(Re,{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:((le=re.listing)==null?void 0:le.property_address)||((pe=re.listing)==null?void 0:pe.city)})]}),e.jsx(tt,{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(mr,{className:"h-4 w-4"}),"Referrals Received (",((X=C==null?void 0:C.received)==null?void 0:X.length)||0,")"]}),((ce=C==null?void 0:C.received)==null?void 0:ce.length)===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-8 text-center text-muted-foreground",children:"No referrals received yet"})}):e.jsx("div",{className:"space-y-3",children:(ne=C==null?void 0:C.received)==null?void 0:ne.map(re=>{var le;return e.jsx(Pe,{children:e.jsxs(Re,{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: ",(le=re.sender)==null?void 0:le.name]})]}),e.jsx(tt,{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(ks,{value:"brokerage",className:"space-y-4",children:L?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[...Array(3)].map((re,le)=>e.jsxs(Pe,{children:[e.jsx(vs,{className:"h-48 w-full"}),e.jsxs(Re,{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"})]})]},le))}):(I==null?void 0:I.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(G4,{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:I==null?void 0:I.map(re=>e.jsx(Hz,{listing:re,onClick:()=>t(`/mission-control/listings/${re.id}`)},re.id))})}),e.jsx(ks,{value:"map",children:e.jsx(U_s,{listings:g||[],isLoading:b})}),e.jsx(ks,{value:"leaderboard",children:e.jsx($_s,{leaderboard:R})})]})]})}):e.jsx(Ts,{title:"Listing Exchange",description:"Community-powered listing collaboration",children:e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(Sn,{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 yx(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 Vhe(){const t=li();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 Yat(){const t=li(),s=es();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 Hhe(){const t=li();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 Xat(){const t=li(),s=es();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 Qat(){const t=es();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 H_s(){const t=es();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 W_s(){const t=es();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 G_s(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 K_s(){const t=es();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 Z_s(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 Y_s(){const t=es();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 X_s(){const t=es();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 Q_s(){const t=li();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+(yx(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+(yx(c)||0)*u},0),ytdWonDeals:l.length,ytdWonGCI:l.reduce((i,c)=>i+(c.expected_commission||0),0),ytdWonNet:l.reduce((i,c)=>i+(yx(c)||0),0),projectedAnnualNet:l.reduce((i,c)=>i+(yx(c)||0),0)+n.reduce((i,c)=>{const u=(c.probability??50)/100;return i+(yx(c)||0)*u},0)}},enabled:!!t})}function J_s(t){const s=li();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 ews(){const t=es();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 tws(){const t=es();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 sws({listing:t}){const s=pr(),[r,n]=k.useState(""),[a,o]=k.useState(!1),{data:l,isLoading:i}=J_s(t.id),{data:c,isLoading:u}=Vhe(),{data:p,isLoading:f}=Hhe(),g=Yat(),b=ews(),_=tws(),j=Xat(),w=(p==null?void 0:p.filter(L=>!L.listing_id))||[],N=L=>{if(!(c!=null&&c.length))return null;switch(L){case"coming_soon":case"active":case"price_improvement":return c.find(R=>R.name==="Active");case"under_contract":return c.find(R=>R.name==="Under Contract");case"sold":return c.find(R=>R.is_won_stage);default:return c.find(R=>R.name==="Active")}},C=async()=>{o(!0);try{c!=null&&c.length||await g.mutateAsync();const L=N(t.status);await j.mutateAsync({deal_name:t.property_address?`${t.property_address}, ${t.city}`:`${t.city}, ${t.state}`,deal_type:"seller",stage_id:(L==null?void 0:L.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}),he.success("Deal created and linked to listing!")}catch(L){console.error("Failed to create deal:",L),he.error("Failed to create deal")}finally{o(!1)}},M=async()=>{if(!r){he.error("Please select a deal");return}try{await b.mutateAsync({dealId:r,listingId:t.id}),he.success("Listing linked to deal!"),n("")}catch{he.error("Failed to link listing")}},I=async()=>{if(l)try{await _.mutateAsync({dealId:l.id,listingId:t.id}),he.success("Listing unlinked from deal")}catch{he.error("Failed to unlink listing")}};return i||u?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(u0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsx(Re,{children:e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})})]}):l?e.jsxs(Pe,{className:"border-primary/20 bg-primary/5",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(cl,{className:"h-4 w-4 text-primary"}),"Linked to Pipeline"]})}),e.jsxs(Re,{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(tt,{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(fi,{className:"h-3 w-3 ml-1"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:I,disabled:_.isPending,children:_.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(uS,{className:"h-4 w-4"})})]})]})]}):e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"flex items-center gap-2 text-base",children:[e.jsx(u0,{className:"h-4 w-4"}),"Deal Pipeline"]})}),e.jsxs(Re,{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:C,disabled:a||j.isPending,className:"w-full",size:"sm",children:[a||j.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Create New Deal"]}),w.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(Ys,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"flex-1 text-sm",children:e.jsx(Qs,{placeholder:"Link to existing deal..."})}),e.jsx(Ks,{children:w.map(L=>e.jsx(Mt,{value:L.id,children:L.deal_name},L.id))})]}),e.jsx(K,{variant:"secondary",size:"icon",onClick:M,disabled:!r||b.isPending,children:b.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(cl,{className:"h-4 w-4"})})]})]})]})]})}const rws={active:"bg-emerald-500",coming_soon:"bg-sky-500",price_improvement:"bg-orange-500",under_contract:"bg-purple-500",sold:"bg-gray-500"},nws={active:"Active",coming_soon:"Coming Soon",price_improvement:"Price Improvement",under_contract:"Under Contract",sold:"Sold"},t7e={single_family:"Single Family",condo:"Condo",townhouse:"Townhouse",land:"Land",multi_family:"Multi-Family",luxury:"Luxury",commercial:"Commercial",other:"Other"};function aws(){var te,X,ce,ne,re,le,pe,xe,_e;const{listingId:t}=yo(),s=pr(),{user:r}=Rs(),{data:n,isLoading:a}=XYe(t||""),{data:o}=eXe(t||""),{data:l}=ILt(t||""),i=JYe(),c=PLt(),u=LLt(),p=QYe(),f=OLt(),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[C,M]=k.useState(null),[I,L]=k.useState({buyerName:"",buyerType:"",notes:""}),R=(r==null?void 0:r.id)===(n==null?void 0:n.agent_id),q=fe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(fe),U=async fe=>{const we=`https://listings.relevelup.com/${(n==null?void 0:n.slug)||(n==null?void 0:n.id)}`,Ie=`Check out this listing: ${(n==null?void 0:n.property_address)||(n==null?void 0:n.city)}`;u.mutate({listingId:n.id,shareType:fe});try{switch(fe){case"facebook":window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(we)}`,"_blank");break;case"copy":await navigator.clipboard.writeText(we),he.success("Link copied to clipboard!");break;case"text":window.open(`sms:?body=${encodeURIComponent(`${Ie} ${we}`)}`);break;case"email":window.open(`mailto:?subject=${encodeURIComponent(Ie)}&body=${encodeURIComponent(`Check out this listing: ${we}`)}`);break}}catch(Ne){console.error("Share error:",Ne),he.error("Failed to share")}},B=async()=>{try{await p.mutateAsync(n.id),he.success("Listing deleted"),s("/mission-control/listings")}catch{he.error("Failed to delete listing")}},V=async()=>{if(!I.buyerName.trim()){he.error("Please enter buyer name");return}try{await f.mutateAsync({listingId:n.id,listingAgentId:n.agent_id,buyerName:I.buyerName,buyerType:I.buyerType||void 0,notes:I.notes||void 0}),he.success("Referral sent successfully!"),j(!1),L({buyerName:"",buyerType:"",notes:""})}catch{he.error("Failed to send referral")}},Y=fe=>{var Me,$e;const we=(n==null?void 0:n.property_address)||`${n==null?void 0:n.city}, ${n==null?void 0:n.state}`,Ie=q((n==null?void 0:n.price)||0),Ne=n!=null&&n.bedrooms?`${n.bedrooms}BD`:"",Ae=n!=null&&n.bathrooms?`${n.bathrooms}BA`:"",Fe=n!=null&&n.square_footage?`${n.square_footage.toLocaleString()}SF`:"",Ce=[Ne,Ae,Fe].filter(Boolean).join(" | ");switch(fe){case"just_listed":return`🏡 JUST LISTED! ${we} ${Ie} ${Ce} ${(n==null?void 0:n.description)||"Schedule your showing today!"} #JustListed #RealEstate #HomeForSale #${(Me=n==null?void 0:n.city)==null?void 0:Me.replace(/\s/g,"")}`;case"price_improvement":return`📣 PRICE IMPROVEMENT! ${we} Now ${Ie}! ${Ce} Don't miss this opportunity! #PriceReduced #RealEstate #HomeForSale`;case"teaser":return`Looking for a ${t7e[(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! ${Ce} DM me for details! 📩 #ComingSoon #RealEstate #${($e=n==null?void 0:n.city)==null?void 0:$e.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(Pe,{children:e.jsxs(Re,{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 J=((te=n.photos)==null?void 0:te.find(fe=>fe.is_primary))||((X=n.photos)==null?void 0:X[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(ri,{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:()=>J&&M(J.photo_url),children:J?e.jsx("img",{src:J.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((fe,we)=>e.jsx("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted cursor-pointer",onClick:()=>M(fe.photo_url),children:e.jsx("img",{src:fe.photo_url,alt:`Photo ${we+2}`,className:"w-full h-full object-cover"})},fe.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(Pe,{children:e.jsxs(Re,{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(tt,{className:`${rws[n.status]} text-white border-0`,children:nws[n.status]}),n.is_featured&&e.jsxs(tt,{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(tt,{variant:"outline",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),"Open to Referrals"]})]}),e.jsx("h1",{className:"text-3xl font-bold text-primary mb-2",children:q(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(Ba,{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(ii,{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(e1,{className:"h-4 w-4"}):e.jsx(Pm,{className:"h-4 w-4"})}),!R&&e.jsxs(K,{variant:"outline",className:"border-amber-500 text-amber-600 hover:bg-amber-50",onClick:()=>N(!0),children:[e.jsx(un,{className:"h-4 w-4 mr-2"}),"Share & Earn Leads"]}),e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsxs(K,{variant:"outline",children:[e.jsx(bd,{className:"h-4 w-4 mr-2"}),"Share"]})}),e.jsxs(zd,{children:[e.jsxs(Ca,{onClick:()=>U("copy"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Link"]}),e.jsxs(Ca,{onClick:()=>U("facebook"),children:[e.jsx(ku,{className:"h-4 w-4 mr-2"}),"Facebook"]}),e.jsxs(Ca,{onClick:()=>U("text"),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text"]}),e.jsxs(Ca,{onClick:()=>U("email"),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Email"]})]})]}),R&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",onClick:()=>s(`/mission-control/listings/${n.id}/edit`),children:[e.jsx(dd,{className:"h-4 w-4 mr-2"}),"Edit"]}),e.jsx(K,{variant:"destructive",size:"icon",onClick:()=>b(!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(Np,{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(Nh,{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(x0,{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(cn,{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(tt,{variant:"secondary",children:[e.jsx(wa,{className:"h-3 w-3 mr-1"}),t7e[n.property_type]]}),n.lot_size&&e.jsxs(tt,{variant:"secondary",children:["Lot: ",n.lot_size]}),n.has_hoa&&e.jsx(tt,{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(an,{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(qn,{className:"h-4 w-4"}),n.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(bd,{className:"h-4 w-4"}),n.share_count," shares"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ii,{className:"h-4 w-4"}),n.save_count," saves"]})]})]})}),n.allow_sharing&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Share Content"})}),e.jsx(Re,{className:"space-y-4",children:["just_listed","price_improvement","teaser"].map(fe=>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:[fe.replace("_"," ")," Caption"]}),e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>{navigator.clipboard.writeText(Y(fe)),he.success("Caption copied!")},children:e.jsx(gi,{className:"h-3 w-3"})})]}),e.jsx("p",{className:"text-xs text-muted-foreground whitespace-pre-wrap",children:Y(fe)})]},fe))})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Listing Agent"})}),e.jsxs(Re,{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:((le=n.agent)==null?void 0:le.name)||"Unknown"}),((xe=(pe=n.agent)==null?void 0:pe.brokerage)==null?void 0:xe.name)&&e.jsx("p",{className:"text-sm text-muted-foreground",children:n.agent.brokerage.name})]})]}),!R&&e.jsx("div",{className:"space-y-2",children:((_e=n.agent)==null?void 0:_e.email)&&e.jsx(K,{variant:"outline",className:"w-full",asChild:!0,children:e.jsxs("a",{href:`mailto:${n.agent.email}`,children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Email Agent"]})})})]})]}),R&&e.jsx(sws,{listing:n}),!R&&n.open_to_referrals&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Send a Buyer"]})}),e.jsxs(Re,{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:()=>j(!0),children:"Send Referral"})]})]})]})]})]}),e.jsx(xs,{open:!!C,onOpenChange:()=>M(null),children:e.jsx(fs,{className:"max-w-4xl",children:e.jsx("img",{src:C||"",alt:"Full size",className:"w-full h-auto"})})}),e.jsx(xs,{open:g,onOpenChange:b,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Delete Listing"}),e.jsx(Wr,{children:"Are you sure you want to delete this listing? This action cannot be undone."})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:B,disabled:p.isPending,children:p.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(xs,{open:_,onOpenChange:j,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Buyer Name *"}),e.jsx(ze,{value:I.buyerName,onChange:fe=>L({...I,buyerName:fe.target.value}),placeholder:"Enter buyer's name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Buyer Type"}),e.jsxs(Ys,{value:I.buyerType,onValueChange:fe=>L({...I,buyerType:fe}),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select type"})}),e.jsxs(Ks,{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(ye,{children:"Notes"}),e.jsx(Er,{value:I.notes,onChange:fe=>L({...I,notes:fe.target.value}),placeholder:"Any additional information..."})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),e.jsx(K,{onClick:V,disabled:f.isPending,children:f.isPending?"Sending...":"Send Referral"})]})]})}),e.jsx(Zat,{open:w,onOpenChange:N,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 iws({photo:t,onRemove:s,onSetPrimary:r}){const{attributes:n,listeners:a,setNodeRef:o,transform:l,transition:i,isDragging:c}=Wke({id:t.id}),u={transform:GS.Transform.toString(l),transition:i};return e.jsxs("div",{ref:o,style:u,className:Pt("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(Ju,{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(Or,{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 ows({photos:t,uploading:s,onUpload:r,onRemove:n,onReorder:a,onSetPrimary:o}){const l=Fke(Ble(JO,{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(N=>N.id===p.id),b=i.findIndex(N=>N.id===f.id),_=[...i],[j]=_.splice(g,1);_.splice(b,0,j);const w=_.map((N,C)=>({...N,sort_order:C}));a(w)};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(Uke,{sensors:l,collisionDetection:zke,onDragEnd:c,children:e.jsx(Hke,{items:i.map(u=>u.id),strategy:eR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[i.map(u=>e.jsx(iws,{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(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{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 lws({selectedVideoId:t,onVideoSelect:s,listingId:r}){const n=pr(),{user:a}=Rs(),[o,l]=k.useState(!1),[i,c]=k.useState([]),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState({});k.useEffect(()=>{t&&a?j():g(null)},[t,a]);const j=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),w(B))},w=async B=>{try{const{data:V,error:Y}=await H.functions.invoke("bunny-upload",{body:{action:"asset-urls",videoId:B.bunny_video_id,isAgentVideo:!0}});!Y&&(V!=null&&V.thumbnailUrl)&&_(J=>({...J,[B.id]:{thumbnailUrl:V.thumbnailUrl}}))}catch(V){console.warn("Failed to get signed URL",V)}},N=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&&C(B)}catch(B){console.error("Error fetching videos:",B),he.error("Failed to load videos")}finally{p(!1)}}},C=async B=>{var V;try{const Y=B.map(ne=>ne.bunny_video_id),{data:J,error:te}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Y,isAgentVideo:!0}});if(te)throw te;const X=(J==null?void 0:J.assets)||{},ce={};for(const ne of B)(V=X[ne.bunny_video_id])!=null&&V.thumbnailUrl&&(ce[ne.id]={thumbnailUrl:X[ne.bunny_video_id].thumbnailUrl});_(ne=>({...ne,...ce}))}catch(Y){console.warn("Failed to bulk-fetch signed URLs",Y)}},M=()=>{l(!0),N()},I=B=>{s(B.id),g(B),l(!1),he.success("Video selected")},L=()=>{s(null),g(null)},R=()=>{const B=r?`/mission-control/listings/${r}/edit`:"/mission-control/listings/new";n(`/mission-control/video?returnUrl=${encodeURIComponent(B)}`)},q=B=>{if(!B)return"0:00";const V=Math.floor(B/60),Y=B%60;return`${V}:${Y.toString().padStart(2,"0")}`},U=B=>{var V;return((V=b[B.id])==null?void 0:V.thumbnailUrl)||B.thumbnail_url};return e.jsxs("div",{className:"space-y-3",children:[f?e.jsx(Pe,{className:"overflow-hidden",children:e.jsx(Re,{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(rl,{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:q(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:L,className:"text-destructive hover:text-destructive",children:e.jsx(Or,{className:"h-4 w-4"})})]})]})})}):e.jsx(Pe,{className:"border-dashed",children:e.jsx(Re,{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(TM,{className:"h-4 w-4"}),"Select from Library"]}),e.jsxs(K,{type:"button",variant:"outline",onClick:R,className:"gap-2",children:[e.jsx(kx,{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(_s,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(TM,{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(ws,{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:R,className:"gap-2",children:[e.jsx(kx,{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:()=>I(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(rl,{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:q(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:R,className:"gap-2",children:[e.jsx(kx,{className:"h-4 w-4"}),"Record New Video"]}),e.jsx(K,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"})]})]})})]})}const cws=[{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"}],dws=[{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 uws({id:t,url:s,index:r,onRemove:n}){const{attributes:a,listeners:o,setNodeRef:l,transform:i,transition:c,isDragging:u}=Wke({id:t}),p={transform:GS.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(Ju,{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(Or,{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 hws({photoUrls:t,pendingPhotos:s,onRemove:r,onReorder:n,uploading:a,onUpload:o}){const l=Fke(Ble(JO,{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),b=i.indexOf(f.id),_=[...t],j=[...s],[w]=_.splice(g,1),[N]=j.splice(g,1);_.splice(b,0,w),j.splice(b,0,N),n(_,j)};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(Uke,{sensors:l,collisionDetection:zke,onDragEnd:c,children:e.jsx(Hke,{items:i,strategy:eR,children:e.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-4",children:[t.map((u,p)=>e.jsx(uws,{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(ws,{className:"h-8 w-8 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{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 s7e(){const{listingId:t}=yo(),[s]=qc(),r=s.get("brokerage"),n=pr(),{user:a}=Rs(),o=!!t&&t!=="new",l=!!r&&!o,{data:i,isLoading:c}=XYe(o?t:""),u=NLt(),p=kLt(),f=SLt(),g=CLt(),b=MLt(),_=TLt(),j=ALt(),{data:w=[]}=mt({queryKey:["brokerage-agents",r],queryFn:async()=>{if(!r)return[];const{data:re,error:le}=await H.from("profiles").select("id, name, email").eq("brokerage_id",r).order("name");if(le)throw le;return re||[]},enabled:l}),[N,C]=k.useState(""),[M,I]=k.useState(!1),[L,R]=k.useState([]),[q,U]=k.useState([]),[B,V]=k.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});k.useEffect(()=>{var re,le,pe,xe,_e;i&&o&&V({property_address:i.property_address||"",city:i.city||"",state:i.state||"",neighborhood:i.neighborhood||"",price:((re=i.price)==null?void 0:re.toString())||"",property_type:i.property_type,status:i.status,bedrooms:((le=i.bedrooms)==null?void 0:le.toString())||"",bathrooms:((pe=i.bathrooms)==null?void 0:pe.toString())||"",square_footage:((xe=i.square_footage)==null?void 0:xe.toString())||"",lot_size:i.lot_size||"",year_built:((_e=i.year_built)==null?void 0:_e.toString())||"",has_hoa:i.has_hoa,description:i.description||"",agent_notes:i.agent_notes||"",agent_notes_public:i.agent_notes_public,mls_link:i.mls_link||"",video_link:i.video_link||"",video_id:i.video_id||null,allow_sharing:i.allow_sharing,open_to_referrals:i.open_to_referrals,open_to_social_promotion:i.open_to_social_promotion,share_with_brokerage:i.share_with_brokerage??!1,is_public:i.is_public})},[i,o]);const Y=re=>{if(!re)return;const le=Array.from(re);R(xe=>[...xe,...le]);const pe=le.map(xe=>URL.createObjectURL(xe));U(xe=>[...xe,...pe])},J=re=>{URL.revokeObjectURL(q[re]),R(le=>le.filter((pe,xe)=>xe!==re)),U(le=>le.filter((pe,xe)=>xe!==re))},te=async re=>{var le;if(!(!re||!i)){I(!0);try{for(const pe of Array.from(re)){const xe=pe.name.split(".").pop(),_e=`${a==null?void 0:a.id}/${i.id}/${Date.now()}.${xe}`,{error:fe}=await H.storage.from("listing-photos").upload(_e,pe);if(fe)throw fe;const{data:{publicUrl:we}}=H.storage.from("listing-photos").getPublicUrl(_e);await g.mutateAsync({listingId:i.id,photoUrl:we,isPrimary:!((le=i.photos)!=null&&le.length)})}he.success("Photos uploaded!")}catch(pe){console.error("Upload error:",pe),he.error("Failed to upload photos")}finally{I(!1)}}},X=async re=>{for(let le=0;le{if(i)try{await b.mutateAsync({photoId:re,listingId:i.id}),he.success("Photo removed")}catch{he.error("Failed to remove photo")}},ne=async re=>{if(re.preventDefault(),!B.city.trim()||!B.state.trim()||!B.price){he.error("Please fill in required fields (City, State, Price)");return}if(l&&!N){he.error("Please select an agent to assign this listing to");return}try{const le={property_address:B.property_address||null,city:B.city,state:B.state,neighborhood:B.neighborhood||null,price:Number(B.price),property_type:B.property_type,status:B.status,bedrooms:B.bedrooms?Number(B.bedrooms):null,bathrooms:B.bathrooms?Number(B.bathrooms):null,square_footage:B.square_footage?Number(B.square_footage):null,lot_size:B.lot_size||null,year_built:B.year_built?Number(B.year_built):null,has_hoa:B.has_hoa,description:B.description||null,agent_notes:B.agent_notes||null,agent_notes_public:B.agent_notes_public,mls_link:B.mls_link||null,video_link:B.video_link||null,video_id:B.video_id||null,allow_sharing:B.allow_sharing,open_to_referrals:B.open_to_referrals,open_to_social_promotion:B.open_to_social_promotion,share_with_brokerage:B.share_with_brokerage,is_public:B.is_public};if(o)await f.mutateAsync({id:t,...le}),he.success("Listing updated!"),n(`/mission-control/listings/${t}`);else{I(!0);let pe;if(l&&N?pe=await p.mutateAsync({agentId:N,...le}):pe=await u.mutateAsync(le),L.length>0)try{await X(pe.id),q.forEach(xe=>URL.revokeObjectURL(xe)),R([]),U([])}catch(xe){console.error("Photo upload error:",xe),he.error("Listing created but some photos failed to upload")}I(!1),he.success("Listing created!"),n(l?"/my-brokerage":`/mission-control/listings/${pe.id}`)}}catch(le){console.error("Save error:",le),he.error("Failed to save listing"),I(!1)}};return o&&c?e.jsx(Ts,{title:"Loading...",description:"",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(vs,{className:"h-10 w-32"}),e.jsx(vs,{className:"h-[600px] w-full"})]})}):e.jsx(Ts,{title:o?"Edit Listing":l?"Add Listing for Agent":"Add Listing",description:"",children:e.jsxs("form",{onSubmit:ne,className:"space-y-6",children:[e.jsxs(K,{type:"button",variant:"ghost",onClick:()=>n(l?"/my-brokerage":"/mission-control/listings"),children:[e.jsx(ri,{className:"h-4 w-4 mr-2"}),l?"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:[l&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Assign to Agent *"})}),e.jsxs(Re,{children:[e.jsxs(Ys,{value:N,onValueChange:C,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select an agent..."})}),e.jsx(Ks,{children:w.map(re=>e.jsx(Mt,{value:re.id,children:re.name||re.email},re.id))})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"This listing will appear on the selected agent's Listing Exchange."})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Property Details"})}),e.jsx(Re,{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(ye,{children:"Property Address"}),e.jsx(ze,{value:B.property_address,onChange:re=>V({...B,property_address:re.target.value}),placeholder:"123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"City *"}),e.jsx(ze,{value:B.city,onChange:re=>V({...B,city:re.target.value}),placeholder:"City",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"State *"}),e.jsx(ze,{value:B.state,onChange:re=>V({...B,state:re.target.value}),placeholder:"State",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Neighborhood"}),e.jsx(ze,{value:B.neighborhood,onChange:re=>V({...B,neighborhood:re.target.value}),placeholder:"Neighborhood"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Price *"}),e.jsx(ze,{type:"number",value:B.price,onChange:re=>V({...B,price:re.target.value}),placeholder:"500000",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Type"}),e.jsxs(Ys,{value:B.property_type,onValueChange:re=>V({...B,property_type:re}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:dws.map(re=>e.jsx(Mt,{value:re.value,children:re.label},re.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Status"}),e.jsxs(Ys,{value:B.status,onValueChange:re=>V({...B,status:re}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:cws.map(re=>e.jsx(Mt,{value:re.value,children:re.label},re.value))})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Property Specs (Optional)"})}),e.jsx(Re,{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(ye,{children:"Bedrooms"}),e.jsx(ze,{type:"number",value:B.bedrooms,onChange:re=>V({...B,bedrooms:re.target.value}),placeholder:"3"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Bathrooms"}),e.jsx(ze,{type:"number",step:"0.5",value:B.bathrooms,onChange:re=>V({...B,bathrooms:re.target.value}),placeholder:"2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Sq Ft"}),e.jsx(ze,{type:"number",value:B.square_footage,onChange:re=>V({...B,square_footage:re.target.value}),placeholder:"2000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Lot Size"}),e.jsx(ze,{value:B.lot_size,onChange:re=>V({...B,lot_size:re.target.value}),placeholder:"0.25 acres"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Year Built"}),e.jsx(ze,{type:"number",value:B.year_built,onChange:re=>V({...B,year_built:re.target.value}),placeholder:"2005"})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-6",children:[e.jsx($r,{checked:B.has_hoa,onCheckedChange:re=>V({...B,has_hoa:re})}),e.jsx(ye,{children:"Has HOA"})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Description & Links"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:B.description,onChange:re=>V({...B,description:re.target.value}),placeholder:"Tell the story of this property...",rows:4})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Agent Notes"}),e.jsx(Er,{value:B.agent_notes,onChange:re=>V({...B,agent_notes:re.target.value}),placeholder:"Notes for other agents...",rows:2}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{checked:B.agent_notes_public,onCheckedChange:re=>V({...B,agent_notes_public:re})}),e.jsx(ye,{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(ye,{children:"MLS Link"}),e.jsx(ze,{value:B.mls_link,onChange:re=>V({...B,mls_link:re.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Video Link"}),e.jsx(ze,{value:B.video_link,onChange:re=>V({...B,video_link:re.target.value}),placeholder:"YouTube or Vimeo URL"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Cn,{className:"h-5 w-5"}),"Property Video"]})}),e.jsx(Re,{children:e.jsx(lws,{selectedVideoId:B.video_id,onVideoSelect:re=>V({...B,video_id:re}),listingId:o?t:void 0})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Photos"})}),e.jsx(Re,{children:o&&(i!=null&&i.photos)?e.jsx(ows,{photos:i.photos,uploading:M,onUpload:re=>te(re),onRemove:re=>ce(re),onReorder:re=>{_.mutate({photos:re.map(le=>({id:le.id,sort_order:le.sort_order,is_primary:le.is_primary}))})},onSetPrimary:re=>{i&&j.mutate({photoId:re,listingId:i.id})}}):e.jsx(hws,{photoUrls:q,onRemove:J,onReorder:(re,le)=>{U(re),R(le)},pendingPhotos:L,uploading:M,onUpload:Y})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Sharing & Collaboration"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Allow Sharing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Other agents can share this listing"})]}),e.jsx($r,{checked:B.allow_sharing,onCheckedChange:re=>V({...B,allow_sharing:re})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Open to Referrals"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Accept buyer referrals"})]}),e.jsx($r,{checked:B.open_to_referrals,onCheckedChange:re=>V({...B,open_to_referrals:re})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Social Promotion"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can be promoted on social media"})]}),e.jsx($r,{checked:B.open_to_social_promotion,onCheckedChange:re=>V({...B,open_to_social_promotion:re})})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Share with Brokerage"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Visible to agents in your brokerage"})]}),e.jsx($r,{checked:B.share_with_brokerage,onCheckedChange:re=>V({...B,share_with_brokerage:re})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Make Public"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Publish on listings.relevelup.com to get leads"})]}),e.jsx($r,{checked:B.is_public,onCheckedChange:re=>V({...B,is_public:re})})]})]})]}),e.jsx(K,{type:"submit",className:"w-full",size:"lg",disabled:u.isPending||f.isPending,children:u.isPending||f.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Saving..."]}):o?"Update Listing":"Create Listing"})]})]})]})})}let ip=null;function mws(){if(ip)return ip;try{const t=document.createElement("canvas"),s=t.getContext("webgl2")||t.getContext("webgl");if(!s)return ip={canRunVirtualBg:!1,reason:"WebGL is not supported on this device"},ip;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 ip={canRunVirtualBg:!1,reason:"Your device uses a software renderer which may cause lag",renderer:n},ip;const i=performance;return i.memory&&i.memory.jsHeapSizeLimit<256*1024*1024?(ip={canRunVirtualBg:!1,reason:"Limited device memory detected",renderer:n},ip):navigator.hardwareConcurrency&&navigator.hardwareConcurrency<2?(ip={canRunVirtualBg:!1,reason:"Single-core device detected — virtual backgrounds may cause lag",renderer:n},ip):(ip={canRunVirtualBg:!0,renderer:n},ip)}catch{return ip={canRunVirtualBg:!0},ip}}const pws=[{type:"none",label:"Off"},{type:"blur",label:"Blur"}];function fws({value:t,onChange:s,isLoading:r=!1,disabled:n=!1,className:a}){const o=k.useRef(null),[l,i]=k.useState(!1),[c]=k.useState(()=>mws()),u=!c.canRunVirtualBg,{data:p=[],refetch:f}=mt({queryKey:["video-backgrounds"],queryFn:async()=>{const{data:{user:w}}=await H.auth.getUser();if(!w)return[];const{data:N,error:C}=await H.from("video_backgrounds").select("*").eq("is_active",!0).order("sort_order",{ascending:!0});return C?(console.error("Failed to load backgrounds:",C),[]):N||[]}}),g=p.map(w=>({type:"image",label:w.name,imageUrl:w.image_url,thumbnail:w.thumbnail_url||w.image_url})),b=[...pws,...g],_=w=>w.type!==t.type?!1:w.type==="image"?w.imageUrl===t.imageUrl:!0,j=async w=>{var C;const N=(C=w.target.files)==null?void 0:C[0];if(N){if(!N.type.startsWith("image/")){he.error("Please select an image file");return}if(N.size>5*1024*1024){he.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 I=N.name.split(".").pop()||"jpg",L=`${M.id}/${crypto.randomUUID()}.${I}`,{error:R}=await H.storage.from("video-backgrounds").upload(L,N,{contentType:N.type});if(R)throw R;const{data:q}=H.storage.from("video-backgrounds").getPublicUrl(L),U=q.publicUrl,{error:B}=await H.from("video_backgrounds").insert({name:N.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}),he.success("Background uploaded!")}catch(M){console.error("Upload error:",M),he.error("Failed to upload background")}finally{i(!1),o.current&&(o.current.value="")}}};return e.jsxs("div",{className:Pt("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(Gu,{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(ws,{className:"h-3 w-3 animate-spin"}),e.jsx("span",{children:"Loading…"})]}),b.map((w,N)=>{const C=_(w);return e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({type:w.type,imageUrl:w.imageUrl,blurRadius:15}),className:Pt("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",C?"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:[w.type==="none"&&e.jsx(WI,{className:"h-4 w-4 text-muted-foreground"}),w.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"})}),w.type==="image"&&w.thumbnail&&e.jsx("img",{src:w.thumbnail,alt:w.label,className:"w-full h-full object-cover"})]}),e.jsx("span",{className:"text-[10px] text-muted-foreground truncate max-w-14",children:w.label})]},`${w.type}-${w.imageUrl||N}`)}),e.jsxs("button",{type:"button",disabled:n||l,onClick:()=>{var w;return(w=o.current)==null?void 0:w.click()},className:Pt("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(ws,{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:j}),e.jsxs("button",{type:"button",disabled:n,onClick:()=>s({...t,mirror:!t.mirror}),className:Pt("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(rL,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Mirror"})]})]})]})}var _A=typeof self<"u"?self:{};function Jat(t,s){e:{for(var r=["CLOSURE_FLAGS"],n=_A,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 tit(t){_A.setTimeout(()=>{throw t},0)}var z_e,vws=Jat(610401301,!1),n7e=Jat(748402147,!0);function a7e(){var t=_A.navigator;return t&&(t=t.userAgent)?t:""}const i7e=_A.navigator;function Whe(t){return Whe[" "](t),t}z_e=i7e&&i7e.userAgentData||null,Whe[" "]=function(){};const sit={};let MI=null;function bws(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 rit(){if(!MI){MI={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),s=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){const n=t.concat(s[r].split(""));sit[r]=n;for(let a=0;a0)&&(a7e().indexOf("Trident")!=-1||a7e().indexOf("MSIE")!=-1))&&typeof btoa=="function";const o7e=/[-_.]/g,wws={"-":"+",_:"/",".":"="};function jws(t){return wws[t]||""}function ait(t){if(!nit)return bws(t);t=o7e.test(t)?t.replace(o7e,jws):t,t=atob(t);const s=new Uint8Array(t.length);for(let r=0;r=s||(r[t]=n+1,oit(t=Error(),"incident"),tit(t))}}function kE(){return typeof BigInt=="function"}var SE=typeof Symbol=="function"&&typeof Symbol()=="symbol";function q0(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 Sws=q0("jas",void 0,!0),l7e=q0(void 0,"0di"),lI=q0(void 0,"1oa"),Nf=q0(void 0,Symbol()),Cws=q0(void 0,"0ub"),Mws=q0(void 0,"0ubs"),$_e=q0(void 0,"0ubsb"),Tws=q0(void 0,"0actk"),NA=q0("m_m","Pa",!0),c7e=q0();const lit={Ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},cit=Object.defineProperties,Ma=SE?Sws:"Ga";var wC;const d7e=[];function fR(t,s){SE||Ma in t||cit(t,lit),t[Ma]|=s}function Eu(t,s){SE||Ma in t||cit(t,lit),t[Ma]=s}function xR(t){return fR(t,34),t}function tO(t){return fR(t,8192),t}Eu(d7e,7),wC=Object.freeze(d7e);var kA={};function Mf(t,s){return s===void 0?t.h!==rC&&!!(2&(0|t.v[Ma])):!!(2&s)&&t.h!==rC}const rC={};function uSe(t,s){if(t!=null){if(typeof t=="string")t=t?new j0(t,wA):sC();else if(t.constructor!==j0)if(cSe(t))t=t.length?new j0(new Uint8Array(t),wA):sC();else{if(!s)throw Error();t=void 0}}return t}class u7e{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 Aws=Object.freeze({});function dit(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"),h7e=Ghe(t=>typeof t=="string"),Pws=Ghe(t=>typeof t=="boolean"),Khe=typeof _A.BigInt=="function"&&typeof _A.BigInt(0)=="bigint";function kf(t){var s=t;if(h7e(s)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(s))throw Error(String(s))}else if(Ews(s)&&!Number.isSafeInteger(s))throw Error(String(s));return Khe?BigInt(t):t=Pws(t)?t?"1":"0":h7e(t)?t.trim()||"0":String(t)}var q_e=Ghe(t=>Khe?t>=Lws&&t<=Ows:t[0]==="-"?m7e(t,Iws):m7e(t,Dws));const Iws=Number.MIN_SAFE_INTEGER.toString(),Lws=Khe?BigInt(Number.MIN_SAFE_INTEGER):void 0,Dws=Number.MAX_SAFE_INTEGER.toString(),Ows=Khe?BigInt(Number.MAX_SAFE_INTEGER):void 0;function m7e(t,s){if(t.length>s.length)return!1;if(t.lengtha)return!1;if(n>>0;Kc=s,Xd=(t-s)/4294967296>>>0}function SA(t){if(t<0){p7e(-t);const[s,r]=pSe(Kc,Xd);Kc=s>>>0,Xd=r>>>0}else p7e(t)}function hSe(t){const s=Fws||(Fws=new DataView(new ArrayBuffer(8)));s.setFloat32(0,+t,!0),Xd=0,Kc=s.getUint32(0,!0)}function hit(t,s){const r=4294967296*s+(t>>>0);return Number.isSafeInteger(r)?r:sO(t,s)}function zws(t,s){return kf(kE()?BigInt.asUintN(64,(BigInt(s>>>0)<>>0)):sO(t,s))}function mit(t,s){return kE()?kf(BigInt.asIntN(64,(BigInt.asUintN(32,BigInt(s))<>>=0,(s>>>=0)<=2097151)var r=""+(4294967296*s+t);else kE()?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+f7e(r)+f7e(t));return r}function f7e(t){return t=String(t),"0000000".slice(t.length)+t}function mSe(t,s){if(2147483648&s)if(kE())t=""+(BigInt(0|s)<>>0));else{const[r,n]=pSe(t,s);t="-"+sO(r,n)}else t=sO(t,s);return t}function Zhe(t){if(t.length<16)SA(Number(t));else if(kE())t=BigInt(t),Kc=Number(t&BigInt(4294967295))>>>0,Xd=Number(t>>BigInt(32)&BigInt(4294967295));else{const s=+(t[0]==="-");Xd=Kc=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,Kc=1e6*Kc+o,Kc>=4294967296&&(Xd+=Math.trunc(Kc/4294967296),Xd>>>=0,Kc>>>=0)}if(s){const[n,a]=pSe(Kc,Xd);Kc=n,Xd=a}}}function pSe(t,s){return s=~s,t?t=1+~t:s+=1,[t,s]}function sy(t){return Array.prototype.slice.call(t)}const gR=typeof BigInt=="function"?BigInt.asIntN:void 0,Bws=typeof BigInt=="function"?BigInt.asUintN:void 0,nC=Number.isSafeInteger,Yhe=Number.isFinite,CA=Math.trunc,$ws=kf(0);function TI(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 l0(t){return t==null||typeof t=="number"?t:t==="NaN"||t==="Infinity"||t==="-Infinity"?Number(t):void 0}function rO(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 pit(t){return t==null||typeof t=="boolean"?t:typeof t=="number"?!!t:void 0}const qws=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function yR(t){switch(typeof t){case"bigint":return!0;case"number":return Yhe(t);case"string":return qws.test(t);default:return!1}}function ME(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Yhe(t)?0|t:void 0}function fit(t){if(t==null)return t;if(typeof t=="string"&&t)t=+t;else if(typeof t!="number")return;return Yhe(t)?t>>>0:void 0}function xit(t){const s=t.length;return(t[0]==="-"?s<20||s===20&&t<="-9223372036854775808":s<19||s===19&&t<="9223372036854775807")?t:(Zhe(t),mSe(Kc,Xd))}function fSe(t){if(t=CA(t),!nC(t)){SA(t);var s=Kc,r=Xd;(t=2147483648&r)&&(r=~r>>>0,(s=1+~s>>>0)==0&&(r=r+1>>>0)),t=typeof(s=hit(s,r))=="number"?t?-s:s:t?"-"+s:s}return t}function git(t){var s=CA(Number(t));return nC(s)?String(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),xit(t))}function yit(t){var s=CA(Number(t));return nC(s)?kf(s):((s=t.indexOf("."))!==-1&&(t=t.substring(0,s)),kE()?kf(gR(64,BigInt(t))):kf(xit(t)))}function vit(t){return nC(t)?t=kf(fSe(t)):(t=CA(t),nC(t)?t=String(t):(SA(t),t=mSe(Kc,Xd)),t=kf(t)),t}function Hce(t){const s=typeof t;return t==null?t:s==="bigint"?kf(gR(64,t)):yR(t)?s==="string"?yit(t):vit(t):void 0}function bit(t){if(typeof t!="string")throw Error();return t}function vR(t){if(t!=null&&typeof t!="string")throw Error();return t}function Ah(t){return t==null||typeof t=="string"?t:void 0}function xSe(t,s,r,n){return t!=null&&t[NA]===kA?t:Array.isArray(t)?((n=(r=0|t[Ma])|32&n|2&n)!==r&&Eu(t,n),new s(t)):(r?2&n?((t=s[l7e])||(xR((t=new s).v),t=s[l7e]=t),s=t):s=new s:s=void 0,s)}function Uws(t,s,r){if(s)e:{if(!yR(s=t))throw B_e("int64");switch(typeof s){case"string":s=yit(s);break e;case"bigint":s=kf(gR(64,s));break e;default:s=vit(s)}}else s=Hce(t);return(t=s)==null?r?$ws:void 0:t}const Vws={};let Hws=function(){try{return Whe(new class extends Map{constructor(){super()}}),!1}catch{return!0}}();class pye{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 Wws=Hws?(Object.setPrototypeOf(pye.prototype,Map.prototype),Object.defineProperties(pye.prototype,{size:{value:0,configurable:!0,enumerable:!0,writable:!0}}),pye):class extends Map{constructor(){super()}};function x7e(t){return t}function fye(t){if(2&t.J)throw Error("Cannot mutate an immutable Map")}var I1=class extends Wws{constructor(t,s,r=x7e,n=x7e){super(),this.J=0|t[Ma],this.K=s,this.S=r,this.fa=this.K?Gws:n;for(let a=0;a{t.call(s,a.get(n),n,a)}):super.forEach(t,s)}set(t,s){return fye(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 Gws(t,s,r,n,a,o){return t=xSe(t,n,r,o),a&&(t=ySe(t)),t}function Kws(t){return[t,this.get(t)]}let Zws;function g7e(){return Zws||(Zws=new I1(xR([]),void 0,void 0,void 0,Vws))}function Xhe(t){return Nf?t[Nf]:void 0}function Wce(t,s){for(const r in t)!isNaN(r)&&s(t,+r,t[r])}I1.prototype.toJSON=void 0;var U_e=class{};const Yws={Ka:!0};function Xws(t,s){s<100||jA(Mws,1)}function Qhe(t,s,r,n){const a=n!==void 0;n=!!n;var o,l=Nf;!a&&SE&&l&&(o=t[l])&&Wce(o,Xws),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={}))[_]=b}else l[g]=b}if(c)for(let b in c){if((i=c[b])==null||(i=r(i,n))==null)continue;let _;g=+b,p&&!Number.isNaN(g)&&(_=g+f){_[w]=sy(N)}),_.da=b.da,_}(t)),l}function Qws(t){return t[0]=nO(t[0]),t[1]=nO(t[1]),t}function nO(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return q_e(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var s=0|t[Ma];return t.length===0&&1&s?void 0:Qhe(t,s,nO)}if(t!=null&&t[NA]===kA)return _it(t);if(t instanceof j0){if((s=t.g)==null)t="";else if(typeof s=="string")t=s;else{if(nit){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 I1?t=t.size!==0?t.V(Qws):void 0:void 0}return t}let Jws,e2s;function _it(t){return Qhe(t=t.v,0|t[Ma],nO)}function _S(t,s){return wit(t,s[0],s[1])}function wit(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[Ma],n7e&&1&a)throw Error("rfarr");if(2048&a&&!(2&a)&&function(){if(n7e)throw Error("carr");jA(Tws,5)}(),256&a)throw Error("farr");if(64&a)return(a|n)!==a&&Eu(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 Eu(t,64|a|n),t}function t2s(t,s){if(typeof t!="object")return t;if(Array.isArray(t)){var r=0|t[Ma];return t.length===0&&1&r?void 0:y7e(t,r,s)}if(t!=null&&t[NA]===kA)return v7e(t);if(t instanceof I1){if(2&(s=t.J))return t;if(!t.size)return;if(r=xR(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 kl(t,s,r,n){EE(t),Tu(t=t.v,0|t[Ma],s,r,n)}function Tu(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[Ma]))>>14&1023||536870912)?n!=null&&(t[l+(a?0:-1)]={[r]:n}):t[o]=n),s)}function C4(){return Aws===void 0?2:4}function M4(t,s,r,n,a){let o=t.v,l=0|o[Ma];n=Mf(t,l)?1:n,a=!!a||n===3,n===2&&AE(t)&&(o=t.v,l=0|o[Ma]);let i=(t=bSe(o,s))===wC?7:0|t[Ma],c=_Se(i,l);var u=!(4&c);if(u){4&c&&(t=sy(t),i=0,c=jS(c,l),l=Tu(o,l,s,t));let p=0,f=0;for(;p{const i=xSe(l,r,!1,s);return o=i!==l&&i!=null,i}))!=null)return o&&!Mf(n)&&jC(t,s),n}function Zo(t,s,r,n){let a=t.v,o=0|a[Ma];if((s=Mit(a,o,s,r,n))==null)return s;if(o=0|a[Ma],!Mf(t,o)){const l=ySe(s);l!==s&&(AE(t)&&(a=t.v,o=0|a[Ma]),o=Tu(a,o,r,s=l,n),jC(a,o))}return s}function Tit(t,s,r,n,a,o,l,i){var c=Mf(t,r);o=c?1:o,l=!!l||o===3,c=i&&!c,(o===2||c)&&AE(t)&&(r=0|(s=t.v)[Ma]);var u=(t=bSe(s,a))===wC?7:0|t[Ma],p=_Se(u,r);if(i=!(4&p)){var f=t,g=r;const b=!!(2&p);b&&(g|=2);let _=!b,j=!0,w=0,N=0;for(;w32)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 MSe(t){let s=0,r=t.g;const n=r+10,a=t.h;for(;r>>0}function Kce(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],NS(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 s2s(t){return xw(t)}function NS(t,s){if(t.g=s,s>t.l)throw Error()}function Eit(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 Pit(t,s){if(s==0)return sC();var r=Eit(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):Rws?t.slice(r,s):new Uint8Array(t.subarray(r,s))),r.length==0?sC():new j0(r,wA)}var b7e=[];function Iit(t,s,r,n){if(Zce.length){const a=Zce.pop();return a.o(n),a.g.init(t,s,r,n),a}return new r2s(t,s,r,n)}function Lit(t){t.g.clear(),t.l=-1,t.h=-1,Zce.length<100&&Zce.push(t)}function Dit(t){var s=t.g;if(s.g==s.l)return!1;t.m=t.g.g;var r=P0(t.g);if(s=r>>>3,!((r&=7)>=0&&r<=5)||s<1)throw Error();return t.l=s,t.h=r,!0}function Eie(t){switch(t.h){case 0:t.h!=0?Eie(t):MSe(t.g);break;case 1:NS(t=t.g,t.g+8);break;case 2:if(t.h!=2)Eie(t);else{var s=P0(t.g);NS(t=t.g,t.g+s)}break;case 5:NS(t=t.g,t.g+4);break;case 3:for(s=t.l;;){if(!Dit(t))throw Error();if(t.h==4){if(t.l!=s)throw Error();break}Eie(t)}break;default:throw Error()}}function bR(t,s,r){const n=t.g.l;var a=P0(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 TSe(t){var s=P0(t.g),r=Eit(t=t.g,s);if(t=t.h,xws){var n,a=t;(n=mye)||(n=mye=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(Wz===void 0){try{n.decode(new Uint8Array([128]))}catch{}try{n.decode(new Uint8Array([97])),Wz=!0}catch{Wz=!1}}throw!Wz&&(mye=void 0),i}}else{s=(o=r)+s,r=[];let i,c=null;for(;o=s?B2():(i=t[o++],l<194||(192&i)!=128?(o--,B2()):r.push((31&l)<<6|63&i)):l<240?o>=s-1?B2():(i=t[o++],(192&i)!=128||l===224&&i<160||l===237&&i>=160||(192&(n=t[o++]))!=128?(o--,B2()):r.push((15&l)<<12|(63&i)<<6|63&n)):l<=244?o>=s-2?B2():(i=t[o++],(192&i)!=128||i-144+(l<<28)>>30||(192&(n=t[o++]))!=128||(192&(a=t[o++]))!=128?(o--,B2()):(l=(7&l)<<18|(63&i)<<12|(63&n)<<6|63&a,l-=65536,r.push(55296+(l>>10&1023),56320+(1023&l)))):B2(),r.length>=8192&&(c=r7e(c,r),r.length=0)}o=r7e(c,r)}return o}function Oit(t){const s=P0(t.g);return Pit(t.g,s)}function eme(t,s,r){var n=P0(t.g);for(n=t.g.g+n;t.g.g>>0,this.g=s>>>0}};let n2s;function w7e(t){return t?/^-?\d+$/.test(t)?(Zhe(t),new H_e(Kc,Xd)):null:a2s||(a2s=new H_e(0,0))}var H_e=class{constructor(t,s){this.h=t>>>0,this.g=s>>>0}};let a2s;function oT(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 IE(t,s){for(;s>127;)t.g.push(127&s|128),s>>>=7;t.g.push(s)}function tme(t,s){if(s>=0)IE(t,s);else{for(let r=0;r<9;r++)t.g.push(127&s|128),s>>=7;t.g.push(1)}}function ASe(t){var s=Kc;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 MA(t,s){s.length!==0&&(t.l.push(s),t.h+=s.length)}function Wx(t,s,r){IE(t.g,8*s+r)}function ESe(t,s){return Wx(t,s,2),s=t.g.end(),MA(t,s),s.push(t.h),s}function PSe(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 sme(t,s,r){Wx(t,s,2),IE(t.g,r.length),MA(t,t.g.end()),MA(t,r)}function Yce(t,s,r,n){r!=null&&(s=ESe(t,s),n(r,t),PSe(t,s))}function U0(){const t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var ISe=U0(),Rit=U0(),LSe=U0(),DSe=U0(),OSe=U0(),Fit=U0(),i2s=U0(),rme=U0(),zit=U0(),Bit=U0();function V0(t,s,r){var n=t.v;Nf&&Nf in n&&(n=n[Nf])&&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 Ta=class{constructor(t,s){this.v=wit(t,s,void 0,2048)}toJSON(){return _it(this)}j(){var a;var t=$2s,s=this.v,r=t.g,n=Nf;if(SE&&n&&((a=s[n])==null?void 0:a[r])!=null&&jA(Cws,3),s=t.g,c7e&&Nf&&c7e===void 0&&(n=(r=this.v)[Nf])&&(n=n.da))try{n(r,s,Yws)}catch(o){tit(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[Ma];return vSe(this,t,s)?gSe(this,t,!0):new this.constructor(TE(t,s,!1))}};Ta.prototype[NA]=kA,Ta.prototype.toString=function(){return this.v.toString()};var LE=class{constructor(t,s,r){this.g=t,this.h=s,t=ISe,this.l=!!t&&r===t||!1}};function nme(t,s){return new LE(t,s,ISe)}function $it(t,s,r,n,a){Yce(t,r,Hit(s,n),a)}const o2s=nme(function(t,s,r,n,a){return t.h===2&&(bR(t,NSe(s,n,r),a),!0)},$it),l2s=nme(function(t,s,r,n,a){return t.h===2&&(bR(t,NSe(s,n,r),a),!0)},$it);var ame=Symbol(),ime=Symbol(),W_e=Symbol(),j7e=Symbol(),N7e=Symbol();let qit,Uit;function NC(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 Jws||(Jws=[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,qit??(qit=o),Uit??(Uit=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 FSe(t,s,r,n,a){const o=r.g;let l,i;t[s]=(c,u,p)=>o(c,u,p,i||(i=NC(ime,RSe,FSe,n).T),l||(l=zSe(n)),a)}function zSe(t){let s=t[W_e];if(s!=null)return s;const r=NC(ime,RSe,FSe,t);return s=r.ma?(n,a)=>qit(n,a,r):(n,a)=>{for(;Dit(a)&&a.h!=4;){var o=a.l,l=r[o];if(l==null){var i=r.ba;i&&(i=i[o])&&(i=d2s(i))!=null&&(l=r[o]=i)}if(l==null||!l(a,n,o)){if(l=(i=a).m,Eie(i),i.ha)var c=void 0;else c=i.g.g-l,i.g.g=l,c=Pit(i.g,c);l=void 0,i=n,c&&((l=i[Nf]??(i[Nf]=new U_e))[o]??(l[o]=[])).push(c)}}return(n=Xhe(n))&&(n.da=r.qa[N7e]),!0},t[W_e]=s,t[N7e]=c2s.bind(t),s}function c2s(t,s,r,n){var a=this[ime];const o=this[W_e],l=_S(void 0,a.T),i=Xhe(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 b of g){p=Iit(b);try{c=!0,o(l,p)}finally{Lit(p)}}else n==null||n(t,f,g)},s==null)Wce(i,a);else if(i!=null){const p=i[s];p&&a(i,s,p)}if(c){let p=0|t[Ma];if(2&p&&2048&p&&!(r!=null&&r.Ka))throw Error();const f=CE(p),g=(b,_)=>{if(L1(t,b,f)!=null){if((r==null?void 0:r.Qa)===1)return;throw Error()}_!=null&&(p=Tu(t,p,b,_,f)),delete i[b]};s==null?dit(l,0|l[Ma],(b,_)=>{g(b,_)}):g(s,L1(l,s,f))}}}}function d2s(t){const s=(t=Vit(t))[0].g;if(t=t[1]){const r=zSe(t),n=NC(ime,RSe,FSe,t).T;return(a,o,l)=>s(a,o,l,n,r)}return s}function ome(t,s,r){t[s]=r.h}function lme(t,s,r,n){let a,o;const l=r.h;t[s]=(i,c,u)=>l(i,c,u,o||(o=NC(ame,ome,lme,n).T),a||(a=Wit(n)))}function Wit(t){let s=t[j7e];if(!s){const r=NC(ame,ome,lme,t);s=(n,a)=>Git(n,a,r),t[j7e]=s}return s}function Git(t,s,r){dit(t,0|t[Ma],(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=Vit(c))[0].h;if(c=c[1]){const p=Wit(c),f=NC(ame,ome,lme,c).T;c=l.ma?Uit(f,p):(g,b,_)=>u(g,b,_,f,p)}else c=u;return l[i]=c}}(r,n);o?o(s,a,n):n<500||jA($_e,3)}}),(t=Xhe(t))&&Wce(t,(n,a,o)=>{for(MA(s,s.g.end()),n=0;n{Yce(t,r,_S([l,o],n),a)});else if(Array.isArray(s)){for(let o=0;o>BigInt(32))),oT(t.g,r.h,r.g);break;default:r=w7e(s),oT(t.g,r.h,r.g)}}function Yit(t,s,r){(s=ME(s))!=null&&s!=null&&(Wx(t,r,0),tme(t.g,s))}function Xit(t,s,r){(s=pit(s))!=null&&(Wx(t,r,0),t.g.g.push(s?1:0))}function Qit(t,s,r){(s=Ah(s))!=null&&sme(t,r,eit(s))}function Jit(t,s,r,n,a){Yce(t,r,Hit(s,n),a)}function eot(t,s,r){(s=s==null||typeof s=="string"||s instanceof j0?s:void 0)!=null&&sme(t,r,SSe(s,!0).buffer)}function tot(t,s,r){(s=fit(s))!=null&&s!=null&&(Wx(t,r,0),IE(t.g,s))}function sot(t,s,r){return(t.h===5||t.h===2)&&(s=PE(s,0|s[Ma],r),t.h==2?eme(t,Kce,s):s.push(Kce(t.g)),!0)}var eu=sm(function(t,s,r){return t.h===5&&(rm(s,r,Kce(t.g)),!0)},Kit,rme),m2s=OE(sot,function(t,s,r){if((s=DE(l0,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"))||(Zhe(n),n=sO(Kc,Xd))),n;if(a==="number")return(n=CA(n))>=0&&nC(n)||(SA(n),n=hit(Kc,Xd)),n}}(s),s!=null&&(typeof s=="string"&&_7e(s),s!=null))switch(Wx(t,r,0),typeof s){case"number":t=t.g,SA(s),oT(t,Kc,Xd);break;case"bigint":r=BigInt.asUintN(64,s),r=new V_e(Number(r&BigInt(4294967295)),Number(r>>BigInt(32))),oT(t.g,r.h,r.g);break;default:r=_7e(s),oT(t.g,r.h,r.g)}},i2s),ju=sm(function(t,s,r){return t.h===0&&(rm(s,r,xw(t.g)),!0)},Yit,DSe),_R=OE(function(t,s,r){return(t.h===0||t.h===2)&&(s=PE(s,0|s[Ma],r),t.h==2?eme(t,xw,s):s.push(xw(t.g)),!0)},function(t,s,r){if((s=DE(ME,s))!=null&&s.length){r=ESe(t,r);for(let n=0;n{{const o={ea:!0};n&&Object.assign(o,n),r=Iit(r,void 0,void 0,o);try{const l=new t,i=l.v;zSe(s)(i,r);var a=l}finally{Lit(r)}}return a}}function cme(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}}}};Git(this.v,s,NC(ame,ome,lme,t)),MA(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=C7e.createPolicy("goog#html",{createHTML:n,createScript:n,createScriptURL:n})}catch{}return r}()),t=(s=yye)?s.createScriptURL(t):t,new class{constructor(r){this.g=r}toString(){return this.g+""}}(t)}function Gz(t,...s){if(s.length===0)return M7e(t[0]);let r=t[0];for(let n=0;n({index:wx(n,1)??0??-1,score:Ed(n,2)??0,categoryName:Ah(Xc(n,3))??""??"",displayName:Ah(Xc(n,4))??""??""})),headIndex:s,headName:r}}function H2s(t){const s={classifications:D1(t,S2s,1).map(r=>{var n;return KSe(((n=Zo(r,uot,4))==null?void 0:n.g())??[],wx(r,2)??0,Ah(Xc(r,3))??"")})};return function(r){return r==null?r:typeof r=="bigint"?(q_e(r)?r=Number(r):(r=gR(64,r),r=q_e(r)?Number(r):String(r)),r):yR(r)?typeof r=="number"?fSe(r):git(r):void 0}(Xc(t,2,void 0,void 0,Hce))!=null&&(s.timestampMs=Fot(Xc(t,2,void 0,void 0,Hce)??jit)),s}function zot(t){var l,i;var s=M4(t,3,l0,C4()),r=M4(t,2,ME,C4()),n=M4(t,1,Ah,C4()),a=M4(t,9,Ah,C4());const o={categories:[],keypoints:[]};for(let c=0;cs>127?s-256:s)}function B7e(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 $7e(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 qot(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 La(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 q7e(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]=qot(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 U7e(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 By(t,s,r){t.i.simpleListeners=t.i.simpleListeners||{},t.i.simpleListeners[s]=r}function Ob(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)}}B5.forVisionTasks=function(t,s=!1){return Zz("vision",t??Gz``,s)},B5.forTextTasks=function(t,s=!1){return Zz("text",t??Gz``,s)},B5.forGenAiTasks=function(t,s=!1){return Zz("genai",t??Gz``,s)},B5.forAudioTasks=function(t,s=!1){return Zz("audio",t??Gz``,s)},B5.isSimdSupported=function(t=!1){return Bot(t)};async function G2s(t,s,r,n){return t=await(async(a,o,l,i,c)=>{if(o&&await $7e(o),!self.ModuleFactory||l&&(await $7e(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 _ye(t,s){const r=Zo(t.baseOptions,Xce,1)||new Xce;typeof s=="string"?(kl(r,2,vR(s)),kl(r,1)):s instanceof Uint8Array&&(kl(r,1,uSe(s,!1)),kl(r,2)),ai(t.baseOptions,0,1,r)}function V7e(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 ia(t,s){t.C=Math.max(t.C,s)}function mme(t,s){t.B=new Lp,Tf(t.B,2,"PassThroughCalculator"),Bc(t.B,"free_memory"),Io(t.B,"free_memory_unused_out"),td(s,"free_memory"),Gx(s,t.B)}function TA(t,s){Bc(t.B,s),Io(t.B,s+"_unused_out")}function pme(t){t.g.addBoolToStream(!0,"free_memory",t.C)}var X_e=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=Zo(this.baseOptions,Xce,1))!=null&&a.g()||(o=Zo(this.baseOptions,Xce,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=Zo(u.baseOptions,D7e,3);if(!f){var g=f=new D7e,b=new T7e;y8(g,4,Pie,b)}"delegate"in p&&(p.delegate==="GPU"?(p=f,g=new v2s,y8(p,2,Pie,g)):(p=f,g=new T7e,y8(p,4,Pie,g))),ai(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),_ye(this,"/model.dat"),this.m(),this.L()});if(c.modelAssetBuffer instanceof Uint8Array)_ye(this,c.modelAssetBuffer);else if(c.modelAssetBuffer)return async function(u){const p=[];for(var f=0;;){const{done:g,value:b}=await u.read();if(g)break;p.push(b),f+=b.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=>{_ye(this,u),this.m(),this.L()})}return this.m(),this.L(),Promise.resolve()}L(){}ca(){let t;if(this.g.ca(s=>{t=b2s(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,V7e(this)}finishProcessing(){this.g.finishProcessing(),V7e(this)}close(){this.B=void 0,this.g.closeGraph()}};function tw(t,s){if(!t)throw Error(`Unable to obtain required WebGL resource: ${s}`);return t}X_e.prototype.close=X_e.prototype.close;class K2s{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 H7e(t,s,r){const n=t.g;if(r=tw(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 W7e(t,s){const r=t.g,n=tw(r.createVertexArray(),"Failed to create vertex array");r.bindVertexArray(n);const a=tw(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=tw(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 K2s(r,n,a,o)}function ZSe(t,s){if(t.g){if(s!==t.g)throw Error("Cannot change GL context once initialized")}else t.g=s}function Z2s(t,s,r,n){return ZSe(t,s),t.h||(t.m(),t.D()),r?(t.u||(t.u=W7e(t,!0)),r=t.u):(t.A||(t.A=W7e(t,!1)),r=t.A),s.useProgram(t.h),r.bind(),t.l(),t=n(),r.g.bindVertexArray(null),t}function Uot(t,s,r){return ZSe(t,s),t=tw(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 Vot(t,s,r){ZSe(t,s),t.B||(t.B=tw(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 Y2s(t){var s;(s=t.g)==null||s.bindFramebuffer(t.g.FRAMEBUFFER,null)}var Hot=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=tw(t.createProgram(),"Failed to create WebGL program"),this.X=H7e(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=H7e(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 Uv(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 Q_e(t){var s=Uv(t,1);if(!s){if(s=Uv(t,0))s=new Float32Array(s).map(n=>n/255);else{s=new Float32Array(t.width*t.height);const n=AA(t);var r=YSe(t);if(Vot(r,n,Wot(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 Q_e(this)}N(){return Wot(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=AA(this),a=YSe(this);n.activeTexture(n.TEXTURE1),r=Uot(a,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);const o=Got(this);n.texImage2D(n.TEXTURE_2D,0,o,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Vot(a,n,r),Z2s(a,n,!1,()=>{Kot(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),J_e(this)}),Y2s(a),J_e(this)}}t.push(r)}return new qu(t,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&AA(this).deleteTexture(Uv(this,2)),G7e=-1}};qu.prototype.close=qu.prototype.close,qu.prototype.clone=qu.prototype.clone,qu.prototype.getAsWebGLTexture=qu.prototype.N,qu.prototype.getAsFloat32Array=qu.prototype.ia,qu.prototype.getAsUint8Array=qu.prototype.ja,qu.prototype.hasWebGLTexture=qu.prototype.R,qu.prototype.hasFloat32Array=qu.prototype.ka,qu.prototype.hasUint8Array=qu.prototype.Fa;var G7e=250;function py(...t){return t.map(([s,r])=>({start:s,end:r}))}const X2s=function(t){return class extends t{Ja(){this.i._registerModelResourcesGraphService()}}}((K7e=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:$ot()?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?'),La(this,n||"input_audio",o=>{La(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){By(this,"__graph_config__",s=>{t(s)}),La(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),La(this,n,l=>{this.i._addAudioToInputStream(this.g,s,r,l,a)})}addGpuBufferToStream(t,s,r){La(this,s,n=>{const[a,o]=q7e(this,t,n);this.i._addBoundTextureToStream(n,a,o,r)})}addBoolToStream(t,s,r){La(this,s,n=>{this.i._addBoolToInputStream(t,n,r)})}addDoubleToStream(t,s,r){La(this,s,n=>{this.i._addDoubleToInputStream(t,n,r)})}addFloatToStream(t,s,r){La(this,s,n=>{this.i._addFloatToInputStream(t,n,r)})}addIntToStream(t,s,r){La(this,s,n=>{this.i._addIntToInputStream(t,n,r)})}addUintToStream(t,s,r){La(this,s,n=>{this.i._addUintToInputStream(t,n,r)})}addStringToStream(t,s,r){La(this,s,n=>{La(this,t,a=>{this.i._addStringToInputStream(a,n,r)})})}addStringRecordToStream(t,s,r){La(this,s,n=>{U7e(this,Object.keys(t),a=>{U7e(this,Object.values(t),o=>{this.i._addFlatHashMapToInputStream(a,o,Object.keys(t).length,n,r)})})})}addProtoToStream(t,s,r,n){La(this,r,a=>{La(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){La(this,t,r=>{this.i._addEmptyPacketToInputStream(r,s)})}addBoolVectorToStream(t,s,r){La(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){La(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){La(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){La(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){La(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){La(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)La(this,o,l=>{this.i._addStringVectorEntry(a,l)});this.i._addStringVectorToInputStream(a,n,r)})}addBoolToInputSidePacket(t,s){La(this,s,r=>{this.i._addBoolToInputSidePacket(t,r)})}addDoubleToInputSidePacket(t,s){La(this,s,r=>{this.i._addDoubleToInputSidePacket(t,r)})}addFloatToInputSidePacket(t,s){La(this,s,r=>{this.i._addFloatToInputSidePacket(t,r)})}addIntToInputSidePacket(t,s){La(this,s,r=>{this.i._addIntToInputSidePacket(t,r)})}addUintToInputSidePacket(t,s){La(this,s,r=>{this.i._addUintToInputSidePacket(t,r)})}addStringToInputSidePacket(t,s){La(this,s,r=>{La(this,t,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(t,s,r){La(this,r,n=>{La(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){La(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){La(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){La(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){La(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){La(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){La(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)La(this,a,o=>{this.i._addStringVectorEntry(n,o)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(t,s){By(this,t,s),La(this,t,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(t,s){Ob(this,t,s),La(this,t,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(t,s,r){By(this,t,s),La(this,t,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(t,s,r){Ob(this,t,s),La(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?'),By(this,t,(n,a)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),s(n,a)}),La(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 K7e{get ga(){return this.i}pa(t,s,r){La(this,s,n=>{const[a,o]=q7e(this,t,n);this.ga._addBoundTextureAsImageToStream(n,a,o,r)})}Z(t,s){By(this,t,s),La(this,t,r=>{this.ga._attachImageListener(r)})}aa(t,s){Ob(this,t,s),La(this,t,r=>{this.ga._attachImageVectorListener(r)})}}));var K7e,fy=class extends X2s{};async function qo(t,s,r){return async function(n,a,o,l){return G2s(n,a,o,l)}(t,r.canvas??($ot()?void 0:document.createElement("canvas")),s,r)}function Zot(t,s,r,n){if(t.U){const o=new xot;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].");Va(o,1,(a.left+a.right)/2),Va(o,2,(a.top+a.bottom)/2),Va(o,4,a.right-a.left),Va(o,3,a.bottom-a.top)}else Va(o,1,.5),Va(o,2,.5),Va(o,4,1),Va(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(Va(o,5,-Math.PI*r.rotationDegrees/180),(r==null?void 0:r.rotationDegrees)%180!=0){const[l,i]=qot(s);r=Ed(o,3)*i/l,a=Ed(o,4)*l/i,Va(o,4,r),Va(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 xy(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'.");Zot(t,s,r,t.C+1)}function W0(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'.");Zot(t,s,r,n)}function EA(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 qu([a],r,!1,t.g.i.canvas,t.P,o,s),n?t.clone():t}var Af=class extends X_e{constructor(t,s,r,n){super(t),this.g=t,this.X=s,this.U=r,this.oa=n,this.P=new Hot}l(t,s=!0){if("runningMode"in t&&kl(this.baseOptions,2,rO(!!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()}};Af.prototype.close=Af.prototype.close;var ex=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect_in",!1),this.j={detections:[]},ai(t=this.h=new ume,0,1,s=new Nd),Va(this.h,2,.5),Va(this.h,3,.3)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return"minDetectionConfidence"in t&&Va(this.h,2,t.minDetectionConfidence??.5),"minSuppressionThreshold"in t&&Va(this.h,3,t.minSuppressionThreshold??.3),this.l(t)}F(t,s){return this.j={detections:[]},xy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},W0(this,t,r,s),this.j}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect_in"),tl(t,"detections");const s=new If;V0(s,P2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect_in"),Io(r,"DETECTIONS:detections"),r.o(s),Gx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=mot(o),this.j.detections.push(zot(n));ia(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};ex.prototype.detectForVideo=ex.prototype.G,ex.prototype.detect=ex.prototype.F,ex.prototype.setOptions=ex.prototype.o,ex.createFromModelPath=async function(t,s){return qo(ex,t,{baseOptions:{modelAssetPath:s}})},ex.createFromModelBuffer=function(t,s){return qo(ex,t,{baseOptions:{modelAssetBuffer:s}})},ex.createFromOptions=function(t,s){return qo(ex,t,s)};var XSe=py([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]),QSe=py([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]),JSe=py([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Yot=py([474,475],[475,476],[476,477],[477,474]),eCe=py([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]),tCe=py([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Xot=py([469,470],[470,471],[471,472],[472,469]),sCe=py([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]),Qot=[...XSe,...QSe,...JSe,...eCe,...tCe,...sCe],Jot=py([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 Z7e(t){t.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var od=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,ai(t=this.h=new _ot,0,1,s=new Nd),this.A=new bot,ai(this.h,0,3,this.A),this.u=new ume,ai(this.h,0,2,this.u),O1(this.u,4,1),Va(this.u,2,.5),Va(this.A,2,.5),Va(this.h,4,.5)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return"numFaces"in t&&O1(this.u,4,t.numFaces??1),"minFaceDetectionConfidence"in t&&Va(this.u,2,t.minFaceDetectionConfidence??.5),"minTrackingConfidence"in t&&Va(this.h,4,t.minTrackingConfidence??.5),"minFacePresenceConfidence"in t&&Va(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 Z7e(this),xy(this,t,s),this.j}G(t,s,r){return Z7e(this),W0(this,t,r,s),this.j}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect"),tl(t,"face_landmarks");const s=new If;V0(s,L2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"NORM_LANDMARKS:face_landmarks"),r.o(s),Gx(t,r),this.g.attachProtoVectorListener("face_landmarks",(n,a)=>{for(const o of n)n=wR(o),this.j.faceLandmarks.push(hme(n));ia(this,a)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{ia(this,n)}),this.outputFaceBlendshapes&&(tl(t,"blendshapes"),Io(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,a)=>{if(this.outputFaceBlendshapes)for(const o of n)n=dme(o),this.j.faceBlendshapes.push(KSe(n.g()??[]));ia(this,a)}),this.g.attachEmptyPacketListener("blendshapes",n=>{ia(this,n)})),this.outputFacialTransformationMatrixes&&(tl(t,"face_geometry"),Io(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,a)=>{if(this.outputFacialTransformationMatrixes)for(const o of n)(n=Zo(n=I2s(o),N2s,2))&&this.j.facialTransformationMatrixes.push({rows:wx(n,1)??0??0,columns:wx(n,2)??0??0,data:M4(n,3,l0,C4()).slice()??[]});ia(this,a)}),this.g.attachEmptyPacketListener("face_geometry",n=>{ia(this,n)})),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};od.prototype.detectForVideo=od.prototype.G,od.prototype.detect=od.prototype.F,od.prototype.setOptions=od.prototype.o,od.createFromModelPath=function(t,s){return qo(od,t,{baseOptions:{modelAssetPath:s}})},od.createFromModelBuffer=function(t,s){return qo(od,t,{baseOptions:{modelAssetBuffer:s}})},od.createFromOptions=function(t,s){return qo(od,t,s)},od.FACE_LANDMARKS_LIPS=XSe,od.FACE_LANDMARKS_LEFT_EYE=QSe,od.FACE_LANDMARKS_LEFT_EYEBROW=JSe,od.FACE_LANDMARKS_LEFT_IRIS=Yot,od.FACE_LANDMARKS_RIGHT_EYE=eCe,od.FACE_LANDMARKS_RIGHT_EYEBROW=tCe,od.FACE_LANDMARKS_RIGHT_IRIS=Xot,od.FACE_LANDMARKS_FACE_OVAL=sCe,od.FACE_LANDMARKS_CONTOURS=Qot,od.FACE_LANDMARKS_TESSELATION=Jot;var rCe=py([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 Y7e(t){t.gestures=[],t.landmarks=[],t.worldLandmarks=[],t.handedness=[]}function X7e(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 Q7e(t,s=!0){const r=[];for(const a of t){var n=dme(a);t=[];for(const o of n.g())n=s&&wx(o,1)!=null?wx(o,1)??0:-1,t.push({score:Ed(o,2)??0,index:n,categoryName:Ah(Xc(o,3))??""??"",displayName:Ah(Xc(o,4))??""??""});r.push(t)}return r}var Wp=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ai(t=this.j=new Not,0,1,s=new Nd),this.u=new VSe,ai(this.j,0,2,this.u),this.D=new USe,ai(this.u,0,3,this.D),this.A=new jot,ai(this.u,0,2,this.A),this.h=new D2s,ai(this.j,0,3,this.h),Va(this.A,2,.5),Va(this.u,4,.5),Va(this.D,2,.5)}get baseOptions(){return Zo(this.j,Nd,1)}set baseOptions(t){ai(this.j,0,1,t)}o(t){var a,o,l,i;if(O1(this.A,3,t.numHands??1),"minHandDetectionConfidence"in t&&Va(this.A,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Va(this.u,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Va(this.D,2,t.minHandPresenceConfidence??.5),t.cannedGesturesClassifierOptions){var s=new M5,r=s,n=Y_e(t.cannedGesturesClassifierOptions,(a=Zo(this.h,M5,3))==null?void 0:a.l());ai(r,0,2,n),ai(this.h,0,3,s)}else t.cannedGesturesClassifierOptions===void 0&&((o=Zo(this.h,M5,3))==null||o.g());return t.customGesturesClassifierOptions?(ai(r=s=new M5,0,2,n=Y_e(t.customGesturesClassifierOptions,(l=Zo(this.h,M5,4))==null?void 0:l.l())),ai(this.h,0,4,s)):t.customGesturesClassifierOptions===void 0&&((i=Zo(this.h,M5,4))==null||i.g()),this.l(t)}Ha(t,s){return Y7e(this),xy(this,t,s),X7e(this)}Ia(t,s,r){return Y7e(this),W0(this,t,r,s),X7e(this)}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect"),tl(t,"hand_gestures"),tl(t,"hand_landmarks"),tl(t,"world_hand_landmarks"),tl(t,"handedness");const s=new If;V0(s,O2s,this.j);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"HAND_GESTURES:hand_gestures"),Io(r,"LANDMARKS:hand_landmarks"),Io(r,"WORLD_LANDMARKS:world_hand_landmarks"),Io(r,"HANDEDNESS:handedness"),r.o(s),Gx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n){n=wR(o);const l=[];for(const i of D1(n,fot,1))l.push({x:Ed(i,1)??0,y:Ed(i,2)??0,z:Ed(i,3)??0,visibility:Ed(i,4)??0});this.landmarks.push(l)}ia(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n){n=lT(o);const l=[];for(const i of D1(n,pot,1))l.push({x:Ed(i,1)??0,y:Ed(i,2)??0,z:Ed(i,3)??0,visibility:Ed(i,4)??0});this.worldLandmarks.push(l)}ia(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,a)=>{this.gestures.push(...Q7e(n,!1)),ia(this,a)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{ia(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{this.handedness.push(...Q7e(n)),ia(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};function J7e(t){return{landmarks:t.landmarks,worldLandmarks:t.worldLandmarks,handednesses:t.handedness,handedness:t.handedness}}Wp.prototype.recognizeForVideo=Wp.prototype.Ia,Wp.prototype.recognize=Wp.prototype.Ha,Wp.prototype.setOptions=Wp.prototype.o,Wp.createFromModelPath=function(t,s){return qo(Wp,t,{baseOptions:{modelAssetPath:s}})},Wp.createFromModelBuffer=function(t,s){return qo(Wp,t,{baseOptions:{modelAssetBuffer:s}})},Wp.createFromOptions=function(t,s){return qo(Wp,t,s)},Wp.HAND_CONNECTIONS=rCe;var Gp=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],ai(t=this.h=new VSe,0,1,s=new Nd),this.u=new USe,ai(this.h,0,3,this.u),this.j=new jot,ai(this.h,0,2,this.j),O1(this.j,3,1),Va(this.j,2,.5),Va(this.u,2,.5),Va(this.h,4,.5)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return"numHands"in t&&O1(this.j,3,t.numHands??1),"minHandDetectionConfidence"in t&&Va(this.j,2,t.minHandDetectionConfidence??.5),"minTrackingConfidence"in t&&Va(this.h,4,t.minTrackingConfidence??.5),"minHandPresenceConfidence"in t&&Va(this.u,2,t.minHandPresenceConfidence??.5),this.l(t)}F(t,s){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],xy(this,t,s),J7e(this)}G(t,s,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],W0(this,t,r,s),J7e(this)}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect"),tl(t,"hand_landmarks"),tl(t,"world_hand_landmarks"),tl(t,"handedness");const s=new If;V0(s,R2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"LANDMARKS:hand_landmarks"),Io(r,"WORLD_LANDMARKS:world_hand_landmarks"),Io(r,"HANDEDNESS:handedness"),r.o(s),Gx(t,r),this.g.attachProtoVectorListener("hand_landmarks",(n,a)=>{for(const o of n)n=wR(o),this.landmarks.push(hme(n));ia(this,a)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,a)=>{for(const o of n)n=lT(o),this.worldLandmarks.push(b8(n));ia(this,a)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{ia(this,n)}),this.g.attachProtoVectorListener("handedness",(n,a)=>{var o=this.handedness,l=o.push;const i=[];for(const c of n){n=dme(c);const u=[];for(const p of n.g())u.push({score:Ed(p,2)??0,index:wx(p,1)??0??-1,categoryName:Ah(Xc(p,3))??""??"",displayName:Ah(Xc(p,4))??""??""});i.push(u)}l.call(o,...i),ia(this,a)}),this.g.attachEmptyPacketListener("handedness",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Gp.prototype.detectForVideo=Gp.prototype.G,Gp.prototype.detect=Gp.prototype.F,Gp.prototype.setOptions=Gp.prototype.o,Gp.createFromModelPath=function(t,s){return qo(Gp,t,{baseOptions:{modelAssetPath:s}})},Gp.createFromModelBuffer=function(t,s){return qo(Gp,t,{baseOptions:{modelAssetBuffer:s}})},Gp.createFromOptions=function(t,s){return qo(Gp,t,s)},Gp.HAND_CONNECTIONS=rCe;var elt=py([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 eze(t){t.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function tze(t){try{if(!t.D)return t.h;t.D(t.h)}finally{pme(t)}}function Xz(t,s){t=wR(t),s.push(hme(t))}var Mc=class extends Af{constructor(t,s){super(new fy(t,s),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,ai(t=this.j=new Tot,0,1,s=new Nd),this.I=new USe,ai(this.j,0,2,this.I),this.W=new F2s,ai(this.j,0,3,this.W),this.u=new ume,ai(this.j,0,4,this.u),this.O=new bot,ai(this.j,0,5,this.O),this.A=new Cot,ai(this.j,0,6,this.A),this.M=new Mot,ai(this.j,0,7,this.M),Va(this.u,2,.5),Va(this.u,3,.3),Va(this.O,2,.5),Va(this.A,2,.5),Va(this.A,3,.3),Va(this.M,2,.5),Va(this.I,2,.5)}get baseOptions(){return Zo(this.j,Nd,1)}set baseOptions(t){ai(this.j,0,1,t)}o(t){return"minFaceDetectionConfidence"in t&&Va(this.u,2,t.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in t&&Va(this.u,3,t.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in t&&Va(this.O,2,t.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in t&&(this.outputFaceBlendshapes=!!t.outputFaceBlendshapes),"minPoseDetectionConfidence"in t&&Va(this.A,2,t.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in t&&Va(this.A,3,t.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in t&&Va(this.M,2,t.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in t&&(this.outputPoseSegmentationMasks=!!t.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in t&&Va(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,eze(this),xy(this,t,n),tze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.D=typeof r=="function"?r:n,eze(this),W0(this,t,a,s),tze(this)}m(){var t=new Lf;td(t,"input_frames_image"),tl(t,"pose_landmarks"),tl(t,"pose_world_landmarks"),tl(t,"face_landmarks"),tl(t,"left_hand_landmarks"),tl(t,"left_hand_world_landmarks"),tl(t,"right_hand_landmarks"),tl(t,"right_hand_world_landmarks");const s=new If,r=new k7e;Tf(r,1,"type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),function(a,o){if(o!=null)if(Array.isArray(o))kl(a,2,Qhe(o,0,nO));else{if(!(typeof o=="string"||o instanceof j0||cSe(o)))throw Error("invalid value in Any.value field: "+o+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");Jb(a,2,uSe(o,!1),sC())}}(r,this.j.g());const n=new Lp;Tf(n,2,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),kSe(n,8,k7e,r),Bc(n,"IMAGE:input_frames_image"),Io(n,"POSE_LANDMARKS:pose_landmarks"),Io(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),Io(n,"FACE_LANDMARKS:face_landmarks"),Io(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),Io(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),Io(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),Io(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(s),Gx(t,n),mme(this,t),this.g.attachProtoListener("pose_landmarks",(a,o)=>{Xz(a,this.h.poseLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("pose_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("pose_world_landmarks",(a,o)=>{var l=this.h.poseWorldLandmarks;a=lT(a),l.push(b8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("pose_world_landmarks",a=>{ia(this,a)}),this.outputPoseSegmentationMasks&&(Io(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),TA(this,"pose_segmentation_mask"),this.g.Z("pose_segmentation_mask",(a,o)=>{this.h.poseSegmentationMasks=[EA(this,a,!0,!this.D)],ia(this,o)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",a=>{this.h.poseSegmentationMasks=[],ia(this,a)})),this.g.attachProtoListener("face_landmarks",(a,o)=>{Xz(a,this.h.faceLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",a=>{ia(this,a)}),this.outputFaceBlendshapes&&(tl(t,"extra_blendshapes"),Io(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(a,o)=>{var l=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(a=dme(a),l.push(KSe(a.g()??[]))),ia(this,o)}),this.g.attachEmptyPacketListener("extra_blendshapes",a=>{ia(this,a)})),this.g.attachProtoListener("left_hand_landmarks",(a,o)=>{Xz(a,this.h.leftHandLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("left_hand_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("left_hand_world_landmarks",(a,o)=>{var l=this.h.leftHandWorldLandmarks;a=lT(a),l.push(b8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("right_hand_landmarks",(a,o)=>{Xz(a,this.h.rightHandLandmarks),ia(this,o)}),this.g.attachEmptyPacketListener("right_hand_landmarks",a=>{ia(this,a)}),this.g.attachProtoListener("right_hand_world_landmarks",(a,o)=>{var l=this.h.rightHandWorldLandmarks;a=lT(a),l.push(b8(a)),ia(this,o)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",a=>{ia(this,a)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Mc.prototype.detectForVideo=Mc.prototype.G,Mc.prototype.detect=Mc.prototype.F,Mc.prototype.setOptions=Mc.prototype.o,Mc.createFromModelPath=function(t,s){return qo(Mc,t,{baseOptions:{modelAssetPath:s}})},Mc.createFromModelBuffer=function(t,s){return qo(Mc,t,{baseOptions:{modelAssetBuffer:s}})},Mc.createFromOptions=function(t,s){return qo(Mc,t,s)},Mc.HAND_CONNECTIONS=rCe,Mc.POSE_CONNECTIONS=elt,Mc.FACE_LANDMARKS_LIPS=XSe,Mc.FACE_LANDMARKS_LEFT_EYE=QSe,Mc.FACE_LANDMARKS_LEFT_EYEBROW=JSe,Mc.FACE_LANDMARKS_LEFT_IRIS=Yot,Mc.FACE_LANDMARKS_RIGHT_EYE=eCe,Mc.FACE_LANDMARKS_RIGHT_EYEBROW=tCe,Mc.FACE_LANDMARKS_RIGHT_IRIS=Xot,Mc.FACE_LANDMARKS_FACE_OVAL=sCe,Mc.FACE_LANDMARKS_CONTOURS=Qot,Mc.FACE_LANDMARKS_TESSELATION=Jot;var tx=class extends Af{constructor(t,s){super(new fy(t,s),"input_image","norm_rect",!0),this.j={classifications:[]},ai(t=this.h=new Aot,0,1,s=new Nd)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return ai(this.h,0,2,Y_e(t,Zo(this.h,$Se,2))),this.l(t)}sa(t,s){return this.j={classifications:[]},xy(this,t,s),this.j}ta(t,s,r){return this.j={classifications:[]},W0(this,t,r,s),this.j}m(){var t=new Lf;td(t,"input_image"),td(t,"norm_rect"),tl(t,"classifications");const s=new If;V0(s,z2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),Bc(r,"IMAGE:input_image"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"CLASSIFICATIONS:classifications"),r.o(s),Gx(t,r),this.g.attachProtoListener("classifications",(n,a)=>{this.j=H2s(C2s(n)),ia(this,a)}),this.g.attachEmptyPacketListener("classifications",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};tx.prototype.classifyForVideo=tx.prototype.ta,tx.prototype.classify=tx.prototype.sa,tx.prototype.setOptions=tx.prototype.o,tx.createFromModelPath=function(t,s){return qo(tx,t,{baseOptions:{modelAssetPath:s}})},tx.createFromModelBuffer=function(t,s){return qo(tx,t,{baseOptions:{modelAssetBuffer:s}})},tx.createFromOptions=function(t,s){return qo(tx,t,s)};var Kp=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!0),this.h=new Eot,this.embeddings={embeddings:[]},ai(t=this.h,0,1,s=new Nd)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){var s=this.h,r=Zo(this.h,L7e,2);return r=r?r.clone():new L7e,t.l2Normalize!==void 0?kl(r,1,rO(t.l2Normalize)):"l2Normalize"in t&&kl(r,1),t.quantize!==void 0?kl(r,2,rO(t.quantize)):"quantize"in t&&kl(r,2),ai(s,0,2,r),this.l(t)}za(t,s){return xy(this,t,s),this.embeddings}Aa(t,s,r){return W0(this,t,r,s),this.embeddings}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect"),tl(t,"embeddings_out");const s=new If;V0(s,B2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"EMBEDDINGS:embeddings_out"),r.o(s),Gx(t,r),this.g.attachProtoListener("embeddings_out",(n,a)=>{n=A2s(n),this.embeddings=function(o){return{embeddings:D1(o,T2s,1).map(l=>{var u,p;const i={headIndex:wx(l,3)??0??-1,headName:Ah(Xc(l,4))??""??""};var c=l.v;return Mit(c,0|c[Ma],I7e,xye(l,1))!==void 0?(l=M4(l=Zo(l,I7e,xye(l,1),void 0),1,l0,C4()),i.floatEmbedding=l.slice()):(c=new Uint8Array(0),i.quantizedEmbedding=((p=(u=Zo(l,M2s,xye(l,2),void 0))==null?void 0:u.na())==null?void 0:p.h())??c),i}),timestampMs:Fot(Xc(o,2,void 0,void 0,Hce)??jit)}}(n),ia(this,a)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};Kp.cosineSimilarity=function(t,s){if(t.floatEmbedding&&s.floatEmbedding)t=B7e(t.floatEmbedding,s.floatEmbedding);else{if(!t.quantizedEmbedding||!s.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");t=B7e(z7e(t.quantizedEmbedding),z7e(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 qo(Kp,t,{baseOptions:{modelAssetPath:s}})},Kp.createFromModelBuffer=function(t,s){return qo(Kp,t,{baseOptions:{modelAssetBuffer:s}})},Kp.createFromOptions=function(t,s){return qo(Kp,t,s)};var ewe=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 Q2s(t){var r,n;const s=function(a){return D1(a,Lp,1)}(t.ca()).filter(a=>(Ah(Xc(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=Zo(s[0],If,7))==null?void 0:r.j())==null?void 0:n.g())??new Map).forEach((a,o)=>{t.u[Number(o)]=Ah(Xc(a,1))??""})}function sze(t){t.categoryMask=void 0,t.confidenceMasks=void 0,t.qualityScores=void 0}function rze(t){try{const s=new ewe(t.confidenceMasks,t.categoryMask,t.qualityScores);if(!t.j)return s;t.j(s)}finally{pme(t)}}ewe.prototype.close=ewe.prototype.close;var fm=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!1),this.u=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new GSe,this.A=new Pot,ai(this.h,0,3,this.A),ai(t=this.h,0,1,s=new Nd)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?kl(this.h,2,vR(t.displayNamesLocale)):"displayNamesLocale"in t&&kl(this.h,2),"outputCategoryMask"in t&&(this.outputCategoryMask=t.outputCategoryMask??!1),"outputConfidenceMasks"in t&&(this.outputConfidenceMasks=t.outputConfidenceMasks??!0),super.l(t)}L(){Q2s(this)}segment(t,s,r){const n=typeof s!="function"?s:{};return this.j=typeof s=="function"?s:r,sze(this),xy(this,t,n),rze(this)}La(t,s,r,n){const a=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,sze(this),W0(this,t,a,s),rze(this)}Da(){return this.u}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect");const s=new If;V0(s,Lot,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),r.o(s),Gx(t,r),mme(this,t),this.outputConfidenceMasks&&(tl(t,"confidence_masks"),Io(r,"CONFIDENCE_MASKS:confidence_masks"),TA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>EA(this,o,!0,!this.j)),ia(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ia(this,n)})),this.outputCategoryMask&&(tl(t,"category_mask"),Io(r,"CATEGORY_MASK:category_mask"),TA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=EA(this,n,!1,!this.j),ia(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ia(this,n)})),tl(t,"quality_scores"),Io(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ia(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};fm.prototype.getLabels=fm.prototype.Da,fm.prototype.segmentForVideo=fm.prototype.La,fm.prototype.segment=fm.prototype.segment,fm.prototype.setOptions=fm.prototype.o,fm.createFromModelPath=function(t,s){return qo(fm,t,{baseOptions:{modelAssetPath:s}})},fm.createFromModelBuffer=function(t,s){return qo(fm,t,{baseOptions:{modelAssetBuffer:s}})},fm.createFromOptions=function(t,s){return qo(fm,t,s)};var twe=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()}};twe.prototype.close=twe.prototype.close;var $y=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new GSe,this.u=new Pot,ai(this.h,0,3,this.u),ai(t=this.h,0,1,s=new Nd)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(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 Dot,s.keypoint&&s.scribble)throw Error("Cannot provide both keypoint and scribble.");if(s.keypoint){var o=new bye;Jb(o,3,rO(!0),!1),Jb(o,1,TI(s.keypoint.x),0),Jb(o,2,TI(s.keypoint.y),0),y8(n,1,Z_e,o)}else{if(!s.scribble)throw Error("Must provide either a keypoint or a scribble.");{const i=new q2s;for(o of s.scribble)Jb(s=new bye,3,rO(!0),!1),Jb(s,1,TI(o.x),0),Jb(s,2,TI(o.y),0),kSe(i,1,bye,s);y8(n,2,Z_e,i)}}this.g.addProtoToStream(n.g(),"mediapipe.tasks.vision.interactive_segmenter.proto.RegionOfInterest","roi_in",r),xy(this,t,a);e:{try{const i=new twe(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var l=i;break e}this.j(i)}finally{pme(this)}l=void 0}return l}m(){var t=new Lf;td(t,"image_in"),td(t,"roi_in"),td(t,"norm_rect_in");const s=new If;V0(s,Lot,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraphV2"),Bc(r,"IMAGE:image_in"),Bc(r,"ROI:roi_in"),Bc(r,"NORM_RECT:norm_rect_in"),r.o(s),Gx(t,r),mme(this,t),this.outputConfidenceMasks&&(tl(t,"confidence_masks"),Io(r,"CONFIDENCE_MASKS:confidence_masks"),TA(this,"confidence_masks"),this.g.aa("confidence_masks",(n,a)=>{this.confidenceMasks=n.map(o=>EA(this,o,!0,!this.j)),ia(this,a)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],ia(this,n)})),this.outputCategoryMask&&(tl(t,"category_mask"),Io(r,"CATEGORY_MASK:category_mask"),TA(this,"category_mask"),this.g.Z("category_mask",(n,a)=>{this.categoryMask=EA(this,n,!1,!this.j),ia(this,a)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,ia(this,n)})),tl(t,"quality_scores"),Io(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,a)=>{this.qualityScores=n,ia(this,a)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,ia(this,n)}),t=t.g(),this.setGraph(new Uint8Array(t),!0)}};$y.prototype.segment=$y.prototype.segment,$y.prototype.setOptions=$y.prototype.o,$y.createFromModelPath=function(t,s){return qo($y,t,{baseOptions:{modelAssetPath:s}})},$y.createFromModelBuffer=function(t,s){return qo($y,t,{baseOptions:{modelAssetBuffer:s}})},$y.createFromOptions=function(t,s){return qo($y,t,s)};var sx=class extends Af{constructor(t,s){super(new fy(t,s),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},ai(t=this.h=new Oot,0,1,s=new Nd)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return t.displayNamesLocale!==void 0?kl(this.h,2,vR(t.displayNamesLocale)):"displayNamesLocale"in t&&kl(this.h,2),t.maxResults!==void 0?O1(this.h,3,t.maxResults):"maxResults"in t&&kl(this.h,3),t.scoreThreshold!==void 0?Va(this.h,4,t.scoreThreshold):"scoreThreshold"in t&&kl(this.h,4),t.categoryAllowlist!==void 0?Gce(this.h,5,t.categoryAllowlist):"categoryAllowlist"in t&&kl(this.h,5),t.categoryDenylist!==void 0?Gce(this.h,6,t.categoryDenylist):"categoryDenylist"in t&&kl(this.h,6),this.l(t)}F(t,s){return this.j={detections:[]},xy(this,t,s),this.j}G(t,s,r){return this.j={detections:[]},W0(this,t,r,s),this.j}m(){var t=new Lf;td(t,"input_frame_gpu"),td(t,"norm_rect"),tl(t,"detections");const s=new If;V0(s,U2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.ObjectDetectorGraph"),Bc(r,"IMAGE:input_frame_gpu"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"DETECTIONS:detections"),r.o(s),Gx(t,r),this.g.attachProtoVectorListener("detections",(n,a)=>{for(const o of n)n=mot(o),this.j.detections.push(zot(n));ia(this,a)}),this.g.attachEmptyPacketListener("detections",n=>{ia(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 qo(sx,t,{baseOptions:{modelAssetPath:s}})},sx.createFromModelBuffer=function(t,s){return qo(sx,t,{baseOptions:{modelAssetBuffer:s}})},sx.createFromOptions=function(t,s){return qo(sx,t,s)};var swe=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 aze(t){try{const s=new swe(t.landmarks,t.worldLandmarks,t.segmentationMasks);if(!t.u)return s;t.u(s)}finally{pme(t)}}swe.prototype.close=swe.prototype.close;var Zp=class extends Af{constructor(t,s){super(new fy(t,s),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,ai(t=this.h=new Rot,0,1,s=new Nd),this.A=new Mot,ai(this.h,0,3,this.A),this.j=new Cot,ai(this.h,0,2,this.j),O1(this.j,4,1),Va(this.j,2,.5),Va(this.A,2,.5),Va(this.h,4,.5)}get baseOptions(){return Zo(this.h,Nd,1)}set baseOptions(t){ai(this.h,0,1,t)}o(t){return"numPoses"in t&&O1(this.j,4,t.numPoses??1),"minPoseDetectionConfidence"in t&&Va(this.j,2,t.minPoseDetectionConfidence??.5),"minTrackingConfidence"in t&&Va(this.h,4,t.minTrackingConfidence??.5),"minPosePresenceConfidence"in t&&Va(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),xy(this,t,n),aze(this)}G(t,s,r,n){const a=typeof r!="function"?r:{};return this.u=typeof r=="function"?r:n,nze(this),W0(this,t,a,s),aze(this)}m(){var t=new Lf;td(t,"image_in"),td(t,"norm_rect"),tl(t,"normalized_landmarks"),tl(t,"world_landmarks"),tl(t,"segmentation_masks");const s=new If;V0(s,V2s,this.h);const r=new Lp;Tf(r,2,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),Bc(r,"IMAGE:image_in"),Bc(r,"NORM_RECT:norm_rect"),Io(r,"NORM_LANDMARKS:normalized_landmarks"),Io(r,"WORLD_LANDMARKS:world_landmarks"),r.o(s),Gx(t,r),mme(this,t),this.g.attachProtoVectorListener("normalized_landmarks",(n,a)=>{this.landmarks=[];for(const o of n)n=wR(o),this.landmarks.push(hme(n));ia(this,a)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],ia(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,a)=>{this.worldLandmarks=[];for(const o of n)n=lT(o),this.worldLandmarks.push(b8(n));ia(this,a)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],ia(this,n)}),this.outputSegmentationMasks&&(Io(r,"SEGMENTATION_MASK:segmentation_masks"),TA(this,"segmentation_masks"),this.g.aa("segmentation_masks",(n,a)=>{this.segmentationMasks=n.map(o=>EA(this,o,!0,!this.u)),ia(this,a)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],ia(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 qo(Zp,t,{baseOptions:{modelAssetPath:s}})},Zp.createFromModelBuffer=function(t,s){return qo(Zp,t,{baseOptions:{modelAssetBuffer:s}})},Zp.createFromOptions=function(t,s){return qo(Zp,t,s)},Zp.POSE_CONNECTIONS=elt;let T4=null,AI=null;async function J2s(){return T4||AI||(AI=(async()=>{const t=await B5.forVisionTasks("https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@latest/wasm");return T4=await fm.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}),T4})(),AI)}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 tjs(){T4&&(T4.close(),T4=null,AI=null)}function sjs(t,s){const r=k.useRef(null),n=k.useRef(null),a=k.useRef(null),o=k.useRef(null),l=k.useRef(0),i=k.useRef(0),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(null),_=s.type!=="none"&&t!==null;return k.useEffect(()=>{if(s.type==="image"&&s.imageUrl){const j=new Image;j.crossOrigin="anonymous",j.src=s.imageUrl,j.onload=()=>{o.current=j}}else o.current=null},[s.type,s.imageUrl]),k.useEffect(()=>{if(!_||!t){a.current&&(a.current.srcObject=null,a.current=null);return}const j=document.createElement("video");return j.srcObject=t,j.muted=!0,j.playsInline=!0,j.autoplay=!0,j.play().catch(()=>{}),a.current=j,()=>{j.srcObject=null,a.current=null}},[_,t]),k.useEffect(()=>{if(!_){u(null),b(null);return}let j=!1;return(async()=>{f(!0),b(null);try{const N=await J2s();if(j)return;f(!1);const C=a.current;if(!C||(await new Promise(fe=>{if(C.videoWidth>0)return fe();C.onloadedmetadata=()=>fe(),setTimeout(fe,2e3)}),j))return;const M=C.videoWidth||640,I=C.videoHeight||480,L=r.current;if(!L)return;L.width=M,L.height=I;const R=L.getContext("2d",{willReadFrequently:!1});n.current||(n.current=document.createElement("canvas"));const q=n.current;q.width=M,q.height=I;const U=q.getContext("2d",{willReadFrequently:!0}),B=document.createElement("canvas");B.width=M,B.height=I;const V=B.getContext("2d"),Y=L.captureStream(30);((t==null?void 0:t.getAudioTracks())||[]).forEach(fe=>Y.addTrack(fe)),j||u(Y);const te=s.blurRadius??15,X=s.mirror??!1,ce=new Float32Array(M*I),ne=new Float32Array(M*I),re=new Float32Array(M*I);let le=!1;const pe=4,xe=.6,_e=()=>{if(j||!a.current)return;const fe=performance.now();if(fe-i.current<30){l.current=requestAnimationFrame(_e);return}i.current=fe;const we=a.current;if(we.readyState<2){l.current=requestAnimationFrame(_e);return}try{const Ne=N.segmentForVideo(we,fe).confidenceMasks;if(Ne&&Ne.length>0){ne.fill(0);for(let Ce=1;Ce$e?(ft=Ce.height*$e,ct=(Ce.width-ft)/2):(me=Ce.width/$e,Te=(Ce.height-me)/2),R.drawImage(Ce,ct,Te,ft,me,0,0,M,I)}U.clearRect(0,0,M,I),U.drawImage(we,0,0,M,I);const Ae=U.getImageData(0,0,M,I),Fe=Ae.data;for(let Ce=0;Ce{j=!0,l.current&&cancelAnimationFrame(l.current),u(null)}},[_,s.type,s.blurRadius,s.imageUrl,t]),k.useEffect(()=>()=>{tjs()},[]),{canvasRef:r,compositedStream:c,isLoading:p,isActive:_,error:g}}function fme({maxDurationSeconds:t=30,onRecordingComplete:s,onError:r,onRecordingStateChange:n,className:a,teleprompterContent:o}){const l=k.useRef(null),i=k.useRef(null),c=k.useRef(null),[u,p]=k.useState(null),f=k.useRef([]),g=k.useRef(null),b=k.useRef(null),_=k.useRef(null),j=k.useRef(null),w=NE(),[N,C]=k.useState("camera"),M=k.useRef(null),I=k.useRef(null),L=k.useRef(null),R=k.useRef(null),q=k.useRef(null),[U,B]=k.useState(!0),[V,Y]=k.useState(!0),[J,te]=k.useState(null),[X,ce]=k.useState(!1),[ne,re]=k.useState(!1),[le,pe]=k.useState(null),[xe,_e]=k.useState(null),[fe,we]=k.useState(0),[Ie,Ne]=k.useState("user"),[Ae,Fe]=k.useState(0),[Ce,Me]=k.useState(!1),[$e,ct]=k.useState(!0),[Te,ft]=k.useState(null),[me,Ve]=k.useState(!1),[nt,et]=k.useState(null),Se=k.useRef(null),[rt,Ge]=k.useState(()=>{try{const cr=localStorage.getItem("video-bg-config");if(cr)return JSON.parse(cr)}catch{}return{type:"none"}});k.useEffect(()=>{try{localStorage.setItem("video-bg-config",JSON.stringify(rt))}catch{}},[rt]);const{canvasRef:lt,compositedStream:qe,isLoading:Ze,isActive:Je}=sjs(u,rt),He=k.useRef(r);He.current=r;const Qe=k.useCallback(cr=>{B(cr)},[]),at=k.useRef(U),It=k.useCallback(()=>{L.current&&(cancelAnimationFrame(L.current),L.current=null),M.current&&(M.current.getTracks().forEach(cr=>cr.stop()),M.current=null),R.current&&(R.current.getTracks().forEach(cr=>cr.stop()),R.current=null),q.current&&(q.current.srcObject=null,q.current=null)},[]),Ut=k.useCallback(async()=>{var cr;try{const Qr=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080}},audio:!0});M.current=Qr;let Hr=null;try{Hr=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 ln=null;if(!Hr)try{ln=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{console.warn("[VideoRecorder] No mic audio")}const Zr=Qr.getVideoTracks()[0],yi=Zr.getSettings(),pt=yi.width||1920,ir=yi.height||1080,Bn=document.createElement("canvas");Bn.width=pt,Bn.height=ir,I.current=Bn;const Cr=Bn.getContext("2d");let jr=null;Hr&&(jr=document.createElement("video"),jr.srcObject=Hr,jr.muted=!0,jr.playsInline=!0,jr.autoplay=!0,await jr.play(),q.current=jr);const Xn=document.createElement("video");Xn.srcObject=Qr,Xn.muted=!0,Xn.playsInline=!0,Xn.autoplay=!0,await Xn.play();const Aa=()=>{if(Cr.drawImage(Xn,0,0,pt,ir),jr&&jr.readyState>=2){const Be=Math.round(pt*.2),Ye=Math.round(Be*(jr.videoHeight/jr.videoWidth||.75)),vt=pt-Be-20,xt=ir-Ye-20,Rt=12;Cr.save(),Cr.beginPath(),Cr.moveTo(vt+Rt,xt),Cr.lineTo(vt+Be-Rt,xt),Cr.quadraticCurveTo(vt+Be,xt,vt+Be,xt+Rt),Cr.lineTo(vt+Be,xt+Ye-Rt),Cr.quadraticCurveTo(vt+Be,xt+Ye,vt+Be-Rt,xt+Ye),Cr.lineTo(vt+Rt,xt+Ye),Cr.quadraticCurveTo(vt,xt+Ye,vt,xt+Ye-Rt),Cr.lineTo(vt,xt+Rt),Cr.quadraticCurveTo(vt,xt,vt+Rt,xt),Cr.closePath(),Cr.clip(),Cr.translate(vt+Be,xt),Cr.scale(-1,1),Cr.drawImage(jr,0,0,Be,Ye),Cr.restore(),Cr.strokeStyle="rgba(255,255,255,0.6)",Cr.lineWidth=2,Cr.beginPath(),Cr.moveTo(vt+Rt,xt),Cr.lineTo(vt+Be-Rt,xt),Cr.quadraticCurveTo(vt+Be,xt,vt+Be,xt+Rt),Cr.lineTo(vt+Be,xt+Ye-Rt),Cr.quadraticCurveTo(vt+Be,xt+Ye,vt+Be-Rt,xt+Ye),Cr.lineTo(vt+Rt,xt+Ye),Cr.quadraticCurveTo(vt,xt+Ye,vt,xt+Ye-Rt),Cr.lineTo(vt,xt+Rt),Cr.quadraticCurveTo(vt,xt,vt+Rt,xt),Cr.closePath(),Cr.stroke()}L.current=requestAnimationFrame(Aa)};Aa();const Pi=Bn.captureStream(30),Oo=[],$t=Qr.getAudioTracks();if($t.length&&Oo.push(...$t),Hr){const Be=Hr.getAudioTracks();Be.length&&Oo.push(...Be)}else ln&&Oo.push(...ln.getAudioTracks());const je=new MediaStream([...Pi.getVideoTracks(),...Oo]);return R.current=je,Zr.onended=()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),It()},je}catch(Qr){return console.error("[VideoRecorder] Screen capture error:",Qr),Qr.name!=="NotAllowedError"&&((cr=He.current)==null||cr.call(He,"Failed to start screen capture: "+(Qr.message||"Unknown error"))),null}},[It]),hs=k.useCallback(async()=>{var Qr,Hr;Y(!0),ft(null);const cr=w&&U;console.log("[VideoRecorder] initCamera start",{isMobile:w,usePortraitMode:U,shouldBePortrait:cr,facingMode:Ie});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(ir=>ir.stop()));const ln=w&&cr?{facingMode:{ideal:Ie},width:{ideal:720},height:{ideal:1280}}:{facingMode:{ideal:Ie},width:{ideal:1280},height:{ideal:720}};console.log("[VideoRecorder] requesting getUserMedia",ln);const Zr=await navigator.mediaDevices.getUserMedia({video:ln,audio:{echoCancellation:!0,noiseSuppression:!0}});if(console.log("[VideoRecorder] getUserMedia success"),Zr.getVideoTracks().length===0)throw new Error("Camera stream started but no video track was provided.");c.current=Zr,p(Zr),te(!0);const pt=Zr.getVideoTracks()[0].getSettings();if(console.log("[VideoRecorder] Camera initialized with dimensions:",pt.width,"x",pt.height),l.current){const ir=l.current;ir.srcObject=Zr,ir.muted=!0,ir.playsInline=!0,ir.autoplay=!0,ir.setAttribute("muted",""),ir.setAttribute("playsinline",""),ir.setAttribute("autoplay","");try{(Qr=ir.load)==null||Qr.call(ir)}catch(Cr){console.warn("[VideoRecorder] videoEl.load failed",Cr)}const Bn=async()=>{try{return await ir.play(),console.log("[VideoRecorder] preview play ok"),Ve(!1),setTimeout(()=>{console.debug("[VideoRecorder] preview metrics",{readyState:ir.readyState,videoWidth:ir.videoWidth,videoHeight:ir.videoHeight})},300),!0}catch(Cr){return console.warn("[VideoRecorder] preview play blocked",Cr),Ve(!0),!1}};await new Promise(Cr=>{let jr=!1;const Xn=()=>{jr||(jr=!0,Cr())},Aa=()=>{Bn().finally(Xn)};ir.onloadedmetadata=Aa,ir.onloadeddata=Aa,setTimeout(Xn,1500)})}try{b.current=new AudioContext;const ir=b.current.createMediaStreamSource(Zr);_.current=b.current.createAnalyser(),_.current.fftSize=256,ir.connect(_.current);const Bn=()=>{if(_.current){const Cr=new Uint8Array(_.current.frequencyBinCount);_.current.getByteFrequencyData(Cr);const jr=Cr.reduce((Xn,Aa)=>Xn+Aa)/Cr.length;Fe(Math.min(100,jr/128*100))}j.current=requestAnimationFrame(Bn)};Bn()}catch(ir){console.warn("Audio context not available:",ir)}}catch(ln){console.error("Camera initialization error:",ln),te(!1);let Zr="Failed to access camera or microphone.";ln.name==="NotAllowedError"?Zr="Camera permission denied. Please allow camera access in your browser settings.":ln.name==="NotFoundError"?Zr="No camera found. Please connect a camera and try again.":ln.name==="NotReadableError"?Zr="Camera is in use by another application. Please close other apps using the camera.":ln.message&&(Zr=ln.message),ft(Zr),(Hr=He.current)==null||Hr.call(He,Zr)}finally{Y(!1)}},[Ie,w,U]);k.useEffect(()=>{at.current!==U&&J&&!X&&!xe&&(at.current=U,hs())},[U,J,X,xe,hs]),k.useEffect(()=>(hs(),()=>{c.current&&c.current.getTracks().forEach(cr=>cr.stop()),g.current&&clearInterval(g.current),j.current&&cancelAnimationFrame(j.current),b.current&&b.current.close(),Se.current&&clearInterval(Se.current),xe&&URL.revokeObjectURL(xe),It()}),[hs,xe]),k.useEffect(()=>{if(V||J!==!0||xe)return;const cr=c.current,Qr=l.current;!cr||!Qr||Je||(Qr.srcObject!==cr&&(Qr.srcObject=cr,Qr.muted=!0,Qr.playsInline=!0,Qr.autoplay=!0,Qr.setAttribute("muted",""),Qr.setAttribute("playsinline",""),Qr.setAttribute("autoplay","")),Qr.play().then(()=>Ve(!1)).catch(Hr=>{Ve(!0),console.warn("Live preview play blocked on mount:",Hr)}))},[J,V,xe,Je]),k.useEffect(()=>{n==null||n(X)},[X,n]);const Yt=k.useCallback(async()=>{if(xe)return;const cr=l.current;if(cr)try{await cr.play(),Ve(!1)}catch(Qr){Ve(!0),console.warn("Live preview still blocked (needs user gesture):",Qr)}},[xe]),ts=k.useCallback(()=>{i.current&&i.current.state!=="inactive"&&i.current.stop(),g.current&&(clearInterval(g.current),g.current=null),It(),ce(!1),re(!1)},[It]),Ds=k.useCallback(async()=>{let cr=null;if(N==="screen"){if(cr=await Ut(),!cr)return}else cr=Je&&qe?qe:c.current;if(!cr)return;Yt(),f.current=[],we(0);const Hr=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"].find(Zr=>MediaRecorder.isTypeSupported(Zr)),ln=new MediaRecorder(cr,Hr?{mimeType:Hr,videoBitsPerSecond:N==="screen"?4e6:25e5}:{videoBitsPerSecond:N==="screen"?4e6:25e5});ln.ondataavailable=Zr=>{Zr.data.size>0&&f.current.push(Zr.data)},ln.onstop=()=>{var ir;const Zr=ln.mimeType||Hr||((ir=f.current[0])==null?void 0:ir.type)||"video/webm",yi=new Blob(f.current,{type:Zr});pe(yi);const pt=URL.createObjectURL(yi);_e(pt)},i.current=ln,ln.start(100),ce(!0),g.current=setInterval(()=>{we(Zr=>Zr>=t-1?(ts(),t):Zr+1)},1e3)},[Yt,t,ts,Je,qe,N,Ut]),vr=k.useCallback(()=>{Se.current&&(clearInterval(Se.current),Se.current=null),et(3);let cr=3;Se.current=setInterval(()=>{cr-=1,cr<=0?(Se.current&&clearInterval(Se.current),Se.current=null,et(null),Ds()):et(cr)},1e3)},[Ds]),Ct=k.useCallback(()=>{i.current&&i.current.state==="recording"&&(i.current.pause(),re(!0),g.current&&clearInterval(g.current))},[]),As=k.useCallback(()=>{i.current&&i.current.state==="paused"&&(i.current.resume(),re(!1),g.current=setInterval(()=>{we(cr=>cr>=t-1?(ts(),t):cr+1)},1e3))},[t,ts]),Us=k.useCallback(()=>{xe&&URL.revokeObjectURL(xe),pe(null),_e(null),we(0),Me(!1),ct(!0),l.current&&c.current&&!Je&&(l.current.srcObject=c.current,l.current.muted=!0,Yt())},[Yt,xe,Je]),kr=k.useCallback(()=>{Ne(cr=>cr==="user"?"environment":"user")},[]),ta=k.useCallback(()=>{le&&s(le,fe)},[le,fe,s]),ka=k.useCallback(()=>{l.current&&xe&&(Ce?l.current.pause():(ct(!1),l.current.muted=!1,l.current.play()),Me(!Ce))},[xe,Ce]);k.useEffect(()=>{if(!xe)return;const cr=l.current;if(!cr)return;ct(!1),cr.pause(),cr.removeAttribute("src"),cr.srcObject=null,cr.load(),cr.src=xe,cr.currentTime=0,cr.playsInline=!0,cr.muted=!1,cr.onended=()=>Me(!1);const Qr=()=>{var Zr;const Hr=cr.error,ln=Hr?`Recorded video failed to play (code ${Hr.code}). Likely unsupported format/codec in this browser.`:"Recorded video failed to play.";console.warn("[VideoRecorder] recorded playback error",Hr),(Zr=He.current)==null||Zr.call(He,ln)};return cr.addEventListener("error",Qr),cr.load(),()=>{cr.removeEventListener("error",Qr)}},[xe]);const Li=cr=>{const Qr=Math.floor(cr/60),Hr=cr%60;return`${Qr}:${Hr.toString().padStart(2,"0")}`},Wa=N==="screen"?"aspect-video":w&&U?"aspect-[9/16]":"aspect-video";return V?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Wa,a),children:e.jsxs("div",{className:"text-center text-white",children:[e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto mb-4"}),e.jsx("p",{children:"Initializing camera..."})]})}):J===!1?e.jsx("div",{className:Pt("flex items-center justify-center bg-black rounded-lg",Wa,a),children:e.jsxs("div",{className:"text-center text-white p-8 max-w-md",children:[e.jsx(Nl,{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:Pt("flex flex-col gap-2",a),children:[!X&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-1 p-1 bg-muted rounded-lg",children:[e.jsxs(K,{variant:N==="camera"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("camera"),children:[e.jsx(kx,{className:"h-4 w-4"}),"Camera"]}),e.jsxs(K,{variant:N==="screen"?"default":"ghost",size:"sm",className:"gap-1.5 flex-1",onClick:()=>C("screen"),children:[e.jsx(nS,{className:"h-4 w-4"}),"Screen"]})]}),N==="camera"&&!X&&!xe&&e.jsx(fws,{value:rt,onChange:Ge,isLoading:Ze,disabled:X}),N==="camera"&&w&&!X&&!xe&&e.jsxs("div",{className:"flex items-center justify-center gap-3 py-2 bg-muted/50 rounded-lg",children:[e.jsx(aS,{className:Pt("h-4 w-4",U?"text-muted-foreground":"text-primary")}),e.jsx(ye,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Landscape"}),e.jsx($r,{id:"orientation-toggle",checked:U,onCheckedChange:Qe}),e.jsx(ye,{htmlFor:"orientation-toggle",className:"text-sm text-muted-foreground",children:"Portrait"}),e.jsx(u1,{className:Pt("h-4 w-4",U?"text-primary":"text-muted-foreground")})]}),N==="screen"&&!X&&!xe&&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(nS,{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:Pt("relative bg-black rounded-lg overflow-hidden"),onPointerDown:()=>{Yt()},children:[e.jsx("video",{ref:l,src:xe??void 0,className:Pt("w-full bg-black",U&&!xe?"object-contain":"object-cover",Wa,!xe&&Ie==="user"!==(rt.mirror??!1)&&"scale-x-[-1]",Je&&!xe&&"hidden"),playsInline:!0,controls:!!xe,muted:xe?$e:!0,autoPlay:!xe},xe??"live"),Je&&!xe&&e.jsx("canvas",{ref:lt,className:Pt("w-full bg-black",U?"object-contain":"object-cover",Wa,Ie==="user"!==(rt.mirror??!1)&&"scale-x-[-1]")}),Je&&Ze&&!xe&&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(ws,{className:"h-8 w-8 animate-spin mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Loading virtual background…"})]})}),!xe&&me&&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 Yt(),className:"bg-white/20 hover:bg-white/30 text-white",children:"Tap to enable preview"})}),o&&!xe&&e.jsx("div",{className:"absolute inset-0 pointer-events-none",children:o}),nt!==null&&!xe&&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:nt},nt),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),X&&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:Pt("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:[Li(fe)," / ",Li(t)]})]}),X&&e.jsx("div",{className:"absolute top-0 left-0 right-0",children:e.jsx(Bi,{value:fe/t*100,className:"h-1 rounded-none"})}),!xe&&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(pL,{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:`${Ae}%`}})})]}),e.jsx("div",{className:"absolute bottom-4 left-0 right-0 flex justify-center gap-3 px-4",children:xe?e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"secondary",size:"lg",className:"bg-white/20 hover:bg-white/30 text-white",onClick:Us,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:ka,children:Ce?e.jsx(Dm,{className:"h-5 w-5"}):e.jsx(rl,{className:"h-5 w-5"})}),e.jsxs(K,{size:"lg",className:"bg-green-500 hover:bg-green-600 text-white",onClick:ta,children:[e.jsx(fa,{className:"h-5 w-5 mr-2"}),"Use This Video"]})]}):e.jsxs(e.Fragment,{children:[N==="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:kr,disabled:X||nt!==null,children:e.jsx(c1,{className:"h-5 w-5"})}):e.jsx("div",{className:"h-12 w-12"}),!X&&nt===null?e.jsx(K,{size:"icon",className:"h-16 w-16 rounded-full bg-red-500 hover:bg-red-600 text-white",onClick:N==="screen"?Ds:vr,children:N==="screen"?e.jsx(nS,{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?As:Ct,children:ne?e.jsx(rl,{className:"h-5 w-5"}):e.jsx(Dm,{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:ts,children:e.jsx(x0,{className:"h-6 w-6 fill-current"})})]}),e.jsx("div",{className:"h-12 w-12"})]})})]})]})}const tlt="teleprompter_settings",wye={scrollSpeed:30,fontSize:24,lineHeight:1.6,opacity:.85,position:"top",isMirrored:!1};function rjs(){try{const t=localStorage.getItem(tlt);return t?{...wye,...JSON.parse(t)}:wye}catch{return wye}}function njs(t){try{localStorage.setItem(tlt,JSON.stringify(t))}catch{}}function slt({text:t,isVisible:s,onToggleVisibility:r,isRecording:n=!1,startCountdown:a=!1,onCountdownComplete:o,className:l}){const i=k.useRef(null),c=k.useRef(null),u=k.useRef(0),p=k.useRef(0),[f,g]=k.useState(rjs),{scrollSpeed:b,fontSize:_,lineHeight:j,opacity:w,position:N,isMirrored:C}=f,M=k.useCallback((J,te)=>{g(X=>{const ce={...X,[J]:te};return njs(ce),ce})},[]),[I,L]=k.useState(!1),[R,q]=k.useState(null),U=k.useCallback(J=>{if(!i.current)return;u.current===0&&(u.current=J);const te=J-u.current;u.current=J,p.current+=b*te/1e3;const X=Math.floor(p.current);X>0&&(i.current.scrollTop+=X,p.current-=X);const{scrollTop:ce,scrollHeight:ne,clientHeight:re}=i.current;if(ce+re>=ne){L(!1);return}c.current=requestAnimationFrame(U)},[b]);k.useEffect(()=>(I?(u.current=0,p.current=0,c.current=requestAnimationFrame(U)):c.current&&cancelAnimationFrame(c.current),()=>{c.current&&cancelAnimationFrame(c.current)}),[I,U]),k.useEffect(()=>{if(n&&s)if(i.current&&(i.current.scrollTop=0),a){q(3);let J=3;const te=setInterval(()=>{J-=1,J<=0?(clearInterval(te),q(null),o==null||o(),L(!0)):q(J)},1e3);return()=>clearInterval(te)}else setTimeout(()=>L(!0),100);else n||(L(!1),q(null))},[n,s,a,o]);const B=k.useCallback(()=>{i.current&&(i.current.scrollTop=0),L(!1)},[]),V=k.useCallback(()=>{L(J=>!J)},[]);if(!s)return e.jsx("div",{className:Pt("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(qn,{className:"h-4 w-4 mr-2"}),"Show Script"]})});const Y={top:"top-0 pt-16",center:"top-1/2 -translate-y-1/2",bottom:"bottom-0 pb-24"};return e.jsxs("div",{className:Pt("absolute inset-0 pointer-events-none",l),children:[R!==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:R},R),e.jsx("p",{className:"text-white/80 text-lg font-medium drop-shadow-md",children:"Get ready…"})]})}),e.jsx("div",{className:Pt("absolute left-0 right-0 h-[60%] overflow-hidden pointer-events-auto",Y[N],R!==null&&"opacity-30"),style:{opacity:R!==null?.3:w},children:e.jsxs("div",{ref:i,className:Pt("mx-auto max-w-2xl px-6 overflow-y-auto scrollbar-hide h-full",C&&"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:j,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(Bo,{children:[e.jsx($o,{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(Yo,{className:"h-4 w-4"})})}),e.jsx(Do,{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(ye,{className:"text-xs",children:"Scroll Speed"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:b})]}),e.jsx(Wg,{value:[b],onValueChange:([J])=>M("scrollSpeed",J),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(ye,{className:"text-xs",children:"Font Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[_,"px"]})]}),e.jsx(Wg,{value:[_],onValueChange:([J])=>M("fontSize",J),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(ye,{className:"text-xs",children:"Line Spacing"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:j.toFixed(1)})]}),e.jsx(Wg,{value:[j*10],onValueChange:([J])=>M("lineHeight",J/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(ye,{className:"text-xs",children:"Opacity"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(w*100),"%"]})]}),e.jsx(Wg,{value:[w*100],onValueChange:([J])=>M("opacity",J/100),min:30,max:100,step:5})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-xs",children:"Position"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(K,{variant:N==="top"?"default":"outline",size:"sm",onClick:()=>M("position","top"),children:e.jsx(pf,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="center"?"default":"outline",size:"sm",onClick:()=>M("position","center"),children:e.jsx(m0,{className:"h-4 w-4"})}),e.jsx(K,{variant:N==="bottom"?"default":"outline",size:"sm",onClick:()=>M("position","bottom"),children:e.jsx(To,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-xs",children:"Mirror Mode"}),e.jsx($r,{checked:C,onCheckedChange:J=>M("isMirrored",J)})]})]})})]}),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:I?e.jsx(Dm,{className:"h-4 w-4"}):e.jsx(rl,{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(c1,{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 ajs({onSelectScript:t,onCreateNew:s,selectedScriptId:r,className:n}){const{toast:a}=qa(),[o,l]=k.useState(""),[i,c]=k.useState(null),[u,p]=k.useState("levelup"),{data:f,isLoading:g}=Ubs(),{data:b,isLoading:_}=Vbs(),{data:j,isLoading:w}=Hbs(),N=Wbs(),C=k.useMemo(()=>b?b.filter(q=>{const U=!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())||q.tags.some(V=>V.toLowerCase().includes(o.toLowerCase())),B=!i||q.category_id===i;return U&&B}):[],[b,o,i]),M=k.useMemo(()=>j?j.filter(q=>!o||q.title.toLowerCase().includes(o.toLowerCase())||q.script_text.toLowerCase().includes(o.toLowerCase())):[],[j,o]),I=q=>{t({title:q.title,text:q.script_text})},L=async q=>{try{await N.mutateAsync(q),a({title:"Script saved to My Scripts"})}catch{a({title:"Failed to save script",variant:"destructive"})}},R=g||_||w;return e.jsxs("div",{className:Pt("flex flex-col h-full",n),children:[e.jsx("div",{className:"p-4 border-b",children:e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:q=>l(q.target.value),className:"pl-9"})]})}),e.jsxs(ja,{value:u,onValueChange:q=>p(q),className:"flex-1 flex flex-col",children:[e.jsxs(ga,{className:"mx-4 mt-4 grid grid-cols-2",children:[e.jsxs(us,{value:"levelup",children:[e.jsx(En,{className:"h-4 w-4 mr-2"}),"LevelUp Scripts"]}),e.jsxs(us,{value:"my-scripts",children:[e.jsx(Nx,{className:"h-4 w-4 mr-2"}),"My Scripts"]})]}),e.jsxs(ks,{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(tt,{variant:i?"outline":"default",className:"cursor-pointer",onClick:()=>c(null),children:"All"}),f==null?void 0:f.map(q=>e.jsx(tt,{variant:i===q.id?"default":"outline",className:"cursor-pointer",onClick:()=>c(q.id),children:q.name},q.id))]}),e.jsx(Gi,{className:"flex-1 max-h-[50vh]",children:R?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(En,{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:C.map(q=>e.jsxs(Pe,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>I(q),children:[e.jsx(Dt,{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(zt,{className:"text-sm font-medium truncate",children:q.title}),q.category&&e.jsx(tt,{variant:"secondary",className:"mt-1 text-xs",children:q.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(),L(q)},children:e.jsx(Nx,{className:"h-4 w-4"})}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]})]})}),e.jsx(Re,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]}),e.jsxs(ks,{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(Gi,{className:"flex-1 max-h-[50vh]",children:w?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(ws,{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(Nx,{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(q=>e.jsxs(Pe,{className:Pt("cursor-pointer hover:bg-accent/50 transition-colors",r===q.id&&"ring-2 ring-primary"),onClick:()=>I(q),children:[e.jsx(Dt,{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(zt,{className:"text-sm font-medium truncate",children:q.title}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:q.is_custom?e.jsx(tt,{variant:"outline",className:"text-xs",children:"Custom"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Saved"})})]}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground ml-2"})]})}),e.jsx(Re,{className:"p-3 pt-0",children:e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:q.script_text})})]},q.id))})})]})]})]})}function ijs({selectedTemplate:t,onSelect:s,contactName:r,saving:n=!1}){const[a,o]=k.useState(()=>{const i=YM(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(ye,{className:"text-sm font-medium",children:"Share Page Template"}),n&&e.jsx(ws,{className:"h-3 w-3 animate-spin text-muted-foreground"})]}),e.jsx("div",{className:"space-y-3",children:MIt.map(i=>{const c=TIt(i.id),u=a.has(i.id),p=c.some(f=>f.id===t);return e.jsxs(gf,{open:u,onOpenChange:()=>l(i.id),children:[e.jsxs(yf,{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(To,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",u&&"rotate-180")})]}),e.jsx(vf,{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:Pt("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(fa,{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: "',YM(t).headerText(r),'"']})]})}function rlt({open:t,onOpenChange:s,video:r,contactName:n,onTemplateUpdated:a}){const[o,l]=k.useState(r.page_template||"default"),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState(r.page_template||"default"),[b,_]=k.useState([]),[j,w]=k.useState(r.contact_id&&n?{id:r.contact_id,name:n,email:null}:null),[N,C]=k.useState(!1),[M,I]=k.useState(!1),L=r.share_token?`https://video.relevelup.com/${r.share_token}`:"";k.useEffect(()=>{t&&b.length===0&&R()},[t]);const R=async()=>{I(!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(le=>({id:le.id,name:[le.first_name,le.last_name].filter(Boolean).join(" ")||"Unnamed",email:le.email||null}));_(re)}catch(ce){console.error("Failed to fetch contacts:",ce)}finally{I(!1)}},q=async ce=>{w(ce),C(!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;he.success(ce?`Assigned to ${ce.name}`:"Contact removed"),a==null||a()}catch(ne){console.error("Failed to update contact:",ne),he.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),he.success("Template saved!"),a==null||a()}catch(ne){console.error("Failed to save template:",ne),he.error("Failed to save template"),l(f)}finally{c(!1)}},B=(j==null?void 0:j.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``},Y=async()=>{if(!r.thumbnail_url){he.error("Video thumbnail not available yet");return}const ce=V(),ne=`Watch: ${r.title||"Video Message"} ${L}`;try{const re=new Blob([ce],{type:"text/html"}),le=new Blob([ne],{type:"text/plain"}),pe=new ClipboardItem({"text/html":re,"text/plain":le});await navigator.clipboard.write([pe]),he.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ne+` `+ce),he.success("Copied! Paste into your email.")}},J=async()=>{await navigator.clipboard.writeText(L),p(!0),he.success("Share link copied!"),setTimeout(()=>p(!1),2e3)},te=()=>{const ne=YM(o).headerText(B),re=o==="default"?`Check out this video: ${L}`:`${ne} Check out this special video: ${L}`;window.open(`sms:?body=${encodeURIComponent(re)}`,"_self")},X=()=>{const ce=YM(o),ne=ce.headerText(B),re=o==="default"?r.title||"Video Message":ne,le=`${ce.subText} Watch the video: ${L}`,pe=j!=null&&j.email?encodeURIComponent(j.email):"";window.open(`mailto:${pe}?subject=${encodeURIComponent(re)}&body=${encodeURIComponent(le)}`,"_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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(zo,{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(ye,{className:"text-sm font-medium",children:"Personalize for Contact (Optional)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bo,{open:N,onOpenChange:C,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":N,className:"flex-1 justify-between",disabled:i,children:[j?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),j.name]}):e.jsx("span",{className:"text-muted-foreground",children:"Select a contact..."}),e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[300px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:M?"Loading...":"No contacts found."}),e.jsx(Fx,{children:b.map(ce=>e.jsxs(vp,{value:ce.name,onSelect:()=>q(ce),children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",(j==null?void 0:j.id)===ce.id?"opacity-100":"opacity-0")}),ce.name]},ce.id))})]})]})})]}),j&&e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>q(null),disabled:i,className:"shrink-0",children:e.jsx(Or,{className:"h-4 w-4"})})]}),j&&o!=="default"&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:['Page will show: "',YM(o).headerText(j.name),'"']})]}),e.jsx(ijs,{selectedTemplate:o,onSelect:U,contactName:B,saving:i}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Share Link"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:L,readOnly:!0,className:"font-mono text-sm"}),e.jsx(K,{onClick:J,variant:u?"default":"outline",className:"shrink-0 gap-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-4 w-4"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(gi,{className:"h-4 w-4"}),"Copy"]})})]})]}),r.thumbnail_url&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Share for Email"}),e.jsxs(K,{variant:"outline",className:"w-full gap-2",onClick:Y,children:[e.jsx(fl,{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(ye,{children:"Quick Share"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:te,children:[e.jsx(io,{className:"h-4 w-4"}),"Text"]}),e.jsxs(K,{variant:"outline",className:"flex-1 gap-2",onClick:X,children:[e.jsx(dr,{className:"h-4 w-4"}),"Email"]})]})]})]}),e.jsx(zn,{children:e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Done"})})]})})}function ojs(){var et;const t=pr(),[s]=qc(),{toast:r}=qa(),n=s.get("contact_id"),a=s.get("task_id"),{canRecord:o,remainingMb:l,usagePercent:i,isNearLimit:c}=zat(),{data:u}=Wm(),p=_C(),f=Xbs(),[g,b]=k.useState("record"),[_,j]=k.useState(""),[w,N]=k.useState(!1),[C,M]=k.useState(!1),[I,L]=k.useState(!1),[R,q]=k.useState(null),[U,B]=k.useState(0),[V,Y]=k.useState(0),[J,te]=k.useState(null),[X,ce]=k.useState(null),[ne,re]=k.useState(n||""),[le,pe]=k.useState(""),[xe,_e]=k.useState(""),[fe,we]=k.useState(null),[Ie,Ne]=k.useState(null),[Ae,Fe]=k.useState(null),[Ce,Me]=k.useState(!1),$e=k.useCallback(async(Se,rt)=>{q(Se),b("uploading");try{const{videoId:Ge,uploadUrl:lt}=await hR(le||"Quick Video Touch");te(Ge);const{apiKey:qe}=await mR(Ge),Ze=new XMLHttpRequest;Ze.upload.onprogress=at=>{at.lengthComputable&&B(at.loaded/at.total*100)},await new Promise((at,It)=>{Ze.onload=()=>{Ze.status>=200&&Ze.status<300?at():It(new Error(`Upload failed: ${Ze.status}`))},Ze.onerror=()=>It(new Error("Upload failed")),Ze.open("PUT",lt),Ze.setRequestHeader("AccessKey",qe),Ze.send(Se)}),b("processing");let Je=0;const He=Date.now(),Qe=90*1e3;for(;Je<4;){if(await new Promise(It=>setTimeout(It,3e3)),Date.now()-He>Qe){const It=Se.size/1048576,Ut=`https://iframe.mediadelivery.net/play/${Ge}/${Ge}`;await p.mutateAsync({bunny_video_id:Ge,playback_url:Ut,file_size_mb:It,title:le||"Quick Video Touch",notes:xe||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 at=await bA(Ge);if(Je=at.status,Y(at.encodeProgress||0),Je===4)ce({playbackUrl:at.directPlayUrl,thumbnailUrl:at.thumbnailUrl,previewUrl:at.previewUrl||null,duration:at.length||rt,fileSizeMb:(at.storageSize||Se.size)/(1024*1024)});else if(Je===5||Je===6)throw new Error("Video processing failed")}b("details")}catch(Ge){console.error("Upload error:",Ge),r({title:"Upload failed",description:"Please try recording again.",variant:"destructive"}),b("record")}},[le,r]),ct=async()=>{if(!(!J||!X))try{const Se=ne&&ne!=="none"?ne:null,rt=await p.mutateAsync({bunny_video_id:J,contact_id:Se,playback_url:X.playbackUrl,thumbnail_url:X.thumbnailUrl,preview_url:X.previewUrl,duration_seconds:X.duration,file_size_mb:X.fileSizeMb,title:le||"Quick Video Touch",notes:xe,task_id:a||null,status:"ready"});we(rt.id),Ne(rt.share_token||null),Se&&await f.mutateAsync({contactId:Se,videoId:rt.id,notes:xe}),r({title:"Video saved successfully!"}),b("share")}catch(Se){console.error("Save video error:",Se),r({title:"Failed to save video",description:(Se==null?void 0:Se.message)||"Please try again.",variant:"destructive"})}},Te=(Se,rt)=>{navigator.clipboard.writeText(rt),Fe(Se),setTimeout(()=>Fe(null),2e3),r({title:"Copied to clipboard!"})},ft=()=>Ie?`https://video.relevelup.com/${Ie}`:(X==null?void 0:X.playbackUrl)||"",me=()=>{const Se=u==null?void 0:u.find(Ze=>Ze.id===ne),rt=Se?`${Se.first_name}`:"",Ge=(Se==null?void 0:Se.phone)||"",lt=(Se==null?void 0:Se.email)||"",qe=ft();return{text:`Hey${rt?` ${rt}`:""}! I recorded a quick video for you: ${qe}`,link:qe,contactPhone:Ge,contactEmail:lt}},Ve=()=>{const{text:Se,contactPhone:rt}=me(),Ge=rt?`sms:${rt}?body=${encodeURIComponent(Se)}`:`sms:?body=${encodeURIComponent(Se)}`;window.open(Ge,"_self")},nt=()=>{const{link:Se,contactEmail:rt}=me(),Ge="Check out this video",lt=`I recorded a quick video for you: ${Se}`,qe=rt?`mailto:${rt}?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(lt)}`:`mailto:?subject=${encodeURIComponent(Ge)}&body=${encodeURIComponent(lt)}`;window.open(qe,"_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(ri,{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(En,{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(fme,{maxDurationSeconds:60,onRecordingComplete:$e,onRecordingStateChange:L,className:"w-full",teleprompterContent:w&&_&&e.jsx(slt,{text:_,isVisible:w,onToggleVisibility:()=>N(!1),isRecording:I,startCountdown:!0})}),!w&&_&&e.jsxs(K,{variant:"outline",className:"mt-4",onClick:()=>N(!0),children:[e.jsx(En,{className:"h-4 w-4 mr-2"}),"Show Teleprompter"]})]}),e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-lg",children:"Teleprompter Script"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(Er,{placeholder:"Type or paste your script here...",value:_,onChange:Se=>j(Se.target.value),rows:6}),e.jsxs(QA,{open:C,onOpenChange:M,children:[e.jsx(Jje,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:"w-full",children:[e.jsx(En,{className:"h-4 w-4 mr-2"}),"Browse Scripts"]})}),e.jsxs(mC,{side:"right",className:"w-[400px] sm:w-[540px] p-0",children:[e.jsx(JA,{className:"p-4 border-b",children:e.jsx(eE,{children:"Select a Script"})}),e.jsx(ajs,{onSelectScript:Se=>{j(Se.text),M(!1),N(!0)},className:"h-[calc(100vh-80px)]"})]})]}),_&&e.jsx(K,{className:"w-full",onClick:()=>N(!0),children:"Use Script"})]})]})]}),g==="uploading"&&e.jsx(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Re,{className:"pt-6 text-center",children:[e.jsx(oi,{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(Pe,{className:"max-w-md mx-auto",children:e.jsxs(Re,{className:"pt-6 text-center space-y-4",children:[e.jsx(ws,{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(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Video Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(ze,{value:le,onChange:Se=>pe(Se.target.value),placeholder:"Quick Video Touch"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Attach to Contact (Optional)"}),e.jsxs(Ys,{value:ne,onValueChange:re,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"No contact - use anywhere"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(zo,{className:"h-4 w-4"}),"No contact - use anywhere"]})}),u==null?void 0:u.map(Se=>e.jsx(Mt,{value:Se.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"}),Se.first_name," ",Se.last_name]})},Se.id))]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Er,{value:xe,onChange:Se=>_e(Se.target.value),placeholder:"Add notes about this video...",rows:3})]}),e.jsxs(K,{className:"w-full",onClick:ct,disabled:p.isPending,children:[p.isPending&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Save Video"]})]})]}),g==="share"&&e.jsxs(Pe,{className:"max-w-lg mx-auto",children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(fa,{className:"h-5 w-5 text-green-500"}),"Video Saved!"]})}),e.jsxs(Re,{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:Ve,children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:nt,children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Te("link",me().link),children:[e.jsx(zo,{className:"h-4 w-4 mr-2"}),"Copy Video Link",Ae==="link"&&e.jsx(fa,{className:"h-4 w-4 ml-auto text-green-500"})]}),e.jsxs(K,{variant:"outline",className:"justify-start",onClick:()=>Me(!0),children:[e.jsx(sc,{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:()=>{b("record"),q(null),te(null),ce(null)},children:"Record Another"})]})]})]}),fe&&Ie&&e.jsx(rlt,{open:Ce,onOpenChange:Me,video:{id:fe,share_token:Ie,title:le||null,contact_id:ne||null,thumbnail_url:(X==null?void 0:X.thumbnailUrl)||null},contactName:((et=u==null?void 0:u.find(Se=>Se.id===ne))==null?void 0:et.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(Gu,{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 ljs({open:t,onOpenChange:s}){const{data:r}=Wm(),{data:n}=Uhe(),a=_C(),o=k.useRef(null),[l,i]=k.useState(null),[c,u]=k.useState(""),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState(!1),[w,N]=k.useState(0),[C,M]=k.useState("idle"),I=(n==null?void 0:n.total_storage_mb)||0,R=((n==null?void 0:n.max_storage_mb)||1024)-I,q=Y=>{var X;const J=(X=Y.target.files)==null?void 0:X[0];if(!J)return;if(!J.type.startsWith("video/")){he.error("Please select a video file");return}const te=J.size/(1024*1024);if(te>500){he.error("Video file must be less than 500MB");return}if(te>R){he.error(`Not enough storage. You have ${R.toFixed(1)} MB remaining.`);return}i(J),c||u(J.name.replace(/\.[^/.]+$/,""))},U=async()=>{if(!l){he.error("Please select a video file");return}j(!0),N(0),M("creating");try{const{data:Y,error:J}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:c||l.name,isAgentVideo:!0}});if(J)throw new Error(J.message);const{videoId:te,libraryId:X}=Y;M("uploading");const{data:ce,error:ne}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:te,isAgentVideo:!0}});if(ne)throw new Error(ne.message);await new Promise((pe,xe)=>{const _e=new XMLHttpRequest;_e.upload.addEventListener("progress",fe=>{if(fe.lengthComputable){const we=Math.round(fe.loaded/fe.total*100);N(we)}}),_e.addEventListener("load",()=>{_e.status>=200&&_e.status<300?pe():xe(new Error(`Upload failed with status ${_e.status}`))}),_e.addEventListener("error",()=>xe(new Error("Upload failed"))),_e.open("PUT",ce.uploadUrl),_e.setRequestHeader("AccessKey",ce.apiKey),_e.send(l)}),M("processing");const re=l.size/(1024*1024),le=`https://iframe.mediadelivery.net/embed/${X}/${te}`;await a.mutateAsync({bunny_video_id:te,playback_url:le,file_size_mb:re,title:c||l.name,notes:p||void 0,contact_id:g||void 0,status:"processing",touch_type:"video_upload"}),he.success("Video uploaded successfully! Processing may take a few minutes."),B()}catch(Y){console.error("Upload error:",Y),he.error(Y instanceof Error?Y.message:"Failed to upload video")}finally{j(!1),M("idle")}},B=()=>{_||(i(null),u(""),f(""),b(""),N(0),M("idle"),s(!1))},V=()=>{switch(C){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${w}%`;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(_s,{children:[e.jsx(bs,{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(ye,{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:Y=>{Y.stopPropagation(),i(null)},children:e.jsx(Or,{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 Y;return(Y=o.current)==null?void 0:Y.click()},children:[e.jsx(oi,{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:q,disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"title",children:"Title"}),e.jsx(ze,{id:"title",value:c,onChange:Y=>u(Y.target.value),placeholder:"Enter video title",disabled:_})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Associate with Contact (optional)"}),e.jsxs(Ys,{value:g||"__none__",onValueChange:Y=>b(Y==="__none__"?"":Y),disabled:_,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a contact"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"__none__",children:"No contact"}),r==null?void 0:r.map(Y=>e.jsxs(Mt,{value:Y.id,children:[Y.first_name," ",Y.last_name||""]},Y.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"notes",children:"Notes (optional)"}),e.jsx(Er,{id:"notes",value:p,onChange:Y=>f(Y.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(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:V()})]}),e.jsx(Bi,{value:C==="uploading"?w:C==="processing"?100:10})]})]}),e.jsxs(zn,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Upload Video"]})})]})]})})}function cjs(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 djs(){const{user:t}=Rs();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 ujs(){const{user:t}=Rs();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 hjs(){const{user:t}=Rs(),s=es();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 mjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=open`}function pjs(t){return`https://relzejiswnotikjgvjhz.supabase.co/functions/v1/track-video-share?t=${t}&e=click`}function fjs({open:t,onOpenChange:s,video:r,gmailEmail:n,signedThumbnailUrl:a,onSendComplete:o}){const[l,i]=k.useState([]),[c,u]=k.useState(null),[p,f]=k.useState(!1),[g,b]=k.useState(!1),[_,j]=k.useState(""),[w,N]=k.useState(""),[C,M]=k.useState(""),[I,L]=k.useState(!1),R=hjs(),q=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";k.useEffect(()=>{t&&l.length===0&&V()},[t]),k.useEffect(()=>{if(t&&(N(`I recorded a video for you — ${B}`),M("Hey! I recorded a quick video just for you. Click below to watch it:"),u(null),j(""),r.contact_id)){const ne=l.find(re=>re.id===r.contact_id);ne&&(u(ne),j(ne.email||""))}},[t,r.contact_id,l]);const V=async()=>{b(!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{b(!1)}},Y=ne=>{u(ne),f(!1),j(ne.email||""),M(`Hey ${ne.first_name}! I recorded a quick video just for you. Click below to watch it:`),N(`I recorded a video for you — ${B}`)},J=()=>{u(null),j(""),M("Hey! I recorded a quick video just for you. Click below to watch it:")},te=ne=>`${ne.first_name} ${ne.last_name||""}`.trim(),X=ne=>{const re=C.split(/\n\n+/).map(xe=>`

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

`).join(""),le=ne?pjs(ne):q,pe=ne?``:"";return`
${re}

▶ Watch Video

${pe}
`},ce=async()=>{if(!_){he.error("Please enter a recipient email");return}if(!q){he.error("Video does not have a share link");return}L(!0);try{let ne;try{const xe=c?te(c):_.split("@")[0];ne=(await R.mutateAsync({video_id:r.id,recipient_email:_,recipient_name:xe,contact_id:(c==null?void 0:c.id)||null,sent_via:"gmail"})).share_token}catch(xe){console.warn("Failed to create tracking record, sending without tracking:",xe)}const re=X(ne),{data:le,error:pe}=await H.functions.invoke("gmail-send",{body:{to:_,subject:w,body:re,contactId:(c==null?void 0:c.id)||null}});if(pe)throw pe;if(!(le!=null&&le.success))throw new Error((le==null?void 0:le.error)||"Failed to send");he.success("Video email sent!"),s(!1),o==null||o()}catch(ne){console.error("Gmail send error:",ne),he.error("Failed to send: "+(ne instanceof Error?ne.message:"Unknown error"))}finally{L(!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(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(dr,{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(ye,{children:"Send to Contact"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(Bo,{open:p,onOpenChange:f,children:[e.jsx($o,{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(to,{className:"h-4 w-4 text-muted-foreground"}),te(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(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[350px] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:g?"Loading...":"No contacts found."}),e.jsx(Fx,{children:l.filter(ne=>ne.email).map(ne=>e.jsxs(vp,{value:`${ne.first_name} ${ne.last_name||""} ${ne.email||""}`,onSelect:()=>Y(ne),children:[e.jsx(fa,{className:Pt("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:te(ne)}),e.jsx("div",{className:"text-xs text-muted-foreground",children:ne.email})]})]},ne.id))})]})]})})]}),c&&e.jsx(K,{variant:"ghost",size:"icon",onClick:J,className:"shrink-0",children:e.jsx(Or,{className:"h-4 w-4"})})]})]}),!c&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-to",children:"Or type email address"}),e.jsx(ze,{id:"video-to",value:_,onChange:ne=>j(ne.target.value),placeholder:"recipient@example.com",type:"email"})]}),e.jsx(sl,{}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-subject",children:"Subject"}),e.jsx(ze,{id:"video-subject",value:w,onChange:ne=>N(ne.target.value)})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{htmlFor:"video-message",children:"Personal Message"}),e.jsx(Er,{id:"video-message",value:C,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(ye,{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(rl,{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(rl,{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:I,children:"Cancel"}),e.jsxs(K,{onClick:ce,disabled:I||!_||!w,className:"gap-2",children:[I?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"}),I?"Sending...":"Send Video Email"]})]})]})]})})}const xjs=()=>{const{user:t}=Rs();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 gjs({recipient:t}){return t.watched_at?e.jsxs(tt,{className:"bg-emerald-100 text-emerald-800 text-[10px]",children:[e.jsx(rl,{className:"h-2.5 w-2.5 mr-0.5"}),"Watched"]}):t.clicked_at?e.jsxs(tt,{className:"bg-blue-100 text-blue-800 text-[10px]",children:[e.jsx(bh,{className:"h-2.5 w-2.5 mr-0.5"}),"Clicked"]}):t.opened_at?e.jsxs(tt,{className:"bg-amber-100 text-amber-800 text-[10px]",children:[e.jsx(qn,{className:"h-2.5 w-2.5 mr-0.5"}),"Opened"]}):e.jsxs(tt,{variant:"outline",className:"text-[10px]",children:[e.jsx(Rn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]})}function yjs({open:t,onOpenChange:s,videoId:r,videoTitle:n}){const{data:a=[],isLoading:o}=cjs(r);return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-2xl max-h-[80vh]",children:[e.jsx(_s,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Ro,{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(Gi,{className:"h-[400px]",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Recipient"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Sent"}),e.jsx(kt,{children:"Last Activity"})]})}),e.jsx(On,{children:a.map(l=>e.jsxs(Ss,{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(gjs,{recipient:l})}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:ps(new Date(l.sent_at),"MMM d, h:mm a")}),e.jsx(dt,{className:"text-xs text-muted-foreground",children:l.last_activity_at?_d(new Date(l.last_activity_at),{addSuffix:!0}):"—"})]},l.id))})]})})]})]})})}function vjs(){const{data:t,isLoading:s}=djs(),{data:r=[],isLoading:n}=ujs(),[a,o]=k.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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(vs,{className:"h-4 w-20"})}),e.jsx(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Total Sent"}),e.jsx(Rn,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Re,{children:e.jsx("div",{className:"text-2xl font-bold",children:(t==null?void 0:t.totalSent)||0})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Open Rate"}),e.jsx(qn,{className:"h-4 w-4 text-amber-500"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:"Click Rate"}),e.jsx(bh,{className:"h-4 w-4 text-blue-500"})]}),e.jsxs(Re,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{className:"text-sm font-medium",children:"Send History by Video"}),e.jsx(xr,{children:"Click a video to see individual recipient tracking"})]}),e.jsx(Re,{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(Rn,{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(qn,{className:"h-3 w-3"})," ",u]}),e.jsxs("span",{className:"text-xs text-blue-600 flex items-center gap-1",children:[e.jsx(bh,{className:"h-3 w-3"})," ",p]})]})]}),e.jsx(Ol,{className:"h-4 w-4 text-muted-foreground"})]},c.videoId)})})})]}),e.jsx(yjs,{open:!!a,onOpenChange:c=>!c&&o(null),videoId:(a==null?void 0:a.id)||null,videoTitle:(a==null?void 0:a.title)||""})]})}function bjs({previewSrc:t,thumbnailSrc:s,alt:r,isHovered:n}){const[a,o]=k.useState(!1),[l,i]=k.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 _js({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:b,getShareUrl:_,copyToClipboard:j,formatDuration:w}){const[N,C]=k.useState(!1);return e.jsxs(Pe,{className:"overflow-hidden group cursor-pointer",onClick:n,onMouseEnter:()=>C(!0),onMouseLeave:()=>C(!1),children:[e.jsxs("div",{className:"relative aspect-video bg-muted overflow-hidden",children:[e.jsx(bjs,{previewSrc:s,thumbnailSrc:r,alt:t.title||"Video preview",isHovered:N}),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(rl,{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:w(t.duration_seconds)}),t.status!=="ready"&&e.jsx(tt,{variant:t.status==="processing"?"secondary":"destructive",className:"absolute top-2 left-2",children:t.status})]}),e.jsx(Re,{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(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(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(mn,{className:"h-3 w-3"}),e.jsx("span",{children:ps(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(qn,{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(dr,{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(to,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:b(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(mn,{className:"h-3 w-3"}),e.jsx("span",{children:ps(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(qn,{className:"h-3 w-3"}),e.jsxs("span",{children:[t.view_count," ",t.view_count===1?"view":"views"]})]})]})]}),e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:M=>M.stopPropagation(),children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",className:"bg-popover",children:[e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),n()},children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),"Watch"]}),e.jsx(lw,{}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),p()},children:[e.jsx(sc,{className:"h-4 w-4 mr-2"}),"Share with Template"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),j(_(t),"Share link")},children:[e.jsx(zo,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),i()},children:[e.jsx(K4,{className:"h-4 w-4 mr-2"}),"Get Embed Code"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),c()},children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),u()},children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),g&&t.share_token&&e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),f==null||f()},children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Send via Gmail"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),o()},children:[e.jsx(Da,{className:"h-4 w-4 mr-2"}),"Rename"]}),e.jsx(lw,{}),t.contact_id&&e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),l()},children:[e.jsx(to,{className:"h-4 w-4 mr-2"}),"View Contact"]}),e.jsxs(Ca,{onClick:M=>{M.stopPropagation(),a()},className:"text-destructive",children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})]})})]})}function wjs(){var at,It;const t=pr(),{data:s,isLoading:r,refetch:n}=Gbs(),{data:a}=Uhe(),{data:o}=Wm(),l=Ybs(),i=Zbs(),{isGmailConnected:c,gmailEmail:u}=$0(),{data:p}=Bx(),{data:f=[],isLoading:g}=xjs(),[b,_]=k.useState("my"),[j,w]=k.useState(""),[N,C]=k.useState(null),[M,I]=k.useState(!1),[L,R]=k.useState(!1),[q,U]=k.useState(!1),[B,V]=k.useState(!1),[Y,J]=k.useState(!1),[te,X]=k.useState(""),[ce,ne]=k.useState(!1),[re,le]=k.useState(!1),[pe,xe]=k.useState(!1),[_e,fe]=k.useState(!1),[we,Ie]=k.useState(""),[Ne,Ae]=k.useState({}),Fe=Ut=>{if(!Ut)return"Unassigned";const hs=o==null?void 0:o.find(Yt=>Yt.id===Ut);return hs?`${hs.first_name} ${hs.last_name||""}`.trim():"Unknown"},Ce=Ut=>{if(!Ut)return"0:00";const hs=Math.floor(Ut/60),Yt=Ut%60;return`${hs}:${Yt.toString().padStart(2,"0")}`},Me=s==null?void 0:s.filter(Ut=>{if(!j)return!0;const hs=Fe(Ut.contact_id).toLowerCase(),Yt=(Ut.title||"").toLowerCase(),ts=(Ut.notes||"").toLowerCase();return hs.includes(j.toLowerCase())||Yt.includes(j.toLowerCase())||ts.includes(j.toLowerCase())}),[$e,ct]=k.useState(!1);k.useEffect(()=>{if($e)return;(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(ts=>ts.status==="processing"&&ts.bunny_video_id);if(!hs.length)return;let Yt=!1;for(const ts of hs)try{const{data:Ds,error:vr}=await H.functions.invoke("bunny-upload",{body:{action:"status",videoId:ts.bunny_video_id,isAgentVideo:!0}});if(vr||!Ds)continue;Ds.status===4&&(await H.from("agent_videos").update({status:"ready",playback_url:Ds.directPlayUrl,thumbnail_url:Ds.thumbnailUrl,preview_url:Ds.previewUrl,duration_seconds:Ds.length||ts.duration_seconds,updated_at:new Date().toISOString()}).eq("id",ts.id),Yt=!0)}catch(Ds){console.warn("Reconcile check failed for video",ts.id,Ds)}ct(!0),Yt&&n()})()},[s,$e,n]),k.useEffect(()=>{(async()=>{if(!(s!=null&&s.length))return;const hs=s.filter(Ct=>(Ct==null?void 0:Ct.bunny_video_id)&&!Ne[Ct.id]);if(!hs.length)return;const Yt=hs.map(Ct=>Ct.bunny_video_id),{data:ts,error:Ds}=await H.functions.invoke("bunny-upload",{body:{action:"bulk-asset-urls",videoIds:Yt,isAgentVideo:!0}});if(Ds)throw Ds;const vr=(ts==null?void 0:ts.assets)||{};Ae(Ct=>{const As={...Ct};for(const Us of hs)vr[Us.bunny_video_id]&&(As[Us.id]={previewUrl:vr[Us.bunny_video_id].previewUrl,thumbnailUrl:vr[Us.bunny_video_id].thumbnailUrl});return As})})().catch(hs=>console.warn("Failed to load signed Bunny asset URLs",hs))},[s,Ne]);const Te=(a==null?void 0:a.total_storage_mb)||0,ft=(a==null?void 0:a.max_storage_mb)||1024,me=Te/ft*100,Ve=me>=80,nt=me>=100,et=async(Ut,hs)=>{await navigator.clipboard.writeText(Ut),he.success(`${hs} copied to clipboard`)},Se=Ut=>Ut.share_token?`https://video.relevelup.com/${Ut.share_token}`:Ut.playback_url||"",rt=Ut=>{const hs=Se(Ut),Yt=o==null?void 0:o.find(Us=>Us.id===Ut.contact_id),ts=Fe(Ut.contact_id),Ds=ts!=="Unassigned"?ts.split(" ")[0]:"",vr=(Yt==null?void 0:Yt.phone)||"",Ct=`Hey${Ds?` ${Ds}`:""}! I recorded a quick video message for you. Check it out: ${hs}`,As=vr?`sms:${vr}?body=${encodeURIComponent(Ct)}`:`sms:?body=${encodeURIComponent(Ct)}`;window.open(As,"_self")},Ge=Ut=>{const hs=o==null?void 0:o.find(As=>As.id===Ut.contact_id),Yt=(hs==null?void 0:hs.email)||"",ts=Se(Ut),Ds="Check out this video",vr=`I recorded a quick video for you: ${ts}`,Ct=Yt?`mailto:${Yt}?subject=${encodeURIComponent(Ds)}&body=${encodeURIComponent(vr)}`:`mailto:?subject=${encodeURIComponent(Ds)}&body=${encodeURIComponent(vr)}`;window.open(Ct,"_self")},lt=Ut=>{var Ds;const hs=Se(Ut),Yt=Ut.title||"Video Message",ts=Ut.share_token?`https://video.relevelup.com/thumb/${Ut.share_token}`:((Ds=Ne[Ut.id])==null?void 0:Ds.thumbnailUrl)||Ut.thumbnail_url||"";return``},qe=async Ut=>{if(!Ut.thumbnail_url&&!Ut.share_token){he.error("Video thumbnail not available yet");return}const hs=lt(Ut),Yt=Se(Ut),ts=`Watch: ${Ut.title||"Video Message"} ${Yt}`;try{const Ds=new Blob([hs],{type:"text/html"}),vr=new Blob([ts],{type:"text/plain"}),Ct=new ClipboardItem({"text/html":Ds,"text/plain":vr});await navigator.clipboard.write([Ct]),he.success("Copied! Paste into Gmail - the thumbnail will appear after sending.")}catch{await navigator.clipboard.writeText(ts+` `+hs),he.success("Copied! Paste into your email.")}},Ze=async Ut=>{try{he.loading("Preparing download...",{id:"download"});const{data:hs,error:Yt}=await H.functions.invoke("bunny-upload",{body:{action:"download-url",videoId:Ut.bunny_video_id,isAgentVideo:!0}});if(Yt||!(hs!=null&&hs.downloadUrl))throw new Error((Yt==null?void 0:Yt.message)||"Failed to get download URL");const Ds=`${((Ut.title||"video").toString().trim()||"video").replace(/[\\/:*?"<>|]+/g,"-")}.mp4`,vr=await fetch(hs.downloadUrl);if(!vr.ok)throw new Error("Failed to fetch video file");const Ct=await vr.blob(),As=URL.createObjectURL(Ct),Us=document.createElement("a");Us.href=As,Us.download=Ds,Us.rel="noreferrer",document.body.appendChild(Us),Us.click(),Us.remove(),URL.revokeObjectURL(As),he.success("Download started",{id:"download"})}catch(hs){console.error("Download error:",hs),he.error("Could not force download (your browser may block it).",{id:"download"})}},Je=async Ut=>{C(Ut),ne(!0),X(""),J(!0);try{const{data:hs,error:Yt}=await H.functions.invoke("bunny-upload",{body:{action:"crm-embed",videoId:Ut.bunny_video_id,title:Ut.title,isAgentVideo:!0,shareToken:Ut.share_token}});if(Yt||!(hs!=null&&hs.html))throw new Error("Failed to generate CRM embed code");X(hs.html)}catch(hs){console.error("CRM embed error:",hs),he.error("Failed to generate CRM embed code"),J(!1)}finally{ne(!1)}},He=Ut=>{C(Ut),I(!0)},Qe=async()=>{if(N)try{await l.mutateAsync({id:N.id,bunnyVideoId:N.bunny_video_id,hardDelete:!0}),R(!1),C(null),he.success("Video deleted successfully")}catch{he.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 ${b==="my"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:"My Videos"}),p&&((at=p.team)==null?void 0:at.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 ${b==="team"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(mr,{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 ${b==="analytics"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(Ro,{className:"h-3.5 w-3.5"}),"Analytics"]})]})]}),b==="my"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",onClick:()=>U(!0),children:[e.jsx(oi,{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"]})]})]}),b==="team"?e.jsx(jjs,{videos:f,isLoading:g,searchTerm:j,setSearchTerm:w}):b==="analytics"?e.jsx(vjs,{}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:Ve?"border-amber-500":nt?"border-destructive":"",children:e.jsxs(Re,{className:"py-4",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(iL,{className:`h-5 w-5 ${nt?"text-destructive":Ve?"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 / ",ft>=1024?`${(ft/1024).toFixed(0)} GB`:`${ft} MB`]})]}),e.jsx(Bi,{value:Math.min(me,100),className:`h-2 ${nt?"[&>div]:bg-destructive":Ve?"[&>div]:bg-amber-500":""}`})]}),Ve&&!nt&&e.jsxs(tt,{variant:"outline",className:"border-amber-500 text-amber-600",children:[e.jsx(Nl,{className:"h-3 w-3 mr-1"}),"Near Limit"]}),nt&&e.jsxs(tt,{variant:"destructive",children:[e.jsx(Nl,{className:"h-3 w-3 mr-1"}),"At Limit"]})]}),nt&&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(hn,{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:j,onChange:Ut=>w(Ut.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"})}):(Me==null?void 0:Me.length)===0?e.jsx(Pe,{children:e.jsxs(Re,{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:Me==null?void 0:Me.map(Ut=>{var hs,Yt;return e.jsx(_js,{video:Ut,previewSrc:(hs=Ne[Ut.id])==null?void 0:hs.previewUrl,thumbnailSrc:(Yt=Ne[Ut.id])==null?void 0:Yt.thumbnailUrl,onOpen:()=>He(Ut),onDelete:()=>{C(Ut),R(!0)},onRename:()=>{C(Ut),Ie(Ut.title||""),fe(!0)},onNavigateToContact:()=>t(`/mission-control/contacts/${Ut.contact_id}`),onGetEmbedCode:()=>{C(Ut),V(!0)},onCopyEmailHtml:()=>qe(Ut),onEmbedToCrm:()=>Je(Ut),onShareWithTemplate:()=>{C(Ut),le(!0)},onSendViaGmail:()=>{C(Ut),xe(!0)},isGmailConnected:c,getContactName:Fe,getShareUrl:Se,copyToClipboard:et,formatDuration:Ce},Ut.id)})}),e.jsx(xs,{open:M,onOpenChange:I,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsx(bs,{children:(N==null?void 0:N.title)||"Video Preview"}),e.jsx(Wr,{children:(N==null?void 0:N.contact_id)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(to,{className:"h-3 w-3"}),Fe(N.contact_id)]})})]}),N&&e.jsxs("div",{className:"space-y-4",children:[N.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(ws,{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:()=>{I(!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:N.playback_url?(()=>{let Ut=N.playback_url;return Ut.includes("iframe.mediadelivery.net/play/")&&(Ut=Ut.replace("/play/","/embed/"),Ut+=(Ut.includes("?")?"&":"?")+"autoplay=false&responsive=true"),Ut.includes("iframe.mediadelivery.net")?e.jsx("iframe",{src:Ut,title:N.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:N.playback_url,controls:!0,playsInline:!0,preload:"metadata",poster:N.thumbnail_url||void 0,className:"absolute top-0 left-0 w-full h-full rounded-lg object-cover",onError:()=>he.error("Video preview failed to load")},N.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(N),children:[e.jsx(io,{className:"h-4 w-4 mr-2"}),"Text Contact Video"]}),!c&&e.jsxs(K,{variant:"outline",onClick:()=>Ge(N),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Email Contact Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>et(Se(N),"Share link"),children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Share Link"]}),e.jsxs(K,{variant:"outline",onClick:()=>qe(N),children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Copy HTML for Email"]}),e.jsxs(K,{variant:"outline",onClick:()=>Ze(N),children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Download Video"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),Je(N)},children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Embed to CRM"]}),e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),le(!0)},children:[e.jsx(sc,{className:"h-4 w-4 mr-2"}),"Send with Page Template"]}),c&&(N==null?void 0:N.share_token)&&e.jsxs(K,{variant:"outline",onClick:()=>{I(!1),xe(!0)},children:[e.jsx(Rn,{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:()=>{I(!1),R(!0)},children:[e.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Delete Video"]})})]})]})}),e.jsx(xs,{open:L,onOpenChange:R,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Delete Video"}),e.jsx(Wr,{children:"Are you sure you want to delete this video? This action cannot be undone."})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>R(!1),children:"Cancel"}),e.jsx(K,{variant:"destructive",onClick:Qe,disabled:l.isPending,children:l.isPending?"Deleting...":"Delete"})]})]})}),e.jsx(ljs,{open:q,onOpenChange:U}),e.jsx(xs,{open:B,onOpenChange:V,children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Embed Video"}),e.jsx(Wr,{children:"Copy this code to embed the video on your website."})]}),N&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Embed Code"}),e.jsx(Er,{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 Ut=``;et(Ut,"Embed code")},children:[e.jsx(gi,{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."})]})]})}),N&&e.jsx(rlt,{open:re,onOpenChange:le,video:N,contactName:Fe(N.contact_id)}),N&&e.jsx(fjs,{open:pe,onOpenChange:xe,video:N,gmailEmail:u,signedThumbnailUrl:(It=Ne[N.id])==null?void 0:It.thumbnailUrl}),e.jsx(xs,{open:_e,onOpenChange:fe,children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(bs,{children:"Rename Video"}),e.jsx(Wr,{children:"Enter a new title for this video."})]}),e.jsx(ze,{value:we,onChange:Ut=>Ie(Ut.target.value),placeholder:"Video title",autoFocus:!0,onKeyDown:Ut=>{Ut.key==="Enter"&&we.trim()&&i.mutate({id:N.id,title:we.trim()},{onSuccess:()=>{he.success("Video renamed"),fe(!1)}})}}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>fe(!1),children:"Cancel"}),e.jsx(K,{disabled:!we.trim()||i.isPending,onClick:()=>{i.mutate({id:N.id,title:we.trim()},{onSuccess:()=>{he.success("Video renamed"),fe(!1)}})},children:i.isPending?"Saving...":"Save"})]})]})}),e.jsx(xs,{open:Y,onOpenChange:J,children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(an,{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(ws,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):te?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"CRM Email HTML"}),e.jsx(Er,{readOnly:!0,rows:12,value:te,className:"font-mono text-xs"})]}),e.jsxs(K,{className:"w-full",onClick:()=>{et(te,"CRM embed code")},children:[e.jsx(gi,{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 jjs({videos:t,isLoading:s,searchTerm:r,setSearchTerm:n}){const a=k.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=k.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(hn,{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(Pe,{children:e.jsxs(Re,{className:"py-12 text-center",children:[e.jsx(mr,{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(_n,{className:"h-7 w-7",children:[e.jsx(za,{src:c.avatar||""}),e.jsx(wn,{children:(c.name||"?").charAt(0).toUpperCase()})]}),e.jsx("h3",{className:"font-semibold text-sm",children:c.name}),e.jsx(tt,{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(Pe,{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(Re,{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(to,{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(qn,{className:"h-3 w-3"}),u.view_count]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),ps(new Date(u.created_at),"MMM d")]})]})]})]},u.id))})]},i))})]})}const Njs=()=>{const{user:t}=Rs();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})},ize=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function kjs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=Njs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=k.useMemo(()=>{if(!r)return new Map;const _=new Map;let j=0;return r.forEach(w=>{_.has(w.owner_user_id)||(_.set(w.owner_user_id,{name:w.owner_name||"Unknown",avatar:w.owner_avatar_url,color:ize[j%ize.length]}),j++)}),_},[r]),u=k.useMemo(()=>Array.from(c.entries()).map(([_,j])=>({id:_,...j})),[c]),p=k.useMemo(()=>{if(!r)return[];let _=r;if(l!=="all"&&(_=_.filter(j=>j.owner_user_id===l)),a.trim()){const j=a.toLowerCase();_=_.filter(w=>{var N,C,M,I;return w.deal_name.toLowerCase().includes(j)||((N=w.contact_name)==null?void 0:N.toLowerCase().includes(j))||((C=w.property_address)==null?void 0:C.toLowerCase().includes(j))||((M=w.city)==null?void 0:M.toLowerCase().includes(j))||((I=w.owner_name)==null?void 0:I.toLowerCase().includes(j))})}return _},[r,a,l]),f=k.useMemo(()=>{const _=new Map;return p.forEach(j=>{const w=j.stage_name||"Unknown";_.has(w)||_.set(w,{name:w,color:j.stage_color,icon:j.stage_icon,deals:[],totalValue:0});const N=_.get(w);N.deals.push(j),N.totalValue+=j.sale_price||0}),Array.from(_.values())},[p]),g=_=>_>=1e6?`$${(_/1e6).toFixed(1)}M`:_>=1e3?`$${(_/1e3).toFixed(0)}K`:`$${_.toFixed(0)}`,b=_=>_?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(_s,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(mr,{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(hn,{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(Ys,{value:l,onValueChange:i,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"All Members"})}),e.jsxs(Ks,{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(mr,{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 j=_.icon&&h2e[_.icon]||vd;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(j,{className:"h-3.5 w-3.5",style:{color:_.color||void 0}})}),e.jsx("h3",{className:"font-semibold text-sm",children:_.name})]}),e.jsx(tt,{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(Gi,{className:"flex-1 p-2",children:e.jsx("div",{className:"space-y-2",children:_.deals.map(w=>{const N=c.get(w.owner_user_id);return e.jsx(Sjs,{deal:w,ownerColor:(N==null?void 0:N.color)||"#888",ownerName:(N==null?void 0:N.name)||"Unknown",ownerAvatar:(N==null?void 0:N.avatar)||null,formatPrice:b},w.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 Sjs({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(_n,{className:"h-4 w-4",children:[e.jsx(za,{src:n||""}),e.jsx(wn,{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(tt,{variant:"outline",className:Pt("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(Sn,{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(wc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:a(t.sale_price)})]})]})}function Cjs({members:t,enabledMembers:s,onToggleMember:r,isOpen:n,onToggleOpen:a}){const o=s.size;return e.jsxs("div",{className:Pt("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(mr,{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(ll,{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(Gi,{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:Pt("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(_n,{className:"h-7 w-7",children:[e.jsx(za,{src:l.avatar_url||""}),e.jsx(wn,{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:Pt("text-xs truncate flex-1",i?"font-medium text-foreground":"text-muted-foreground"),children:l.name}),e.jsx($r,{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(_n,{className:Pt("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(za,{src:l.avatar_url||""}),e.jsx(wn,{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 oze=["#8B5CF6","#EC4899","#F59E0B","#10B981","#3B82F6","#EF4444","#06B6D4","#F97316"];function Mjs(){const t=li(),{data:s}=Bx(),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:oze[f%oze.length]}))},enabled:!!n&&!!t&&r,staleTime:5*60*1e3});return{isTeamLeader:r,teamMembers:a.data||[],isLoadingMembers:a.isLoading}}function Tjs(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 nlt({stages:t,currentStageId:s,onStageSelect:r,disabled:n}){const[a,o]=k.useState(!1),l=t.find(c=>c.id===s),i=c=>{c.id!==s&&r(c.id,c.name),o(!1)};return e.jsxs(au,{open:a,onOpenChange:o,children:[e.jsx(iu,{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(xa,{className:"h-3 w-3 shrink-0"})]})}),e.jsx(zd,{align:"end",className:"w-48 z-50 bg-popover",onClick:c=>c.stopPropagation(),children:t.map(c=>{const u=c.icon&&h2e[c.icon]||vd,p=c.id===s;return e.jsxs(Ca,{onClick:()=>i(c),className:Pt("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(fa,{className:"h-4 w-4 text-primary"})]},c.id)})})]})}const Ajs={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"}},Ejs={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 alt({deal:t,onClick:s,isDragging:r,stages:n,onStageChange:a,showStagePicker:o=!1,isWonStage:l=!1,ownerInfo:i=null}){var C,M;const c=NE(),u=Ajs[t.deal_type],p=Ejs[t.priority],f=k.useMemo(()=>t.target_close_date?iy(Il(t.target_close_date),new Date):null,[t.target_close_date]),g=f!==null&&f<0,b=f!==null&&f<=7&&f>=0,_=k.useMemo(()=>{var R;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const I=((R=t.listing)==null?void 0:R.created_at)||t.listing_date;if(!I)return null;const L=t.contract_date?Il(t.contract_date):new Date;return iy(L,Il(I))},[t]),j=l&&!t.scorecard_transaction_id,w=!!t.scorecard_transaction_id,N=I=>I?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I):null;return e.jsx(Pe,{className:Pt("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",j&&"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(Re,{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(_n,{className:"h-4 w-4",children:[e.jsx(za,{src:i.avatar_url||""}),e.jsx(wn,{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(tt,{variant:"outline",className:Pt("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(_n,{className:"h-5 w-5",children:e.jsxs(wn,{className:"text-[10px] bg-primary/10 text-primary",children:[(C=t.contact.first_name)==null?void 0:C[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(cl,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"text-primary truncate",children:"Linked to Listing Exchange"})]}),j&&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(xo,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate font-medium",children:"Add to Scorecard"})]}),w&&l&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 dark:text-green-400",children:[e.jsx(la,{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(XI,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsxs("span",{className:Pt("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(Sn,{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(wc,{className:"h-3 w-3 text-emerald-500 shrink-0"}),e.jsx("span",{className:"font-semibold text-foreground",children:N(t.expected_price)}),t.expected_commission&&e.jsxs("span",{className:"text-muted-foreground",children:["• ",N(t.expected_commission)," GCI"]}),(()=>{const I=yx(t);return I!==null&&I!==t.expected_commission?e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:["• ",N(I)," 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:Pt("flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px]",p.color),children:[e.jsx("div",{className:Pt("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(nlt,{stages:n,currentStageId:t.stage_id||"",onStageSelect:(I,L)=>a(t.id,I,L)}):t.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-[10px]",g&&"text-red-600",b&&!g&&"text-amber-600",!g&&!b&&"text-muted-foreground"),children:[g?e.jsx(Nl,{className:"h-3 w-3"}):e.jsx(cn,{className:"h-3 w-3"}),e.jsx("span",{children:g?`${Math.abs(f)}d overdue`:b?`${f}d left`:ps(Il(t.target_close_date),"MMM d")})]}):null]})]})})}function Pjs({stage:t,deals:s,onDealClick:r,onAddDeal:n,onDragStart:a,onDragOver:o,onDrop:l,isDragOver:i,isWonStage:c=!1,getOwnerInfo:u}){const p=k.useRef(null),f=s.reduce((w,N)=>w+(N.expected_price||0),0),g=s.reduce((w,N)=>w+(N.expected_commission||0),0),b=s.reduce((w,N)=>w+(yx(N)||0),0),_=w=>w>=1e6?`$${(w/1e6).toFixed(1)}M`:w>=1e3?`$${(w/1e3).toFixed(0)}K`:`$${w.toFixed(0)}`,j=t.icon&&h2e[t.icon]||vd;return e.jsxs("div",{ref:p,className:Pt("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:w=>o(w,t.id),onDrop:w=>l(w,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(j,{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(tt,{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"]}),b>0&&b!==g&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-teal-600 dark:text-teal-400",children:[_(b)," Net"]})]})]})]}),e.jsx(Gi,{className:"flex-1 p-2",children:e.jsxs("div",{className:"space-y-2",children:[s.map(w=>e.jsx("div",{draggable:!0,onDragStart:N=>{N.dataTransfer.effectAllowed="move",a(w.id,t.id)},children:e.jsx(alt,{deal:w,onClick:()=>r(w),isWonStage:c,ownerInfo:(u==null?void 0:u(w))||null})},w.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 Ijs({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:Rm,color:"text-blue-500",bgColor:"bg-blue-500/10"},{label:"Weighted GCI",value:r((t==null?void 0:t.weightedGCI)||0),icon:wL,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:DL,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:YI,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:Ol,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(Pe,{className:"animate-pulse",children:e.jsx(Re,{className:"p-4",children:e.jsx("div",{className:"h-10 bg-muted rounded"})})},a))}):e.jsx(F1,{children:e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:n.map(a=>{const o=e.jsx(Pe,{className:"border-border/50 hover:shadow-sm transition-shadow",children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("p-2 rounded-lg",a.bgColor),children:e.jsx(a.icon,{className:Pt("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(Oc,{children:[e.jsx(Rc,{asChild:!0,children:o}),e.jsx(gc,{children:e.jsx("p",{children:a.tooltip})})]},a.label):o})})})}function Ljs({formData:t,onChange:s,isEditing:r}){const{isAdmin:n}=Rs(),[a,o]=k.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(un,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(tt,{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(gf,{open:a,onOpenChange:o,children:e.jsxs("div",{className:"border rounded-lg",children:[e.jsxs(yf,{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(un,{className:"h-4 w-4 text-primary"}),e.jsx("h4",{className:"font-medium text-sm",children:"Client Portal"}),t.portal_enabled&&e.jsx(tt,{className:"text-xs bg-emerald-500/10 text-emerald-600 border-emerald-200",variant:"outline",children:"Enabled"})]}),e.jsx(To,{className:Pt("h-4 w-4 text-muted-foreground transition-transform",a&&"rotate-180")})]}),e.jsx(vf,{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(ye,{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($r,{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(ye,{className:"text-sm font-medium",children:"Portal Visibility"}),e.jsxs(pNe,{value:t.visibility,onValueChange:i=>l({visibility:i}),className:"grid grid-cols-2 gap-3",children:[e.jsxs("label",{className:Pt("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(Voe,{value:"private"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Mh,{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:Pt("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(Voe,{value:"public"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Su,{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(Lo,{id:"require_onboarding",checked:t.require_onboarding,onCheckedChange:i=>l({require_onboarding:!!i}),className:"mt-0.5"}),e.jsxs("div",{children:[e.jsx(ye,{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(Lo,{id:"allow_spouse",checked:t.allow_spouse,onCheckedChange:i=>l({allow_spouse:!!i})}),e.jsx(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{className:"text-xs text-muted-foreground",children:"Preferred Invite Method"}),e.jsxs(Ys,{value:t.invite_method,onValueChange:i=>l({invite_method:i}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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 Djs=[{value:"buyer",label:"Buyer"},{value:"seller",label:"Seller"},{value:"dual",label:"Dual Agency"},{value:"referral",label:"Referral"},{value:"lease",label:"Lease"}],Ojs=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"},{value:"urgent",label:"Urgent"}];function Rjs({open:t,onOpenChange:s,deal:r,defaultStageId:n}){const{data:a}=Vhe(),{data:o}=Wm(),{data:l}=YYe(),i=vue(),c=Xat(),u=Qat(),p=aSe(),[f,g]=k.useState({portal_enabled:!1,visibility:"private",require_onboarding:!0,allow_spouse:!1,client_name:"",client_email:"",client_phone:"",invite_method:"email"}),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!1),[M,I]=k.useState({first_name:"",last_name:"",email:"",phone:""}),L=(l==null?void 0:l.filter(te=>((r==null?void 0:r.listing_id)===te.id,!0)))||[],[R,q]=k.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:""});k.useEffect(()=>{var te,X,ce,ne,re,le,pe,xe;t&&(r?(q({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:((te=r.expected_price)==null?void 0:te.toString())||"",commission_percentage:((X=r.commission_percentage)==null?void 0:X.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:((le=r.franchise_fee_pct)==null?void 0:le.toString())||"",transaction_fee:((pe=r.transaction_fee)==null?void 0:pe.toString())||"",commission_calc_method:r.commission_calc_method||"standard",target_close_date:r.target_close_date?Il(r.target_close_date):void 0,contract_date:r.contract_date?Il(r.contract_date):void 0,listing_date:r.listing_date?Il(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}`)):(q({deal_name:"",deal_type:"buyer",stage_id:n||((xe=a==null?void 0:a[0])==null?void 0:xe.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(te=>{var ce,ne,re;const X=b.toLowerCase();return((ce=te.first_name)==null?void 0:ce.toLowerCase().includes(X))||((ne=te.last_name)==null?void 0:ne.toLowerCase().includes(X))||((re=te.email)==null?void 0:re.toLowerCase().includes(X))}).slice(0,5),B=()=>{const te=parseFloat(R.expected_price)||0,X=parseFloat(R.commission_percentage)||0;return te*(X/100)},V=()=>{const te=B();if(!te)return null;const X=parseFloat(R.brokerage_split_pct)||0,ce=parseFloat(R.team_split_pct)||0,ne=parseFloat(R.referral_fee_pct)||0,re=parseFloat(R.franchise_fee_pct)||0,le=parseFloat(R.transaction_fee)||0;if(R.commission_calc_method==="referral_first"){let xe=te;ne&&(xe-=te*ne/100);let _e=xe;return X&&(_e-=xe*X/100),ce&&(_e-=te*ce/100),re&&(_e-=te*re/100),le&&(_e-=le),Math.max(0,_e)}let pe=te;return X&&(pe=pe*((100-X)/100)),ce&&(pe=pe*((100-ce)/100)),ne&&(pe=pe-te*ne/100),re&&(pe=pe-te*re/100),le&&(pe=pe-le),Math.max(0,pe)},Y=async te=>{var X,ce,ne;if(te.preventDefault(),!R.deal_name.trim()){he.error("Please enter a deal name");return}try{const re={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?parseFloat(R.expected_price):null,expected_commission:B()||null,commission_percentage:R.commission_percentage?parseFloat(R.commission_percentage):3,brokerage_split_pct:R.brokerage_split_pct?parseFloat(R.brokerage_split_pct):null,team_split_pct:R.team_split_pct?parseFloat(R.team_split_pct):null,referral_fee_pct:R.referral_fee_pct?parseFloat(R.referral_fee_pct):null,franchise_fee_pct:R.franchise_fee_pct?parseFloat(R.franchise_fee_pct):null,transaction_fee:R.transaction_fee?parseFloat(R.transaction_fee):null,commission_calc_method:R.commission_calc_method,target_close_date:((X=R.target_close_date)==null?void 0:X.toISOString().split("T")[0])||null,contract_date:((ce=R.contract_date)==null?void 0:ce.toISOString().split("T")[0])||null,listing_date:((ne=R.listing_date)==null?void 0:ne.toISOString().split("T")[0])||null,priority:R.priority,probability:parseInt(R.probability)||50,notes:R.notes||null};if(r)await u.mutateAsync({id:r.id,...re}),he.success("Deal updated successfully");else{const le=await c.mutateAsync(re);if(he.success("Deal created successfully"),f.portal_enabled&&(le!=null&&le.id))try{await p.mutateAsync({deal_id:le.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}),he.success("Client portal created!")}catch{he.error("Deal created, but portal setup failed")}}s(!1)}catch{he.error("Failed to save deal")}},J=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(_s,{children:[e.jsx(bs,{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:Y,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(ye,{htmlFor:"deal_name",children:"Deal Name *"}),e.jsx(ze,{id:"deal_name",value:R.deal_name,onChange:te=>q(X=>({...X,deal_name:te.target.value})),placeholder:"e.g., Smith Family - 123 Main St"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Deal Type"}),e.jsxs(Ys,{value:R.deal_type,onValueChange:te=>q(X=>({...X,deal_type:te})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:Djs.map(te=>e.jsx(Mt,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Stage"}),e.jsxs(Ys,{value:R.stage_id||"none",onValueChange:te=>q(X=>({...X,stage_id:te==="none"?"":te})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select stage"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No Stage"}),a==null?void 0:a.map(te=>e.jsx(Mt,{value:te.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:te.color}}),te.name]})},te.id))]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Link to Contact"}),e.jsxs("div",{className:"relative",children:[e.jsx(hn,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{value:b,onChange:te=>{_(te.target.value),w(!0),C(!1),te.target.value||q(X=>({...X,contact_id:""}))},onFocus:()=>w(!0),placeholder:"Search contacts...",className:"pl-9"}),j&&b&&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(te=>e.jsxs("button",{type:"button",className:"w-full px-3 py-2 text-left hover:bg-muted flex items-center gap-2",onClick:()=>{q(X=>({...X,contact_id:te.id})),_(`${te.first_name} ${te.last_name}`),w(!1)},children:[e.jsx(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:[te.first_name," ",te.last_name]}),te.email&&e.jsx("span",{className:"text-xs text-muted-foreground ml-auto",children:te.email})]},te.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 te=b.trim().split(/\s+/);I({first_name:te[0]||"",last_name:te.slice(1).join(" ")||"",email:"",phone:""}),C(!0),w(!1)},children:[e.jsx(rc,{className:"h-4 w-4"}),e.jsxs("span",{children:['Create new contact "',b.trim(),'"']})]})]})]}),N&&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(rc,{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:()=>C(!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:te=>I(X=>({...X,first_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Last name",value:M.last_name,onChange:te=>I(X=>({...X,last_name:te.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Email",type:"email",value:M.email,onChange:te=>I(X=>({...X,email:te.target.value})),className:"h-8 text-sm"}),e.jsx(ze,{placeholder:"Phone",type:"tel",value:M.phone,onChange:te=>I(X=>({...X,phone:te.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 te=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});te&&(q(X=>({...X,contact_id:te.id})),_(`${te.first_name} ${te.last_name||""}`.trim()),C(!1))}catch{}},children:i.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-3.5 w-3.5 mr-1 animate-spin"})," Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(rc,{className:"h-3.5 w-3.5 mr-1"})," Add & Link Contact"]})})]})]}),L.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"flex items-center gap-2",children:[e.jsx(cl,{className:"h-4 w-4"}),"Link to Listing Exchange"]}),e.jsxs(Ys,{value:R.listing_id||"none",onValueChange:te=>{const X=te==="none"?"":te,ce=L.find(ne=>ne.id===X);q(ce?ne=>{var re;return{...ne,listing_id:X,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:X}))},children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a listing to sync status..."})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"None"}),L.map(te=>e.jsx(Mt,{value:te.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{children:te.property_address||`${te.city}, ${te.state}`}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["$",(te.price/1e3).toFixed(0),"K"]})]})},te.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(ye,{htmlFor:"property_address",children:"Address"}),e.jsx(ze,{id:"property_address",value:R.property_address,onChange:te=>q(X=>({...X,property_address:te.target.value})),placeholder:"123 Main Street"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:R.city,onChange:te=>q(X=>({...X,city:te.target.value}))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:R.state,onChange:te=>q(X=>({...X,state:te.target.value})),maxLength:2,placeholder:"TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zip_code",children:"ZIP"}),e.jsx(ze,{id:"zip_code",value:R.zip_code,onChange:te=>q(X=>({...X,zip_code:te.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(ye,{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:R.expected_price,onChange:te=>q(X=>({...X,expected_price:te.target.value})),className:"pl-7",placeholder:"500000"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"commission_percentage",children:"Commission %"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{id:"commission_percentage",type:"number",step:"0.1",value:R.commission_percentage,onChange:te=>q(X=>({...X,commission_percentage:te.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(ye,{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(ye,{className:"text-xs whitespace-nowrap",children:"Calculation Method:"}),e.jsxs(Ys,{value:R.commission_calc_method,onValueChange:te=>q(X=>({...X,commission_calc_method:te})),children:[e.jsx(Gs,{className:"h-7 text-xs",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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)"})]})]})]}),R.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(ye,{className:"text-xs",children:"Brokerage Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:R.brokerage_split_pct,onChange:te=>q(X=>({...X,brokerage_split_pct:te.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(ye,{className:"text-xs",children:"Team Split"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:R.team_split_pct,onChange:te=>q(X=>({...X,team_split_pct:te.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(ye,{className:"text-xs",children:"Referral Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:R.referral_fee_pct,onChange:te=>q(X=>({...X,referral_fee_pct:te.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(ye,{className:"text-xs",children:"Franchise Fee"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",step:"1",min:"0",max:"100",value:R.franchise_fee_pct,onChange:te=>q(X=>({...X,franchise_fee_pct:te.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(ye,{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:R.transaction_fee,onChange:te=>q(X=>({...X,transaction_fee:te.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(ye,{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(ye,{children:"Target Close Date"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.target_close_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),R.target_close_date?ps(R.target_close_date,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:R.target_close_date,onSelect:te=>q(X=>({...X,target_close_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Contract Date"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.contract_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),R.contract_date?ps(R.contract_date,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:R.contract_date,onSelect:te=>q(X=>({...X,contract_date:te})),initialFocus:!0,className:"pointer-events-auto"})})]})]}),(R.deal_type==="seller"||R.deal_type==="dual")&&!R.listing_id&&e.jsxs("div",{className:"space-y-2 col-span-2",children:[e.jsx(ye,{children:"Listing Date (for Days on Market)"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R.listing_date&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),R.listing_date?ps(R.listing_date,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:R.listing_date,onSelect:te=>q(X=>({...X,listing_date:te})),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(ye,{children:"Priority"}),e.jsxs(Ys,{value:R.priority,onValueChange:te=>q(X=>({...X,priority:te})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:Ojs.map(te=>e.jsx(Mt,{value:te.value,children:te.label},te.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Win Probability"}),e.jsxs("div",{className:"relative",children:[e.jsx(ze,{type:"number",min:"0",max:"100",value:R.probability,onChange:te=>q(X=>({...X,probability:te.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(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:R.notes,onChange:te=>q(X=>({...X,notes:te.target.value})),placeholder:"Add any additional notes about this deal...",rows:3})]}),!r&&e.jsx(Ljs,{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:J,children:[J&&e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),r?"Update Deal":"Create Deal"]})]})]})]})})}function Fjs({dealId:t}){const s=li(),r=es(),[n,a]=k.useState(""),[o,l]=k.useState(!1),{data:i=[]}=mt({queryKey:["deal-tags",t],queryFn:async()=>{const{data:_,error:j}=await H.from("deal_tags").select("*").eq("deal_id",t).order("created_at");if(j)throw j;return _},enabled:!!t}),{data:c=[]}=mt({queryKey:["all-deal-tags",s],queryFn:async()=>{if(!s)return[];const{data:_,error:j}=await H.from("deal_tags").select("tag").eq("owner_user_id",s);if(j)throw j;return[...new Set(_.map(N=>N.tag))].sort()},enabled:!!s}),u=Lt({mutationFn:async _=>{if(!s)throw new Error("Not authenticated");const{error:j}=await H.from("deal_tags").insert({deal_id:t,owner_user_id:s,tag:_.trim()});if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]}),r.invalidateQueries({queryKey:["all-deal-tags"]}),a("")}}),p=Lt({mutationFn:async _=>{const{error:j}=await H.from("deal_tags").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["deal-tags",t]})}}),f=()=>{const _=n.trim();_&&(i.some(j=>j.tag.toLowerCase()===_.toLowerCase())||u.mutate(_))},g=i.map(_=>_.tag.toLowerCase()),b=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(tt,{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(Or,{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&&b.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:b.map(_=>e.jsx("button",{type:"button",className:"w-full px-3 py-1.5 text-left text-xs hover:bg-muted",onMouseDown:j=>{j.preventDefault(),u.mutate(_)},children:_},_))})]})]})}function zjs(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 Bjs(){const t=li(),s=es();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 $js(){const t=es();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 qjs(){const t=es();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 Ujs(t){const{data:s,error:r}=await H.storage.from("deal-files").createSignedUrl(t,3600);if(r)throw r;return s.signedUrl}const lze={text:"Short Text",textarea:"Long Text",dropdown:"Dropdown",toggle:"Yes / No"};function Vjs({open:t,onOpenChange:s}){const{data:r,isLoading:n}=r_s(),a=n_s(),o=a_s(),l=i_s(),[i,c]=k.useState(!1),[u,p]=k.useState({question_text:"",field_type:"text",options:[],is_required:!1}),[f,g]=k.useState(""),b=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),he.success("Question added")}catch{he.error("Failed to add question")}},_=async C=>{try{await l.mutateAsync(C),he.success("Question removed")}catch{he.error("Failed to remove question")}},j=async(C,M)=>{try{await o.mutateAsync({id:C,is_required:M})}catch{he.error("Failed to update question")}},w=()=>{f.trim()&&(p(C=>({...C,options:[...C.options,f.trim()]})),g(""))},N=C=>{p(M=>({...M,options:M.options.filter((I,L)=>L!==C)}))};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(_s,{children:[e.jsx(bs,{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(Gi,{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(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),r==null?void 0:r.map(C=>{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(Ju,{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:C.question_text}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"secondary",className:"text-xs",children:lze[C.field_type]||C.field_type}),C.is_required&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Required"})]}),C.field_type==="dropdown"&&((M=C.options)==null?void 0:M.length)>0&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Options: ",C.options.join(", ")]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx($r,{checked:C.is_required,onCheckedChange:I=>j(C.id,I),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:()=>_(C.id),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})},C.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(ye,{className:"text-sm font-medium",children:"Question"}),e.jsx(ze,{value:u.question_text,onChange:C=>p(M=>({...M,question_text:C.target.value})),className:"mt-1",placeholder:"e.g., Do you have a home to sell first?",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Answer Type"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(lze).map(([C,M])=>e.jsx("button",{type:"button",onClick:()=>p(I=>({...I,field_type:C,options:[]})),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${u.field_type===C?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:M},C))})]}),u.field_type==="dropdown"&&e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Options"}),e.jsxs("div",{className:"space-y-1.5 mt-1.5",children:[u.options.map((C,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:C}),e.jsx("button",{onClick:()=>N(M),className:"text-muted-foreground hover:text-destructive",children:e.jsx(Or,{className:"h-3.5 w-3.5"})})]},M)),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:f,onChange:C=>g(C.target.value),onKeyDown:C=>C.key==="Enter"&&(C.preventDefault(),w()),placeholder:"Add option...",className:"h-8 text-sm"}),e.jsx(K,{variant:"outline",size:"sm",onClick:w,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($r,{checked:u.is_required,onCheckedChange:C=>p(M=>({...M,is_required:C}))}),e.jsx(ye,{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:b,disabled:!u.question_text.trim()||a.isPending,className:"flex-1",children:[a.isPending?e.jsx(ws,{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 Hjs({portalId:t,ownerId:s,clientEmail:r,linkedPortalId:n,onLink:a}){const[o,l]=k.useState(""),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["all-owner-portals",s],queryFn:async()=>{const{data:_,error:j}=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(j)throw j;return _},enabled:i||!!n}),f=k.useMemo(()=>!n||!u?null:u.find(_=>_.id===n),[n,u]),g=k.useMemo(()=>!u||!r?[]:u.filter(_=>{var j;return((j=_.client_email)==null?void 0:j.toLowerCase())===r.toLowerCase()&&_.id!==t}),[u,r,t]),b=k.useMemo(()=>{if(!u||!o.trim())return[];const _=o.toLowerCase();return u.filter(j=>{var N,C,M,I;const w=j.deal_pipeline;return((N=j.client_name)==null?void 0:N.toLowerCase().includes(_))||((C=j.client_email)==null?void 0:C.toLowerCase().includes(_))||((M=w==null?void 0:w.deal_name)==null?void 0:M.toLowerCase().includes(_))||((I=w==null?void 0:w.property_address)==null?void 0:I.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(ye,{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(cl,{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(uS,{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(ye,{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(cl,{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 j=_.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(tt,{variant:"outline",className:"text-[10px] shrink-0 bg-amber-100 border-amber-300 text-amber-700",children:(j==null?void 0:j.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:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:j==null?void 0:j.property_address})]}),e.jsx(cl,{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(hn,{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(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"})}),b.length>0&&e.jsx("div",{className:"space-y-1 max-h-[200px] overflow-y-auto",children:b.map(_=>{const j=_.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(tt,{variant:"outline",className:"text-[10px] shrink-0",children:(j==null?void 0:j.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:(j==null?void 0:j.deal_name)||_.client_name}),e.jsx("p",{className:"text-[11px] text-muted-foreground truncate",children:_.client_email})]})]},_.id)})}),o&&b.length===0&&!p&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No portals found"})]})]})}function nCe({userId:t,onSelect:s,triggerLabel:r="Library",triggerSize:n="sm",triggerVariant:a="outline",triggerClassName:o}){const[l,i]=k.useState(!1),[c,u]=k.useState([]),[p,f]=k.useState(!1),[g,b]=k.useState("");k.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:j})=>{u(j||[]),f(!1)}))},[l,t]);const _=c.filter(j=>!g||(j.title||j.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(xu,{className:"h-3.5 w-3.5"}),r]})}),e.jsxs(fs,{className:"max-w-lg max-h-[70vh] flex flex-col",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(hn,{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:j=>b(j.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(j=>e.jsxs("button",{onClick:()=>{s(j.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:j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"w-full h-full object-cover",referrerPolicy:"no-referrer",onError:w=>{const N=w.currentTarget.parentElement;if(N){w.currentTarget.remove();const C=document.createElement("span");C.innerHTML="🎬",C.className="text-lg",N.appendChild(C)}}}):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:j.title||j.recipient_name||"Untitled Video"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.duration_seconds?`${Math.round(j.duration_seconds)}s`:"",j.created_at?` · ${new Date(j.created_at).toLocaleDateString()}`:""]})]})]},j.id))})]})]})}function aCe({contactId:t,onVideoReady:s}){const[r,n]=k.useState(!1),[a,o]=k.useState("record"),[l,i]=k.useState(0),[c,u]=k.useState(0),p=_C(),f=()=>{o("record"),i(0),u(0)},g=_=>{!_&&(a==="uploading"||a==="processing")||(n(_),_||f())},b=k.useCallback(async(_,j)=>{o("uploading");try{const w="Card Video",{videoId:N,libraryId:C}=await hR(w),{uploadUrl:M,apiKey:I}=await mR(N),L=new XMLHttpRequest;L.upload.onprogress=J=>{J.lengthComputable&&i(J.loaded/J.total*100)},await new Promise((J,te)=>{L.onload=()=>L.status>=200&&L.status<300?J():te(new Error("Upload failed")),L.onerror=()=>te(new Error("Upload failed")),L.open("PUT",M),L.setRequestHeader("AccessKey",I),L.send(_)}),o("processing");let R=0;const q=Date.now(),U=9e4,B=`https://iframe.mediadelivery.net/embed/${C}/${N}`;for(;R<4;){if(await new Promise(te=>setTimeout(te,3e3)),Date.now()-q>U){const te=_.size/1048576;await p.mutateAsync({bunny_video_id:N,playback_url:`https://iframe.mediadelivery.net/play/${C}/${N}`,file_size_mb:te,title:w,contact_id:t||void 0,status:"processing",touch_type:"video"}),s(B),he.success("Video saved — still encoding. It will be ready shortly."),o("done"),setTimeout(()=>{n(!1),f()},1500);return}const J=await bA(N);if(R=J.status,u(J.encodeProgress||0),R===5||R===6)throw new Error("Video processing failed")}const V=await bA(N),Y=(V.storageSize||_.size)/(1024*1024);await p.mutateAsync({bunny_video_id:N,contact_id:t||void 0,playback_url:V.directPlayUrl||B,thumbnail_url:V.thumbnailUrl,preview_url:V.previewUrl||null,duration_seconds:V.length||j,file_size_mb:Y,title:w,status:"ready",touch_type:"video"}),s(B),he.success("Video recorded & added to your library!"),o("done"),setTimeout(()=>{n(!1),f()},1500)}catch(w){console.error("Recording upload error:",w),he.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(_s,{children:e.jsx(bs,{children:"Record a Video for Your Card"})}),a==="record"&&e.jsx(fme,{maxDurationSeconds:60,onRecordingComplete:b,onError:_=>he.error(_)}),a==="uploading"&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-12",children:[e.jsx(ws,{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(ws,{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(xi,{className:"h-12 w-12 text-emerald-500"}),e.jsx("p",{className:"text-sm font-medium",children:"Video attached to your card!"})]})]})]})}function ilt({open:t,onOpenChange:s,portal:r,dealOwnerId:n}){const a=pR(),[o,l]=k.useState(!1),[i,c]=k.useState(r.next_step_text||""),[u,p]=k.useState(r.next_step_video_url||""),[f,g]=k.useState(r.inspection_date||""),[b,_]=k.useState(r.appraisal_date||""),[j,w]=k.useState(r.welcome_message||""),[N,C]=k.useState(r.review_url||""),[M,I]=k.useState(r.show_post_close_tips),[L,R]=k.useState(r.notify_client),[q,U]=k.useState(r.require_onboarding),[B,V]=k.useState(r.allow_spouse),[Y,J]=k.useState(r.visibility),[te,X]=k.useState(r.stage_mapping||[]),[ce,ne]=k.useState(null),[re,le]=k.useState(r.linked_portal_id||null),{data:pe}=mt({queryKey:["pipeline-stages-for-portal",n],queryFn:async()=>{const{data:Ne,error:Ae}=await H.from("deal_pipeline_stages").select("*").eq("owner_user_id",n).order("sort_order",{ascending:!0});if(Ae)throw Ae;return Ne},enabled:t});k.useEffect(()=>{c(r.next_step_text||""),p(r.next_step_video_url||""),g(r.inspection_date||""),_(r.appraisal_date||""),w(r.welcome_message||""),C(r.review_url||""),I(r.show_post_close_tips),R(r.notify_client),U(r.require_onboarding),V(r.allow_spouse),J(r.visibility),X(r.stage_mapping||[]),le(r.linked_portal_id||null)},[r]);const xe=async()=>{try{await a.mutateAsync({id:r.id,next_step_text:i||null,next_step_video_url:u||null,inspection_date:f||null,appraisal_date:b||null,welcome_message:j||null,review_url:N||null,show_post_close_tips:M,notify_client:L,require_onboarding:q,allow_spouse:B,visibility:Y,stage_mapping:te.length>0?te:null,linked_portal_id:re});const Ne=r.linked_portal_id;re&&re!==Ne&&await H.from("client_portals").update({linked_portal_id:r.id}).eq("id",re),!re&&Ne&&await H.from("client_portals").update({linked_portal_id:null}).eq("id",Ne),he.success("Portal settings saved"),s(!1)}catch{he.error("Failed to save settings")}},_e=()=>{X([...te,{label:""}])},fe=Ne=>{X(te.filter((Ae,Fe)=>Fe!==Ne)),ce===Ne&&ne(null)},we=(Ne,Ae,Fe)=>{const Ce=[...te];Ce[Ne]={...Ce[Ne],[Ae]:Fe},X(Ce)},Ie=()=>{const Ae=Qje(null).map(Fe=>({label:Fe.label,description:Fe.description,stageId:void 0}));X(Ae)};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(_s,{children:e.jsx(bs,{children:"Portal Settings"})}),e.jsxs(ja,{defaultValue:"general",className:"flex-1 overflow-hidden flex flex-col",children:[e.jsxs(ga,{className:"grid grid-cols-3 shrink-0",children:[e.jsx(us,{value:"general",children:"General"}),e.jsx(us,{value:"timeline",children:"Timeline"}),e.jsx(us,{value:"content",children:"Content"})]}),e.jsxs(Gi,{className:"flex-1 mt-4",children:[e.jsxs(ks,{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(ye,{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(Ne=>e.jsx("button",{onClick:()=>J(Ne),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${Y===Ne?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:Ne.charAt(0).toUpperCase()+Ne.slice(1)},Ne))})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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($r,{checked:q,onCheckedChange:U})]}),q&&e.jsxs("div",{className:"flex items-center justify-between pl-4 border-l-2 border-primary/20",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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($r,{checked:B,onCheckedChange:V})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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($r,{checked:M,onCheckedChange:I})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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($r,{checked:L,onCheckedChange:R})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx(Hjs,{portalId:r.id,ownerId:n,clientEmail:r.client_email,linkedPortalId:re,onLink:le})}),e.jsx("div",{children:e.jsx(ze,{type:"date",value:f,onChange:Ne=>g(Ne.target.value),className:"mt-1"})}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Appraisal Date"}),e.jsx(ze,{type:"date",value:b,onChange:Ne=>_(Ne.target.value),className:"mt-1"})]})]}),e.jsx(ks,{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(ye,{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:Ie,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.'}),te.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:Ie,children:"Customize journey labels"})]}),e.jsx("div",{className:"space-y-2 mt-2",children:te.map((Ne,Ae)=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ju,{className:"h-4 w-4 text-muted-foreground/50 flex-shrink-0"}),e.jsx(ze,{value:Ne.label,onChange:Fe=>we(Ae,"label",Fe.target.value),placeholder:`Stage ${Ae+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:()=>ne(ce===Ae?null:Ae),children:ce===Ae?"Less":"More"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-destructive",onClick:()=>fe(Ae),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]}),ce===Ae&&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(ye,{className:"text-xs text-muted-foreground",children:"Description"}),e.jsx("textarea",{value:Ne.description||"",onChange:Fe=>we(Ae,"description",Fe.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(ye,{className:"text-xs text-muted-foreground",children:"Video"}),Ne.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:Ne.video_url.length>40?Ne.video_url.slice(0,40)+"...":Ne.video_url}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>we(Ae,"video_url",""),children:"Remove"})]}):e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(aCe,{onVideoReady:Fe=>we(Ae,"video_url",Fe)}),e.jsx(nCe,{userId:n,onSelect:Fe=>we(Ae,"video_url",Fe),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 Fe=prompt("Paste a YouTube or Loom URL:");Fe&&we(Ae,"video_url",Fe)},children:[e.jsx(zo,{className:"h-3 w-3"}),"Paste URL"]})]})]})]})]},Ae))}),te.length>0&&e.jsxs(K,{variant:"outline",size:"sm",onClick:_e,className:"mt-2 text-xs w-full",children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Stage"]})]})}),e.jsxs(ks,{value:"content",className:"space-y-4 mt-0 px-1",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Welcome Message"}),e.jsx("textarea",{value:j,onChange:Ne=>w(Ne.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(ye,{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:i,onChange:Ne=>c(Ne.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(ye,{className:"text-sm font-medium",children:"Next Step Video (optional)"}),e.jsx(ze,{value:u,onChange:Ne=>p(Ne.target.value),className:"mt-1",placeholder:"YouTube or Loom URL"})]}),e.jsxs("div",{children:[e.jsx(ye,{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:N,onChange:Ne=>C(Ne.target.value),className:"mt-1",placeholder:"https://g.page/r/..."})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t shrink-0",children:[e.jsx(K,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsxs(K,{onClick:xe,disabled:a.isPending,children:[a.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ed,{className:"h-4 w-4 mr-2"}),"Save Settings"]})]})]})}),e.jsx(Vjs,{open:o,onOpenChange:l})]})}function olt({open:t,onOpenChange:s,portalId:r,portalSlug:n,notifyClient:a}){const[o,l]=k.useState(""),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(!1),[b,_]=k.useState(a??!1),j=Bat(),w=async()=>{if(o.trim())try{if(await j.mutateAsync({portal_id:r,title:o.trim(),content:i.trim()||void 0,video_url:u.trim()||void 0,is_stage_change:f}),b&&n)try{const N=v1(n);await H.functions.invoke("send-portal-notification",{body:{portal_id:r,update_title:o.trim(),update_content:i.trim()||null,portal_url:N}}),he.success("Update posted & client notified")}catch(N){console.error("Notification failed:",N),he.success("Update posted (notification failed to send)")}else he.success("Update posted to portal");l(""),c(""),p(""),g(!1),s(!1)}catch{he.error("Failed to post update")}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Post Portal Update"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Title *"}),e.jsx(ze,{value:o,onChange:N=>l(N.target.value),className:"mt-1",placeholder:"Inspection cleared!"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Message"}),e.jsx("textarea",{value:i,onChange:N=>c(N.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(ye,{className:"text-sm font-medium",children:"Video URL (optional)"}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx(ze,{value:u,onChange:N=>p(N.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:()=>g(!f),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors ${f?"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:()=>_(!b),className:`px-3 py-1.5 rounded-full text-xs font-medium border transition-colors flex items-center gap-1.5 ${b?"bg-blue-500/10 text-blue-700 border-blue-200":"bg-background text-muted-foreground border-input"}`,children:[b?e.jsx(Pm,{className:"h-3 w-3"}):e.jsx(e1,{className:"h-3 w-3"}),b?"Notify Client":"No Notification"]})]})]}),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:w,disabled:!o.trim()||j.isPending,children:[j.isPending?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Post Update"]})]})]})})}function llt({open:t,onOpenChange:s,portal:r,dealName:n}){const a=pR(),{isGmailConnected:o,gmailEmail:l}=$0(),[i,c]=k.useState(r.client_name||""),[u,p]=k.useState(r.client_email||""),[f,g]=k.useState(!1),[b,_]=k.useState(!1),j=v1(r.slug),w=i.split(" ")[0]||"there",N=`Your Transaction Portal – ${n}`,C=`Hi ${w}, I've set up a dedicated portal where you can track the progress of your transaction in real-time. Here's your link: ${j} 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(j),_(!0),setTimeout(()=>_(!1),2e3),he.success("Portal link copied!")},I=async()=>{if(!u.trim()){he.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:R}=await H.functions.invoke("gmail-send",{body:{to:u,subject:N,body:C.replace(/\n/g,"
")}});if(R)throw R;he.success(`Invite sent to ${u}`),s(!1)}catch(R){he.error(R.message||"Failed to send invite")}finally{g(!1)}},L=()=>{const R=encodeURIComponent(N),q=encodeURIComponent(C);window.open(`mailto:${u}?subject=${R}&body=${q}`,"_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(_s,{children:e.jsx(bs,{children:"Invite Client to Portal"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Client Name"}),e.jsx(ze,{value:i,onChange:R=>c(R.target.value),className:"mt-1",placeholder:"John Doe"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-sm font-medium",children:"Client Email"}),e.jsx(ze,{type:"email",value:u,onChange:R=>p(R.target.value),className:"mt-1",placeholder:"john@example.com"})]}),e.jsxs("div",{children:[e.jsx(ye,{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:j})}),e.jsx(K,{variant:"outline",size:"icon",onClick:M,className:"shrink-0",children:b?e.jsx(fa,{className:"h-4 w-4 text-emerald-600"}):e.jsx(gi,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"space-y-2 pt-2 border-t",children:[o?e.jsxs(K,{onClick:I,disabled:f||!u.trim(),className:"w-full",children:[f?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(dr,{className:"h-4 w-4 mr-2"}),"Send via Gmail (",l,")"]}):e.jsxs(K,{onClick:L,disabled:!u.trim(),className:"w-full",variant:"outline",children:[e.jsx(an,{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(gi,{className:"h-4 w-4 mr-2"}),"Just Copy Link"]})]})]})]})})}function Wjs({deal:t}){const{isAdmin:s,user:r}=Rs(),{data:n,isLoading:a}=Jbs(t.id),o=aSe(),l=pR(),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(!1);if(a)return e.jsx("div",{className:"border rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(ws,{className:"h-3 w-3 animate-spin ml-auto"})]})});const j=async()=>{var L,R;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:((L=t.contact)==null?void 0:L.email)||void 0,client_phone:((R=t.contact)==null?void 0:R.phone)||void 0}),he.success("Client portal enabled!")}catch{he.error("Failed to create portal")}finally{c(!1)}},w=async L=>{if(n)try{await l.mutateAsync({id:n.id,is_enabled:L}),he.success(L?"Portal enabled":"Portal disabled")}catch{he.error("Failed to update portal")}},N=()=>{if(!n)return;const L=v1(n.slug);navigator.clipboard.writeText(L),he.success("Portal link copied!")},C=()=>{if(!n)return;const L=v1(n.slug);window.open(L,"_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(un,{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(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(un,{className:"h-4 w-4 mr-2"}),"Enable Client Portal"]})]});const M=v1(n.slug),I=(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(un,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-medium text-sm",children:"Client Portal"}),e.jsx(tt,{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($r,{checked:n.is_enabled,onCheckedChange:w})]}),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(tt,{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:M})}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:N,className:"text-xs flex-1 min-w-0",children:[e.jsx(gi,{className:"h-3 w-3 mr-1 shrink-0"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:C,className:"text-xs flex-1 min-w-0",children:[e.jsx(an,{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(Rn,{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(DM,{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(Yo,{className:"h-3 w-3 mr-1 shrink-0"}),"Settings"]})]})]}),e.jsx(ilt,{open:u,onOpenChange:p,portal:n,dealOwnerId:I}),e.jsx(olt,{open:f,onOpenChange:g,portalId:n.id,portalSlug:n.slug,notifyClient:n.notify_client}),e.jsx(llt,{open:b,onOpenChange:_,portal:n,dealName:t.deal_name})]})}const Gjs=["Client","Co-Buyer","Co-Seller","Spouse","Lender","Title Company","Inspector","Appraiser","Attorney","Contractor","Other"];function Kjs(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 Zjs(){const t=es();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]}),he.success("Contact linked to deal")},onError:s=>{var r;(r=s.message)!=null&&r.includes("duplicate")?he.error("This contact is already linked to this deal"):he.error("Failed to link contact")}})}function Yjs(){const t=es();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]}),he.success("Contact removed from deal")},onError:()=>{he.error("Failed to remove contact")}})}function Xjs({dealId:t,primaryContactId:s}){const r=pr(),{data:n,isLoading:a}=Kjs(t),{data:o}=Wm(),l=Zjs(),i=Yjs(),[c,u]=k.useState(!1),[p,f]=k.useState(""),[g,b]=k.useState("Client"),_=new Set((n==null?void 0:n.map(M=>M.contact_id))||[]);s&&_.add(s);const j=o==null?void 0:o.filter(M=>{var L,R,q;if(_.has(M.id))return!1;if(!p.trim())return!0;const I=p.toLowerCase();return((L=M.first_name)==null?void 0:L.toLowerCase().includes(I))||((R=M.last_name)==null?void 0:R.toLowerCase().includes(I))||((q=M.email)==null?void 0:q.toLowerCase().includes(I))}).slice(0,8),w=M=>{l.mutate({dealId:t,contactId:M,role:g}),u(!1),f("")},N=M=>{i.mutate({id:M,dealId:t})},C={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(mr,{className:"h-4 w-4"}),"Additional Contacts"]})}),e.jsxs(Bo,{open:c,onOpenChange:u,children:[e.jsx($o,{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(Do,{className:"w-80 p-3",align:"start",children:e.jsx(cze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}):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(mr,{className:"h-4 w-4"}),"Linked Contacts",n&&n.length>0&&e.jsx(tt,{variant:"secondary",className:"text-[10px] px-1.5",children:n.length})]}),e.jsxs(Bo,{open:c,onOpenChange:u,children:[e.jsx($o,{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(Do,{className:"w-80 p-3",align:"end",children:e.jsx(cze,{search:p,setSearch:f,selectedRole:g,setSelectedRole:b,filteredContacts:j,onAdd:w})})]})]}),e.jsx("div",{className:"space-y-1.5",children:n==null?void 0:n.map(M=>{var I,L,R,q,U,B,V,Y;return e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-muted/40 group",children:[e.jsx(_n,{className:"h-7 w-7",children:e.jsxs(wn,{className:"text-[10px] bg-primary/10 text-primary",children:[(L=(I=M.contact)==null?void 0:I.first_name)==null?void 0:L[0],(q=(R=M.contact)==null?void 0:R.last_name)==null?void 0:q[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(tt,{variant:"outline",className:`text-[10px] px-1.5 py-0 shrink-0 ${C[M.role]||C.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(Un,{className:"h-3 w-3"})})}),((Y=M.contact)==null?void 0:Y.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(dr,{className:"h-3 w-3"})})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-6 w-6 text-destructive",onClick:()=>N(M.id),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]},M.id)})})]})}function cze({search:t,setSearch:s,selectedRole:r,setSelectedRole:n,filteredContacts:a,onAdd:o}){return e.jsxs("div",{className:"space-y-3",children:[e.jsxs(Ys,{value:r,onValueChange:n,children:[e.jsx(Gs,{className:"h-8 text-sm",children:e.jsx(Qs,{placeholder:"Role"})}),e.jsx(Ks,{children:Gjs.map(l=>e.jsx(Mt,{value:l,children:l},l))})]}),e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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(Gi,{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 Qjs={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"}},Jjs={note:io,call:Un,email:dr,meeting:cn,stage_change:an,task_completed:la,document:Sn,system:mn};function eNs({deal:t,open:s,onOpenChange:r,onEdit:n,onAddToScorecard:a,isWonStage:o}){var Fe,Ce;const{data:l,isLoading:i}=G_s((t==null?void 0:t.id)||""),{data:c,isLoading:u}=Z_s((t==null?void 0:t.id)||""),p=K_s(),f=X_s(),g=Y_s(),b=W_s(),{data:_,isLoading:j}=zjs((t==null?void 0:t.id)||""),w=Bjs(),N=$js(),C=qjs(),M=k.useRef(null),[I,L]=k.useState(""),[R,q]=k.useState(""),[U,B]=k.useState(!1),[V,Y]=k.useState(!1);if(!t)return null;const J=Qjs[t.deal_type],te=(()=>{var ct;if(t.deal_type!=="seller"&&t.deal_type!=="dual")return null;const Me=((ct=t.listing)==null?void 0:ct.created_at)||t.listing_date;if(!Me)return null;const $e=t.contract_date?Il(t.contract_date):new Date;return iy($e,Il(Me))})(),X=Me=>Me?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Me):"-",ce=async()=>{if(I.trim())try{await p.mutateAsync({deal_id:t.id,activity_type:"note",title:"Note added",description:I}),L(""),he.success("Note added")}catch{he.error("Failed to add note")}},ne=async()=>{if(R.trim())try{await f.mutateAsync({deal_id:t.id,title:R,sort_order:((c==null?void 0:c.length)||0)+1}),q(""),he.success("Task added")}catch{he.error("Failed to add task")}},re=async(Me,$e)=>{try{await g.mutateAsync({id:Me,is_completed:$e,deal_id:t.id})}catch{he.error("Failed to update task")}},le=async()=>{try{await b.mutateAsync(t.id),he.success("Deal deleted"),r(!1)}catch{he.error("Failed to delete deal")}},pe=(c==null?void 0:c.filter(Me=>Me.is_completed).length)||0,xe=(c==null?void 0:c.length)||0,_e=(_==null?void 0:_.length)||0,fe=Me=>Me<1024?`${Me} B`:Me<1024*1024?`${(Me/1024).toFixed(1)} KB`:`${(Me/(1024*1024)).toFixed(1)} MB`,we=Me=>Me?Me.startsWith("image/")?fl:Me.includes("pdf")?En:NM:NM,Ie=async Me=>{const $e=Me.target.files;if(!(!$e||!t)){Y(!0);try{for(const ct of Array.from($e)){if(ct.size>20*1024*1024){he.error(`${ct.name} exceeds 20MB limit`);continue}await w.mutateAsync({dealId:t.id,file:ct})}he.success("File(s) uploaded")}catch{he.error("Failed to upload file")}finally{Y(!1),M.current&&(M.current.value="")}}},Ne=async(Me,$e)=>{if(t)try{await N.mutateAsync({fileId:Me,storagePath:$e,dealId:t.id}),he.success("File deleted")}catch{he.error("Failed to delete file")}},Ae=async(Me,$e)=>{try{const ct=await Ujs(Me),Te=document.createElement("a");Te.href=ct,Te.download=$e,Te.target="_blank",document.body.appendChild(Te),Te.click(),document.body.removeChild(Te)}catch{he.error("Failed to download file")}};return e.jsxs(e.Fragment,{children:[e.jsx(QA,{open:s,onOpenChange:r,children:e.jsxs(mC,{className:"w-full sm:max-w-xl p-0 flex flex-col",children:[e.jsx(JA,{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(tt,{variant:"outline",className:Pt("text-xs",J.color),children:J.label}),e.jsxs(tt,{variant:"secondary",className:"text-xs capitalize",children:[t.priority," priority"]})]}),e.jsx(eE,{className:"text-xl",children:t.deal_name}),e.jsx("div",{className:"mt-2",children:e.jsx(Fjs,{dealId:t.id})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(K,{variant:"outline",size:"icon",onClick:()=>n(t),children:e.jsx(dd,{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(Gi,{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(_n,{className:"h-10 w-10",children:e.jsxs(wn,{className:"bg-primary/10 text-primary",children:[(Fe=t.contact.first_name)==null?void 0:Fe[0],(Ce=t.contact.last_name)==null?void 0:Ce[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(Un,{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(dr,{className:"h-4 w-4"})})})]})]}),e.jsx(Xjs,{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(Sn,{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:X(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:X(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?` (${X(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:X(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:X(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(xo,{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(la,{className:"h-4 w-4 text-green-600"}),e.jsx("span",{children:"Synced to Scorecard"})]}),te!==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:Pt("text-lg font-bold",te>90?"text-red-600":te>60?"text-amber-600":"text-foreground"),children:[te," ",t.contract_date?"(final)":"days"]})]}),t.target_close_date&&e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("span",{children:["Close: ",ps(Il(t.target_close_date),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(wc,{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(Wjs,{deal:t}),e.jsxs(ja,{defaultValue:"tasks",className:"w-full",children:[e.jsxs(ga,{className:"w-full grid grid-cols-3",children:[e.jsxs(us,{value:"tasks",className:"gap-1",children:[e.jsx(la,{className:"h-4 w-4"}),"Tasks ",xe>0&&`(${pe}/${xe})`]}),e.jsxs(us,{value:"files",className:"gap-1",children:[e.jsx(iS,{className:"h-4 w-4"}),"Files ",_e>0&&`(${_e})`]}),e.jsxs(us,{value:"activity",className:"gap-1",children:[e.jsx(mn,{className:"h-4 w-4"}),"Activity"]})]}),e.jsxs(ks,{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:R,onChange:Me=>q(Me.target.value),onKeyDown:Me=>Me.key==="Enter"&&ne()}),e.jsx(K,{onClick:ne,disabled:!R.trim(),children:e.jsx(qs,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[c==null?void 0:c.map(Me=>e.jsxs("div",{className:Pt("flex items-center gap-3 p-3 rounded-lg border transition-colors",Me.is_completed?"bg-muted/50 border-border":"bg-background"),children:[e.jsx(Lo,{checked:Me.is_completed,onCheckedChange:$e=>re(Me.id,!!$e)}),e.jsx("span",{className:Pt("flex-1 text-sm",Me.is_completed&&"line-through text-muted-foreground"),children:Me.title}),Me.due_date&&e.jsx("span",{className:"text-xs text-muted-foreground",children:ps(new Date(Me.due_date),"MMM d")})]},Me.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(ks,{value:"files",className:"mt-4 space-y-3",children:[e.jsx("input",{type:"file",ref:M,className:"hidden",multiple:!0,onChange:Ie,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 Me;return(Me=M.current)==null?void 0:Me.click()},disabled:V,children:[V?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(oi,{className:"h-4 w-4 mr-2"}),V?"Uploading...":"Upload Files"]}),e.jsxs("div",{className:"space-y-2",children:[_==null?void 0:_.map(Me=>{const $e=we(Me.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($e,{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:Me.file_name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[fe(Me.file_size)," · ",ps(new Date(Me.created_at),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F1,{children:e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:`h-8 w-8 transition-colors ${Me.visible_on_portal?"text-primary bg-primary/10 hover:bg-primary/20":"text-muted-foreground/40 hover:text-muted-foreground"}`,onClick:()=>C.mutate({fileId:Me.id,visible:!Me.visible_on_portal,dealId:t.id}),children:Me.visible_on_portal?e.jsx(qn,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})})}),e.jsx(gc,{side:"top",children:Me.visible_on_portal?"Visible on client portal":"Hidden from client portal"})]})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Ae(Me.storage_path,Me.file_name),children:e.jsx(Ci,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>Ne(Me.id,Me.storage_path),children:e.jsx(Or,{className:"h-4 w-4"})})]})]},Me.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(ks,{value:"activity",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(Er,{placeholder:"Add a note...",value:I,onChange:Me=>L(Me.target.value),rows:2}),e.jsxs(K,{onClick:ce,disabled:!I.trim(),size:"sm",className:"w-full",children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Add Note"]})]}),e.jsxs("div",{className:"space-y-3",children:[l==null?void 0:l.map(Me=>{const $e=Jjs[Me.activity_type]||mn;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($e,{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:Me.title}),Me.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:Me.description}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:_d(new Date(Me.created_at),{addSuffix:!0})})]})]},Me.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(_c,{open:U,onOpenChange:B,children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Deal?"}),e.jsxs(Jl,{children:['This will permanently delete "',t.deal_name,'" and all associated data. This action cannot be undone.']})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:le,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})}function tNs({open:t,onOpenChange:s,deal:r,onComplete:n}){const a=bue(),o=Qat(),{data:l}=tE(),{data:i}=Ux(),[c,u]=k.useState({property_address:"",city:"",state:"",zip:"",transaction_type:"buyer",close_date:ps(new Date,"yyyy-MM-dd"),sale_price:0,commission_amount:0,lead_source_id:"",client_type_id:"",notes:""});k.useEffect(()=>{if(r&&t){const g=r.deal_type==="seller"?"seller":"buyer",b=r.expected_price||0,_=r.commission_percentage||3,j=r.expected_commission||b*_/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||ps(new Date,"yyyy-MM-dd"),sale_price:b,commission_amount:j,lead_source_id:"",client_type_id:"",notes:r.notes||""})}},[r,t]);const p=async g=>{if(g.preventDefault(),!!r)try{const b=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:b.id,actual_close_date:c.close_date}),he.success("Deal added to Scorecard! 🎉"),s(!1),n==null||n()}catch(b){console.error("Error syncing to scorecard:",b),he.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(_s,{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(xo,{className:"h-6 w-6 text-green-600 dark:text-green-400"})}),e.jsx(bs,{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(ye,{htmlFor:"property_address",className:"flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4 text-muted-foreground"}),"Property Address *"]}),e.jsx(ze,{id:"property_address",value:c.property_address,onChange:g=>u(b=>({...b,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(ye,{htmlFor:"city",children:"City"}),e.jsx(ze,{id:"city",value:c.city,onChange:g=>u(b=>({...b,city:g.target.value})),placeholder:"City"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"state",children:"State"}),e.jsx(ze,{id:"state",value:c.state,onChange:g=>u(b=>({...b,state:g.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"zip",children:"Zip"}),e.jsx(ze,{id:"zip",value:c.zip,onChange:g=>u(b=>({...b,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(ye,{children:"Transaction Type *"}),e.jsxs(Ys,{value:c.transaction_type,onValueChange:g=>u(b=>({...b,transaction_type:g})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{htmlFor:"close_date",className:"flex items-center gap-2",children:[e.jsx(cn,{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(b=>({...b,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(ye,{htmlFor:"sale_price",className:"flex items-center gap-2",children:[e.jsx(wc,{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(b=>({...b,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(ye,{htmlFor:"commission_amount",className:"flex items-center gap-2",children:[e.jsx(OM,{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(b=>({...b,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(ye,{children:"Lead Source"}),e.jsxs(Ys,{value:c.lead_source_id,onValueChange:g=>u(b=>({...b,lead_source_id:g})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select source"})}),e.jsx(Ks,{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(ye,{children:"Client Type"}),e.jsxs(Ys,{value:c.client_type_id,onValueChange:g=>u(b=>({...b,client_type_id:g})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select type"})}),e.jsx(Ks,{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(ye,{htmlFor:"notes",children:"Notes"}),e.jsx(Er,{id:"notes",value:c.notes,onChange:g=>u(b=>({...b,notes:g.target.value})),placeholder:"Any additional notes about this transaction...",rows:2})]}),e.jsxs(zn,{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(fi,{className:"ml-2 h-4 w-4"})]})})]})]})]})})}const sNs={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"}},dze={urgent:0,high:1,medium:2,low:3};function rNs({deals:t,stages:s,onDealClick:r,onStageChange:n}){const[a,o]=k.useState("target_close_date"),[l,i]=k.useState("asc"),c=b=>{a===b?i(_=>_==="asc"?"desc":"asc"):(o(b),i("asc"))},u=k.useMemo(()=>[...t].sort((b,_)=>{var w,N;let j=0;switch(a){case"deal_name":j=b.deal_name.localeCompare(_.deal_name);break;case"stage":{const C=((w=s.find(I=>I.id===b.stage_id))==null?void 0:w.sort_order)||0,M=((N=s.find(I=>I.id===_.stage_id))==null?void 0:N.sort_order)||0;j=C-M;break}case"expected_price":j=(b.expected_price||0)-(_.expected_price||0);break;case"expected_commission":j=(b.expected_commission||0)-(_.expected_commission||0);break;case"target_close_date":{const C=b.target_close_date?Il(b.target_close_date).getTime():1/0,M=_.target_close_date?Il(_.target_close_date).getTime():1/0;j=C-M;break}case"priority":j=dze[b.priority]-dze[_.priority];break}return l==="asc"?j:-j}),[t,s,a,l]),p=b=>b?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(b):"—",f=b=>b?s.find(_=>_.id===b):null,g=({field:b,children:_})=>e.jsxs(K,{variant:"ghost",size:"sm",className:"h-8 -ml-3 font-medium",onClick:()=>c(b),children:[_,a===b?l==="asc"?e.jsx(Nu,{className:"ml-2 h-4 w-4"}):e.jsx(Hh,{className:"ml-2 h-4 w-4"}):e.jsx(yd,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{className:"bg-muted/50",children:[e.jsx(kt,{className:"w-[250px]",children:e.jsx(g,{field:"deal_name",children:"Deal Name"})}),e.jsx(kt,{className:"w-[150px]",children:e.jsx(g,{field:"stage",children:"Stage"})}),e.jsx(kt,{className:"w-[100px]",children:"Type"}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(g,{field:"expected_price",children:"Price"})}),e.jsx(kt,{className:"w-[120px]",children:e.jsx(g,{field:"expected_commission",children:"GCI"})}),e.jsx(kt,{className:"w-[130px]",children:e.jsx(g,{field:"target_close_date",children:"Close Date"})}),e.jsx(kt,{className:"w-[100px]",children:e.jsx(g,{field:"priority",children:"Priority"})})]})}),e.jsx(On,{children:u.map(b=>{f(b.stage_id);const _=sNs[b.deal_type],j=b.target_close_date?iy(Il(b.target_close_date),new Date):null,w=j!==null&&j<0,N=j!==null&&j<=7&&j>=0;return e.jsxs(Ss,{className:Pt("cursor-pointer hover:bg-muted/50 transition-colors",w&&"bg-red-50/50"),onClick:()=>r(b),children:[e.jsx(dt,{className:"font-medium",children:e.jsxs("div",{children:[e.jsx("p",{className:"truncate max-w-[230px]",children:b.deal_name}),b.contact&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate",children:[b.contact.first_name," ",b.contact.last_name]})]})}),e.jsx(dt,{onClick:C=>C.stopPropagation(),children:e.jsx(nlt,{stages:s,currentStageId:b.stage_id||"",onStageSelect:(C,M)=>n(b.id,C,M)})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:Pt("text-xs",_.color),children:_.label})}),e.jsx(dt,{children:e.jsx("span",{className:"font-medium",children:p(b.expected_price)})}),e.jsx(dt,{children:e.jsx("span",{className:"text-emerald-600",children:p(b.expected_commission)})}),e.jsx(dt,{children:b.target_close_date?e.jsxs("div",{className:Pt("flex items-center gap-1 text-sm",w&&"text-red-600",N&&!w&&"text-amber-600"),children:[w&&e.jsx(Nl,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:ps(Il(b.target_close_date),"MMM d, yyyy")})]}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:Pt("text-xs capitalize",b.priority==="urgent"&&"border-red-200 bg-red-50 text-red-700",b.priority==="high"&&"border-orange-200 bg-orange-50 text-orange-700",b.priority==="medium"&&"border-amber-200 bg-amber-50 text-amber-700",b.priority==="low"&&"border-slate-200 bg-slate-50 text-slate-600"),children:b.priority})})]},b.id)})})]})})}function nNs(){const t=li();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 aNs(t){const s=li();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 iNs(){const t=li(),s=es();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 oNs(){const t=es();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 lNs(){const t=es();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 iCe(){const t=es();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 cNs(){const t=es();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 dNs(t){const s=li();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 uNs(){const t=li(),s=es();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=es();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 mNs(){const t=li(),s=es();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 pNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function fNs({open:t,onOpenChange:s,dealId:r,dealName:n,fromStageName:a,toStageName:o,toStageId:l,onConfirm:i}){const{data:c,isLoading:u}=aNs(t?r:void 0),p=cNs(),f=mNs(),[g,b]=k.useState(new Set),[_,j]=k.useState(!1),w=(c||[]).filter(I=>I.status!=="done");k.useEffect(()=>{w.length>0&&b(new Set(w.map(I=>I.id)))},[c]);const N=I=>{b(L=>{const R=new Set(L);return R.has(I)?R.delete(I):R.add(I),R})},C=async()=>{j(!0);try{const I=Array.from(g);I.length>0&&await p.mutateAsync(I),await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move failed:",I),he.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{j(!1)}},M=async()=>{j(!0);try{await i(),await f.mutateAsync({dealId:r,stageId:l}),s(!1)}catch(I){console.error("Stage move (skip) failed:",I),he.error((I==null?void 0:I.message)||"Failed to move deal. Please try again.")}finally{j(!1)}};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{className:"sm:max-w-[480px]",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(tt,{variant:"outline",className:"text-sm",children:a}),e.jsx(fi,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(tt,{className:"text-sm bg-primary",children:o})]}),u?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(ws,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):w.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:w.length})," incomplete task",w.length!==1?"s":"",". Select which to mark as done:"]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsx("div",{className:"space-y-1",children:w.map(I=>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(Lo,{checked:g.has(I.id),onCheckedChange:()=>N(I.id)}),e.jsxs("span",{className:"text-sm flex-1",children:[pNs[I.priority]," ",I.title]}),I.stage&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full",style:{backgroundColor:I.stage.color+"20",color:I.stage.color},children:I.stage.name})]},I.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===w.length?b(new Set):b(new Set(w.map(I=>I.id)))},children:g.size===w.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:C,disabled:_,children:[_&&e.jsx(ws,{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(la,{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:C,disabled:_,children:[_&&e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}),"Move to ",o]})]})]})]})})}function xNs(){const t=li();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 gNs({dealId:t,dealName:s,contactName:r,portal:n,onSettingsOpen:a,onComposerOpen:o,onInviteOpen:l,onDeleteConfirm:i}){const c=aSe(),u=pR(),p=e_s(),f=t_s(),[g,b]=k.useState(!1),_=!!(n!=null&&n.archived_at),j=async()=>{b(!0);try{await c.mutateAsync({deal_id:t,visibility:"private",require_onboarding:!0}),he.success("Portal enabled!")}catch{he.error("Failed to create portal")}finally{b(!1)}},w=async L=>{if(n)try{await u.mutateAsync({id:n.id,is_enabled:L}),he.success(L?"Portal enabled":"Portal disabled")}catch{he.error("Failed to update portal")}},N=()=>{n&&(navigator.clipboard.writeText(v1(n.slug)),he.success("Link copied!"))},C=()=>{n&&window.open(v1(n.slug),"_blank")},M=async()=>{if(n)try{await p.mutateAsync(n.id),he.success("Portal archived")}catch{he.error("Failed to archive portal")}},I=async()=>{if(n)try{await f.mutateAsync(n.id),he.success("Portal restored")}catch{he.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(tt,{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:I,className:"text-xs gap-1",children:[e.jsx(UI,{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(tt,{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:N,title:"Copy link",children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:C,title:"Preview",children:e.jsx(an,{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(Rn,{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(DM,{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(Yo,{className:"h-3.5 w-3.5"})}),e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(px,{className:"h-3.5 w-3.5"})})}),e.jsx(zd,{align:"end",children:e.jsxs(Ca,{onClick:M,children:[e.jsx(vM,{className:"h-4 w-4 mr-2"}),"Archive Portal"]})})]}),e.jsx($r,{checked:n.is_enabled,onCheckedChange:w,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:j,disabled:g,className:"shrink-0 ml-4",children:[g?e.jsx(ws,{className:"h-3 w-3 animate-spin mr-1"}):e.jsx(un,{className:"h-3 w-3 mr-1"}),"Enable Portal"]})]})}function yNs(){const{data:t,isLoading:s}=Hhe(),{data:r,isLoading:n}=xNs(),[a,o]=k.useState(""),[l,i]=k.useState("all"),c=s_s(),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(null),N=li(),C=s||n,M=new Map;r==null||r.forEach(V=>M.set(V.deal_id,V));const L=[...(t||[]).filter(V=>{var ce,ne,re,le,pe;const Y=M.get(V.id),J=a.toLowerCase(),te=!J||V.deal_name.toLowerCase().includes(J)||((ne=(ce=V.contact)==null?void 0:ce.first_name)==null?void 0:ne.toLowerCase().includes(J))||((le=(re=V.contact)==null?void 0:re.last_name)==null?void 0:le.toLowerCase().includes(J))||((pe=Y==null?void 0:Y.client_name)==null?void 0:pe.toLowerCase().includes(J));let X=!0;return l==="active"?X=!!(Y!=null&&Y.is_enabled)&&!(Y!=null&&Y.archived_at):l==="disabled"?X=!!Y&&!Y.is_enabled&&!Y.archived_at:l==="archived"?X=!!(Y!=null&&Y.archived_at):l==="none"?X=!Y:l==="all"&&(X=!(Y!=null&&Y.archived_at)||!Y),te&&X})].sort((V,Y)=>{const J=M.get(V.id),te=M.get(Y.id);if(J!=null&&J.archived_at&&!(te!=null&&te.archived_at))return 1;if(!(J!=null&&J.archived_at)&&(te!=null&&te.archived_at)||J&&!te)return-1;if(!J&&te)return 1;if(J&&te){if(J.is_enabled&&!te.is_enabled)return-1;if(!J.is_enabled&&te.is_enabled)return 1}return 0}),R=(r==null?void 0:r.filter(V=>!V.archived_at).length)||0,q=(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(j)try{await c.mutateAsync({id:j.id,dealId:j.deal_id}),he.success("Portal permanently deleted"),w(null)}catch{he.error("Failed to delete portal")}};return C?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(ws,{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(un,{className:"h-4 w-4 text-primary"}),e.jsxs("span",{className:"font-medium",children:[R," Portals"]})]}),e.jsxs("span",{className:"text-muted-foreground",children:[q," active · ",R-q," 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(hn,{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(Or,{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(Gi,{className:"h-[calc(100vh-22rem)]",children:e.jsxs("div",{className:"space-y-2 pb-4",children:[L.map(V=>{const Y=M.get(V.id)||null,J=V.contact?`${V.contact.first_name||""} ${V.contact.last_name||""}`.trim():"";return e.jsx(gNs,{dealId:V.id,dealName:V.deal_name,contactName:J,portal:Y,onSettingsOpen:p,onComposerOpen:te=>g(te),onInviteOpen:(te,X)=>_({portal:te,dealName:X}),onDeleteConfirm:w},V.id)}),L.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(un,{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(ilt,{open:!!u,onOpenChange:V=>!V&&p(null),portal:u,dealOwnerId:N||""}),f&&e.jsx(olt,{open:!!f,onOpenChange:V=>!V&&g(null),portalId:f.id,portalSlug:f.slug,notifyClient:f.notify_client}),b&&e.jsx(llt,{open:!!b,onOpenChange:V=>!V&&_(null),portal:b.portal,dealName:b.dealName}),e.jsx(_c,{open:!!j,onOpenChange:V=>!V&&w(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Permanently delete this portal?"}),e.jsx(Jl,{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(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:B,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete Permanently"})]})]})})]})}class vNs extends k.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}}function bNs(){var hs;const t=NE(),{data:s,isLoading:r}=Vhe(),{data:n,isLoading:a,refetch:o}=Hhe(),{data:l,isLoading:i}=Q_s(),c=Yat(),u=H_s(),[p,f]=k.useState("board"),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(null),[C,M]=k.useState(null),[I,L]=k.useState(null),[R,q]=k.useState(null),[U,B]=k.useState(!1),[V,Y]=k.useState(null),[J,te]=k.useState(""),[X,ce]=k.useState("all"),[ne,re]=k.useState(!1),[le,pe]=k.useState(!1),[xe,_e]=k.useState(new Set),[fe,we]=k.useState(null),{data:Ie}=Bx(),{isTeamLeader:Ne,teamMembers:Ae}=Mjs(),Fe=k.useMemo(()=>Array.from(xe),[xe]),{data:Ce}=Tjs(Fe),Me=k.useMemo(()=>{const Yt=new Map;return Ae.forEach(ts=>Yt.set(ts.id,{name:ts.name,avatar_url:ts.avatar_url,color:ts.color})),Yt},[Ae]),$e=k.useCallback(Yt=>Yt.owner_user_id&&Me.get(Yt.owner_user_id)||null,[Me]),ct=k.useCallback(Yt=>{_e(ts=>{const Ds=new Set(ts);return Ds.has(Yt)?Ds.delete(Yt):Ds.add(Yt),Ds})},[]);k.useEffect(()=>{!r&&s&&s.length===0&&c.mutate()},[r,s]);const[Te,ft]=qc(),me=k.useRef(!1);k.useEffect(()=>{const Yt=Te.get("deal");if(Yt&&n&&n.length>0&&!me.current){const ts=n.find(Ds=>Ds.id===Yt);ts&&(me.current=!0,N(ts),j(!0),Te.delete("deal"),ft(Te,{replace:!0}))}},[n,Te]);const Ve=k.useMemo(()=>{if(!Ce||!s)return[];const Yt=new Map(s.map(ts=>[ts.name,ts.id]));return Ce.map(ts=>{const Ds=ts._stage_name&&Yt.get(ts._stage_name)||null;return{...ts,stage_id:Ds||ts.stage_id}})},[Ce,s]),nt=k.useMemo(()=>[...n||[],...Ve],[n,Ve]),et=nt.filter(Yt=>{var Ct,As,Us,kr,ta,ka;const ts=J.toLowerCase(),Ds=!ts||Yt.deal_name.toLowerCase().includes(ts)||((As=(Ct=Yt.contact)==null?void 0:Ct.first_name)==null?void 0:As.toLowerCase().includes(ts))||((kr=(Us=Yt.contact)==null?void 0:Us.last_name)==null?void 0:kr.toLowerCase().includes(ts))||((ta=Yt.property_address)==null?void 0:ta.toLowerCase().includes(ts))||((ka=Yt.city)==null?void 0:ka.toLowerCase().includes(ts)),vr=X==="all"||Yt.deal_type===X;return Ds&&vr}),Se=k.useMemo(()=>{if(!s)return l||null;const Yt=new Set(s.filter(Us=>Us.is_won_stage).map(Us=>Us.id)),ts=new Set(s.filter(Us=>Us.is_lost_stage).map(Us=>Us.id)),Ds=nt.filter(Us=>Us.stage_id&&!Yt.has(Us.stage_id)&&!ts.has(Us.stage_id)),vr=nt.filter(Us=>Us.stage_id&&Yt.has(Us.stage_id)),Ct=new Date().getFullYear(),As=vr.filter(Us=>Us.actual_close_date?new Date(Us.actual_close_date).getFullYear()===Ct:!0);return{totalDeals:nt.length,activeDeals:Ds.length,wonDeals:vr.length,pipelineValue:Ds.reduce((Us,kr)=>Us+(kr.expected_price||0),0),expectedCommission:Ds.reduce((Us,kr)=>Us+(kr.expected_commission||0),0),expectedNetToAgent:Ds.reduce((Us,kr)=>Us+(yx(kr)||0),0),wonValue:vr.reduce((Us,kr)=>Us+(kr.expected_price||0),0),weightedGCI:Ds.reduce((Us,kr)=>Us+(kr.expected_commission||0)*((kr.probability??50)/100),0),weightedNet:Ds.reduce((Us,kr)=>Us+(yx(kr)||0)*((kr.probability??50)/100),0),ytdWonDeals:As.length,ytdWonGCI:As.reduce((Us,kr)=>Us+(kr.expected_commission||0),0),ytdWonNet:As.reduce((Us,kr)=>Us+(yx(kr)||0),0),projectedAnnualNet:As.reduce((Us,kr)=>Us+(yx(kr)||0),0)+Ds.reduce((Us,kr)=>Us+(yx(kr)||0)*((kr.probability??50)/100),0)}},[nt,s,l]),rt=Yt=>{N(Yt),j(!0)},Ge=Yt=>{M(Yt||null),N(null),b(!0)},lt=Yt=>{N(Yt),j(!1),b(!0)},qe=(Yt,ts)=>{L(Yt)},Ze=(Yt,ts)=>{Yt.preventDefault(),Yt.dataTransfer.dropEffect="move",q(ts)},Je=async(Yt,ts)=>{if(Yt.preventDefault(),q(null),!I)return;const Ds=n==null?void 0:n.find(As=>As.id===I),vr=s==null?void 0:s.find(As=>As.id===ts),Ct=s==null?void 0:s.find(As=>As.id===(Ds==null?void 0:Ds.stage_id));if(!Ds||!vr||Ds.stage_id===ts){L(null);return}we({dealId:I,dealName:Ds.deal_name,fromStageName:(Ct==null?void 0:Ct.name)||"Unknown",toStageName:vr.name,toStageId:ts,isWonStage:vr.is_won_stage,deal:Ds}),L(null)},He=async()=>{if(!fe)return;const{dealId:Yt,toStageId:ts,toStageName:Ds,isWonStage:vr,deal:Ct}=fe;if(await u.mutateAsync({dealId:Yt,stageId:ts,stageName:Ds}),he.success(`Moved to ${Ds}`),vr&&!Ct.scorecard_transaction_id){const As={...Ct,stage_id:ts};Y(As),B(!0)}},Qe=k.useCallback(async(Yt,ts,Ds)=>{const vr=n==null?void 0:n.find(Us=>Us.id===Yt),Ct=s==null?void 0:s.find(Us=>Us.id===ts),As=s==null?void 0:s.find(Us=>Us.id===(vr==null?void 0:vr.stage_id));!vr||!Ct||vr.stage_id===ts||we({dealId:Yt,dealName:vr.deal_name,fromStageName:(As==null?void 0:As.name)||"Unknown",toStageName:Ds,toStageId:ts,isWonStage:Ct.is_won_stage,deal:vr})},[n,s]),at=Yt=>et.filter(ts=>ts.stage_id===Yt),It=r||a,Ut=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(F1,{children:e.jsxs("div",{className:"flex bg-muted rounded-lg p-1 gap-0.5",children:[e.jsxs(Oc,{children:[e.jsx(Rc,{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(gc,{children:"Kanban board view"})]}),e.jsxs(Oc,{children:[e.jsx(Rc,{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(Ch,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"List"})]})}),e.jsx(gc,{children:"Grouped list view"})]}),e.jsxs(Oc,{children:[e.jsx(Rc,{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(BM,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Table"})]})}),e.jsx(gc,{children:"Sortable table view"})]}),e.jsxs(Oc,{children:[e.jsx(Rc,{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(un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Portals"})]})}),e.jsx(gc,{children:"Client portal management"})]})]})}),Ie&&!Ne&&e.jsxs(K,{variant:"outline",onClick:()=>re(!0),children:[e.jsx(mr,{className:"h-4 w-4 mr-2"}),"Team"]}),e.jsxs(K,{onClick:()=>Ge(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Deal"]})]})]}),Ut!=="portals"&&e.jsx(Ijs,{stats:Se,isLoading:i}),Ut!=="portals"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(hn,{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:J,onChange:Yt=>te(Yt.target.value),className:"pl-9 pr-8"}),J&&e.jsx("button",{onClick:()=>te(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:e.jsx(Or,{className:"h-4 w-4"})})]}),e.jsxs(Ys,{value:X,onValueChange:ce,children:[e.jsx(Gs,{className:"w-[140px]",children:e.jsx(Qs,{placeholder:"All Types"})}),e.jsxs(Ks,{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"})]})]}),(J||X!=="all")&&e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[et.length," of ",(n==null?void 0:n.length)||0," deals"]})]})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[Ne&&!t&&Ae.length>0&&e.jsx(Cjs,{members:Ae,enabledMembers:xe,onToggleMember:ct,isOpen:le,onToggleOpen:()=>pe(Yt=>!Yt)}),e.jsx("div",{className:"flex-1 min-w-0 min-h-0 p-4 md:p-6 pt-4",children:It?e.jsx("div",{className:"flex gap-4 h-full",children:[1,2,3,4].map(Yt=>e.jsx("div",{className:"min-w-[280px] max-w-[320px] flex-shrink-0",children:e.jsx(vs,{className:"h-full rounded-xl"})},Yt))}):Ut==="board"?e.jsxs(Gi,{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(Yt=>e.jsx(Pjs,{stage:Yt,deals:at(Yt.id),onDealClick:rt,onAddDeal:Ge,onDragStart:qe,onDragOver:Ze,onDrop:Je,isDragOver:R===Yt.id,isWonStage:Yt.is_won_stage,getOwnerInfo:$e},Yt.id))}),e.jsx(tue,{orientation:"horizontal"})]}):Ut==="table"?e.jsx(Gi,{className:"h-full",children:e.jsx(rNs,{deals:et,stages:s||[],onDealClick:rt,onStageChange:Qe})}):Ut==="portals"?e.jsx(yNs,{}):e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"space-y-6",children:[s==null?void 0:s.map(Yt=>{const ts=at(Yt.id);return ts.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:Yt.color}}),e.jsx("h3",{className:"font-semibold",children:Yt.name}),e.jsxs("span",{className:"text-muted-foreground text-sm",children:["(",ts.length,")"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3",children:ts.map(Ds=>e.jsx(alt,{deal:Ds,onClick:()=>rt(Ds),stages:s,onStageChange:Qe,showStagePicker:!0,isWonStage:Yt.is_won_stage,ownerInfo:$e(Ds)},Ds.id))})]},Yt.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:()=>Ge(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Your First Deal"]})]}),((n==null?void 0:n.length)||0)>0&&et.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(hn,{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:()=>{te(""),ce("all")},children:"Clear Filters"})]})]})})})]})]}),e.jsx(Rjs,{open:g,onOpenChange:b,deal:w,defaultStageId:C}),e.jsx(eNs,{deal:w,open:_,onOpenChange:j,onEdit:lt,isWonStage:w?(hs=s==null?void 0:s.find(Yt=>Yt.id===w.stage_id))==null?void 0:hs.is_won_stage:!1,onAddToScorecard:Yt=>{Y(Yt),B(!0),j(!1)}}),e.jsx(tNs,{open:U,onOpenChange:B,deal:V,onComplete:()=>{o(),Y(null)}}),fe&&e.jsx(fNs,{open:!!fe,onOpenChange:Yt=>{Yt||we(null)},dealId:fe.dealId,dealName:fe.dealName,fromStageName:fe.fromStageName,toStageName:fe.toStageName,toStageId:fe.toStageId,onConfirm:He}),e.jsx(kjs,{open:ne,onOpenChange:re})]})}function _Ns(){return e.jsx(vNs,{children:e.jsx(bNs,{})})}function clt({open:t,onOpenChange:s,editTask:r,defaultDealId:n,defaultStageId:a}){var te;const o=iNs(),l=oNs(),{data:i}=Hhe(),c=li(),{data:u}=mt({queryKey:["contacts-for-tasks",c],queryFn:async()=>{if(!c)return[];const{data:X,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 X},enabled:!!c&&t}),[p,f]=k.useState(""),[g,b]=k.useState(""),[_,j]=k.useState("none"),[w,N]=k.useState("none"),[C,M]=k.useState("medium"),[I,L]=k.useState("todo"),[R,q]=k.useState(),[U,B]=k.useState(!1),[V,Y]=k.useState(!1);k.useEffect(()=>{r?(f(r.title),b(r.description||""),j(r.deal_id||"none"),N(r.contact_id||"none"),M(r.priority),L(r.status),q(r.due_date?wm(r.due_date):void 0)):(f(""),b(""),j(n||"none"),N("none"),M("medium"),L("todo"),q(void 0))},[r,t,n]);const J=async()=>{if(!p.trim()){he.error("Task title is required");return}try{const X={title:p.trim(),description:g.trim()||null,deal_id:_==="none"?null:_,contact_id:w==="none"?null:w,stage_id:a||null,priority:C,status:I,due_date:R?ps(R,"yyyy-MM-dd"):null};r?(await l.mutateAsync({id:r.id,...X}),he.success("Task updated")):(await o.mutateAsync(X),he.success("Task created")),s(!1)}catch{he.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(_s,{children:e.jsx(bs,{children:r?"Edit Task":"New Task"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title *"}),e.jsx(ze,{value:p,onChange:X=>f(X.target.value),placeholder:"e.g., Send inspection report"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:g,onChange:X=>b(X.target.value),placeholder:"Optional details...",rows:2})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Priority"}),e.jsxs(Ys,{value:C,onValueChange:X=>M(X),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Status"}),e.jsxs(Ys,{value:I,onValueChange:X=>L(X),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Due Date"}),e.jsxs(Bo,{children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",className:Pt("w-full justify-start text-left font-normal",!R&&"text-muted-foreground"),children:[e.jsx(cn,{className:"mr-2 h-4 w-4"}),R?ps(R,"PPP"):"Pick a date"]})}),e.jsx(Do,{className:"w-auto p-0",align:"start",children:e.jsx(_f,{mode:"single",selected:R,onSelect:q,initialFocus:!0,className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Link to Deal"}),e.jsxs(Bo,{open:U,onOpenChange:B,children:[e.jsx($o,{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(wa,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),_!=="none"?((te=i==null?void 0:i.find(X=>X.id===_))==null?void 0:te.deal_name)||"Select deal":"No Deal"]}),e.jsx(Sx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search deals..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No deals found."}),e.jsxs(Fx,{children:[e.jsxs(vp,{value:"no-deal",onSelect:()=>{j("none"),B(!1)},children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",_==="none"?"opacity-100":"opacity-0")}),"No Deal"]}),i==null?void 0:i.map(X=>e.jsxs(vp,{value:X.deal_name,onSelect:()=>{j(X.id),B(!1)},children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",_===X.id?"opacity-100":"opacity-0")}),X.deal_name]},X.id))]})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Link to Contact"}),e.jsxs(Bo,{open:V,onOpenChange:Y,children:[e.jsx($o,{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(to,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),w!=="none"?(()=>{const X=u==null?void 0:u.find(ce=>ce.id===w);return X?`${X.first_name} ${X.last_name}`:"Select contact"})():"No Contact"]}),e.jsx(Sx,{className:"h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{children:[e.jsx(Dx,{placeholder:"Search contacts..."}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No contacts found."}),e.jsxs(Fx,{children:[e.jsxs(vp,{value:"no-contact",onSelect:()=>{N("none"),Y(!1)},children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",w==="none"?"opacity-100":"opacity-0")}),"No Contact"]}),u==null?void 0:u.map(X=>e.jsxs(vp,{value:`${X.first_name} ${X.last_name}`,onSelect:()=>{N(X.id),Y(!1)},children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",w===X.id?"opacity-100":"opacity-0")}),X.first_name," ",X.last_name]},X.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:J,disabled:o.isPending||l.isPending,children:r?"Save Changes":"Create Task"})]})]})]})})}const wNs={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 jNs({tasks:t}){const s=iCe(),r=lNs(),n=pr(),[a,o]=k.useState(null),l=async p=>{const f=p.status==="done"?"todo":"done";try{await s.mutateAsync({id:p.id,status:f})}catch{he.error("Failed to update task")}},i=async p=>{try{await r.mutateAsync(p),he.success("Task deleted")}catch{he.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(la,{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(uze,{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(wa,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("h3",{className:"font-medium text-sm",children:f.dealName}),e.jsxs(tt,{variant:"secondary",className:"ml-auto text-xs",children:[f.tasks.filter(g=>g.status==="done").length,"/",f.tasks.length]}),e.jsx(xa,{className:"h-3.5 w-3.5 text-muted-foreground"})]}),f.tasks.map(g=>e.jsx(uze,{task:g,onToggle:l,onDelete:i,onEdit:o,onNavigateDeal:b=>n(`/mission-control/pipeline?deal=${b}`)},g.id))]},p)),a&&e.jsx(clt,{open:!!a,onOpenChange:()=>o(null),editTask:a})]})}function uze({task:t,onToggle:s,onDelete:r,onEdit:n,onNavigateDeal:a}){const o=t.status==="done",l=!o&&t.due_date&&y0(wm(t.due_date))&&!vu(wm(t.due_date)),i=!o&&t.due_date&&vu(wm(t.due_date)),c=wNs[t.priority];return e.jsxs("div",{className:Pt("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(la,{className:"h-5 w-5 text-emerald-500"}):e.jsx(vd,{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:Pt("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(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]})]}),e.jsxs(tt,{variant:"outline",className:Pt("text-[10px] shrink-0",c.color),children:[c.dot," ",c.label]}),t.due_date&&e.jsxs("span",{className:Pt("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(mn,{className:"h-3 w-3"}),ps(wm(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(dd,{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 NNs=[{status:"todo",label:"To Do",icon:vd,color:"border-t-slate-400"},{status:"in_progress",label:"In Progress",icon:mp,color:"border-t-blue-500"},{status:"done",label:"Done",icon:la,color:"border-t-emerald-500"}],kNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function SNs({tasks:t}){const s=iCe(),r=k.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{he.error("Failed to move task")}};return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:NNs.map(o=>e.jsxs("div",{className:Pt("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(tt,{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(CNs,{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 CNs({task:t,onDragStart:s}){const r=t.status==="done",n=!r&&t.due_date&&y0(wm(t.due_date))&&!vu(wm(t.due_date)),a=!r&&t.due_date&&vu(wm(t.due_date));return e.jsx("div",{draggable:!0,onDragStart:o=>s(o,t.id),className:Pt("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:kNs[t.priority]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:Pt("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(wa,{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(to,{className:"h-2.5 w-2.5"}),t.contact.first_name," ",t.contact.last_name]})]}),t.due_date&&e.jsxs("div",{className:Pt("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(mn,{className:"h-2.5 w-2.5"}),n?"Overdue — ":a?"Due today — ":"",ps(wm(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 hze={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function MNs({tasks:t}){const[s,r]=k.useState(new Date),n=iCe(),a=Lc(s),o=lx(s),l=Yh(a),i=Yde(o),c=h4t({start:l,end:i}),u=k.useMemo(()=>{const g=new Map;return t.forEach(b=>{if(!b.due_date)return;const _=b.due_date,j=g.get(_)||[];j.push(b),g.set(_,j)}),g},[t]),p=k.useMemo(()=>t.filter(g=>!g.due_date),[t]),f=async g=>{const b=g.status==="done"?"todo":"done";try{await n.mutateAsync({id:g.id,status:b})}catch{he.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(f4(s,1)),children:e.jsx(ll,{className:"h-4 w-4"})}),e.jsx("h3",{className:"font-semibold",children:ps(s,"MMMM yyyy")}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>r(zm(s,1)),children:e.jsx(xa,{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 b=ps(g,"yyyy-MM-dd"),_=u.get(b)||[],j=Qde(g,s),w=vu(g);return e.jsxs("div",{className:Pt("border-r border-b min-h-[100px] p-1",!j&&"bg-muted/30",w&&"bg-primary/5"),children:[e.jsx("div",{className:Pt("text-xs font-medium mb-1 text-right px-1",!j&&"text-muted-foreground/40",w&&"text-primary font-bold"),children:ps(g,"d")}),e.jsxs("div",{className:"space-y-0.5",children:[_.slice(0,3).map(N=>e.jsxs("button",{onClick:()=>f(N),className:Pt("w-full text-left text-[10px] px-1 py-0.5 rounded truncate flex items-center gap-0.5 hover:bg-muted transition-colors",N.status==="done"?"text-muted-foreground line-through":"text-foreground"),children:[N.status==="done"?e.jsx(la,{className:"h-2.5 w-2.5 text-emerald-500 shrink-0"}):e.jsx(vd,{className:"h-2.5 w-2.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[hze[N.priority]," ",N.title]})]},N.id)),_.length>3&&e.jsxs("p",{className:"text-[9px] text-muted-foreground text-center",children:["+",_.length-3," more"]})]})]},b)})}),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:Pt("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(la,{className:"h-3.5 w-3.5 text-emerald-500 shrink-0"}):e.jsx(vd,{className:"h-3.5 w-3.5 shrink-0"}),e.jsxs("span",{className:"truncate",children:[hze[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 TNs={urgent:"🔴",high:"🟠",medium:"🟡",low:"🟢"};function ANs({open:t,onOpenChange:s,stages:r}){var N;const[n,a]=k.useState(((N=r[0])==null?void 0:N.id)||""),{data:o,isLoading:l}=dNs(n||void 0),i=uNs(),c=hNs(),[u,p]=k.useState(""),[f,g]=k.useState("medium"),[b,_]=k.useState(""),j=async()=>{if(!(!u.trim()||!n))try{await i.mutateAsync({stage_id:n,title:u.trim(),priority:f,default_due_offset_days:b?parseInt(b):null,sort_order:((o==null?void 0:o.length)||0)+1}),p(""),_(""),he.success("Template added")}catch{he.error("Failed to add template")}},w=async C=>{try{await c.mutateAsync(C),he.success("Template deleted")}catch{he.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(_s,{children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(sL,{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(ye,{children:"Pipeline Stage"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:r.filter(C=>!C.is_won_stage&&!C.is_lost_stage).map(C=>e.jsx("button",{onClick:()=>a(C.id),className:Pt("px-3 py-1.5 rounded-full text-xs font-medium border transition-colors",n===C.id?"border-primary bg-primary/10 text-primary":"border-border hover:bg-muted"),children:C.name},C.id))})]}),e.jsx(Gi,{className:"max-h-[250px]",children:e.jsxs("div",{className:"space-y-1.5",children:[o==null?void 0:o.map((C,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:TNs[C.priority]}),e.jsx("span",{className:"text-sm flex-1 truncate",children:C.title}),C.default_due_offset_days&&e.jsxs(tt,{variant:"outline",className:"text-[10px]",children:["+",C.default_due_offset_days,"d"]}),e.jsx("button",{onClick:()=>w(C.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"})})]},C.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(ye,{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:C=>p(C.target.value),className:"flex-1",onKeyDown:C=>C.key==="Enter"&&j()}),e.jsxs(Ys,{value:f,onValueChange:C=>g(C),children:[e.jsx(Gs,{className:"w-[100px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{className:"text-xs",children:"Due offset (days from entering stage)"}),e.jsx(ze,{type:"number",placeholder:"e.g., 7",value:b,onChange:C=>_(C.target.value)})]}),e.jsxs(K,{onClick:j,disabled:!u.trim()||i.isPending,children:[e.jsx(qs,{className:"h-4 w-4 mr-1"}),"Add"]})]})]})]})})}function ENs(){const{data:t,isLoading:s}=nNs(),{data:r}=Vhe(),[n,a]=k.useState("list"),[o,l]=k.useState(""),[i,c]=k.useState("active"),[u,p]=k.useState("all"),[f,g]=k.useState("all"),[b,_]=k.useState(!1),[j,w]=k.useState(!1),N=k.useMemo(()=>{if(!t)return[];const I=new Map;return t.forEach(L=>{L.deal&&I.set(L.deal.id,L.deal.deal_name)}),Array.from(I,([L,R])=>({id:L,name:R}))},[t]),C=k.useMemo(()=>t?t.filter(I=>{var V,Y,J,te;const L=o.toLowerCase(),R=!L||I.title.toLowerCase().includes(L)||((Y=(V=I.deal)==null?void 0:V.deal_name)==null?void 0:Y.toLowerCase().includes(L))||`${((J=I.contact)==null?void 0:J.first_name)||""} ${((te=I.contact)==null?void 0:te.last_name)||""}`.toLowerCase().includes(L),q=i==="all"||i==="active"&&I.status!=="done"||i==="todo"&&I.status==="todo"||i==="in_progress"&&I.status==="in_progress"||i==="done"&&I.status==="done"||i==="overdue"&&I.status!=="done"&&I.due_date&&y0(wm(I.due_date))&&!vu(wm(I.due_date)),U=u==="all"||I.priority===u,B=f==="all"||f==="no_deal"&&!I.deal_id||I.deal_id===f;return R&&q&&U&&B}):[],[t,o,i,u,f]),M=k.useMemo(()=>{if(!t)return{total:0,overdue:0,dueToday:0,dueThisWeek:0,completed:0};const I=t.filter(L=>L.status!=="done");return{total:I.length,overdue:I.filter(L=>L.due_date&&y0(wm(L.due_date))&&!vu(wm(L.due_date))).length,dueToday:I.filter(L=>L.due_date&&vu(wm(L.due_date))).length,dueThisWeek:I.filter(L=>L.due_date&&lCt(wm(L.due_date))).length,completed:t.filter(L=>L.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:()=>w(!0),children:[e.jsx(Yg,{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(Ch,{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(Gu,{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(mn,{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(Dd,{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(la,{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(hn,{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:I=>l(I.target.value),className:"pl-9"})]}),e.jsxs(Ys,{value:u,onValueChange:p,children:[e.jsx(Gs,{className:"w-[130px]",children:e.jsx(Qs,{placeholder:"Priority"})}),e.jsxs(Ks,{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(Ys,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-[160px]",children:e.jsx(Qs,{placeholder:"Deal"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Deals"}),e.jsx(Mt,{value:"no_deal",children:"No Deal"}),N.map(I=>e.jsx(Mt,{value:I.id,children:I.name},I.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(Ch,{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(u0,{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(Dd,{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(jNs,{tasks:C}),n==="kanban"&&e.jsx(SNs,{tasks:C}),n==="calendar"&&e.jsx(MNs,{tasks:C})]}),e.jsx(clt,{open:b,onOpenChange:_}),e.jsx(ANs,{open:j,onOpenChange:w,stages:r||[]})]})})}const rwe=[{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:Om,description:"Tags for your specialties"},{value:"custom_links",label:"Custom Links",icon:cl,description:"Custom CTA buttons"},{value:"social_media",label:"Social Media",icon:bd,description:"Links to your social profiles"}],PNs=["First-Time Buyers","Luxury Homes","Investment Properties","Relocation","New Construction","Condos & Townhomes","Waterfront","Commercial","Land & Lots","Senior Living","Military/VA","Short Sales & Foreclosures"],INs={video_intro:{video_url:""},testimonials:{testimonials:[{name:"",quote:"",role:""}]},specialties:{tags:[]},custom_links:{links:[{label:"",url:""}]},social_media:{platforms:[]}};function dlt({cardId:t}){const{data:s,isLoading:r}=okt(t),n=lkt(),a=ckt(),o=dkt(),[l,i]=k.useState(!1),[c,u]=k.useState(""),[p,f]=k.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:INs[c]||{}},{onSuccess:()=>{i(!1),u("")}})},b=C=>{a.mutate({id:C.id,is_visible:!C.is_visible})},_=(C,M)=>{if(!s)return;const I=s.findIndex(q=>q.id===C.id),L=M==="up"?I-1:I+1;if(L<0||L>=s.length)return;const R=s[L];a.mutate({id:C.id,sort_order:R.sort_order}),a.mutate({id:R.id,sort_order:C.sort_order})},j=C=>{confirm("Remove this block from this card?")&&o.mutate(C.id)},w=(C,M)=>{a.mutate({id:C.id,config:M},{onSuccess:()=>f(null)})},N=C=>rwe.find(M=>M.value===C);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((C,M)=>{const I=N(C.block_type),L=(I==null?void 0:I.icon)||Om;return e.jsx(Pe,{className:C.is_visible?"":"opacity-50",children:e.jsx(Re,{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ju,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx(L,{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:(I==null?void 0:I.label)||C.block_type}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:LNs(C)})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C,"up"),disabled:M===0,children:e.jsx(Nu,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>_(C,"down"),disabled:M===s.length-1,children:e.jsx(Hh,{className:"h-3 w-3"})}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>b(C),children:C.is_visible?e.jsx(qn,{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(C),children:"Edit"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 text-destructive",onClick:()=>j(C),children:e.jsx(Nr,{className:"h-3 w-3"})})]})]})})},C.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(_s,{children:e.jsx(bs,{children:"Add Block"})}),e.jsx("div",{className:"grid gap-3",children:rwe.map(C=>{const M=C.icon;return e.jsxs("button",{onClick:()=>u(C.value),className:`flex items-center gap-3 p-3 rounded-lg border text-left transition-colors ${c===C.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:C.label}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.description})]})]},C.value)})}),e.jsxs(zn,{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(DNs,{block:p,onSave:C=>w(p,C),onClose:()=>f(null)})]})}function LNs(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 DNs({block:t,onSave:s,onClose:r}){const[n,a]=k.useState(t.config),o=rwe.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(_s,{children:e.jsxs(bs,{children:["Edit ",o==null?void 0:o.label]})}),t.block_type==="video_intro"&&e.jsx(ONs,{config:n,onChange:a,cardId:t.card_id}),t.block_type==="testimonials"&&e.jsx(RNs,{config:n,onChange:a}),t.block_type==="specialties"&&e.jsx(FNs,{config:n,onChange:a}),t.block_type==="custom_links"&&e.jsx(zNs,{config:n,onChange:a}),t.block_type==="social_media"&&e.jsx(BNs,{config:n,onChange:a}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:r,children:"Cancel"}),e.jsx(K,{onClick:()=>s(n),children:"Save"})]})]})})}function ONs({config:t,onChange:s,cardId:r}){var b,_;const[n,a]=k.useState(""),[o,l]=k.useState((b=t.video_url)!=null&&b.includes("youtube")||(_=t.video_url)!=null&&_.includes("youtu.be")?"youtube":"library"),{data:i}=mt({queryKey:["card-owner",r],queryFn:async()=>{const{data:j}=await H.from("agent_cards").select("user_id").eq("id",r).single();return j==null?void 0:j.user_id},enabled:!!r}),{data:c,isLoading:u}=mt({queryKey:["agent-videos-library",i],queryFn:async()=>{const{data:j,error:w}=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(w)throw w;return j||[]},enabled:!!i}),p=(c==null?void 0:c.filter(j=>!n||(j.title||"").toLowerCase().includes(n.toLowerCase())))||[],f=t.bunny_video_id,g=j=>{var M;const w=(M=j.playback_url)==null?void 0:M.match(/\/(?:play|embed)\/(\d+)\//),C=`https://iframe.mediadelivery.net/embed/${w?w[1]:"570924"}/${j.bunny_video_id}?autoplay=false&responsive=true`;s({...t,video_url:C,bunny_video_id:j.bunny_video_id,video_source:"library"})};return e.jsx("div",{className:"space-y-4",children:e.jsxs(ja,{value:o,onValueChange:l,children:[e.jsxs(ga,{className:"w-full",children:[e.jsx(us,{value:"library",className:"flex-1",children:"Video Library"}),e.jsx(us,{value:"youtube",className:"flex-1",children:"YouTube URL"})]}),e.jsxs(ks,{value:"library",className:"space-y-3 mt-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:j=>a(j.target.value),className:"pl-9"})]}),e.jsx(Gi,{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(j=>e.jsxs("button",{onClick:()=>g(j),className:`w-full flex items-center gap-3 p-2 rounded-lg border text-left transition-colors ${f===j.bunny_video_id?"border-primary bg-primary/5":"border-border hover:bg-muted"}`,children:[j.thumbnail_url?e.jsx("img",{src:j.thumbnail_url,alt:"",className:"h-10 w-16 rounded object-cover flex-shrink-0 bg-muted",onError:w=>{var N;w.currentTarget.style.display="none",(N=w.currentTarget.nextElementSibling)==null||N.classList.remove("hidden")}}):null,e.jsx("div",{className:`h-10 w-16 rounded bg-muted flex items-center justify-center flex-shrink-0 ${j.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:j.title||"Untitled Video"}),f===j.bunny_video_id&&e.jsx(fa,{className:"h-4 w-4 text-primary flex-shrink-0"})]},j.id))})})]}),e.jsx(ks,{value:"youtube",className:"space-y-3 mt-3",children:e.jsxs("div",{children:[e.jsx(ye,{children:"YouTube URL"}),e.jsx(ze,{placeholder:"https://www.youtube.com/watch?v=...",value:t.video_source==="youtube"&&t.video_url||"",onChange:j=>s({...t,video_url:j.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 RNs({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(Pe,{children:e.jsxs(Re,{className:"p-3 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{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 FNs({config:t,onChange:s}){const r=t.tags||[],[n,a]=k.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(ye,{className:"text-sm mb-2 block",children:"Preset Specialties"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:PNs.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(ye,{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(ye,{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 zNs({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 mze=[{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 BNs({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=mze.filter(c=>!r.find(u=>u.platform===c.value)),i=c=>{const u=Cve[c],p=mze.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(ye,{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=Cve[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 $Ns=Object.defineProperty,Qce=Object.getOwnPropertySymbols,ult=Object.prototype.hasOwnProperty,hlt=Object.prototype.propertyIsEnumerable,pze=(t,s,r)=>s in t?$Ns(t,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[s]=r,nwe=(t,s)=>{for(var r in s||(s={}))ult.call(s,r)&&pze(t,r,s[r]);if(Qce)for(var r of Qce(s))hlt.call(s,r)&&pze(t,r,s[r]);return t},awe=(t,s)=>{var r={};for(var n in t)ult.call(t,n)&&s.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&Qce)for(var n of Qce(t))s.indexOf(n)<0&&hlt.call(t,n)&&(r[n]=t[n]);return r};/** * @license QR Code generator library (TypeScript) * Copyright (c) Project Nayuki. * SPDX-License-Identifier: MIT */var aC;(t=>{const s=class po{constructor(c,u,p,f){if(this.version=c,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],cpo.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 _,j;for(_=p;;_++){const M=po.getNumDataCodewords(_,u)*8,I=l.getTotalBits(c,_);if(I<=M){j=I;break}if(_>=f)throw new RangeError("Data too long")}for(const M of[po.Ecc.MEDIUM,po.Ecc.QUARTILE,po.Ecc.HIGH])b&&j<=po.getNumDataCodewords(_,M)*8&&(u=M);let w=[];for(const M of c){r(M.mode.modeBits,4,w),r(M.numChars,M.mode.numCharCountBits(_),w);for(const I of M.getData())w.push(I)}a(w.length==j);const N=po.getNumDataCodewords(_,u)*8;a(w.length<=N),r(0,Math.min(4,N-w.length),w),r(0,(8-w.length%8)%8,w),a(w.length%8==0);for(let M=236;w.lengthC[I>>>3]|=M<<7-(I&7)),new po(_,u,C,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,b=Math.floor(p/3);this.setFunctionModule(g,b,f),this.setFunctionModule(b,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)),b=c+f,_=u+p;0<=b&&b{(M!=j-g||L>=_)&&C.push(I[M])});return a(C.length==b),C}drawCodewords(c){if(c.length!=Math.floor(po.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(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[g][w],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;g5&&c++):(this.finderPenaltyAddHistory(_,j),b||(c+=this.finderPenaltyCountPatterns(j)*po.PENALTY_N3),b=this.modules[w][g],_=1);c+=this.finderPenaltyTerminateAndCount(b,_,j)*po.PENALTY_N3}for(let g=0;gb+(_?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*po.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.lengthpo.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(po.getNumRawDataModules(c)/8)-po.ECC_CODEWORDS_PER_BLOCK[u.ordinal][c]*po.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((b,_)=>p[_]^=po.reedSolomonMultiply(b,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 ld{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 ld(ld.Mode.BYTE,c.length,u)}static makeNumeric(c){if(!ld.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={}))})(aC||(aC={}));(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={}))})(aC||(aC={}));var hM=aC;/** * @license qrcode.react * Copyright (c) Paul O'Shannessy * SPDX-License-Identifier: ISC */var qNs={L:hM.QrCode.Ecc.LOW,M:hM.QrCode.Ecc.MEDIUM,Q:hM.QrCode.Ecc.QUARTILE,H:hM.QrCode.Ecc.HIGH},mlt=128,plt="L",flt="#FFFFFF",xlt="#000000",glt=!1,ylt=1,UNs=4,VNs=0,HNs=.1;function vlt(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 blt(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 WNs(t,s,r,n){if(n==null)return null;const a=t.length+r*2,o=Math.floor(s*HNs),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),j=Math.floor(p),w=Math.ceil(i+u-_),N=Math.ceil(c+p-j);g={x:_,y:j,w,h:N}}const b=n.crossOrigin;return{x:u,y:p,h:c,w:i,excavation:g,opacity:f,crossOrigin:b}}function GNs(t,s){return s!=null?Math.max(Math.floor(s),0):t?UNs:VNs}function _lt({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((j,w)=>(j.push(...hM.QrSegment.makeSegments(w)),j),[]);return hM.QrCode.encodeSegments(_,qNs[s],r,void 0,void 0,i)},[t,s,r,i]);const{cells:u,margin:p,numCells:f,calculatedImageSettings:g}=ht.useMemo(()=>{let b=c.getModules();const _=GNs(n,a),j=b.length+_*2,w=WNs(b,l,_,o);return{cells:b,margin:_,numCells:j,calculatedImageSettings:w}},[c,l,o,n,a]);return{qrcode:c,margin:p,cells:u,numCells:f,calculatedImageSettings:g}}var KNs=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ZNs=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=mlt,level:l=plt,bgColor:i=flt,fgColor:c=xlt,includeMargin:u=glt,minVersion:p=ylt,boostLevel:f,marginSize:g,imageSettings:b}=n,j=awe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:w}=j,N=awe(j,["style"]),C=b==null?void 0:b.src,M=ht.useRef(null),I=ht.useRef(null),L=ht.useCallback(X=>{M.current=X,typeof r=="function"?r(X):r&&(r.current=X)},[r]),[R,q]=ht.useState(!1),{margin:U,cells:B,numCells:V,calculatedImageSettings:Y}=_lt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:g,imageSettings:b,size:o});ht.useEffect(()=>{if(M.current!=null){const X=M.current,ce=X.getContext("2d");if(!ce)return;let ne=B;const re=I.current,le=Y!=null&&re!==null&&re.complete&&re.naturalHeight!==0&&re.naturalWidth!==0;le&&Y.excavation!=null&&(ne=blt(B,Y.excavation));const pe=window.devicePixelRatio||1;X.height=X.width=o*pe;const xe=o/V*pe;ce.scale(xe,xe),ce.fillStyle=i,ce.fillRect(0,0,V,V),ce.fillStyle=c,KNs?ce.fill(new Path2D(vlt(ne,U))):B.forEach(function(_e,fe){_e.forEach(function(we,Ie){we&&ce.fillRect(Ie+U,fe+U,1,1)})}),Y&&(ce.globalAlpha=Y.opacity),le&&ce.drawImage(re,Y.x+U,Y.y+U,Y.w,Y.h)}}),ht.useEffect(()=>{q(!1)},[C]);const J=nwe({height:o,width:o},w);let te=null;return C!=null&&(te=ht.createElement("img",{src:C,key:C,style:{display:"none"},onLoad:()=>{q(!0)},ref:I,crossOrigin:Y==null?void 0:Y.crossOrigin})),ht.createElement(ht.Fragment,null,ht.createElement("canvas",nwe({style:J,height:o,width:o,ref:L,role:"img"},N)),te)});ZNs.displayName="QRCodeCanvas";var jR=ht.forwardRef(function(s,r){const n=s,{value:a,size:o=mlt,level:l=plt,bgColor:i=flt,fgColor:c=xlt,includeMargin:u=glt,minVersion:p=ylt,boostLevel:f,title:g,marginSize:b,imageSettings:_}=n,j=awe(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:w,cells:N,numCells:C,calculatedImageSettings:M}=_lt({value:a,level:l,minVersion:p,boostLevel:f,includeMargin:u,marginSize:b,imageSettings:_,size:o});let I=N,L=null;_!=null&&M!=null&&(M.excavation!=null&&(I=blt(N,M.excavation)),L=ht.createElement("image",{href:_.src,height:M.h,width:M.w,x:M.x+w,y:M.y+w,preserveAspectRatio:"none",opacity:M.opacity,crossOrigin:M.crossOrigin}));const R=vlt(I,w);return ht.createElement("svg",nwe({height:o,width:o,viewBox:`0 0 ${C} ${C}`,ref:r,role:"img"},j),!!g&&ht.createElement("title",null,g),ht.createElement("path",{fill:i,d:`M0,0 h${C}v${C}H0z`,shapeRendering:"crispEdges"}),ht.createElement("path",{fill:c,d:R,shapeRendering:"crispEdges"}),L)});jR.displayName="QRCodeSVG";function YNs({slug:t,agentName:s}){const r=k.useRef(null),n=`https://cards.relevelup.com/${t}`,a=k.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(),he.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(ye,{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(jR,{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(Ci,{className:"h-3.5 w-3.5"}),"Download PNG"]})]})]})]})}function jye(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 XNs(){const{user:t}=Rs(),{data:s,isLoading:r}=nkt(t==null?void 0:t.id),n=NE(),[a,o]=k.useState(null),l=k.useMemo(()=>a||(s?jye(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(JNs,{userId:t==null?void 0:t.id})});const i=l||jye(s),c=u=>{o(p=>{const f=p||jye(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(eks,{card:s}),e.jsx(nks,{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(aS,{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(QNs,{card:s,form:i})})]})})]})})}function QNs({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=k.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(oje,{card:n})})}function JNs({userId:t}){var c;const[s,r]=k.useState(""),n=tGe(),{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){he.error("Please enter a URL slug for your card");return}n.mutate({user_id:t,slug:u,is_published:!0},{onSuccess:()=>he.success("Your digital card has been created!")})},i=[{icon:Su,title:"Shareable Link",desc:"One link that works everywhere"},{icon:Fm,title:"Lead Capture",desc:"Collect leads automatically"},{icon:Th,title:"Always Up-to-Date",desc:"Edit anytime, changes are instant"},{icon:sc,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(un,{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(Pe,{className:"shadow-lg border-2",children:[e.jsxs(Dt,{className:"text-center pb-2",children:[e.jsx(zt,{className:"text-xl",children:"Set Up Your Card"}),e.jsx(xr,{children:"Choose a URL slug — this is the link you'll share with clients"})]}),e.jsxs(Re,{className:"p-6 pt-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ye,{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(un,{className:"h-4 w-4 mr-2"}),n.isPending?"Creating...":"Create My Card"]})]})]})]})}function eks({card:t}){const r=`https://cards.relevelup.com/${t.slug}`,n=()=>{navigator.clipboard.writeText(r),he.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(tt,{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(Su,{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(gi,{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(an,{className:"h-3.5 w-3.5"})," Preview"]})})]})]})})}function tks({userId:t}){const s=es(),r=k.useRef(null),[n,a]=k.useState(!1),[o,l]=k.useState(""),{data:i,isLoading:c}=mt({queryKey:["card-editor-profile",t],queryFn:async()=>{const{data:Y}=await H.from("profiles").select("name, email, phone, avatar_url").eq("id",t).single();let J=(Y==null?void 0:Y.avatar_url)||null;if(!J){const{data:te}=await H.storage.from("avatars").list(`${t}`);if(te&&te.length>0){const{data:X}=H.storage.from("avatars").getPublicUrl(`${t}/${te[0].name}`);J=`${X.publicUrl}?t=${Date.now()}`,await H.from("profiles").update({avatar_url:J}).eq("id",t)}}return{...Y,avatar_url:J}}}),[u,p]=k.useState(null),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),N=u??(i==null?void 0:i.name)??"",C=f??(i==null?void 0:i.phone)??"",M=b??(i==null?void 0:i.email)??"",I=i==null?void 0:i.avatar_url,L=((i==null?void 0:i.name)||"A").split(" ").map(Y=>Y[0]).join("").toUpperCase().slice(0,2),R=!(i!=null&&i.avatar_url)||!(i!=null&&i.phone),q=Lt({mutationFn:async Y=>{const{error:J}=await H.from("profiles").update(Y).eq("id",t);if(J)throw J},onSuccess:()=>{s.invalidateQueries({queryKey:["card-editor-profile",t]}),s.invalidateQueries({queryKey:["card-preview-profile",t]}),s.invalidateQueries({queryKey:["agent-card-user"]}),he.success("Profile updated!")},onError:()=>he.error("Failed to update profile")}),U=()=>{const Y={};if(u!==null&&u!==(i==null?void 0:i.name)&&(Y.name=u),f!==null&&f!==(i==null?void 0:i.phone)&&(Y.phone=f||null),b!==null&&b!==(i==null?void 0:i.email)&&(Y.email=b),Object.keys(Y).length===0){he.info("No changes to save");return}q.mutate(Y)},B=Y=>{var X;const J=(X=Y.target.files)==null?void 0:X[0];if(!J)return;if(!J.type.startsWith("image/")){he.error("Please select an image file");return}const te=new FileReader;te.onloadend=()=>{l(te.result),a(!0)},te.readAsDataURL(J),Y.target.value=""},V=async Y=>{w(!0);try{const{data:J}=await H.storage.from("avatars").list(`${t}`);J&&J.length>0&&await H.storage.from("avatars").remove(J.map(re=>`${t}/${re.name}`));const te=`${t}/avatar.jpg`,{error:X}=await H.storage.from("avatars").upload(te,Y,{upsert:!0,contentType:"image/jpeg"});if(X)throw X;const{data:ce}=H.storage.from("avatars").getPublicUrl(te),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"]}),he.success("Photo updated!")}catch{he.error("Failed to upload photo")}finally{w(!1)}};return c?e.jsx(vs,{className:"h-32 w-full rounded-xl"}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:R?"border-amber-300 dark:border-amber-700":"",children:e.jsxs(Re,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ye,{className:"text-sm font-semibold",children:"Profile Info"}),R&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-600 dark:text-amber-400 font-medium",children:[e.jsx(Nl,{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 Y;return(Y=r.current)==null?void 0:Y.click()},children:[e.jsxs(_n,{className:"h-16 w-16 ring-2 ring-muted",children:[e.jsx(za,{src:I||void 0,alt:N}),e.jsx(wn,{className:"text-lg font-semibold bg-primary/10 text-primary",children:L})]}),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(kx,{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:j?"Uploading...":I?"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(ye,{className:"text-xs font-medium text-muted-foreground",children:"Full Name"}),e.jsx(ze,{value:N,onChange:Y=>p(Y.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(ye,{className:"text-xs font-medium text-muted-foreground",children:"Phone Number"}),e.jsx(ze,{value:C,onChange:Y=>g(Y.target.value),placeholder:"(555) 123-4567",className:"h-10",type:"tel"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Email"}),e.jsx(ze,{value:M,onChange:Y=>_(Y.target.value),placeholder:"you@example.com",className:"h-10",type:"email"})]})]})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:U,disabled:q.isPending,className:"w-full",children:q.isPending?"Saving...":"Update Profile Info"})]})}),e.jsx(yke,{open:n,onClose:()=>a(!1),imageSrc:o,onCropComplete:V,aspectRatio:1})]})}function sks({form:t,setForm:s,userId:r}){const[n,a]=k.useState(null),[o,l]=k.useState(t.brokerage_logo_url?"logo":"name"),[i,c]=k.useState(t.team_logo_url?"logo":"name"),u=b=>{l(b),s(b==="name"?_=>({..._,brokerage_logo_url:""}):_=>({..._,brokerage_display_name:""}))},p=b=>{c(b),s(b==="name"?_=>({..._,team_logo_url:""}):_=>({..._,team_name:""}))},f=async(b,_)=>{var w;const j=(w=b.target.files)==null?void 0:w[0];if(j){if(!j.type.startsWith("image/")){he.error("Please select an image file");return}a(_);try{const N=j.name.split(".").pop()||"png",M=`${r}/${_==="brokerage_logo_url"?"brokerage-logo":"team-logo"}.${N}`,{error:I}=await H.storage.from("card-logos").upload(M,j,{upsert:!0});if(I)throw I;const{data:L}=H.storage.from("card-logos").getPublicUrl(M),R=L.publicUrl+"?t="+Date.now();s(_==="brokerage_logo_url"?q=>({...q,[_]:R,brokerage_display_name:""}):q=>({...q,[_]:R,team_name:""})),he.success("Logo uploaded!")}catch{he.error("Failed to upload logo")}finally{a(null),b.target.value=""}}},g=b=>{s(_=>({..._,[b]:""}))};return e.jsx(Pe,{children:e.jsxs(Re,{className:"p-5 space-y-5",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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(ye,{className:"text-xs font-medium text-muted-foreground",children:"Brokerage Name"}),e.jsx(ze,{value:t.brokerage_display_name,onChange:b=>s(_=>({..._,brokerage_display_name:b.target.value})),placeholder:"e.g. Keller Williams Realty",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(kx,{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:b=>f(b,"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(ye,{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(Wg,{value:[t.brokerage_logo_size||56],onValueChange:([b])=>s(_=>({..._,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(ye,{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(ye,{className:"text-xs font-medium text-muted-foreground",children:"Team Name"}),e.jsx(ze,{value:t.team_name,onChange:b=>s(_=>({..._,team_name:b.target.value})),placeholder:"e.g. The Smith Group",className:"h-10"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{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(kx,{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:b=>f(b,"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(ye,{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(Wg,{value:[t.team_logo_size||56],onValueChange:([b])=>s(_=>({..._,team_logo_size:b})),min:24,max:120,step:4})]})]})]})]})})}function rks({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(ye,{className:"text-sm font-semibold flex items-center gap-1.5",children:[e.jsx(sc,{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 nks({card:t,form:s,setForm:r}){var j;const n=sGe(),a=es(),{data:o}=rGe(t.id),[l,i]=k.useState(t.slug),[c,u]=k.useState(!1),[p,f]=k.useState("idle"),g=k.useRef(JSON.stringify(s)),b=k.useRef(null);k.useEffect(()=>{const w=JSON.stringify(s);if(w!==g.current)return b.current&&clearTimeout(b.current),b.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=w,f("saved"),setTimeout(()=>f("idle"),2e3)},onError:()=>f("idle")})},1500),()=>{b.current&&clearTimeout(b.current)}},[s]);const _=async()=>{const w=l.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!w){he.error("Please enter a valid URL");return}if(w===t.slug){he.info("No changes to save");return}u(!0);try{const{data:N}=await H.from("agent_cards").select("id").eq("slug",w).neq("id",t.id).maybeSingle();if(N){he.error("This URL is already taken. Try another one.");return}const{error:C}=await H.from("agent_cards").update({slug:w}).eq("id",t.id);if(C)throw C;i(w),a.invalidateQueries({queryKey:["agent-card"]}),he.success("Card address updated!")}catch{he.error("Failed to update card address")}finally{u(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(ja,{defaultValue:"content",children:[e.jsxs(ga,{className:"w-full h-11 p-1",children:[e.jsxs(us,{value:"content",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Cx,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Content"]}),e.jsxs(us,{value:"sections",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(qn,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Sections"]}),e.jsxs(us,{value:"blocks",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Fm,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Blocks"]}),e.jsxs(us,{value:"qrcode",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(o1,{className:"h-3.5 w-3.5 hidden sm:inline"}),"QR Code"]}),e.jsxs(us,{value:"analytics",className:"flex-1 gap-1.5 data-[state=active]:shadow-sm",children:[e.jsx(Xg,{className:"h-3.5 w-3.5 hidden sm:inline"}),"Analytics"]})]}),e.jsxs(ks,{value:"content",className:"mt-4 space-y-4",children:[e.jsx(tks,{userId:t.user_id}),e.jsx(sks,{form:s,setForm:r,userId:t.user_id}),e.jsx(Pe,{children:e.jsxs(Re,{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(ye,{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($r,{checked:s.is_published,onCheckedChange:w=>r(N=>({...N,is_published:w}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{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:w=>i(w.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(ye,{className:"text-sm font-medium",children:"Card Email (Override)"}),e.jsx(ze,{value:s.display_email,onChange:w=>r(N=>({...N,display_email:w.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(ye,{className:"text-sm font-medium",children:"Theme"}),e.jsxs(Ys,{value:s.theme,onValueChange:w=>r(N=>({...N,theme:w})),children:[e.jsx(Gs,{className:"h-11",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(rks,{form:s,setForm:r}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Title / Tagline"}),e.jsx(ze,{value:s.title,onChange:w=>r(N=>({...N,title:w.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(ye,{className:"text-sm font-medium",children:"Positioning Statement"}),e.jsx(ze,{value:s.positioning_statement,onChange:w=>r(N=>({...N,positioning_statement:w.target.value})),placeholder:"Your home journey, handled with care.",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Bio"}),e.jsx(Er,{value:s.bio,onChange:w=>r(N=>({...N,bio:w.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(ye,{className:"text-sm font-medium",children:"Review Snippet"}),e.jsx(ze,{value:s.review_snippet,onChange:w=>r(N=>({...N,review_snippet:w.target.value})),placeholder:"Best agent we've ever worked with...",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Review Source URL"}),e.jsx(ze,{value:s.review_source_url,onChange:w=>r(N=>({...N,review_source_url:w.target.value})),placeholder:"https://g.page/your-business/review",className:"h-11"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Booking URL"}),e.jsx(ze,{value:s.booking_url,onChange:w=>r(N=>({...N,booking_url:w.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(ye,{className:"text-sm font-medium",children:"Custom CTA Label"}),e.jsx(ze,{value:s.custom_cta_label,onChange:w=>r(N=>({...N,custom_cta_label:w.target.value})),placeholder:"Book a Call",className:"h-11"})]})]})})]}),e.jsx(ks,{value:"sections",className:"mt-4",children:e.jsx(Pe,{children:e.jsx(Re,{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:w,label:N,desc:C})=>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(ye,{className:"text-sm font-medium",children:N}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C})]}),e.jsx($r,{checked:s[w],onCheckedChange:M=>r(I=>({...I,[w]:M}))})]},w))})})}),e.jsx(ks,{value:"blocks",className:"mt-4",children:e.jsx(dlt,{cardId:t.id})}),e.jsx(ks,{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:qn,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:Xg,color:"text-amber-600 bg-amber-100 dark:text-amber-400 dark:bg-amber-900/30"},{label:"Leads",value:((j=o==null?void 0:o.leads)==null?void 0:j.length)??0,icon:rc,color:"text-emerald-600 bg-emerald-100 dark:text-emerald-400 dark:bg-emerald-900/30"}].map(w=>e.jsx(Pe,{className:"overflow-hidden",children:e.jsxs(Re,{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 ${w.color}`,children:e.jsx(w.icon,{className:"h-3.5 w-3.5"})}),e.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:w.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:w.value})]})},w.label))}),o&&o.leads.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Recent Leads"})}),e.jsx(Re,{className:"pt-0 space-y-2",children:o.leads.slice(0,5).map(w=>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:w.name}),w.phone&&e.jsx("span",{className:"text-muted-foreground ml-2",children:w.phone})]}),w.intent&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:w.intent})]},w.id))})]}),(!o||o.leads.length===0)&&e.jsx(Pe,{children:e.jsxs(Re,{className:"p-8 text-center",children:[e.jsx(Xg,{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(ks,{value:"qrcode",className:"mt-4 space-y-4",children:e.jsx(Pe,{children:e.jsx(Re,{className:"p-6",children:e.jsx(YNs,{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 aks(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(null),[j,w]=k.useState(null),[N,C]=k.useState(0),{data:M,isLoading:I}=mt({queryKey:["boldtrail-status"],queryFn:async()=>{const{data:te,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"status"}});if(X)throw X;return te}}),L=Lt({mutationFn:async te=>{const{data:X,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_token",api_token:te}});if(ce)throw ce;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),r(""),he.success("BoldTrail connected successfully!")},onError:te=>{he.error(te.message||"Failed to connect BoldTrail")}}),R=Lt({mutationFn:async()=>{const{data:te,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"disconnect"}});if(X)throw X;return te},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),he.success("BoldTrail disconnected")},onError:()=>he.error("Failed to disconnect")}),q=Lt({mutationFn:async te=>{const{data:X,error:ce}=await H.functions.invoke("boldtrail-sync",{body:{action:"save_direction",sync_direction:te}});if(ce)throw ce;if(X!=null&&X.error)throw new Error(X.error);return X},onSuccess:()=>{t.invalidateQueries({queryKey:["boldtrail-status"]}),he.success("Sync direction saved")},onError:te=>{he.error(te.message||"Failed to save sync direction")}}),U=Lt({mutationFn:async()=>{const{data:te,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync_preview"}});if(X)throw X;if(te!=null&&te.error)throw new Error(te.error);return te},onSuccess:te=>{_(null),c(te),a(!0)},onError:te=>{he.error(te.message||"Failed to generate sync preview")}}),B=Lt({mutationFn:async()=>{w("Initializing sync..."),C(5);const{data:te,error:X}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"init",sync_direction:J}});if(X)throw X;if(te!=null&&te.error)throw new Error(te.error);const ce=te;let ne=ce.sync_log_id,re=ce.next_phase,le=ce.next_offset;const pe=ce.push_total||0,xe=ce.pull_total||0,_e=pe+xe;let fe=0,we=0;for(;re!=="finalize";){re==="push"?(w(`Pushing contacts to BoldTrail... (${fe}/${pe})`),C(_e>0?fe/_e*100:0)):re==="pull"&&(w(`Pulling contacts from BoldTrail... (${we}/${xe})`),C(_e>0?(pe+we)/_e*100:0));const{data:Ae,error:Fe}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:re,offset:le,sync_log_id:ne,sync_direction:J}});if(Fe)throw Fe;if(Ae!=null&&Ae.error)throw new Error(Ae.error);const Ce=Ae;fe+=Ce.chunk_pushed||0,we+=Ce.chunk_pulled||0,Ce.progress&&w(Ce.progress),re==="pull"&&xe>0?C(Math.min(95,we/xe*100)):re==="push"&&pe>0&&C(Math.min(95,fe/pe*100)),re=Ce.next_phase,le=Ce.next_offset}w("Finalizing sync..."),C(95);const{data:Ie,error:Ne}=await H.functions.invoke("boldtrail-sync",{body:{action:"sync",phase:"finalize",sync_log_id:ne,sync_direction:J}});if(Ne)throw Ne;return C(100),Ie},onSuccess:te=>{w(null),C(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"]}),he.success(`Sync complete! Pushed ${te.contacts_pushed||0}, pulled ${te.contacts_pulled||0}, skipped ${te.contacts_skipped||0} duplicates.`)},onError:te=>{w(null),C(0),he.error(te.message||"Sync failed")}}),V=M==null?void 0:M.connected,Y=(M==null?void 0:M.sync_direction)||"bidirectional",J=b??Y;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(yd,{className:"h-5 w-5 text-emerald-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["BoldTrail",V&&e.jsx(tt,{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(mp,{className:"h-3.5 w-3.5"}),"Learn More"]})]}),e.jsx(xr,{children:"Sync contacts bidirectionally between Agent OS and your BoldTrail (kvCORE) CRM."})]})]})}),e.jsx(Re,{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(xi,{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(xi,{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(xi,{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(tt,{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(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect BoldTrail?"}),e.jsx(Jl,{children:"This will remove your API token. Previously synced contacts will remain in both systems."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>R.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(D_e,{value:Y,onChange:te=>q.mutate(te)})}),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(qn,{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:te=>r(te.target.value),className:"flex-1"}),e.jsxs(K,{onClick:()=>L.mutate(s),disabled:!s||s.length<10||L.isPending,children:[L.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:te=>{B.isPending||a(te)},children:e.jsxs(fs,{className:"sm:max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(yd,{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 te=J==="pull_only"?0:i.to_push,X=J==="push_only"?0:i.to_pull;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(D_e,{value:J,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 ${J==="pull_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-emerald-600",children:te}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Nu,{className:"h-3 w-3"})," Push to BoldTrail"]})]}),e.jsxs("div",{className:`rounded-lg border p-3 text-center ${J==="push_only"?"opacity-40":""}`,children:[e.jsx("p",{className:"text-2xl font-bold text-blue-600",children:X}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-center justify-center gap-1",children:[e.jsx(Hh,{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(mr,{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:N||10,className:"h-2"}),e.jsx("p",{className:"text-xs text-muted-foreground text-center",children:j||"Sync in progress..."})]}),te>0&&e.jsxs(gf,{open:u,onOpenChange:p,children:[e.jsx(yf,{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(Nu,{className:"h-3 w-3 text-emerald-600"}),te," contacts to push to BoldTrail"]}),e.jsx(To,{className:`h-3 w-3 transition-transform ${u?"rotate-180":""}`})]})}),e.jsx(vf,{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"]})]})})]}),X>0&&e.jsxs(gf,{open:f,onOpenChange:g,children:[e.jsx(yf,{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(Hh,{className:"h-3 w-3 text-blue-600"}),X," contacts to pull from BoldTrail"]}),e.jsx(To,{className:`h-3 w-3 transition-transform ${f?"rotate-180":""}`})]})}),e.jsx(vf,{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"]})]})})]}),te===0&&X===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||te===0&&X===0,className:"gap-2",children:[B.isPending?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(yd,{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(_s,{className:"p-6 pb-0",children:e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(yd,{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 wlt(){const t=pr(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState("Test from ReLevelUp"),[i,c]=k.useState(!1),{data:u,isLoading:p}=mt({queryKey:["ses-config"],queryFn:async()=>{const{data:{session:b}}=await H.auth.getSession();if(!b)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 ${b.access_token}`},body:JSON.stringify({action:"check_config"})})).json()}}),f=async()=>{if(!s||!n){he.error("Please fill in From and To email addresses");return}c(!0);try{const{data:{session:b}}=await H.auth.getSession();if(!b)throw new Error("Not authenticated");const j=await(await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/ses-send-campaign",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${b.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();j.success?he.success(`Test email sent! Message ID: ${j.messageId}`):he.error(j.error||"Failed to send test email")}catch(b){he.error(b.message||"Failed to send test email")}finally{c(!1)}},g=(u==null?void 0:u.configured)===!0;return e.jsxs(Pe,{children:[e.jsx(Dt,{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(dr,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Amazon SES — Mass Email"}),e.jsx(xr,{children:"Send bulk email campaigns via Amazon SES"})]})]}),e.jsx(tt,{variant:g?"default":"secondary",children:p?"Checking...":g?e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(xi,{className:"h-3 w-3"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nl,{className:"h-3 w-3"})," Not Configured"]})})]})}),g&&e.jsxs(Re,{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(ye,{className:"text-xs",children:"From Email"}),e.jsx(ze,{placeholder:"notifications@mail.relevelup.com",value:n,onChange:b=>a(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs",children:"To Email"}),e.jsx(ze,{placeholder:"your@email.com",value:s,onChange:b=>r(b.target.value),className:"text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs",children:"Subject"}),e.jsx(ze,{value:o,onChange:b=>l(b.target.value),className:"text-sm"})]})]}),e.jsxs(K,{onClick:f,disabled:i,size:"sm",children:[i?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Send Test"]})]}),e.jsxs(K,{onClick:()=>t("/admin/email-campaigns"),className:"w-full",children:[e.jsx(Kh,{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(Re,{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 iks(){var _,j,w,N;const{user:t}=Rs(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(""),[l,i]=k.useState(""),{data:c}=mt({queryKey:["mass-email-settings",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:M}=await H.from("mass_email_settings").select("*").eq("user_id",t.id).maybeSingle();if(M)throw M;return C}}),{data:u}=mt({queryKey:["agent-profile-email",t==null?void 0:t.id],enabled:!!t,queryFn:async()=>{const{data:C,error:M}=await H.from("profiles").select("email, name").eq("id",t.id).single();if(M)throw M;return C}}),p=((_=c==null?void 0:c.reply_to_email)==null?void 0:_.trim())||((j=u==null?void 0:u.email)==null?void 0:j.trim())||"",f=((w=c==null?void 0:c.display_name)==null?void 0:w.trim())||((N=u==null?void 0:u.name)==null?void 0:N.trim())||"";k.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 C={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(C).eq("user_id",t.id);if(M)throw M}else{const{error:M}=await H.from("mass_email_settings").insert({user_id:t.id,...C});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]}),he.success("Reply-to email saved!"),n(!1)},onError:C=>he.error(C.message)}),b=!!p;return e.jsxs(Pe,{children:[e.jsx(Dt,{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(Rn,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Mass Email",b?e.jsxs(tt,{variant:"default",className:"text-xs bg-green-600",children:[e.jsx(xi,{className:"h-3 w-3 mr-1"})," Set Up"]}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Setup Required"})]}),e.jsx(xr,{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(Re,{className:"space-y-3",children:b&&!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(Da,{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(ye,{className:"text-xs",children:"Display Name"}),e.jsx(ze,{placeholder:"e.g. 🏡 Karen Hall",value:l,onChange:C=>i(C.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(ye,{className:"text-xs",children:"Reply-To Email *"}),e.jsx(ze,{type:"email",placeholder:"your@email.com",value:a,onChange:C=>o(C.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(ed,{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(Or,{className:"h-4 w-4 mr-1"})," Cancel"]})]})]})})]})}function oks(){const{isAdmin:t}=Rs(),s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(!1),{data:c,isLoading:u}=mt({queryKey:["gmail-integration"],queryFn:async()=>{const{data:I,error:L}=await H.from("gmail_integrations").select("*").maybeSingle();if(L)throw L;return I}}),{data:p}=mt({queryKey:["social-accounts"],queryFn:async()=>{const{data:{user:I}}=await H.auth.getUser();if(!I)return[];const{data:L,error:R}=await H.from("social_accounts").select("*").eq("user_id",I.id).order("created_at",{ascending:!1});if(R)throw R;return L}}),f=async()=>{n(!0);try{const{data:I,error:L}=await H.functions.invoke("gmail-oauth",{body:{action:"get_auth_url"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Gmail OAuth error:",I),he.error("Failed to start Gmail connection"),n(!1)}},g=async()=>{o(!0);try{const{data:I,error:L}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get authorization URL")}catch(I){console.error("Meta OAuth error:",I),he.error("Failed to start connection. Make sure Meta App credentials are configured."),o(!1)}},b=async()=>{i(!0);try{const{data:I,error:L}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(L)throw L;if(I!=null&&I.authUrl)window.location.href=I.authUrl;else throw new Error("Failed to get LinkedIn authorization URL")}catch(I){console.error("LinkedIn OAuth error:",I),he.error("Failed to start LinkedIn connection. Please try again."),i(!1)}},_=Lt({mutationFn:async I=>{const{error:L}=await H.from("gmail_integrations").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["gmail-integration"]}),he.success("Gmail disconnected")},onError:()=>{he.error("Failed to disconnect Gmail")}}),j=Lt({mutationFn:async I=>{const{error:L}=await H.from("social_accounts").delete().eq("id",I);if(L)throw L},onSuccess:()=>{s.invalidateQueries({queryKey:["social-accounts"]}),he.success("Account disconnected")},onError:()=>{he.error("Failed to disconnect account")}}),w=!!(c!=null&&c.is_active),N=(p==null?void 0:p.filter(I=>I.platform==="facebook"))||[],C=(p==null?void 0:p.filter(I=>I.platform==="instagram"))||[],M=(p==null?void 0:p.filter(I=>I.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(Pe,{children:[e.jsx(Dt,{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(dr,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Gmail",w&&e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"})]}),e.jsx(xr,{children:"Send emails directly from your contact pages and auto-log them as touchpoints."})]})]})}),e.jsx(Re,{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(xi,{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(xi,{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(xi,{className:"h-4 w-4 mt-0.5 text-green-500 shrink-0"}),e.jsx("span",{children:"Quick compose from any contact detail page"})]}),w?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(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Gmail?"}),e.jsx(Jl,{children:"This will remove your Gmail connection. You'll need to reconnect to send emails."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{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(dr,{className:"h-4 w-4 mr-2"}),"Connect Gmail",e.jsx(fi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsxs(Pe,{className:t?"":"opacity-70",children:[e.jsx(Dt,{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(ku,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Facebook",t?N.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Mh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(xr,{children:"Connect Facebook Pages to post content and reach your audience."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[N.length>0&&e.jsx("div",{className:"space-y-2",children:N.map(I=>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(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:I.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(ku,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.page_name||I.platform_username||"Facebook Page"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Facebook Page"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Facebook?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.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(Pe,{className:t?"":"opacity-70",children:[e.jsx(Dt,{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(Cu,{className:"h-5 w-5 text-pink-600"})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Instagram",t?C.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Mh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(xr,{children:"Connect Instagram Business accounts to schedule and publish posts."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[C.length>0&&e.jsx("div",{className:"space-y-2",children:C.map(I=>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(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:I.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Cu,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-sm",children:["@",I.platform_username||"Instagram Account"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected Instagram account"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Instagram?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.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(Pe,{className:t?"":"opacity-70",children:[e.jsx(Dt,{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(zt,{className:"text-lg flex items-center gap-2",children:["LinkedIn",t?M.length>0?e.jsx(tt,{variant:"default",className:"text-xs bg-green-600",children:"Connected"}):null:e.jsxs(tt,{variant:"secondary",className:"text-xs gap-1",children:[e.jsx(Mh,{className:"h-3 w-3"}),"Coming Soon"]})]}),e.jsx(xr,{children:"Connect your LinkedIn profile to share content and grow your professional network."})]})]})}),t&&e.jsxs(Re,{className:"space-y-3",children:[M.length>0&&e.jsx("div",{className:"space-y-2",children:M.map(I=>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(_n,{className:"h-8 w-8",children:[e.jsx(za,{src:I.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Mp,{className:"h-4 w-4"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.platform_username||"LinkedIn Account"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connected LinkedIn profile"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect LinkedIn?"}),e.jsx(Jl,{children:"This will remove your LinkedIn connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>j.mutate(I.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},I.id))}),e.jsxs(K,{onClick:b,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(aks,{}),e.jsx(iks,{}),t&&e.jsx(wlt,{})]})})}function lks(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Gmail account...");return k.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"),he.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),he.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!"),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(xc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"Back to Integrations":"Try Again"})})]})})}function cks(){const t=pr();return k.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 dks(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.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"),he.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),he.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/mission-control/integrations/meta/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(xc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Integrations":"Try Again"})})]})})}const jlt=new Date().getFullYear(),uks=Array.from({length:5},(t,s)=>jlt-s);function hks(){const[t,s]=k.useState(jlt),r=pr(),{data:n,isLoading:a}=YLt();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(Ys,{value:String(t),onValueChange:o=>s(Number(o)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:uks.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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ro,{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(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Agents with Scorecards"}),e.jsx(xr,{children:"Click to view individual agent scorecards"})]}),e.jsx(Re,{children:!n||n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Ro,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents have added transactions yet"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Email"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:n.map(o=>e.jsxs(Ss,{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(qn,{className:"h-4 w-4 mr-2"}),"View Scorecard"]})})]},o.id))})]})})]})]})})}const Nlt=new Date().getFullYear(),mks=Array.from({length:10},(t,s)=>Nlt-s);function fze(){var _;const{userId:t}=yo(),s=pr(),n=nu().pathname.startsWith("/mission-control"),[a,o]=k.useState(Nlt),{data:l,isLoading:i}=mt({queryKey:["agent-profile",t],queryFn:async()=>{const{data:j,error:w}=await H.from("profiles").select("id, name, email").eq("id",t).single();if(w)throw w;return j},enabled:!!t}),{data:c,isLoading:u}=jNe(a,t),{yearStats:p,lifetimeStats:f,showCommission:g}=oXe(a,t),{data:b}=iXe(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(j=>e.jsx(vs,{className:"h-24"},j))})]})}):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(ri,{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(Ys,{value:String(a),onValueChange:j=>o(Number(j)),children:[e.jsx(Gs,{className:"w-[120px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:mks.map(j=>e.jsx(Mt,{value:String(j),children:j},j))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 lg:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Sn,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(wc,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Volume"})]}),e.jsx("p",{className:"text-2xl font-bold",children:Gl(p.totalVolume,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ol,{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:Gl(p.averagePrice,!0)})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(bc,{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)||"-"})]})})]}),b&&e.jsx(qat,{goals:b,stats:p,year:a,showCommission:g}),e.jsxs(ja,{defaultValue:"transactions",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"transactions",children:"Transactions"}),e.jsx(us,{value:"charts",children:"Charts"}),e.jsxs(us,{value:"map",children:[e.jsx(Ba,{className:"h-4 w-4 mr-1"}),"Map"]})]}),e.jsx(ks,{value:"transactions",children:e.jsx(iSe,{transactions:c||[],showCommission:g,isLoading:u})}),e.jsx(ks,{value:"charts",children:e.jsx(oSe,{stats:p,year:a})}),e.jsx(ks,{value:"map",children:e.jsx(lSe,{transactions:c||[],isLoading:u})})]})]})})}function pks(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState("all");DZe();const{data:o,refetch:l}=mt({queryKey:["listing-exchange-flag"],queryFn:async()=>{const{data:I}=await H.from("feature_flags").select("enabled").eq("key","listing_exchange_enabled").single();return(I==null?void 0:I.enabled)??!1}}),{data:i,isLoading:c}=mt({queryKey:["admin-listings"],queryFn:async()=>{const{data:I,error:L}=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(L)throw L;return I}}),{data:u}=mt({queryKey:["admin-listing-stats"],queryFn:async()=>{const{data:I}=await H.from("listings").select("id, is_approved, status"),{data:L}=await H.from("listing_shares").select("id"),{data:R}=await H.from("listing_views").select("id");return{total:(I==null?void 0:I.length)||0,pending:(I==null?void 0:I.filter(q=>!q.is_approved).length)||0,active:(I==null?void 0:I.filter(q=>q.status==="active").length)||0,totalShares:(L==null?void 0:L.length)||0,totalViews:(R==null?void 0:R.length)||0}}}),p=async(I,L,R="submit_url")=>{try{const{data:{session:q}}=await H.auth.getSession();if(!q)return;const{data:U,error:B}=await H.functions.invoke("google-indexing",{body:{action:R,listing_id:I,listing_slug:L}});if(B)throw B;if((U==null?void 0:U.configured)===!1)return;U!=null&&U.success&&he.success("Submitted to Google for indexing")}catch(q){console.error("Google indexing submission failed:",q)}},f=Lt({mutationFn:async()=>{const{data:{session:I}}=await H.auth.getSession();if(!I)throw new Error("Not authenticated");const{data:L,error:R}=await H.functions.invoke("google-indexing",{body:{action:"submit_all"}});if(R)throw R;return L},onSuccess:I=>{if((I==null?void 0:I.configured)===!1){he.error("Google Indexing API not configured. Add the GOOGLE_INDEXING_SERVICE_ACCOUNT secret.");return}he.success(`Submitted ${(I==null?void 0:I.succeeded)||0} URLs to Google (${(I==null?void 0:I.failed)||0} failed)`)},onError:I=>{he.error("Failed to submit to Google"),console.error(I)}}),g=Lt({mutationFn:async({id:I,approved:L,slug:R})=>{const{error:q}=await H.from("listings").update({is_approved:L}).eq("id",I);if(q)throw q;return{id:I,approved:L,slug:R}},onSuccess:I=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),he.success(I.approved?"Listing approved":"Listing unapproved"),I.approved?p(I.id,I.slug||null,"submit_url"):p(I.id,I.slug||null,"remove_url")}}),b=Lt({mutationFn:async({id:I,featured:L})=>{const{error:R}=await H.from("listings").update({is_featured:L}).eq("id",I);if(R)throw R},onSuccess:(I,{featured:L})=>{t.invalidateQueries({queryKey:["admin-listings"]}),he.success(L?"Listing featured":"Listing unfeatured")}}),_=Lt({mutationFn:async I=>{const{error:L}=await H.from("listings").delete().eq("id",I);if(L)throw L},onSuccess:()=>{t.invalidateQueries({queryKey:["admin-listings"]}),t.invalidateQueries({queryKey:["admin-listing-stats"]}),he.success("Listing deleted")}}),j=Lt({mutationFn:async I=>{const{error:L}=await H.from("feature_flags").update({enabled:I}).eq("key","listing_exchange_enabled");if(L)throw L},onSuccess:()=>{l(),he.success("Feature flag updated")}}),w=o??!1,N=i==null?void 0:i.filter(I=>{var q,U,B,V;const L=((q=I.city)==null?void 0:q.toLowerCase().includes(s.toLowerCase()))||((B=(U=I.agent)==null?void 0:U.name)==null?void 0:B.toLowerCase().includes(s.toLowerCase()))||((V=I.property_address)==null?void 0:V.toLowerCase().includes(s.toLowerCase())),R=n==="all"||n==="pending"&&!I.is_approved||n==="approved"&&I.is_approved;return L&&R}),C=I=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(I),M=I=>{const L={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 L[I]||L.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(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Su,{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($r,{checked:w,onCheckedChange:I=>j.mutate(I)})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wa,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ol,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qn,{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(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bd,{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(Pe,{children:e.jsx(Re,{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(hn,{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:I=>r(I.target.value),className:"pl-9"})]}),e.jsx(ja,{value:n,onValueChange:I=>a(I),children:e.jsxs(ga,{children:[e.jsx(us,{value:"all",children:"All"}),e.jsx(us,{value:"pending",children:"Pending"}),e.jsx(us,{value:"approved",children:"Approved"})]})})]})})}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{children:["Listings (",(N==null?void 0:N.length)||0,")"]})}),e.jsx(Re,{children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Property"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Price"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-center",children:"Approved"}),e.jsx(kt,{className:"text-center",children:"Featured"}),e.jsx(kt,{children:"Views"}),e.jsx(kt,{children:"Shares"}),e.jsx(kt,{children:"Date"}),e.jsx(kt,{})]})}),e.jsx(On,{children:c?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):(N==null?void 0:N.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:10,className:"text-center py-8 text-muted-foreground",children:"No listings found"})}):N==null?void 0:N.map(I=>{var L,R,q,U,B;return e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[(R=(L=I.photos)==null?void 0:L[0])!=null&&R.photo_url?e.jsx("img",{src:I.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(wa,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.property_address||`${I.city}, ${I.state}`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(q=I.property_type)==null?void 0:q.replace("_"," ")})]})]})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm",children:((U=I.agent)==null?void 0:U.name)||"Unknown"})}),e.jsx(dt,{className:"font-medium",children:C(I.price)}),e.jsx(dt,{children:e.jsx(tt,{variant:"outline",className:M(I.status),children:(B=I.status)==null?void 0:B.replace("_"," ")})}),e.jsx(dt,{className:"text-center",children:e.jsx($r,{checked:I.is_approved??!1,onCheckedChange:V=>g.mutate({id:I.id,approved:V,slug:I.slug})})}),e.jsx(dt,{className:"text-center",children:e.jsx($r,{checked:I.is_featured??!1,onCheckedChange:V=>b.mutate({id:I.id,featured:V})})}),e.jsx(dt,{children:I.view_count||0}),e.jsx(dt,{children:I.share_count||0}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ps(new Date(I.created_at),"MMM d, yyyy")}),e.jsx(dt,{children:e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",children:e.jsx(px,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",children:[e.jsxs(Ca,{onClick:()=>window.open(`/mission-control/listings/${I.id}`,"_blank"),children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),"View Listing"]}),e.jsxs(Ca,{onClick:()=>b.mutate({id:I.id,featured:!I.is_featured}),children:[e.jsx(Jn,{className:"h-4 w-4 mr-2"}),I.is_featured?"Unfeature":"Feature"]}),e.jsxs(Ca,{className:"text-destructive",onClick:()=>{confirm("Are you sure you want to delete this listing?")&&_.mutate(I.id)},children:[e.jsx(Or,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})]},I.id)})})]})})})]})]})})}const fks=()=>{var f,g;const[t,s]=k.useState(""),[r,n]=k.useState(null),{data:a,isLoading:o}=mt({queryKey:["membership-reviews"],queryFn:async()=>{const{data:b,error:_}=await H.from("membership_reviews").select("*").order("created_at",{ascending:!1});if(_)throw _;const j=(b==null?void 0:b.map(C=>C.user_id))||[],{data:w}=await H.from("profiles").select("id, name, email").in("id",j);return b==null?void 0:b.map(C=>({...C,profiles:(w==null?void 0:w.find(M=>M.id===C.user_id))||null}))}}),l=a==null?void 0:a.filter(b=>{var j,w,N,C,M;const _=t.toLowerCase();return((w=(j=b.profiles)==null?void 0:j.name)==null?void 0:w.toLowerCase().includes(_))||((C=(N=b.profiles)==null?void 0:N.email)==null?void 0:C.toLowerCase().includes(_))||((M=b.review_text)==null?void 0:M.toLowerCase().includes(_))}),i=a!=null&&a.length?(a.reduce((b,_)=>b+_.rating,0)/a.length).toFixed(1):"0.0",c=a==null?void 0:a.reduce((b,_)=>(b[_.rating]=(b[_.rating]||0)+1,b),{}),u=(a==null?void 0:a.filter(b=>b.posted_to_google).length)||0,p=b=>e.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(_=>e.jsx(Jn,{className:Pt("h-4 w-4",b>=_?"fill-yellow-400 text-yellow-400":"text-muted-foreground")},_))});return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(ah,{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(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Total Reviews"}),e.jsx(zt,{className:"text-3xl",children:(a==null?void 0:a.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Average Rating"}),e.jsxs(zt,{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(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"5-Star Reviews"}),e.jsx(zt,{className:"text-3xl",children:(c==null?void 0:c[5])||0})]})}),e.jsx(Pe,{children:e.jsxs(Dt,{className:"pb-2",children:[e.jsx(xr,{children:"Posted to Google"}),e.jsxs(zt,{className:"flex items-center gap-2 text-3xl",children:[u,e.jsx(an,{className:"h-5 w-5 text-muted-foreground"})]})]})})]}),e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(hn,{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:b=>s(b.target.value),className:"pl-9"})]}),e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Member"}),e.jsx(kt,{children:"Rating"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Review"}),e.jsx(kt,{children:"Google"}),e.jsx(kt,{children:"Date"})]})}),e.jsx(On,{children:o?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8",children:"Loading reviews..."})}):(l==null?void 0:l.length)===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:5,className:"text-center py-8 text-muted-foreground",children:"No reviews found"})}):l==null?void 0:l.map(b=>{var _,j;return e.jsxs(Ss,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>n(b),children:[e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:((_=b.profiles)==null?void 0:_.name)||"Unknown"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:(j=b.profiles)==null?void 0:j.email})]})}),e.jsx(dt,{children:p(b.rating)}),e.jsx(dt,{className:"hidden md:table-cell max-w-xs",children:e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:b.review_text||"-"})}),e.jsx(dt,{children:b.posted_to_google?e.jsx(tt,{variant:"secondary",className:"bg-green-100 text-green-800",children:"Posted"}):e.jsx(tt,{variant:"outline",children:"No"})}),e.jsx(dt,{className:"text-sm text-muted-foreground",children:ps(new Date(b.created_at),"MMM d, yyyy")})]},b.id)})})]})})}),e.jsx(xs,{open:!!r,onOpenChange:()=>n(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsx(_s,{children:e.jsx(bs,{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(dr,{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(cn,{className:"h-4 w-4"}),ps(new Date(r.created_at),"MMMM d, yyyy 'at' h:mm a")]}),r.posted_to_google?e.jsxs(tt,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(an,{className:"h-3 w-3 mr-1"}),"Posted to Google"]}):e.jsx(tt,{variant:"outline",children:"Not posted to Google"})]})]})]})})]})})},xks=[{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"}],gks=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 yks(){const t=es(),{user:s}=Rs(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.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:b,refetch:_}=mt({queryKey:["digest-queue-status"],queryFn:async()=>{const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Y,J]=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:Y.count||0,failed:J.count||0,total:(B.count||0)+(V.count||0)+(Y.count||0)+(J.count||0)}},refetchInterval:5e3});k.useEffect(()=>{if(b&&(b.pending>0||b.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)}},[b,_,t]);const{data:j=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}}),w=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"]}),he.success("Settings updated")},onError:U=>{he.error("Failed to update settings: "+U.message)}}),N=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?he.success(`${U.queued.toLocaleString()} emails queued! They'll be sent automatically (~80/minute).`):U.sent!==void 0&&he.success(`Digest sent! ${U.sent} emails delivered, ${U.failed} failed`),_(),t.invalidateQueries({queryKey:["weekly-digest-logs"]})}catch(U){he.error("Failed to send digest: "+U.message)}finally{n(!1)}},C=async()=>{var U,B,V,Y,J,te;if(!(s!=null&&s.email)){he.error("No email found for your account");return}o(!0);try{const{data:X,error:ce}=await H.functions.invoke("send-weekly-digest",{body:{preview:!0,previewEmail:s.email}});if(ce)throw ce;const ne=X==null?void 0:X.resendId,re=X==null?void 0:X.resendDetails,le=re==null?void 0:re.status,pe=((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),xe=((J=(Y=re==null?void 0:re.body)==null?void 0:Y.error)==null?void 0:J.message)||((te=re==null?void 0:re.body)==null?void 0:te.message);he.success(ne?`Preview accepted by email provider (id: ${ne})${le?`, status check: ${le}`:""}${pe?`, provider: ${pe}`:""}${xe?` (${xe})`:""}. Check spam/promotions—delivery can take a few minutes.`:"Preview accepted by email provider. Check spam/promotions—delivery can take a few minutes.")}catch(X){he.error("Failed to send preview: "+X.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?he.info("No failed emails to retry"):U.queued?he.success(`${U.queued} emails queued for retry!`):he.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){he.error("Failed to retry: "+U.message)}finally{i(!1)}},I=b!=null&&b.total?Math.round((b.sent+b.failed)/b.total*100):0,L=((b==null?void 0:b.pending)||0)>0||((b==null?void 0:b.processing)||0)>0,{data:R}=mt({queryKey:["digest-delivery-stats"],queryFn:async()=>{var te,X;const U=new Date;U.setUTCHours(0,0,0,0);const[B,V,Y,J]=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:Y.count||0,lastSent:((X=(te=J.data)==null?void 0:te[0])==null?void 0:X.sent_at)||null}},refetchInterval:L?5e3:!1}),q={totalSent:(R==null?void 0:R.totalSent)||0,totalFailed:(R==null?void 0:R.totalFailed)||0,lastSent:R==null?void 0:R.lastSent,agentOsEngaged:(R==null?void 0:R.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(ja,{defaultValue:"settings",className:"space-y-6",children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"settings",className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-4 w-4"}),"Settings"]}),e.jsxs(us,{value:"stats",className:"flex items-center gap-2",children:[e.jsx(Ro,{className:"h-4 w-4"}),"Delivery Stats"]})]}),e.jsxs(ks,{value:"settings",className:"space-y-6",children:[L&&b&&e.jsx(Pe,{className:"border-primary/50 bg-primary/5",children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx(ws,{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:[b.sent.toLocaleString()," sent, ",b.pending.toLocaleString()," pending",b.failed>0&&`, ${b.failed} failed`]})]}),e.jsxs("span",{className:"text-sm font-medium",children:[I,"%"]})]}),e.jsx(Bi,{value:I,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(b.pending/80)," min"]})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4",children:[e.jsx(Pe,{children:e.jsx(Re,{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(mr,{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(Pe,{children:e.jsx(Re,{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(la,{className:"h-5 w-5 text-emerald-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalSent}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Delivered"})]})]})})}),e.jsx(Pe,{children:e.jsx(Re,{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(xc,{className:"h-5 w-5 text-destructive"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.totalFailed}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed"})]})]})})}),e.jsx(Pe,{children:e.jsx(Re,{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(mn,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:q.lastSent?ps(new Date(q.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(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5"}),"Schedule"]}),e.jsx(xr,{children:"Configure when the digest is sent"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Enable Weekly Digest"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Send automated weekly emails to members"})]}),e.jsx($r,{checked:c==null?void 0:c.is_enabled,onCheckedChange:U=>w.mutate({is_enabled:U})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Cron Frequency"}),e.jsxs(Ys,{value:(c==null?void 0:c.cron_frequency)||"daily",onValueChange:U=>w.mutate({cron_frequency:U}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Day of Week"}),e.jsxs(Ys,{value:String(c==null?void 0:c.send_day),onValueChange:U=>w.mutate({send_day:parseInt(U)}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:xks.map(U=>e.jsx(Mt,{value:U.value,children:U.label},U.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Time (UTC)"}),e.jsxs(Ys,{value:String(c==null?void 0:c.send_hour),onValueChange:U=>w.mutate({send_hour:parseInt(U)}),disabled:(c==null?void 0:c.cron_frequency)==="daily",children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:gks.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:C,disabled:a,variant:"outline",className:"flex-1",children:[e.jsx(qn,{className:"h-4 w-4 mr-2"}),a?"Sending...":"Send Preview to Me"]}),e.jsxs(K,{onClick:N,disabled:r,className:"flex-1",children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),r?"Sending...":"Send to All"]})]}),j>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 ${j} Failed`]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(En,{className:"h-5 w-5"}),"Content Sections"]}),e.jsx(xr,{children:"Choose what to include in the digest"})]}),e.jsxs(Re,{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(En,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"New Resources"})]}),e.jsx($r,{checked:c==null?void 0:c.include_new_resources,onCheckedChange:U=>w.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(mr,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Community Highlights"})]}),e.jsx($r,{checked:c==null?void 0:c.include_community_posts,onCheckedChange:U=>w.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(Ro,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Agent OS Stats"})]}),e.jsx($r,{checked:c==null?void 0:c.include_agent_os_stats,onCheckedChange:U=>w.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(cn,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Upcoming Events"})]}),e.jsx($r,{checked:c==null?void 0:c.include_upcoming_events,onCheckedChange:U=>w.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(Rm,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(ye,{children:"Goals Progress"})]}),e.jsx($r,{checked:c==null?void 0:c.include_goals_progress,onCheckedChange:U=>w.mutate({include_goals_progress:U})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Custom Introduction"}),e.jsx(xr,{children:"Personalize the intro message (optional)"})]}),e.jsx(Re,{children:e.jsx(Er,{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=>w.mutate({custom_intro_text:U.target.value||null}),rows:3})})]})]}),e.jsx(ks,{value:"stats",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-5 w-5"}),"Delivery History"]}),e.jsx(xr,{children:"Recent digest emails sent to members"})]}),e.jsx(Re,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Email"}),e.jsx(kt,{children:"Sent At"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{children:"Resources"}),e.jsx(kt,{children:"Agent OS"})]})}),e.jsx(On,{children:p.map(U=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:U.email_sent_to}),e.jsx(dt,{children:ps(new Date(U.sent_at),"MMM d, yyyy h:mm a")}),e.jsx(dt,{children:e.jsx(tt,{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(tt,{variant:"secondary",children:"Active"}):e.jsx(tt,{variant:"outline",children:"Not Started"})})]},U.id))})]}):e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(dr,{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 vks={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 bks(){var fe,we,Ie;const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(null),[o,l]=k.useState(!1),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(!0),[j,w]=k.useState(!1),[N,C]=k.useState(""),[M,I]=k.useState(null),{data:L,isLoading:R}=mt({queryKey:["admin-agent-points"],queryFn:async()=>{const{data:Ne,error:Ae}=await H.from("agent_attendance_stats").select("*").order("total_points",{ascending:!1});if(Ae)throw Ae;const Fe=(Ne==null?void 0:Ne.map($e=>$e.user_id))||[],{data:Ce}=await H.from("profiles").select("id, name, email").in("id",Fe),Me=new Map((Ce==null?void 0:Ce.map($e=>[$e.id,{name:$e.name,email:$e.email}]))||[]);return Ne==null?void 0:Ne.map($e=>({...$e,profile:Me.get($e.user_id)||null}))}}),{data:q}=mt({queryKey:["all-profiles-for-points",L],queryFn:async()=>{const Ae=[];let Fe=0;for(;;){const{data:Ce,error:Me}=await H.from("profiles").select("id, name, email").order("name").range(Fe,Fe+1e3-1);if(Me)throw Me;if(Ae.push(...Ce),!Ce||Ce.length<1e3)break;Fe+=1e3}return Ae}}),B=((q==null?void 0:q.filter(Ne=>!(L!=null&&L.some(Ae=>Ae.user_id===Ne.id))))||[]).filter(Ne=>{var Fe,Ce;if(!N)return!0;const Ae=N.toLowerCase();return((Fe=Ne.name)==null?void 0:Fe.toLowerCase().includes(Ae))||((Ce=Ne.email)==null?void 0:Ce.toLowerCase().includes(Ae))}),{data:V,isLoading:Y}=mt({queryKey:["agent-point-history",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ne,error:Ae}=await H.from("agent_points").select("*").eq("user_id",n.user_id).order("created_at",{ascending:!1});if(Ae)throw Ae;return Ne},enabled:!!(n!=null&&n.user_id)&&i}),{data:J}=mt({queryKey:["agent-badges",n==null?void 0:n.user_id],queryFn:async()=>{if(!(n!=null&&n.user_id))return[];const{data:Ne,error:Ae}=await H.from("agent_badges").select("*").eq("user_id",n.user_id).order("earned_at",{ascending:!1});if(Ae)throw Ae;return Ne},enabled:!!(n!=null&&n.user_id)}),te=Lt({mutationFn:async({userId:Ne,points:Ae,reason:Fe})=>{const{error:Ce}=await H.from("agent_points").insert({user_id:Ne,points:Ae,reason:Fe});if(Ce)throw Ce;const{data:Me}=await H.from("agent_attendance_stats").select("total_points, spendable_points").eq("user_id",Ne).maybeSingle(),$e=((Me==null?void 0:Me.total_points)||0)+Ae,ct=((Me==null?void 0:Me.spendable_points)||0)+Ae,{error:Te}=await H.from("agent_attendance_stats").upsert({user_id:Ne,total_points:Math.max(0,$e),spendable_points:Math.max(0,ct),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(""),he.success(b?"Points awarded successfully!":"Points deducted successfully!")},onError:Ne=>{console.error("Error modifying points:",Ne),he.error("Failed to modify points")}}),X=()=>{if(!n||!u||!f){he.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){he.error("Please enter a valid positive number");return}te.mutate({userId:n.user_id,points:b?Ne:-Ne,reason:f})},ce=()=>{if(!M||!u||!f){he.error("Please fill in all fields");return}const Ne=parseInt(u);if(isNaN(Ne)||Ne<=0){he.error("Please enter a valid positive number");return}te.mutate({userId:M.id,points:Ne,reason:f},{onSuccess:()=>{w(!1),I(null),C("")}})},ne=(Ne,Ae)=>{a(Ne),_(Ae),l(!0)},re=Ne=>{a(Ne),c(!0)},le=L==null?void 0:L.filter(Ne=>{var Me,$e,ct,Te;const Ae=(($e=(Me=Ne.profile)==null?void 0:Me.name)==null?void 0:$e.toLowerCase())||"",Fe=((Te=(ct=Ne.profile)==null?void 0:ct.email)==null?void 0:Te.toLowerCase())||"",Ce=s.toLowerCase();return Ae.includes(Ce)||Fe.includes(Ce)}),pe=(L==null?void 0:L.reduce((Ne,Ae)=>Ne+Ae.total_points,0))||0,xe=(L==null?void 0:L.length)||0,_e=xe>0?Math.round(pe/xe):0;return R?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(Ne=>e.jsx(vs,{className:"h-24"},Ne))}),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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(mr,{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:xe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"with points tracked"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(xo,{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:pe.toLocaleString()}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"awarded across all agents"})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Ol,{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:_e}),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(hn,{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:Ne=>r(Ne.target.value),className:"pl-10"})]}),e.jsxs(K,{onClick:()=>w(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points to New Agent"]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Agent Leaderboard"}),e.jsx(xr,{children:"All agents with their points, events, and streaks"})]}),e.jsx(Re,{children:!le||le.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(xo,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No agents with points yet"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-12",children:"#"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Total Points"}),e.jsx(kt,{className:"text-center",children:"Spendable"}),e.jsx(kt,{className:"text-center",children:"Events"}),e.jsx(kt,{className:"text-center",children:"Streak"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:le.map((Ne,Ae)=>{var Fe,Ce,Me,$e;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:Ae<3?e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center ${Ae===0?"bg-yellow-100 text-yellow-700":Ae===1?"bg-gray-100 text-gray-600":"bg-amber-100 text-amber-700"}`,children:Ae+1}):e.jsx("span",{className:"text-muted-foreground",children:Ae+1})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_n,{className:"h-8 w-8",children:e.jsx(wn,{children:((Ce=(Fe=Ne.profile)==null?void 0:Fe.name)==null?void 0:Ce.charAt(0))||"?"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((Me=Ne.profile)==null?void 0:Me.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:($e=Ne.profile)==null?void 0:$e.email})]})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ne.total_points]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"outline",className:"font-bold text-primary",children:[e.jsx(No,{className:"h-3 w-3 mr-1"}),Ne.spendable_points||0]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3 text-muted-foreground"}),Ne.total_events_attended]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Qu,{className:"h-3 w-3 text-orange-500"}),Ne.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(Ne,!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(Ne,!1),title:"Deduct points",children:e.jsx(m0,{className:"h-4 w-4 text-red-600"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(Ne),title:"View history",children:e.jsx(CM,{className:"h-4 w-4"})})]})})]},Ne.user_id)})})]})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{children:b?"Award Points":"Deduct Points"}),e.jsxs(Wr,{children:[b?"Award":"Deduct"," points ",b?"to":"from"," ",((fe=n==null?void 0:n.profile)==null?void 0:fe.name)||"this agent"]})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"points",children:"Points Amount"}),e.jsx(ze,{id:"points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>p(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"reason",children:"Reason"}),e.jsx(Er,{id:"reason",placeholder:"Enter reason for this adjustment...",value:f,onChange:Ne=>g(Ne.target.value)})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:X,disabled:te.isPending,className:b?"bg-green-600 hover:bg-green-700":"bg-red-600 hover:bg-red-700",children:te.isPending?"Saving...":b?"Award Points":"Deduct Points"})]})]})}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsxs(_s,{children:[e.jsxs(bs,{children:["Point History: ",(we=n==null?void 0:n.profile)==null?void 0:we.name]}),e.jsx(Wr,{children:"View all point transactions and badges for this agent"})]}),e.jsxs(ja,{defaultValue:"history",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2",children:[e.jsx(us,{value:"history",children:"Point History"}),e.jsx(us,{value:"badges",children:"Badges"})]}),e.jsx(ks,{value:"history",className:"mt-4",children:Y?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(Ne=>e.jsx(vs,{className:"h-12"},Ne))}):!V||V.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(CM,{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(Ne=>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:Ne.reason}),e.jsx("p",{className:"text-xs text-muted-foreground",children:ps(new Date(Ne.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(tt,{variant:Ne.points>=0?"default":"destructive",className:Ne.points>=0?"bg-green-100 text-green-800":"",children:[Ne.points>=0?"+":"",Ne.points]})]},Ne.id))})}),e.jsx(ks,{value:"badges",className:"mt-4",children:!J||J.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(bc,{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:J.map(Ne=>e.jsxs("div",{className:`p-3 rounded-lg ${vks[Ne.badge_type]||"bg-gray-100"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(bc,{className:"h-5 w-5"}),e.jsx("span",{className:"font-medium",children:Ne.badge_name})]}),Ne.badge_description&&e.jsx("p",{className:"text-xs mt-1 opacity-80",children:Ne.badge_description}),e.jsxs("p",{className:"text-xs mt-1 opacity-60",children:["Earned ",ps(new Date(Ne.earned_at),"MMM d, yyyy")]})]},Ne.id))})})]})]})}),e.jsx(xs,{open:j,onOpenChange:Ne=>{w(Ne),Ne||(I(null),C(""),p(""),g(""))},children:e.jsxs(fs,{className:"max-w-md",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(_n,{className:"h-10 w-10",children:e.jsx(wn,{children:((Ie=M.name)==null?void 0:Ie.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:()=>I(null),children:"Change"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"new-points",children:"Points Amount"}),e.jsx(ze,{id:"new-points",type:"number",min:"1",placeholder:"Enter points...",value:u,onChange:Ne=>p(Ne.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"new-reason",children:"Reason"}),e.jsx(Er,{id:"new-reason",placeholder:"Enter reason for awarding points...",value:f,onChange:Ne=>g(Ne.target.value)})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Search Agent"}),e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:N,onChange:Ne=>C(Ne.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(mr,{className:"h-6 w-6 mx-auto mb-2 opacity-50"}),e.jsx("p",{className:"text-sm",children:N?"No matching agents found":"All agents already have points"})]}):B.slice(0,20).map(Ne=>{var Ae;return e.jsxs("button",{onClick:()=>I(Ne),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(_n,{className:"h-8 w-8",children:e.jsx(wn,{children:((Ae=Ne.name)==null?void 0:Ae.charAt(0))||"?"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:Ne.name||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ne.email})]})]},Ne.id)})})]})}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),M&&e.jsxs(K,{onClick:ce,disabled:te.isPending,className:"bg-green-600 hover:bg-green-700",children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Award Points"]})]})]})})]})})}function _ks(){const{data:t,isLoading:s}=rkt(),[r,n]=k.useState(null),[a,o]=k.useState(!1),[l,i]=k.useState(""),[c,u]=k.useState("all"),[p,f]=k.useState("newest"),[g,b]=k.useState("table"),_=k.useMemo(()=>(t==null?void 0:t.map(M=>M.user_id))||[],[t]),j=k.useMemo(()=>(t==null?void 0:t.map(M=>M.id))||[],[t]),{data:w}=mt({queryKey:["card-profiles-lookup",_],queryFn:async()=>{if(_.length===0)return{};const{data:M}=await H.from("profiles").select("id, name, email").in("id",_),I={};return M==null||M.forEach(L=>{I[L.id]={name:L.name||"",email:L.email||""}}),I},enabled:_.length>0}),{data:N}=mt({queryKey:["card-stats-all",j],queryFn:async()=>{if(j.length===0)return{};const M={};j.forEach(R=>{M[R]={views:0,leads:0}});const{data:I}=await H.from("agent_card_interactions").select("card_id").in("card_id",j).eq("interaction_type","card_view");I==null||I.forEach(R=>{M[R.card_id]&&M[R.card_id].views++});const{data:L}=await H.from("agent_card_leads").select("card_id").in("card_id",j);return L==null||L.forEach(R=>{M[R.card_id]&&M[R.card_id].leads++}),M},enabled:j.length>0}),C=k.useMemo(()=>{if(!t)return[];let M=[...t];if(c==="live"?M=M.filter(I=>I.is_published):c==="draft"&&(M=M.filter(I=>!I.is_published)),l.trim()){const I=l.toLowerCase();M=M.filter(L=>{var q,U;const R=w==null?void 0:w[L.user_id];return L.slug.toLowerCase().includes(I)||((q=R==null?void 0:R.name)==null?void 0:q.toLowerCase().includes(I))||((U=R==null?void 0:R.email)==null?void 0:U.toLowerCase().includes(I))})}return p==="newest"?M.sort((I,L)=>new Date(L.created_at).getTime()-new Date(I.created_at).getTime()):p==="oldest"?M.sort((I,L)=>new Date(I.created_at).getTime()-new Date(L.created_at).getTime()):p==="name"?M.sort((I,L)=>{var R,q;return(((R=w==null?void 0:w[I.user_id])==null?void 0:R.name)||"").localeCompare(((q=w==null?void 0:w[L.user_id])==null?void 0:q.name)||"")}):p==="slug"?M.sort((I,L)=>I.slug.localeCompare(L.slug)):p==="views_desc"?M.sort((I,L)=>{var R,q;return(((R=N==null?void 0:N[L.id])==null?void 0:R.views)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.views)||0)}):p==="views_asc"?M.sort((I,L)=>{var R,q;return(((R=N==null?void 0:N[I.id])==null?void 0:R.views)||0)-(((q=N==null?void 0:N[L.id])==null?void 0:q.views)||0)}):p==="leads_desc"?M.sort((I,L)=>{var R,q;return(((R=N==null?void 0:N[L.id])==null?void 0:R.leads)||0)-(((q=N==null?void 0:N[I.id])==null?void 0:q.leads)||0)}):p==="leads_asc"&&M.sort((I,L)=>{var R,q;return(((R=N==null?void 0:N[I.id])==null?void 0:R.leads)||0)-(((q=N==null?void 0:N[L.id])==null?void 0:q.leads)||0)}),M},[t,c,l,p,w]);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(hn,{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(Ys,{value:c,onValueChange:u,children:[e.jsx(Gs,{className:"w-full sm:w-36",children:e.jsx(Qs,{placeholder:"Status"})}),e.jsxs(Ks,{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(Ys,{value:p,onValueChange:f,children:[e.jsx(Gs,{className:"w-full sm:w-44",children:e.jsx(Qs,{placeholder:"Sort by"})}),e.jsxs(Ks,{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:()=>b("table"),className:"rounded-r-none",children:e.jsx(BM,{className:"h-4 w-4"})}),e.jsx(K,{variant:g==="grid"?"default":"ghost",size:"sm",onClick:()=>b("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 ",C.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))}):C.length>0?g==="table"?e.jsx(wks,{cards:C,cardProfiles:w,cardStats:N,onEdit:n,sortBy:p,setSortBy:f}):e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:C.map(M=>e.jsx(jks,{card:M,onEdit:()=>n(M),stats:N==null?void 0:N[M.id]},M.id))}):t&&t.length>0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(hn,{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(mr,{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(Nks,{open:a,onOpenChange:o}),r&&e.jsx(kks,{card:r,open:!!r,onOpenChange:M=>!M&&n(null)})]})}function wks({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(Hh,{className:"h-3 w-3"}):a===`${c}_asc`?e.jsx(Nu,{className:"h-3 w-3"}):e.jsx(yd,{className:"h-3 w-3 opacity-40"});return e.jsx(Pe,{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(Nu,{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(tt,{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(Da,{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),he.success("Link copied!")},children:e.jsx(gi,{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(an,{className:"h-3.5 w-3.5"})})})]})})]},c.id)})})]})})})}function jks({card:t,onEdit:s,stats:r}){const[n,a]=k.useState(null);k.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),he.success("Link copied!")};return e.jsx(Pe,{children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start gap-3 mb-3",children:[e.jsxs(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:(n==null?void 0:n.avatar_url)||void 0}),e.jsx(wn,{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(tt,{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(qn,{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(mr,{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(Da,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:l,children:e.jsx(gi,{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(an,{className:"h-3 w-3"})})})]})]})})}function Nks({open:t,onOpenChange:s}){const[r,n]=k.useState(""),[a,o]=k.useState(""),[l,i]=k.useState(""),[c,u]=k.useState(!1),p=tGe(),f=l.trim(),{data:g}=mt({queryKey:["profiles-search-for-cards",f],queryFn:async()=>{let C=H.from("profiles").select("id, name, email").order("name").limit(50);f.length>=2&&(C=C.or(`name.ilike.%${f}%,email.ilike.%${f}%`));const{data:M}=await C;return M||[]},enabled:t}),[b,_]=k.useState(null),j=(g==null?void 0:g.find(C=>C.id===r))||b,w=()=>{if(!r||!a.trim()){he.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("")}})},N=C=>{var I;n(C),u(!1);const M=g==null?void 0:g.find(L=>L.id===C);M&&(_(M),o(((I=M.name)==null?void 0:I.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""))||""))};return e.jsx(xs,{open:t,onOpenChange:s,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Agent"}),e.jsxs(Bo,{open:c,onOpenChange:u,children:[e.jsx($o,{asChild:!0,children:e.jsxs(K,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full justify-between font-normal",children:[j?`${j.name} (${j.email})`:"Search for an agent...",e.jsx(Sx,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),e.jsx(Do,{className:"w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(Lx,{shouldFilter:!1,children:[e.jsx(Dx,{placeholder:"Search by name or email...",value:l,onValueChange:i}),e.jsxs(Ox,{children:[e.jsx(Rx,{children:"No agents found."}),e.jsx(Fx,{children:(g||[]).map(C=>e.jsxs(vp,{value:C.id,onSelect:N,children:[e.jsx(fa,{className:Pt("mr-2 h-4 w-4",r===C.id?"opacity-100":"opacity-0")}),C.name," (",C.email,")"]},C.id))})]})]})})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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:C=>o(C.target.value),placeholder:"john-doe"})]})]}),e.jsx(K,{onClick:w,disabled:p.isPending,className:"w-full",children:p.isPending?"Creating...":"Create Card"})]})]})})}function kks({card:t,open:s,onOpenChange:r}){const n=sGe(),{data:a}=rGe(t.id),o=es(),[l,i]=k.useState(null),[c,u]=k.useState(!1),[p,f]=k.useState(!1),[g,b]=k.useState(""),[_,j]=k.useState(t.slug),[w,N]=k.useState(!1),[C,M]=k.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});k.useEffect(()=>{s&&(async()=>{try{const{data:V}=await H.storage.from("avatars").list(`${t.user_id}`);if(V&&V.length>0){const{data:Y}=H.storage.from("avatars").getPublicUrl(`${t.user_id}/${V[0].name}`);i(`${Y.publicUrl}?t=${Date.now()}`)}}catch{}})()},[t.user_id,s]);const I=B=>{var J;const V=(J=B.target.files)==null?void 0:J[0];if(!V)return;if(!V.type.startsWith("image/")){he.error("Please select an image file");return}if(V.size>5*1024*1024){he.error("Image must be under 5MB");return}const Y=new FileReader;Y.onloadend=()=>{b(Y.result),f(!0)},Y.readAsDataURL(V),B.target.value=""},L=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 Y=`${t.user_id}/avatar.jpg`,{error:J}=await H.storage.from("avatars").upload(Y,B,{upsert:!0,contentType:"image/jpeg"});if(J)throw J;const{data:te}=H.storage.from("avatars").getPublicUrl(Y),X=`${te.publicUrl}?t=${Date.now()}`;i(X),await H.from("profiles").update({avatar_url:X}).eq("id",t.user_id),o.invalidateQueries({queryKey:["agent-card-public"]}),he.success("Photo updated!")}catch(V){he.error(V.message||"Upload failed")}finally{u(!1)}},R=async()=>{const B=_.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/(^-|-$)/g,"");if(!B){he.error("Please enter a valid URL");return}if(B===t.slug){he.info("No changes to save");return}N(!0);try{const{data:V}=await H.from("agent_cards").select("id").eq("slug",B).neq("id",t.id).maybeSingle();if(V){he.error("This URL is already taken. Try another one.");return}const{error:Y}=await H.from("agent_cards").update({slug:B}).eq("id",t.id);if(Y)throw Y;j(B),o.invalidateQueries({queryKey:["agent-cards-admin"]}),he.success("Card address updated!")}catch{he.error("Failed to update card address")}finally{N(!1)}},q=async(B,V)=>{var J;const Y=(J=B.target.files)==null?void 0:J[0];if(Y){if(!Y.type.startsWith("image/")){he.error("Please select an image file");return}try{const te=Y.name.split(".").pop()||"png",X=V==="brokerage_logo_url"?"brokerage-logo":"team-logo",ce=`${t.user_id}/${X}.${te}`,{error:ne}=await H.storage.from("card-logos").upload(ce,Y,{upsert:!0});if(ne)throw ne;const{data:re}=H.storage.from("card-logos").getPublicUrl(ce),le=re.publicUrl+"?t="+Date.now();M(V==="brokerage_logo_url"?pe=>({...pe,[V]:le,brokerage_display_name:""}):pe=>({...pe,[V]:le,team_name:""})),he.success("Logo uploaded!")}catch{he.error("Failed to upload logo")}finally{B.target.value=""}}},U=()=>{n.mutate({id:t.id,...C,title:C.title||null,positioning_statement:C.positioning_statement||null,bio:C.bio||null,review_snippet:C.review_snippet||null,review_source_url:C.review_source_url||null,booking_url:C.booking_url||null,custom_cta_label:C.custom_cta_label||null,custom_cta_url:C.custom_cta_url||null,brokerage_display_name:C.brokerage_display_name||null,brokerage_logo_url:C.brokerage_logo_url||null,brokerage_logo_size:C.brokerage_logo_size,team_name:C.team_name||null,team_logo_url:C.team_logo_url||null,team_logo_size:C.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(_s,{children:[e.jsx(bs,{children:"Edit Agent Card"}),e.jsxs(Wr,{children:["/card/",t.slug]})]}),e.jsxs(ja,{defaultValue:"content",children:[e.jsxs(ga,{className:"w-full",children:[e.jsx(us,{value:"content",className:"flex-1",children:"Content"}),e.jsx(us,{value:"sections",className:"flex-1",children:"Sections"}),e.jsx(us,{value:"blocks",className:"flex-1",children:"Blocks"}),e.jsx(us,{value:"analytics",className:"flex-1",children:"Analytics"})]}),e.jsxs(ks,{value:"content",className:"space-y-4 mt-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Published"}),e.jsx($r,{checked:C.is_published,onCheckedChange:B=>M(V=>({...V,is_published:B}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-4 mt-1",children:[e.jsxs(_n,{className:"h-16 w-16",children:[e.jsx(za,{src:l||void 0}),e.jsx(wn,{children:"?"})]}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:I,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(ws,{className:"h-3 w-3 mr-1 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-3 w-3 mr-1"}),"Change Photo"]})})})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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=>j(B.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"-")),placeholder:"agent-name",className:"rounded-l-none"})]}),e.jsx(K,{variant:"outline",size:"sm",onClick:R,disabled:w||_===t.slug,className:"shrink-0",children:w?"Saving...":"Update"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Theme"}),e.jsxs(Ys,{value:C.theme,onValueChange:B=>M(V=>({...V,theme:B})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"Title / Tagline"}),e.jsx(ze,{value:C.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(ye,{children:"Positioning Statement"}),e.jsx(ze,{value:C.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(ye,{children:"Bio"}),e.jsx(Er,{value:C.bio,onChange:B=>M(V=>({...V,bio:B.target.value})),placeholder:"Short about me...",rows:3})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Review Snippet"}),e.jsx(ze,{value:C.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(ye,{children:"Review Source URL"}),e.jsx(ze,{value:C.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(ye,{children:"Booking URL (optional — if empty, shows lead form)"}),e.jsx(ze,{value:C.booking_url,onChange:B=>M(V=>({...V,booking_url:B.target.value})),placeholder:"https://calendly.com/your-link"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Custom CTA Label (optional)"}),e.jsx(ze,{value:C.custom_cta_label,onChange:B=>M(V=>({...V,custom_cta_label:B.target.value})),placeholder:"Book a Call"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Custom CTA URL (optional)"}),e.jsx(ze,{value:C.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(ye,{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:C.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:!!C.brokerage_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.brokerage_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.brokerage_logo_url,alt:"Brokerage logo",style:{height:`${C.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(oi,{className:"h-3.5 w-3.5"}),C.brokerage_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"brokerage_logo_url")})]})]}),C.brokerage_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.brokerage_logo_size||56,"px"]})]}),e.jsx(Wg,{value:[C.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(ye,{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:C.team_name,onChange:B=>M(V=>({...V,team_name:B.target.value,team_logo_url:""})),placeholder:"Team name (or upload logo below)",disabled:!!C.team_logo_url}),e.jsxs("div",{className:"flex items-center gap-3",children:[C.team_logo_url&&e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:C.team_logo_url,alt:"Team logo",style:{height:`${C.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(oi,{className:"h-3.5 w-3.5"}),C.team_logo_url?"Change Logo":"Upload Logo"]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:B=>q(B,"team_logo_url")})]})]}),C.team_logo_url&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground",children:"Logo Size"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[C.team_logo_size||56,"px"]})]}),e.jsx(Wg,{value:[C.team_logo_size||56],onValueChange:([B])=>M(V=>({...V,team_logo_size:B})),min:24,max:120,step:4})]})]})]})]}),e.jsx(ks,{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:Y})=>e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx(ye,{children:V}),Y&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[Y," ",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($r,{checked:C[B],onCheckedChange:J=>M(te=>({...te,[B]:J}))})]},B))}),e.jsx(ks,{value:"blocks",className:"mt-4",children:e.jsx(dlt,{cardId:t.id})}),e.jsx(ks,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(Pe,{children:e.jsxs(Re,{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(tt,{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(yke,{open:p,onClose:()=>f(!1),imageSrc:g,onCropComplete:L,aspectRatio:1})]})}const cT={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"},oCe={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 lCe(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 Sks(){const t=es();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"]}),he.success("Category created successfully")},onError:s=>{he.error("Failed to create category: "+s.message)}})}function Cks(){const t=es();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"]}),he.success("Category updated successfully")},onError:s=>{he.error("Failed to update category: "+s.message)}})}function Mks(){const t=es();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"]}),he.success("Category deleted successfully")},onError:s=>{he.error("Failed to delete category: "+s.message)}})}function klt(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 Tks(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 Aks(){const t=es();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"]}),he.success("Product created successfully")},onError:s=>{he.error("Failed to create product: "+s.message)}})}function Eks(){const t=es();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]}),he.success("Product updated successfully")},onError:s=>{he.error("Failed to update product: "+s.message)}})}function Pks(){const t=es();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"]}),he.success("Product deleted successfully")},onError:s=>{he.error("Failed to delete product: "+s.message)}})}function Iks(){const t=es();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 Lks(){const t=es();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]}),he.success("Image deleted successfully")},onError:s=>{he.error("Failed to delete image: "+s.message)}})}function Dks(){const t=es();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]}),he.success("Primary image updated")},onError:s=>{he.error("Failed to set primary image: "+s.message)}})}function Oks(){const t=es();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]}),he.success("Variant added successfully")}})}function Rks(){const t=es();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]}),he.success("Variant deleted successfully")}})}function Fks(){const t=es();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]}),he.success("Video updated successfully")}})}function zks(t){const{isAdmin:s}=Rs();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 Bks(){const{user:t}=Rs();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 $ks(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 qks(){const t=es(),{user:s}=Rs();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"]}),he.success("Order status updated")},onError:r=>{he.error("Failed to update order: "+r.message)}})}function Uks(){const t=es();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"]}),he.success("Proof uploaded & customer notified")}})}function Vks(){const t=es();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"]}),he.success("Proof approved")}})}function Hks(){const t=es();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"]}),he.success("Proof rejected - please upload a new proof")}})}function Wks(){const{data:t,isLoading:s}=lCe(!1),r=Sks(),n=Cks(),a=Mks(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.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=j=>{c(j),p({name:j.name,description:j.description||"",image_url:j.image_url||"",sort_order:j.sort_order,is_active:j.is_active}),l(!0)},b=async j=>{j.preventDefault(),i?await n.mutateAsync({id:i.id,...u}):await r.mutateAsync(u),l(!1),f()},_=async j=>{confirm("Are you sure you want to delete this category?")&&await a.mutateAsync(j)};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(j=>e.jsx(vs,{className:"h-12 w-full"},j))})})]}):e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Categories"}),e.jsxs(xs,{open:o,onOpenChange:j=>{l(j),j||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(_s,{children:e.jsx(bs,{children:i?"Edit Category":"Add Category"})}),e.jsxs("form",{onSubmit:b,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"name",children:"Name"}),e.jsx(ze,{id:"name",value:u.name,onChange:j=>p({...u,name:j.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:u.description,onChange:j=>p({...u,description:j.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"image_url",children:"Image URL"}),e.jsx(ze,{id:"image_url",value:u.image_url,onChange:j=>p({...u,image_url:j.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:u.sort_order,onChange:j=>p({...u,sort_order:parseInt(j.target.value)||0})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"is_active",checked:u.is_active,onCheckedChange:j=>p({...u,is_active:j})}),e.jsx(ye,{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(Re,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{children:"Sort Order"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:t.map(j=>e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium",children:j.name}),e.jsx(dt,{className:"max-w-xs truncate",children:j.description}),e.jsx(dt,{children:j.sort_order}),e.jsx(dt,{children:e.jsx("span",{className:`px-2 py-1 rounded-full text-xs ${j.is_active?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:j.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(j),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>_(j.id),disabled:a.isPending,children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},j.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No categories yet. Create your first category to get started."})})]})}function Gks(){var _e,fe;const{data:t,isLoading:s}=klt(void 0,!1),{data:r}=lCe(!1),n=Aks(),a=Eks(),o=Pks(),l=Iks(),i=Lks(),c=Dks(),u=Oks(),p=Rks(),f=Fks(),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[C,M]=k.useState(null),[I,L]=k.useState(null),[R,q]=k.useState(!1),[U,B]=k.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,Y]=k.useState({name:"",price_adjustment:0}),[J,te]=k.useState(""),X=()=>{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=we=>{M(we),B({name:we.name,description:we.description||"",base_price:Number(we.base_price),shipping_fee:Number(we.shipping_fee),category_id:we.category_id||"",allow_artwork_upload:we.allow_artwork_upload,requires_proof_approval:we.requires_proof_approval,is_active:we.is_active,sort_order:we.sort_order}),b(!0)},ne=async we=>{we.preventDefault();const Ie={...U,category_id:U.category_id||null};C?await a.mutateAsync({id:C.id,...Ie}):await n.mutateAsync(Ie),b(!1),X()},re=async we=>{confirm("Are you sure you want to delete this product?")&&await o.mutateAsync(we)},le=async we=>{if(!I||!we.target.files||we.target.files.length===0)return;q(!0);const Ie=we.target.files[0],Ne=Ie.name.split(".").pop(),Ae=`products/${I.id}/${Date.now()}.${Ne}`;try{const{error:Fe}=await H.storage.from("marketplace").upload(Ae,Ie);if(Fe)throw Fe;const{data:{publicUrl:Ce}}=H.storage.from("marketplace").getPublicUrl(Ae);await l.mutateAsync({product_id:I.id,image_url:Ce,is_primary:!I.images||I.images.length===0}),he.success("Image uploaded successfully")}catch(Fe){he.error("Failed to upload image: "+Fe.message)}finally{q(!1)}},pe=async we=>{we.preventDefault(),I&&(await u.mutateAsync({product_id:I.id,name:V.name,price_adjustment:V.price_adjustment}),Y({name:"",price_adjustment:0}))},xe=async()=>{!I||!J||(await f.mutateAsync({productId:I.id,videoUrl:J}),te(""))};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(we=>e.jsx(vs,{className:"h-64 w-full"},we))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Products"}),e.jsxs(xs,{open:g,onOpenChange:we=>{b(we),we||X()},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(_s,{children:e.jsx(bs,{children:C?"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(ye,{htmlFor:"name",children:"Product Name"}),e.jsx(ze,{id:"name",value:U.name,onChange:we=>B({...U,name:we.target.value}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"category",children:"Category"}),e.jsxs(Ys,{value:U.category_id,onValueChange:we=>B({...U,category_id:we}),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsx(Ks,{children:r==null?void 0:r.map(we=>e.jsx(Mt,{value:we.id,children:we.name},we.id))})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"description",children:"Description"}),e.jsx(Er,{id:"description",value:U.description,onChange:we=>B({...U,description:we.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(ye,{htmlFor:"base_price",children:"Base Price ($)"}),e.jsx(ze,{id:"base_price",type:"number",step:"0.01",min:"0",value:U.base_price,onChange:we=>B({...U,base_price:parseFloat(we.target.value)||0}),required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"shipping_fee",children:"Shipping Fee ($)"}),e.jsx(ze,{id:"shipping_fee",type:"number",step:"0.01",min:"0",value:U.shipping_fee,onChange:we=>B({...U,shipping_fee:parseFloat(we.target.value)||0})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"sort_order",children:"Sort Order"}),e.jsx(ze,{id:"sort_order",type:"number",value:U.sort_order,onChange:we=>B({...U,sort_order:parseInt(we.target.value)||0})})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"allow_artwork_upload",checked:U.allow_artwork_upload,onCheckedChange:we=>B({...U,allow_artwork_upload:we})}),e.jsx(ye,{htmlFor:"allow_artwork_upload",children:"Allow customer to upload artwork"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"requires_proof_approval",checked:U.requires_proof_approval,onCheckedChange:we=>B({...U,requires_proof_approval:we})}),e.jsx(ye,{htmlFor:"requires_proof_approval",children:"Requires proof approval"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{id:"is_active",checked:U.is_active,onCheckedChange:we=>B({...U,is_active:we})}),e.jsx(ye,{htmlFor:"is_active",children:"Active"})]})]}),e.jsx(K,{type:"submit",className:"w-full",disabled:n.isPending||a.isPending,children:C?"Update Product":"Create Product"})]})]})]})]}),e.jsx(Re,{children:t&&t.length>0?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:t.map(we=>{var Ie,Ne;return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"aspect-video bg-muted relative",children:[we.images&&we.images.length>0?e.jsx("img",{src:((Ie=we.images.find(Ae=>Ae.is_primary))==null?void 0:Ie.image_url)||we.images[0].image_url,alt:we.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"}),!we.is_active&&e.jsx(tt,{variant:"secondary",className:"absolute top-2 right-2",children:"Inactive"})]}),e.jsxs(Re,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold mb-1",children:we.name}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:((Ne=we.category)==null?void 0:Ne.name)||"No category"}),e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"font-bold",children:["$",Number(we.base_price).toFixed(2)]}),Number(we.shipping_fee)>0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["+$",Number(we.shipping_fee).toFixed(2)," shipping"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[we.allow_artwork_upload&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Artwork Upload"}),we.requires_proof_approval&&e.jsx(tt,{variant:"outline",className:"text-xs",children:"Proof Required"}),we.variants&&we.variants.length>0&&e.jsxs(tt,{variant:"outline",className:"text-xs",children:[we.variants.length," Variants"]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>ce(we),children:[e.jsx(Da,{className:"h-3 w-3 mr-1"}),"Edit"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(we),j(!0)},children:[e.jsx(n1,{className:"h-3 w-3 mr-1"}),"Images"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{L(we),N(!0)},children:[e.jsx(Om,{className:"h-3 w-3 mr-1"}),"Variants"]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>re(we.id),children:e.jsx(Nr,{className:"h-3 w-3 text-destructive"})})]})]})]},we.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:j,children:e.jsxs(fs,{className:"max-w-2xl",children:[e.jsx(_s,{children:e.jsxs(bs,{children:["Manage Images - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-4",children:(_e=I==null?void 0:I.images)==null?void 0:_e.map(we=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:we.image_url,alt:"",className:"w-full aspect-square object-cover rounded-lg"}),we.is_primary&&e.jsx(tt,{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:[!we.is_primary&&e.jsx(K,{variant:"secondary",size:"icon",onClick:async()=>{var Ie;await c.mutateAsync({imageId:we.id,productId:I.id}),L({...I,images:(Ie=I.images)==null?void 0:Ie.map(Ne=>({...Ne,is_primary:Ne.id===we.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 Ne;await i.mutateAsync({id:we.id,productId:I.id});const Ie=t==null?void 0:t.find(Ae=>Ae.id===I.id);Ie&&L({...Ie,images:(Ne=Ie.images)==null?void 0:Ne.filter(Ae=>Ae.id!==we.id)})},disabled:i.isPending,children:e.jsx(Nr,{className:"h-4 w-4"})})]})]},we.id))}),e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6 text-center",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:le,className:"hidden",id:"image-upload",disabled:R}),e.jsxs("label",{htmlFor:"image-upload",className:"cursor-pointer",children:[e.jsx(n1,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:R?"Uploading...":"Click to upload an image"})]})]}),e.jsxs("div",{className:"border-t pt-4 mt-4",children:[e.jsx(ye,{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:J,onChange:we=>te(we.target.value)}),e.jsxs(K,{onClick:xe,disabled:!J,children:[e.jsx(Cn,{className:"h-4 w-4 mr-2"}),"Set Video"]})]}),(I==null?void 0:I.video)&&e.jsxs("p",{className:"text-sm text-muted-foreground mt-2",children:["Current video: ",I.video.video_url]})]})]})]})}),e.jsx(xs,{open:w,onOpenChange:N,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsxs(bs,{children:["Manage Variants - ",I==null?void 0:I.name]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("form",{onSubmit:pe,className:"flex gap-2",children:[e.jsx(ze,{placeholder:"Variant name (e.g., 500 count)",value:V.name,onChange:we=>Y({...V,name:we.target.value}),required:!0}),e.jsx(ze,{type:"number",step:"0.01",placeholder:"Price adj.",value:V.price_adjustment,onChange:we=>Y({...V,price_adjustment:parseFloat(we.target.value)||0}),className:"w-32"}),e.jsx(K,{type:"submit",children:"Add"})]}),e.jsxs("div",{className:"space-y-2",children:[(fe=I==null?void 0:I.variants)==null?void 0:fe.map(we=>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:we.name}),e.jsxs("span",{className:"text-sm text-muted-foreground ml-2",children:[Number(we.price_adjustment)>=0?"+":"","$",Number(we.price_adjustment).toFixed(2)]})]}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>p.mutateAsync({id:we.id,productId:I.id}),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]},we.id)),(!(I!=null&&I.variants)||I.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 Kks=["pending_payment","order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed","cancelled","refunded"];function Zks(){var j,w,N;const{data:t,isLoading:s}=zks(),r=qks(),n=Uks(),[a,o]=k.useState(null),[l,i]=k.useState(!1),[c,u]=k.useState({status:"",notes:"",trackingNumber:"",trackingUrl:""}),[p,f]=k.useState(!1),g=C=>{o(C),u({status:C.status,notes:"",trackingNumber:C.tracking_number||"",trackingUrl:C.tracking_url||""}),i(!0)},b=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(C,M)=>{if(!a||!C.target.files||C.target.files.length===0)return;f(!0);const I=C.target.files[0],L=I.name.split(".").pop(),R=`proofs/${a.id}/${M}/${Date.now()}.${L}`;try{const{error:q}=await H.storage.from("marketplace").upload(R,I);if(q)throw q;const{data:{publicUrl:U}}=H.storage.from("marketplace").getPublicUrl(R);await n.mutateAsync({itemId:M,proofUrl:U,orderId:a.id}),he.success("Proof uploaded successfully")}catch(q){he.error("Failed to upload proof: "+q.message)}finally{f(!1)}};return s?e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(vs,{className:"h-8 w-48"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-4",children:[1,2,3].map(C=>e.jsx(vs,{className:"h-16 w-full"},C))})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Orders"})}),e.jsx(Re,{children:t&&t.length>0?e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Order #"}),e.jsx(kt,{children:"Customer"}),e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"Total"}),e.jsx(kt,{children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:t.map(C=>{var M,I;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-mono",children:C.order_number}),e.jsx(dt,{children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((M=C.user)==null?void 0:M.name)||"Unknown"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(I=C.user)==null?void 0:I.email})]})}),e.jsx(dt,{children:ps(new Date(C.created_at),"MMM d, yyyy")}),e.jsxs(dt,{className:"font-bold",children:["$",Number(C.total).toFixed(2)]}),e.jsx(dt,{children:e.jsx(tt,{className:oCe[C.status],children:cT[C.status]})}),e.jsx(dt,{className:"text-right",children:e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>g(C),children:[e.jsx(qn,{className:"h-4 w-4 mr-1"}),"View"]})})]},C.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(_s,{children:e.jsxs(bs,{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:(j=a.user)==null?void 0:j.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(w=a.user)==null?void 0:w.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:(N=a.items)==null?void 0:N.map(C=>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:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name})]}),e.jsxs("p",{className:"font-bold",children:["$",Number(C.unit_price).toFixed(2)," x ",C.quantity]})]}),C.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:C.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(tt,{variant:C.proof_status==="approved"?"default":"secondary",children:C.proof_status||"No proof yet"})]}),C.proof_url?e.jsx("a",{href:C.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,C.id),className:"hidden",id:`proof-${C.id}`,disabled:p}),e.jsx("label",{htmlFor:`proof-${C.id}`,children:e.jsx(K,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("span",{children:[e.jsx(oi,{className:"h-4 w-4 mr-1"}),p?"Uploading...":"Upload Proof"]})})})]})]})})]},C.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(ye,{children:"Status"}),e.jsxs(Ys,{value:c.status,onValueChange:C=>u({...c,status:C}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:Kks.map(C=>e.jsx(Mt,{value:C,children:cT[C]},C))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Tracking Number"}),e.jsx(ze,{value:c.trackingNumber,onChange:C=>u({...c,trackingNumber:C.target.value}),placeholder:"Enter tracking number"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Tracking URL"}),e.jsx(ze,{value:c.trackingUrl,onChange:C=>u({...c,trackingUrl:C.target.value}),placeholder:"https://..."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Notes (optional)"}),e.jsx(Er,{value:c.notes,onChange:C=>u({...c,notes:C.target.value}),placeholder:"Add a note about this status change..."})]}),e.jsxs(K,{onClick:b,disabled:r.isPending,className:"w-full",children:[e.jsx(Cl,{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(C=>e.jsxs("div",{className:"flex justify-between text-sm p-2 bg-muted rounded",children:[e.jsxs("div",{children:[e.jsx(tt,{variant:"outline",children:cT[C.status]}),C.notes&&e.jsx("p",{className:"text-muted-foreground mt-1",children:C.notes})]}),e.jsx("span",{className:"text-muted-foreground",children:ps(new Date(C.created_at),"MMM d, h:mm a")})]},C.id))})]})]})]})})]})}function Yks(){const[t,s]=k.useState("products"),r=pr();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(an,{className:"h-4 w-4 mr-2"}),"View Store"]})]}),e.jsxs(ja,{value:t,onValueChange:s,children:[e.jsxs(ga,{className:"grid w-full grid-cols-3",children:[e.jsxs(us,{value:"products",className:"flex items-center gap-2",children:[e.jsx(Cl,{className:"h-4 w-4"}),"Products"]}),e.jsxs(us,{value:"categories",className:"flex items-center gap-2",children:[e.jsx(Lm,{className:"h-4 w-4"}),"Categories"]}),e.jsxs(us,{value:"orders",className:"flex items-center gap-2",children:[e.jsx(yp,{className:"h-4 w-4"}),"Orders"]})]}),e.jsx(ks,{value:"products",children:e.jsx(Gks,{})}),e.jsx(ks,{value:"categories",children:e.jsx(Wks,{})}),e.jsx(ks,{value:"orders",children:e.jsx(Zks,{})})]})]})})}function Slt(){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 Xks(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 Qks(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 Jks(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 e4s(){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 t4s(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 s4s(){const t=es();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 r4s(){const t=es();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 n4s(){const t=es();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 a4s(){const t=es();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 i4s(){const t=es();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 o4s(){const t=es();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 l4s(){const t=es();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 c4s(t){const s=t.match(/\/storage\/v1\/object\/public\/([^/]+)\/(.+)$/);return s?{bucket:s[1],path:s[2]}:null}async function Nye(t,s){const r=c4s(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),he.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),he.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),he.error("Failed to download file")}}function Clt(){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 d4s(){const t=es();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 u4s(){const{user:t}=Rs(),[s,r]=k.useState("items"),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(null),[j,w]=k.useState(!1),[N,C]=k.useState(null),[M,I]=k.useState(""),[L,R]=k.useState(""),[q,U]=k.useState(null),[B,V]=k.useState(""),[Y,J]=k.useState("file"),[te,X]=k.useState(""),[ce,ne]=k.useState(""),[re,le]=k.useState(""),[pe,xe]=k.useState(!0),[_e,fe]=k.useState(null),[we,Ie]=k.useState(!1),[Ne,Ae]=k.useState(!1),Fe=k.useRef(null),Ce=k.useRef(null),{data:Me,isLoading:$e}=Slt(),{data:ct,isLoading:Te}=Xks(),{data:ft,isLoading:me}=e4s(),{data:Ve,isLoading:nt}=Clt(),et=r4s(),Se=n4s(),rt=a4s(),Ge=i4s(),lt=o4s(),qe=l4s(),Ze=d4s(),[Je,He]=k.useState({}),Qe=Ct=>{Ct?(l(Ct),c(Ct.name),p(Ct.description||""),g(Ct.icon||"")):(l(null),c(""),p(""),g("")),a(!0)},at=async()=>{if(!i.trim()){he.error("Please enter a category name");return}try{o?(await Se.mutateAsync({id:o.id,name:i,description:u||null,icon:f||null}),he.success("Category updated successfully")):(await et.mutateAsync({name:i,description:u||null,icon:f||null,sort_order:((Me==null?void 0:Me.length)||0)+1}),he.success("Category created successfully")),a(!1)}catch(Ct){console.error("Error saving category:",Ct),he.error("Failed to save category")}},It=async()=>{if(b)try{await rt.mutateAsync(b),he.success("Category deleted successfully"),_(null)}catch(Ct){console.error("Error deleting category:",Ct),he.error("Failed to delete category")}},Ut=Ct=>{var As;Ct?(C(Ct),I(Ct.name),R(Ct.description||""),U(Ct.category_id),V(Ct.points_cost.toString()),J(Ct.item_type),X(Ct.file_url||""),ne(Ct.preview_image_url||""),le(((As=Ct.max_quantity)==null?void 0:As.toString())||""),xe(Ct.is_active)):(C(null),I(""),R(""),U(null),V(""),J("file"),X(""),ne(""),le(""),xe(!0)),w(!0)},hs=async(Ct,As)=>{As==="file"?Ie(!0):Ae(!0);try{const Us=Ct.name.split(".").pop(),kr=`${Date.now()}-${Math.random().toString(36).substring(7)}.${Us}`,ta=`${As==="file"?"items":"previews"}/${kr}`,{error:ka}=await H.storage.from("reward-store").upload(ta,Ct);if(ka)throw ka;const{data:{publicUrl:Li}}=H.storage.from("reward-store").getPublicUrl(ta);As==="file"?X(Li):ne(Li),he.success("File uploaded successfully")}catch(Us){console.error("Error uploading file:",Us),he.error("Failed to upload file")}finally{As==="file"?Ie(!1):Ae(!1)}},Yt=async()=>{if(!M.trim()){he.error("Please enter an item name");return}if(!B||parseInt(B)<0){he.error("Please enter a valid points cost");return}try{const Ct={name:M,description:L||null,category_id:q,points_cost:parseInt(B),item_type:Y,file_url:te||null,preview_image_url:ce||null,max_quantity:re?parseInt(re):null,current_quantity:re?parseInt(re):null,is_active:pe,created_by:t==null?void 0:t.id};N?(await lt.mutateAsync({id:N.id,...Ct,current_quantity:N.max_quantity!==(re?parseInt(re):null)?re?parseInt(re):null:N.current_quantity}),he.success("Item updated successfully")):(await Ge.mutateAsync(Ct),he.success("Item created successfully")),w(!1)}catch(Ct){console.error("Error saving item:",Ct),he.error("Failed to save item")}},ts=async()=>{if(_e)try{await qe.mutateAsync(_e),he.success("Item deleted successfully"),fe(null)}catch(Ct){console.error("Error deleting item:",Ct),he.error("Failed to delete item")}},Ds=async(Ct,As)=>{const Us=Je[Ct];if(Us===void 0||Us===As.toString())return;const kr=parseInt(Us);if(isNaN(kr)||kr<0){he.error("Please enter a valid positive number");return}try{await Ze.mutateAsync({id:Ct,points:kr}),he.success("Points updated successfully"),He(ta=>{const ka={...ta};return delete ka[Ct],ka})}catch(ta){console.error("Error updating points:",ta),he.error("Failed to update points")}};return $e||Te||me||nt?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(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Cl,{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:(ct==null?void 0:ct.length)||0}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(ct==null?void 0:ct.filter(Ct=>Ct.is_active).length)||0," active"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground mb-1",children:[e.jsx(Lm,{className:"h-4 w-4"}),e.jsx("span",{className:"text-xs font-medium",children:"Categories"})]}),e.jsx("p",{className:"text-2xl font-bold",children:(Me==null?void 0:Me.length)||0})]})}),e.jsx(Pe,{children:e.jsxs(Re,{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:[ct&&ct.length>0?Math.round(ct.reduce((Ct,As)=>Ct+As.points_cost,0)/ct.length):0," pts"]})]})})]}),e.jsxs(ja,{value:s,onValueChange:r,children:[e.jsxs(ga,{children:[e.jsx(us,{value:"items",children:"Items"}),e.jsx(us,{value:"categories",children:"Categories"}),e.jsx(us,{value:"purchases",children:"Purchases"}),e.jsx(us,{value:"point-settings",children:"Point Settings"})]}),e.jsx(ks,{value:"items",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Store Items"}),e.jsx(xr,{children:"Manage rewards that agents can purchase"})]}),e.jsxs(K,{onClick:()=>Ut(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Item"]})]}),e.jsx(Re,{children:!ct||ct.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(No,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Item"}),e.jsx(kt,{children:"Category"}),e.jsx(kt,{className:"text-center",children:"Cost"}),e.jsx(kt,{className:"text-center",children:"Type"}),e.jsx(kt,{className:"text-center",children:"Quantity"}),e.jsx(kt,{className:"text-center",children:"Status"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:ct.map(Ct=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[Ct.preview_image_url?e.jsx("img",{src:Ct.preview_image_url,alt:Ct.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(No,{className:"h-5 w-5 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:Ct.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:Ct.description||"No description"})]})]})}),e.jsx(dt,{children:Ct.category?e.jsx(tt,{variant:"outline",children:Ct.category.name}):e.jsx("span",{className:"text-muted-foreground",children:"—"})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ct.points_cost]})}),e.jsx(dt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[Ct.item_type==="file"?e.jsx(En,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(zo,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-xs capitalize",children:Ct.item_type})]})}),e.jsx(dt,{className:"text-center",children:Ct.max_quantity!==null?e.jsxs("span",{className:Ct.current_quantity===0?"text-red-500":"",children:[Ct.current_quantity,"/",Ct.max_quantity]}):e.jsx("span",{className:"text-muted-foreground",children:"Unlimited"})}),e.jsx(dt,{className:"text-center",children:e.jsx(tt,{variant:Ct.is_active?"default":"secondary",children:Ct.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:()=>Ut(Ct),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>fe(Ct.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ct.id))})]})})]})}),e.jsx(ks,{value:"categories",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Categories"}),e.jsx(xr,{children:"Organize your store items into categories"})]}),e.jsxs(K,{onClick:()=>Qe(),children:[e.jsx(qs,{className:"h-4 w-4 mr-2"}),"Add Category"]})]}),e.jsx(Re,{children:!Me||Me.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(Lm,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No categories yet. Add your first category!"})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Name"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"text-center",children:"Items"}),e.jsx(kt,{className:"text-right",children:"Actions"})]})}),e.jsx(On,{children:Me.map(Ct=>e.jsxs(Ss,{children:[e.jsxs(dt,{className:"font-medium",children:[Ct.icon&&e.jsx("span",{className:"mr-2",children:Ct.icon}),Ct.name]}),e.jsx(dt,{className:"text-muted-foreground",children:Ct.description||"—"}),e.jsx(dt,{className:"text-center",children:(ct==null?void 0:ct.filter(As=>As.category_id===Ct.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:()=>Qe(Ct),children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>_(Ct.id),children:e.jsx(Nr,{className:"h-4 w-4 text-destructive"})})]})})]},Ct.id))})]})})]})}),e.jsx(ks,{value:"purchases",className:"mt-4",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(yp,{className:"h-5 w-5"}),"Purchase History"]}),e.jsx(xr,{children:"View all reward redemptions by agents"})]}),e.jsx(Re,{children:!ft||ft.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(yp,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No purchases yet."})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Date"}),e.jsx(kt,{children:"Agent"}),e.jsx(kt,{children:"Item"}),e.jsx(kt,{className:"text-center",children:"Points Spent"})]})}),e.jsx(On,{children:ft.map(Ct=>{var As,Us,kr,ta;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"text-muted-foreground",children:ps(new Date(Ct.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(to,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:((As=Ct.user)==null?void 0:As.name)||"Unknown"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:((Us=Ct.user)==null?void 0:Us.email)||"—"})]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[(kr=Ct.item)!=null&&kr.preview_image_url?e.jsx("img",{src:Ct.item.preview_image_url,alt:Ct.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(No,{className:"h-4 w-4 text-muted-foreground"})}),e.jsx("span",{children:((ta=Ct.item)==null?void 0:ta.name)||"Deleted item"})]})}),e.jsx(dt,{className:"text-center",children:e.jsxs(tt,{variant:"secondary",className:"font-bold",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ct.points_spent]})})]},Ct.id)})})]})})]})})]})]}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{htmlFor:"categoryName",children:"Name"}),e.jsx(ze,{id:"categoryName",value:i,onChange:Ct=>c(Ct.target.value),placeholder:"e.g., Templates, Resources"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"categoryDescription",children:"Description"}),e.jsx(Er,{id:"categoryDescription",value:u,onChange:Ct=>p(Ct.target.value),placeholder:"Optional description..."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"categoryIcon",children:"Icon (emoji)"}),e.jsx(ze,{id:"categoryIcon",value:f,onChange:Ct=>g(Ct.target.value),placeholder:"e.g., 📄, 🎁"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsx(K,{onClick:at,disabled:et.isPending||Se.isPending,children:et.isPending||Se.isPending?"Saving...":"Save"})]})]})}),e.jsx(xs,{open:j,onOpenChange:w,children:e.jsxs(fs,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsxs(_s,{children:[e.jsx(bs,{children:N?"Edit Item":"Add Item"}),e.jsx(Wr,{children:N?"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(ye,{htmlFor:"itemName",children:"Name *"}),e.jsx(ze,{id:"itemName",value:M,onChange:Ct=>I(Ct.target.value),placeholder:"e.g., Premium Template Pack"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"itemDescription",children:"Description"}),e.jsx(Er,{id:"itemDescription",value:L,onChange:Ct=>R(Ct.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(ye,{htmlFor:"itemCategory",children:"Category"}),e.jsxs(Ys,{value:q||"none",onValueChange:Ct=>U(Ct==="none"?null:Ct),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select category"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No category"}),Me==null?void 0:Me.map(Ct=>e.jsxs(Mt,{value:Ct.id,children:[Ct.icon&&`${Ct.icon} `,Ct.name]},Ct.id))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"itemPointsCost",children:"Points Cost *"}),e.jsx(ze,{id:"itemPointsCost",type:"number",min:"0",value:B,onChange:Ct=>V(Ct.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(ye,{htmlFor:"itemType",children:"Type"}),e.jsxs(Ys,{value:Y,onValueChange:J,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{htmlFor:"itemMaxQuantity",children:"Max Quantity"}),e.jsx(ze,{id:"itemMaxQuantity",type:"number",min:"1",value:re,onChange:Ct=>le(Ct.target.value),placeholder:"Leave empty for unlimited"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"File / Link URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:te,onChange:Ct=>X(Ct.target.value),placeholder:Y==="file"?"Upload a file or paste URL":"Paste external link"}),Y==="file"&&e.jsxs(e.Fragment,{children:[e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ct;return(Ct=Fe.current)==null?void 0:Ct.click()},disabled:we,children:e.jsx(oi,{className:"h-4 w-4"})}),e.jsx("input",{ref:Fe,type:"file",className:"hidden",onChange:Ct=>{var Us;const As=(Us=Ct.target.files)==null?void 0:Us[0];As&&hs(As,"file")}})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Preview Image"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:ce,onChange:Ct=>ne(Ct.target.value),placeholder:"Upload an image or paste URL"}),e.jsx(K,{type:"button",variant:"outline",size:"icon",onClick:()=>{var Ct;return(Ct=Ce.current)==null?void 0:Ct.click()},disabled:Ne,children:e.jsx(fl,{className:"h-4 w-4"})}),e.jsx("input",{ref:Ce,type:"file",accept:"image/*",className:"hidden",onChange:Ct=>{var Us;const As=(Us=Ct.target.files)==null?void 0:Us[0];As&&hs(As,"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($r,{id:"itemIsActive",checked:pe,onCheckedChange:xe}),e.jsx(ye,{htmlFor:"itemIsActive",children:"Active (visible to agents)"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),e.jsx(K,{onClick:Yt,disabled:Ge.isPending||lt.isPending,children:Ge.isPending||lt.isPending?"Saving...":"Save"})]})]})}),e.jsx(_c,{open:!!b,onOpenChange:()=>_(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Category"}),e.jsx(Jl,{children:"Are you sure you want to delete this category? Items in this category will become uncategorized."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:It,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(_c,{open:!!_e,onOpenChange:()=>fe(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Item"}),e.jsx(Jl,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:ts,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s==="point-settings"&&e.jsxs(Pe,{className:"mt-4",children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),e.jsxs("div",{children:[e.jsx(zt,{children:"Point Reward Settings"}),e.jsx(xr,{children:"Configure how many points agents earn for various actions. Adjust these values to run double-points promotions."})]})]})}),e.jsx(Re,{children:!Ve||Ve.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 point settings configured."})]}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Action"}),e.jsx(kt,{children:"Description"}),e.jsx(kt,{className:"text-center w-32",children:"Points"}),e.jsx(kt,{className:"text-right w-24",children:"Save"})]})}),e.jsx(On,{children:Ve.map(Ct=>e.jsxs(Ss,{children:[e.jsx(dt,{children:e.jsx("p",{className:"font-medium",children:Ct.action_name})}),e.jsx(dt,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:Ct.description})}),e.jsx(dt,{className:"text-center",children:e.jsx(ze,{type:"number",min:"0",className:"w-20 mx-auto text-center",value:Je[Ct.id]??Ct.points.toString(),onChange:As=>He(Us=>({...Us,[Ct.id]:As.target.value}))})}),e.jsx(dt,{className:"text-right",children:e.jsx(K,{size:"sm",variant:"outline",disabled:Je[Ct.id]===void 0||Je[Ct.id]===Ct.points.toString()||Ze.isPending,onClick:()=>Ds(Ct.id,Ct.points),children:e.jsx(ed,{className:"h-4 w-4"})})})]},Ct.id))})]})})]})]})}const xze=()=>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"})]}),gze=[{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=es(),[s,r]=k.useState(!1),[n,a]=k.useState(!1),[o,l]=k.useState(!1),[i,c]=k.useState({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""}),{data:u,isLoading:p}=mt({queryKey:["canva-integration"],queryFn:async()=>{const{data:C,error:M}=await H.from("canva_integration").select("*").eq("is_active",!0).maybeSingle();if(M)throw M;return C}}),{data:f}=mt({queryKey:["brokerages-list"],queryFn:async()=>{const{data:C,error:M}=await H.from("brokerages").select("id, name").order("name");if(M)throw M;return C}}),{data:g}=mt({queryKey:["canva-brokerage-folders"],queryFn:async()=>{const{data:C,error:M}=await H.from("canva_brokerage_folders").select("*, brokerages(name)").order("sort_order");if(M)throw M;return C}}),b=async()=>{var C;r(!0);try{const{data:M}=await H.auth.getSession(),I=(C=M==null?void 0:M.session)==null?void 0:C.access_token;if(!I)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"get_auth_url"})}),U=await q.json();if(!q.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){he.error("Popup was blocked. Please allow popups for this site and try again."),r(!1);return}const V=J=>{var te,X;J.origin===window.location.origin&&(((te=J.data)==null?void 0:te.type)==="canva-oauth-success"?(window.removeEventListener("message",V),he.success("Canva connected successfully!"),t.invalidateQueries({queryKey:["canva-integration"]}),r(!1)):((X=J.data)==null?void 0:X.type)==="canva-oauth-error"&&(window.removeEventListener("message",V),he.error("Canva connection failed: "+(J.data.error||"Unknown error")),r(!1)))};window.addEventListener("message",V);const Y=setInterval(()=>{B.closed&&(clearInterval(Y),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 I=(M==null?void 0:M.message)||"";I.includes("CANVA_CLIENT_ID")?he.error("Canva app credentials not configured yet."):he.error(I||"Failed to start Canva connection"),r(!1)}},_=Lt({mutationFn:async C=>{var B;const{data:M}=await H.auth.getSession(),I=(B=M==null?void 0:M.session)==null?void 0:B.access_token;if(!I)throw new Error("Not authenticated");const q=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/canva-oauth",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${I}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify({action:"disconnect",integrationId:C})}),U=await q.json();if(!q.ok||U!=null&&U.error)throw new Error((U==null?void 0:U.error)||"Failed to disconnect")},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-integration"]}),he.success("Canva disconnected")},onError:C=>{he.error(C.message||"Failed to disconnect Canva")}}),j=Lt({mutationFn:async C=>{const{error:M}=await H.from("canva_brokerage_folders").insert({brokerage_id:C.brokerage_id,folder_id:C.folder_id.trim(),folder_name:C.folder_name.trim(),folder_type:C.folder_type,description:C.description.trim()||null,sort_order:(g==null?void 0:g.length)||0});if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),he.success("Folder added"),l(!1),c({brokerage_id:"",folder_id:"",folder_name:"",folder_type:"template",description:""})},onError:()=>he.error("Failed to add folder")}),w=Lt({mutationFn:async C=>{const{error:M}=await H.from("canva_brokerage_folders").delete().eq("id",C);if(M)throw M},onSuccess:()=>{t.invalidateQueries({queryKey:["canva-brokerage-folders"]}),he.success("Folder removed")},onError:()=>he.error("Failed to remove folder")}),N=!!u;return e.jsxs(e.Fragment,{children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(xze,{})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:["Canva Connect",N&&e.jsx(tt,{variant:"default",className:"text-xs",children:"Connected"}),e.jsx(tt,{variant:"outline",className:"text-xs",children:"Admin Only"})]}),e.jsx(xr,{children:"Auto-share brokerage asset folders with agents when they connect their Canva accounts."})]})]})})}),e.jsx(Re,{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(xi,{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(xi,{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(xi,{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"})]}),N?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(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Canva?"}),e.jsx(Jl,{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(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{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(Lm,{className:"h-4 w-4 text-primary"}),"Brokerage Folder Mappings",g&&g.length>0&&e.jsx(tt,{variant:"secondary",className:"text-xs",children:g.length})]}),n?e.jsx(pf,{className:"h-4 w-4"}):e.jsx(To,{className:"h-4 w-4"})]}),n&&e.jsxs("div",{className:"border-t p-3 space-y-2",children:[g&&g.length>0?g.map(C=>{var M,I;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:C.folder_name}),e.jsx(tt,{variant:"outline",className:"text-xs shrink-0",children:((M=gze.find(L=>L.value===C.folder_type))==null?void 0:M.label)||C.folder_type})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(I=C.brokerages)==null?void 0:I.name," · ID: ",e.jsx("span",{className:"font-mono",children:C.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:()=>w.mutate(C.id),children:e.jsx(Or,{className:"h-3.5 w-3.5"})})]},C.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:b,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(xze,{})}),"Connect Canva",e.jsx(fi,{className:"h-4 w-4 ml-2"})]})]})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{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(ye,{children:"Brokerage"}),e.jsxs(Ys,{value:i.brokerage_id,onValueChange:C=>c(M=>({...M,brokerage_id:C})),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a brokerage…"})}),e.jsx(Ks,{children:f==null?void 0:f.map(C=>e.jsx(Mt,{value:C.id,children:C.name},C.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Canva Folder ID"}),e.jsx(ze,{placeholder:"e.g. FABCdef123456",value:i.folder_id,onChange:C=>c(M=>({...M,folder_id:C.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(ye,{children:"Folder Display Name"}),e.jsx(ze,{placeholder:"e.g. Brand Templates 2024",value:i.folder_name,onChange:C=>c(M=>({...M,folder_name:C.target.value}))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{children:"Folder Type"}),e.jsxs(Ys,{value:i.folder_type,onValueChange:C=>c(M=>({...M,folder_type:C})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:gze.map(C=>e.jsx(Mt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{children:["Description ",e.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e.jsx(ze,{placeholder:"What's in this folder?",value:i.description,onChange:C=>c(M=>({...M,description:C.target.value}))})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>j.mutate(i),disabled:!i.brokerage_id||!i.folder_id||!i.folder_name||j.isPending,children:[j.isPending?e.jsx(Wo,{className:"h-4 w-4 mr-2 animate-spin"}):null,"Add Folder"]})]})]})})]})}function m4s(){return e.jsx(Ts,{children:e.jsxs("div",{className:"space-y-6 p-4 md:p-8",children:[e.jsx(ah,{title:"Integrations",description:"Manage platform-level service connections"}),e.jsx(h4s,{}),e.jsx(wlt,{})]})})}const p4s={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 cI(t,s=18,r=10){return t.length<=s+r+3?t:`${t.slice(0,s)}…${t.slice(-r)}`}function f4s(){var Y,J,te,X,ce;const t=es(),[s,r]=k.useState("Test Push"),[n,a]=k.useState("Testing web push notification"),[o,l]=k.useState("/community"),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState({isSupported:typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window}),[b,_]=k.useState(null),[j,w]=k.useState(null),{data:N,isLoading:C}=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:I}=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}}}),L=Lt({mutationFn:async({settingKey:ne,isEnabled:re})=>{const{error:le}=await H.from("push_notification_settings").update({is_enabled:re}).eq("setting_key",ne);if(le)throw le},onSuccess:()=>{t.invalidateQueries({queryKey:["push-notification-settings"]}),he.success("Notification setting updated")},onError:ne=>{he.error("Failed to update setting: "+ne.message)}}),R=k.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]);k.useEffect(()=>{let ne=!0;const re=async()=>{var _e,fe,we,Ie,Ne,Ae,Fe;const pe="serviceWorker"in navigator&&"PushManager"in window,xe={isSupported:pe,permission:typeof Notification<"u"?Notification.permission:void 0,controllerPresent:!!((_e=navigator.serviceWorker)!=null&&_e.controller)};if(!pe){ne&&g(xe);return}try{const{data:Ce,error:Me}=await H.functions.invoke("get-vapid-public-key",{body:{}});if(Me)throw Me;xe.vapidPublicKey=Ce==null?void 0:Ce.vapidPublicKey;const ct=(await navigator.serviceWorker.getRegistrations()).find(Te=>{var me,Ve,nt;return(((me=Te.active)==null?void 0:me.scriptURL)||((Ve=Te.waiting)==null?void 0:Ve.scriptURL)||((nt=Te.installing)==null?void 0:nt.scriptURL)||"").includes("/sw.js")});if(ct){xe.pushWorkerScriptUrl=((fe=ct.active)==null?void 0:fe.scriptURL)||((we=ct.waiting)==null?void 0:we.scriptURL)||((Ie=ct.installing)==null?void 0:Ie.scriptURL),xe.serviceWorker={scope:ct.scope,activeState:(Ne=ct.active)==null?void 0:Ne.state};const Te=await ct.pushManager.getSubscription();if(Te){const ft=Te.toJSON();xe.subscription={endpoint:ft.endpoint,p256dh:(Ae=ft.keys)==null?void 0:Ae.p256dh,auth:(Fe=ft.keys)==null?void 0:Fe.auth}}}}catch(Ce){xe.error=(Ce==null?void 0:Ce.message)||String(Ce)}ne&&g(xe)};re();const le=window.setInterval(re,4e3);return()=>{ne=!1,window.clearInterval(le)}},[]);const q=async()=>{if(typeof Notification>"u"){he.error("Notifications API not available in this browser.");return}try{if(Notification.permission!=="granted"&&await Notification.requestPermission()!=="granted"){he.error("Notification permission not granted.");return}new Notification("Local notification test",{body:"If you see this, OS/browser notifications can display."}),he.success("Triggered a local notification (not push).")}catch(ne){he.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?he.success(`Test notification sent to ${ne.sent} subscriber(s)`):(ne==null?void 0:ne.failed)>0?he.warning(`Notification failed for ${ne.failed} subscriber(s). ${ne.expired||0} expired subscriptions cleaned up.`):he.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)}),he.error("Failed to send test notification: "+(ne.message||"Unknown error"))}finally{c(!1)}},B=async()=>{p(!0),w(null);try{const{data:ne,error:re}=await H.functions.invoke("generate-vapid-keys",{body:{}});if(re)throw re;const le=ne==null?void 0:ne.publicKey,pe=ne==null?void 0:ne.privateKey;if(!le||!pe)throw new Error("generate-vapid-keys did not return keys");w({publicKey:le,privateKey:pe}),he.success("Generated new VAPID keys. Update backend secrets, then clear + re-subscribe.")}catch(ne){console.error("Error generating VAPID keys:",ne),he.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:()=>{he.success("All subscriptions cleared. Users will need to re-enable notifications."),t.invalidateQueries({queryKey:["push-subscription-stats"]})},onError:ne=>{he.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(ah,{title:"Notification Settings",description:"Manage push notifications and test the notification system"}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mr,{className:"h-5 w-5"}),"Push Notification Subscribers"]}),e.jsx(xr,{children:"Current active push notification subscriptions"})]}),e.jsx(Re,{children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"text-4xl font-bold",children:I?"...":(M==null?void 0:M.totalSubscriptions)||0}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"active subscriptions"})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Yo,{className:"h-5 w-5"}),"Notification Types"]}),e.jsx(xr,{children:"Control which types of push notifications are sent to users"})]}),e.jsx(Re,{children:C?e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading settings..."}):e.jsx("div",{className:"space-y-4",children:N==null?void 0:N.map(ne=>{const re=p4s[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($r,{checked:ne.is_enabled,onCheckedChange:le=>L.mutate({settingKey:ne.setting_key,isEnabled:le}),disabled:L.isPending})]},ne.id)})})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Pm,{className:"h-5 w-5"}),"Send Test Notification"]}),e.jsx(xr,{children:"Send a test push notification to all subscribed users"})]}),e.jsxs(Re,{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:R}),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?cI(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: ",(Y=f.serviceWorker)!=null&&Y.scope?cI(f.serviceWorker.scope,24,8):"none"]}),e.jsxs("div",{children:["active: ",((J=f.serviceWorker)==null?void 0:J.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: ",(te=f.subscription)!=null&&te.endpoint?cI(f.subscription.endpoint,40,12):"none"]}),e.jsxs("div",{children:["p256dh: ",(X=f.subscription)!=null&&X.p256dh?cI(f.subscription.p256dh,22,10):"none"]}),e.jsxs("div",{children:["auth: ",(ce=f.subscription)!=null&&ce.auth?cI(f.subscription.auth,22,10):"none"]})]})]})]}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx(K,{variant:"outline",onClick:q,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(ye,{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(ye,{htmlFor:"test-body",children:"Notification Body"}),e.jsx(Er,{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(ye,{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(Rn,{className:"h-4 w-4 mr-2"}),i?"Sending...":"Send Test Notification"]}),b&&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"}),b.error?e.jsxs("div",{className:"mt-1 text-destructive",children:["Error: ",b.error]}):e.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[e.jsxs("div",{children:["Result: ",b.sent??0," sent, ",b.failed??0," failed, ",b.expiredCleaned??0," expired cleaned"]}),b.vapidPublicKey?e.jsxs("div",{className:"break-all",children:["Backend VAPID public key: ",e.jsx("span",{className:"font-mono",children:b.vapidPublicKey})]}):e.jsx("div",{children:"Backend VAPID public key: (not returned)"})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2 text-destructive",children:[e.jsx(Nr,{className:"h-5 w-5"}),"Subscription Maintenance"]}),e.jsx(xr,{children:"Clear all push subscriptions if VAPID keys were changed or subscriptions are invalid"})]}),e.jsxs(Re,{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"})}),j&&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:j.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:j.privateKey})]})]})]})]})]})]})})}function x4s(){const{toast:t}=qa(),[s,r]=k.useState([]),[n,a]=k.useState({totalPresentations:0,totalViews:0,totalLeads:0,totalCtaClicks:0,agentsUsing:0}),[o,l]=k.useState(!0),{sortKey:i,sortDirection:c,handleSort:u,sortData:p}=KO("presentation_count","desc"),f=p(s,{name:_=>{var j;return((j=_.name)==null?void 0:j.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});k.useEffect(()=>{g()},[]);const g=async()=>{try{l(!0);const{data:_,error:j}=await H.rpc("get_admin_presentation_stats");if(j)throw j;if(!_||_.length===0){l(!1);return}const w=_.map(L=>L.owner_user_id),{data:N,error:C}=await H.from("profiles").select("id, name, email, avatar_url").in("id",w);if(C)throw C;const M=new Map((N==null?void 0:N.map(L=>[L.id,L]))||[]),I=_.map(L=>{const R=M.get(L.owner_user_id);return{owner_user_id:L.owner_user_id,name:(R==null?void 0:R.name)||"Unknown",email:(R==null?void 0:R.email)||"",avatar_url:(R==null?void 0:R.avatar_url)||null,presentation_count:Number(L.presentation_count),total_views:Number(L.total_views),total_leads:Number(L.total_leads),total_cta_clicks:Number(L.total_cta_clicks)}});r(I),r(I),a({totalPresentations:I.reduce((L,R)=>L+R.presentation_count,0),totalViews:I.reduce((L,R)=>L+R.total_views,0),totalLeads:I.reduce((L,R)=>L+R.total_leads,0),totalCtaClicks:I.reduce((L,R)=>L+R.total_cta_clicks,0),agentsUsing:I.length})}catch(_){console.error("Error loading presentation stats:",_),t({title:"Error",description:"Failed to load presentation analytics",variant:"destructive"})}finally{l(!1)}},b=[{label:"Agents Using",value:n.agentsUsing,icon:mr,color:"text-blue-600"},{label:"Total Presentations",value:n.totalPresentations,icon:Qg,color:"text-violet-600"},{label:"Total Views",value:n.totalViews,icon:qn,color:"text-emerald-600"},{label:"Total Leads",value:n.totalLeads,icon:rc,color:"text-amber-600"},{label:"CTA Clicks",value:n.totalCtaClicks,icon:Xg,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:b.map(_=>e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:_.label}),e.jsx(_.icon,{className:`h-4 w-4 ${_.color}`})]}),e.jsx(Re,{children:o?e.jsx(vs,{className:"h-8 w-16"}):e.jsx("div",{className:"text-2xl font-bold",children:_.value.toLocaleString()})})]},_.label))}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{children:o?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((_,j)=>e.jsx(vs,{className:"h-12 w-full"},j))}):s.length===0?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"No presentations created yet."}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(gl,{sortKey:"name",currentSortKey:i,currentDirection:c,onSort:u,children:"Agent"}),e.jsx(gl,{sortKey:"presentations",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Presentations"}),e.jsx(gl,{sortKey:"views",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Views"}),e.jsx(gl,{sortKey:"leads",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Leads"}),e.jsx(gl,{sortKey:"cta_clicks",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"CTA Clicks"}),e.jsx(gl,{sortKey:"conversion",currentSortKey:i,currentDirection:c,onSort:u,className:"text-center",children:"Conversion"})]})}),e.jsx(On,{children:f.map(_=>{var w,N;const j=_.total_views>0?(_.total_leads/_.total_views*100).toFixed(1):"0.0";return e.jsxs(Ss,{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:((N=(w=_.name)==null?void 0:w.charAt(0))==null?void 0:N.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(tt,{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(j)>0?"text-emerald-600 font-medium":"text-muted-foreground",children:[j,"%"]})})]},_.owner_user_id)})})]})})]})]})})}function g4s(){const{toast:t}=qa(),[s,r]=k.useState([]),[n,a]=k.useState({totalOpenHouses:0,totalVisitors:0,totalLeads:0,activeOpenHouses:0,agentsUsing:0}),[o,l]=k.useState(!0);k.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(w=>w.agent_id),{data:g,error:b}=await H.from("profiles").select("id, name, email, avatar_url").in("id",f);if(b)throw b;const _=new Map((g==null?void 0:g.map(w=>[w.id,w]))||[]),j=u.map(w=>{const N=_.get(w.agent_id);return{agent_id:w.agent_id,name:(N==null?void 0:N.name)||"Unknown",email:(N==null?void 0:N.email)||"",avatar_url:(N==null?void 0:N.avatar_url)||null,open_house_count:Number(w.open_house_count),total_visitors:Number(w.total_visitors),total_leads:Number(w.total_leads),active_count:Number(w.active_count)}});j.sort((w,N)=>N.total_visitors-w.total_visitors),r(j),a({totalOpenHouses:j.reduce((w,N)=>w+N.open_house_count,0),totalVisitors:j.reduce((w,N)=>w+N.total_visitors,0),totalLeads:j.reduce((w,N)=>w+N.total_leads,0),activeOpenHouses:j.reduce((w,N)=>w+N.active_count,0),agentsUsing:j.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:mr,color:"text-blue-600"},{label:"Total Open Houses",value:n.totalOpenHouses,icon:Sn,color:"text-violet-600"},{label:"Active Now",value:n.activeOpenHouses,icon:xi,color:"text-emerald-600"},{label:"Total Visitors",value:n.totalVisitors,icon:qn,color:"text-amber-600"},{label:"Leads Created",value:n.totalLeads,icon:rc,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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(zt,{className:"text-sm font-medium",children:u.label}),e.jsx(u.icon,{className:`h-4 w-4 ${u.color}`})]}),e.jsx(Re,{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(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(Ol,{className:"h-5 w-5"}),"Agent Breakdown"]})}),e.jsx(Re,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Agent"}),e.jsx(kt,{className:"text-center",children:"Open Houses"}),e.jsx(kt,{className:"text-center",children:"Active"}),e.jsx(kt,{className:"text-center",children:"Visitors"}),e.jsx(kt,{className:"text-center",children:"Leads"}),e.jsx(kt,{className:"text-center",children:"Conversion"})]})}),e.jsx(On,{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(Ss,{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(tt,{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(tt,{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 y4s(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing connection...");return k.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"),he.error("Failed to connect: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),he.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!"),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[e.jsxs("div",{className:"mx-auto mb-4",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 text-green-500"}),r==="error"&&e.jsx(xc,{className:"h-12 w-12 text-destructive"})]}),e.jsxs(zt,{children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/admin/integrations"),children:r==="success"?"View Integrations":"Back to Integrations"})})]})})}function v4s(){const t=es(),[s,r]=k.useState(""),[n,a]=k.useState(""),[o,l]=k.useState([]),i=k.useRef(null),{data:c,isLoading:u}=mt({queryKey:["prospect-emails"],queryFn:async()=>{const{data:w,error:N}=await H.from("prospect_emails").select("*").order("sent_at",{ascending:!1});if(N)throw N;return w}}),p={total:(c==null?void 0:c.length)||0,sent:(c==null?void 0:c.filter(w=>w.status==="sent").length)||0,converted:(c==null?void 0:c.filter(w=>w.status==="converted").length)||0,conversionRate:c!=null&&c.length?Math.round(c.filter(w=>w.status==="converted").length/c.length*100):0},f=Lt({mutationFn:async w=>{const{data:N,error:C}=await H.functions.invoke("send-prospect-email",{body:{emails:w}});if(C)throw C;return N},onSuccess:w=>{t.invalidateQueries({queryKey:["prospect-emails"]}),he.success(`${w.sent} email${w.sent>1?"s":""} sent successfully!`),r(""),a(""),l([])},onError:w=>{he.error("Failed to send: "+w.message)}}),g=Lt({mutationFn:async()=>{var M,I;const{data:{user:w}}=await H.auth.getUser();if(!(w!=null&&w.email))throw new Error("Could not get your email");const{data:N,error:C}=await H.functions.invoke("send-prospect-email",{body:{emails:[{email:w.email,first_name:(I=(M=w.user_metadata)==null?void 0:M.name)==null?void 0:I.split(" ")[0]}],test_mode:!0}});if(C)throw C;return N},onSuccess:()=>{he.success("Test email sent to your inbox!")},onError:w=>{he.error("Failed to send test: "+w.message)}}),b=()=>{if(!s.trim()){he.error("Please enter an email address");return}if(c==null?void 0:c.find(N=>N.email.toLowerCase()===s.trim().toLowerCase())){he.error("This email has already been prospected");return}f.mutate([{email:s.trim(),first_name:n.trim()||void 0}])},_=w=>{var M;const N=(M=w.target.files)==null?void 0:M[0];if(!N)return;const C=new FileReader;C.onload=I=>{var B,V;const R=((B=I.target)==null?void 0:B.result).split(` `).filter(Y=>Y.trim()),q=[],U=(V=R[0])!=null&&V.toLowerCase().includes("email")?1:0;for(let Y=U;Yce.trim().replace(/"/g,"")),te=J[0],X=J[1];te&&te.includes("@")&&q.push({email:te,first_name:X||void 0})}l(q),he.success(`${q.length} entries loaded from CSV`)},C.readAsText(N),i.current&&(i.current.value="")},j=()=>{if(o.length===0){he.error("No entries to send");return}const w=new Set((c==null?void 0:c.map(C=>C.email.toLowerCase()))||[]),N=o.filter(C=>!w.has(C.email.toLowerCase()));if(N.length===0){he.error("All emails have already been prospected");return}N.lengthg.mutate(),disabled:g.isPending,className:"gap-2 ml-4 shrink-0",children:[g.isPending?e.jsx(ws,{className:"h-3 w-3 animate-spin"}):e.jsx(dr,{className:"h-3 w-3"}),"Send Test to Me"]})]})]}),e.jsx(Re,{children:e.jsxs(ja,{defaultValue:"single",children:[e.jsxs(ga,{className:"mb-4",children:[e.jsxs(us,{value:"single",children:[e.jsx(Rn,{className:"h-4 w-4 mr-2"}),"Single Send"]}),e.jsxs(us,{value:"bulk",children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Bulk CSV"]})]}),e.jsx(ks,{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(ye,{htmlFor:"prospect-email",className:"sr-only",children:"Email"}),e.jsx(ze,{id:"prospect-email",type:"email",placeholder:"agent@example.com",value:s,onChange:w=>r(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs("div",{className:"w-full sm:w-48",children:[e.jsx(ye,{htmlFor:"prospect-name",className:"sr-only",children:"First Name"}),e.jsx(ze,{id:"prospect-name",placeholder:"First name (optional)",value:n,onChange:w=>a(w.target.value),onKeyDown:w=>w.key==="Enter"&&b()})]}),e.jsxs(K,{onClick:b,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"}),"Send Invite"]})]})}),e.jsx(ks,{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 w;return(w=i.current)==null?void 0:w.click()},className:"gap-2",children:[e.jsx(En,{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(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(mr,{className:"h-3 w-3"}),o.length," entries ready"]}),e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>l([]),children:[e.jsx(Or,{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((w,N)=>e.jsxs("div",{className:"text-muted-foreground",children:[w.email,w.first_name?` — ${w.first_name}`:""]},N)),o.length>20&&e.jsxs("div",{className:"text-muted-foreground/60",children:["...and ",o.length-20," more"]})]}),e.jsxs(K,{onClick:j,disabled:f.isPending,className:"gap-2",children:[f.isPending?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(Rn,{className:"h-4 w-4"}),"Send ",o.length," Invites"]})]})]})})]})})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(dr,{className:"h-5 w-5"}),"Prospect Log"]}),e.jsx(xr,{children:"Track all sent invitations and their conversion status"})]}),e.jsx(Re,{children:u?e.jsx("div",{className:"space-y-3",children:[...Array(5)].map((w,N)=>e.jsx(vs,{className:"h-12 w-full"},N))}):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(w=>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:w.email}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.first_name||"—"}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:ps(new Date(w.sent_at),"MMM d, yyyy")}),e.jsx("td",{className:"py-3 px-4",children:w.status==="converted"?e.jsxs(tt,{className:"bg-green-500/10 text-green-700 hover:bg-green-500/20 border-0",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Converted"]}):e.jsxs(tt,{variant:"secondary",className:"gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),"Sent"]})}),e.jsx("td",{className:"py-3 px-4 text-sm text-muted-foreground",children:w.converted_at?ps(new Date(w.converted_at),"MMM d, yyyy"):"—"})]},w.id))})]})}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Rm,{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 xme(t){const s=es(),{toast:r}=qa(),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:b}=await H.from("recruit_prospects").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1}).range(p,p+c-1);if(b)throw b;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 b4s(t){const s=es(),{toast:r}=qa(),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 yze=(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 Mlt({open:t,onOpenChange:s,stages:r,defaultStageId:n,onSubmit:a,isSubmitting:o}){const[l,i]=k.useState(yze(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(yze(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(_s,{children:e.jsx(bs,{children:"Add Recruit Prospect"})}),e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs(ja,{defaultValue:"basic",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-4",children:[e.jsx(us,{value:"basic",children:"Basic Info"}),e.jsx(us,{value:"production",children:"Production"}),e.jsx(us,{value:"social",children:"Social & Web"}),e.jsx(us,{value:"personal",children:"Personal"})]}),e.jsxs(ks,{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(ye,{children:"First Name *"}),e.jsx(ze,{required:!0,value:l.first_name,onChange:c("first_name")})]}),e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:"Email"}),e.jsx(ze,{type:"email",value:l.email,onChange:c("email")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(ze,{value:l.phone,onChange:c("phone")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:"License #"}),e.jsx(ze,{value:l.license_number,onChange:c("license_number")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Experience (years)"}),e.jsx(ze,{type:"number",min:"0",value:l.experience_years,onChange:c("experience_years")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:"City"}),e.jsx(ze,{value:l.city,onChange:c("city")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"State"}),e.jsx(ze,{value:l.state,onChange:c("state")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Zip"}),e.jsx(ze,{value:l.zip_code,onChange:c("zip_code")})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Pipeline Stage"}),e.jsxs(Ys,{value:l.stage_id,onValueChange:p=>i(f=>({...f,stage_id:p})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:r.map(p=>e.jsx(Mt,{value:p.id,children:p.name},p.id))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Referred By"}),e.jsx(ze,{placeholder:"Who referred this prospect?",value:l.referred_by,onChange:c("referred_by")})]})]}),e.jsxs(ks,{value:"production",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{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(ye,{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(ye,{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(ye,{children:"Specialties / Niche"}),e.jsx(ze,{placeholder:"e.g. Luxury, First-time buyers, Investment",value:l.specialties,onChange:c("specialties")})]})]}),e.jsxs(ks,{value:"social",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ye,{children:"Website URL"}),e.jsx(ze,{type:"url",placeholder:"https://...",value:l.website_url,onChange:c("website_url")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Instagram Handle"}),e.jsx(ze,{placeholder:"@handle",value:l.instagram_handle,onChange:c("instagram_handle")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Facebook URL"}),e.jsx(ze,{type:"url",placeholder:"https://facebook.com/...",value:l.facebook_url,onChange:c("facebook_url")})]})]}),e.jsxs(ks,{value:"personal",className:"space-y-4 mt-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Birthday"}),e.jsx(ze,{type:"date",value:l.birthday,onChange:c("birthday")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Spouse / Partner Name"}),e.jsx(ze,{value:l.spouse_name,onChange:c("spouse_name")})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Interests / Hobbies"}),e.jsx(ze,{placeholder:"Golf, travel, community events...",value:l.interests,onChange:c("interests")})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Er,{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 iwe=[{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 _4s(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 w4s(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 j4s(){const t=es(),{toast:s}=qa();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 Tlt(){const t=es();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 Alt(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 N4s(){const t=es(),{toast:s}=qa();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 k4s(){const t=es();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 S4s({prospectId:t,prospectName:s,brokerageId:r}){var B;const{data:n=[],isLoading:a}=w4s(t),{data:o=[]}=Alt(r),l=j4s(),i=_C(),c=Tlt(),[u,p]=k.useState("idle"),[f,g]=k.useState(0),[b,_]=k.useState(0),[j,w]=k.useState(""),[N,C]=k.useState(""),[M,I]=k.useState(!1),L=((B=o.find(V=>V.id===j))==null?void 0:B.script_text)||"",R=()=>{p("idle"),g(0),_(0),w(""),C("")},q=k.useCallback(async(V,Y)=>{p("uploading");try{const J=`Recruiting: ${s}`,{videoId:te,libraryId:X}=await hR(J),{uploadUrl:ce,apiKey:ne}=await mR(te),re=new XMLHttpRequest;re.upload.onprogress=Ne=>{Ne.lengthComputable&&g(Ne.loaded/Ne.total*100)},await new Promise((Ne,Ae)=>{re.onload=()=>re.status>=200&&re.status<300?Ne():Ae(new Error("Upload failed")),re.onerror=()=>Ae(new Error("Upload failed")),re.open("PUT",ce),re.setRequestHeader("AccessKey",ne),re.send(V)}),p("processing");let le=0;const pe=Date.now(),xe=9e4,_e=`https://iframe.mediadelivery.net/embed/${X}/${te}`;for(;le<4&&(await new Promise(Ae=>setTimeout(Ae,3e3)),!(Date.now()-pe>xe));){const Ne=await bA(te);if(le=Ne.status,_(Ne.encodeProgress||0),le===5||le===6)throw new Error("Video processing failed")}const fe=await bA(te),we=(fe.storageSize||V.size)/(1024*1024),Ie=await i.mutateAsync({bunny_video_id:te,playback_url:fe.directPlayUrl||_e,thumbnail_url:fe.thumbnailUrl,preview_url:fe.previewUrl||null,duration_seconds:fe.length||Y,file_size_mb:we,title:J,status:le>=4?"ready":"processing",touch_type:"recruiting"});await l.mutateAsync({prospect_id:t,video_id:Ie.id,brokerage_id:r,message:N||void 0}),p("done"),he.success("Video recorded and linked to prospect!"),setTimeout(()=>{I(!1),R()},1500)}catch(J){he.error(J.message||"Failed to upload video"),p("record")}},[t,s,r,N,i,l]),U=V=>{V&&(navigator.clipboard.writeText(`${window.location.origin}/recruit-video/${V}`),he.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")||(I(V),V||R())},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(_s,{children:e.jsxs(bs,{children:["Record Video for ",s]})}),u==="script"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Choose a Script (optional)"}),e.jsxs(Ys,{value:j,onValueChange:w,children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Qs,{placeholder:"No script — speak freely"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"none",children:"No script"}),o.map(V=>{var Y;return e.jsx(Mt,{value:V.id,children:e.jsxs("span",{className:"flex items-center gap-2",children:[V.title,e.jsx(tt,{variant:"outline",className:"text-[9px] ml-1",children:(Y=iwe.find(J=>J.value===V.category))==null?void 0:Y.label})]})},V.id)})]})]}),L&&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:L})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Personal Message (shown on landing page)"}),e.jsx(Er,{value:N,onChange:V=>C(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(fme,{maxDurationSeconds:60,onRecordingComplete:q,teleprompterContent:L||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:b,className:"mx-auto max-w-sm"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[Math.round(b),"%"]})]}),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(rl,{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 Y,J;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:(Y=V.video)!=null&&Y.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:((J=V.video)==null?void 0:J.title)||"Untitled"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[V.view_count>0?e.jsxs(tt,{variant:"secondary",className:"text-[9px] h-4",children:[e.jsx(qn,{className:"h-2.5 w-2.5 mr-0.5"}),V.view_count]}):V.sent_at?e.jsxs(tt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(Rn,{className:"h-2.5 w-2.5 mr-0.5"}),"Sent"]}):e.jsxs(tt,{variant:"outline",className:"text-[9px] h-4",children:[e.jsx(mn,{className:"h-2.5 w-2.5 mr-0.5"}),"Draft"]}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:ps(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(gi,{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(Rn,{className:"h-3 w-3"})})]})]},V.id)})})]})}function C4s(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 vze=[{value:"call",label:"Phone Call",icon:Un},{value:"email",label:"Email",icon:dr},{value:"text",label:"Text Message",icon:io},{value:"meeting",label:"Meeting",icon:cn},{value:"note",label:"Note",icon:En},{value:"campaign_email",label:"Campaign Email",icon:Rn}];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 Qz({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(an,{className:"h-3 w-3 opacity-50"})]}):null}function dc({label:t,value:s,onChange:r,type:n="text",placeholder:a}){return e.jsxs("div",{children:[e.jsx(ye,{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 Elt({prospect:t,stages:s,brokerageId:r,open:n,onOpenChange:a,onUpdate:o,onDelete:l}){const{activities:i,addActivity:c}=b4s((t==null?void 0:t.id)||null),{data:u=[]}=C4s((t==null?void 0:t.id)||null),[p,f]=k.useState({type:"note",title:"",description:""}),[g,b]=k.useState(!1),[_,j]=k.useState(!1),[w,N]=k.useState({});if(!t)return null;const C=()=>{var J,te;N({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:((J=t.experience_years)==null?void 0:J.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:((te=t.last_year_transactions)==null?void 0:te.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||""}),j(!0)},M=()=>{const J={id:t.id};for(const[te,X]of Object.entries(w))te==="experience_years"||te==="last_year_transactions"?J[te]=X?parseInt(X):null:J[te]=X||null;o(J),j(!1)},I=()=>j(!1),L=J=>te=>N(X=>({...X,[J]:te})),R=()=>{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:""}),b(!1))},q=s.find(J=>J.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,Y=t.birthday||t.spouse_name||t.interests||t.referred_by;return e.jsx(QA,{open:n,onOpenChange:J=>{J||j(!1),a(J)},children:e.jsx(mC,{className:"w-full sm:max-w-lg p-0",children:e.jsx(Gi,{className:"h-full",children:e.jsxs("div",{className:"p-6 space-y-5",children:[e.jsx(JA,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsxs(eE,{className:"text-xl",children:[t.first_name," ",t.last_name]}),q&&e.jsx(tt,{variant:"outline",style:{borderColor:q.color,color:q.color},className:"mt-1",children:q.name})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[_?e.jsxs(e.Fragment,{children:[e.jsx(K,{variant:"ghost",size:"icon",onClick:I,children:e.jsx(Or,{className:"h-4 w-4"})}),e.jsx(K,{variant:"default",size:"icon",onClick:M,children:e.jsx(ed,{className:"h-4 w-4"})})]}):e.jsx(K,{variant:"ghost",size:"icon",onClick:C,title:"Edit prospect",children:e.jsx(Da,{className:"h-4 w-4"})}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete prospect?"}),e.jsx(Jl,{children:"This will permanently remove this prospect and all their activity history."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{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(dr,{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(Un,{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(Ba,{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(ye,{className:"text-xs text-muted-foreground",children:"Move to Stage"}),e.jsxs(Ys,{value:t.stage_id||"",onValueChange:J=>o({id:t.id,stage_id:J}),children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:s.map(J=>e.jsx(Mt,{value:J.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:J.color}}),J.name]})},J.id))})]})]}),e.jsxs(ja,{defaultValue:"details",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-4 h-8 text-xs",children:[e.jsx(us,{value:"details",className:"text-xs",children:"Details"}),e.jsx(us,{value:"production",className:"text-xs",children:"Production"}),e.jsx(us,{value:"social",className:"text-xs",children:"Social"}),e.jsx(us,{value:"personal",className:"text-xs",children:"Personal"})]}),_?e.jsxs(e.Fragment,{children:[e.jsxs(ks,{value:"details",className:"mt-3 space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(dc,{label:"First Name",value:w.first_name,onChange:L("first_name")}),e.jsx(dc,{label:"Last Name",value:w.last_name,onChange:L("last_name")})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(dc,{label:"Email",value:w.email,onChange:L("email"),type:"email"}),e.jsx(dc,{label:"Phone",value:w.phone,onChange:L("phone")})]}),e.jsx(dc,{label:"Current Brokerage",value:w.current_brokerage,onChange:L("current_brokerage")}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(dc,{label:"License #",value:w.license_number,onChange:L("license_number")}),e.jsx(dc,{label:"Experience (years)",value:w.experience_years,onChange:L("experience_years"),type:"number"})]}),e.jsx(dc,{label:"Address",value:w.address,onChange:L("address"),placeholder:"Street address"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(dc,{label:"City",value:w.city,onChange:L("city")}),e.jsx(dc,{label:"State",value:w.state,onChange:L("state")}),e.jsx(dc,{label:"Zip",value:w.zip_code,onChange:L("zip_code")})]}),e.jsx(dc,{label:"Source",value:w.source,onChange:L("source")}),e.jsx(dc,{label:"Referred By",value:w.referred_by,onChange:L("referred_by")}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Notes"}),e.jsx(Er,{value:w.notes,onChange:J=>N(te=>({...te,notes:J.target.value})),rows:3,className:"mt-1 text-sm"})]})]}),e.jsxs(ks,{value:"production",className:"mt-3 space-y-3",children:[e.jsx(dc,{label:"Annual Production",value:w.annual_production,onChange:L("annual_production"),placeholder:"e.g. $5M"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(dc,{label:"Last Year Volume",value:w.last_year_volume,onChange:L("last_year_volume"),placeholder:"e.g. $8.2M"}),e.jsx(dc,{label:"Last Year Transactions",value:w.last_year_transactions,onChange:L("last_year_transactions"),type:"number",placeholder:"e.g. 24"})]}),e.jsx(dc,{label:"Avg Sale Price",value:w.avg_sale_price,onChange:L("avg_sale_price"),placeholder:"e.g. $350K"}),e.jsx(dc,{label:"Specialties / Niche",value:w.specialties,onChange:L("specialties"),placeholder:"e.g. Luxury, Investment"})]}),e.jsxs(ks,{value:"social",className:"mt-3 space-y-3",children:[e.jsx(dc,{label:"LinkedIn URL",value:w.linkedin_url,onChange:L("linkedin_url"),type:"url",placeholder:"https://linkedin.com/in/..."}),e.jsx(dc,{label:"Website URL",value:w.website_url,onChange:L("website_url"),type:"url",placeholder:"https://..."}),e.jsx(dc,{label:"Instagram Handle",value:w.instagram_handle,onChange:L("instagram_handle"),placeholder:"@handle"}),e.jsx(dc,{label:"Facebook URL",value:w.facebook_url,onChange:L("facebook_url"),type:"url",placeholder:"https://facebook.com/..."})]}),e.jsxs(ks,{value:"personal",className:"mt-3 space-y-3",children:[e.jsx(dc,{label:"Birthday",value:w.birthday,onChange:L("birthday"),type:"date"}),e.jsx(dc,{label:"Spouse / Partner",value:w.spouse_name,onChange:L("spouse_name")}),e.jsx(dc,{label:"Interests / Hobbies",value:w.interests,onChange:L("interests"),placeholder:"Golf, travel, community events..."})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ks,{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(ye,{className:"text-xs text-muted-foreground",children:"Notes"}),e.jsx("p",{className:"text-sm mt-1 whitespace-pre-wrap",children:t.notes})]})]}),e.jsx(ks,{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(ks,{value:"social",className:"mt-3",children:V?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Qz,{label:"LinkedIn",url:t.linkedin_url,icon:Mp}),e.jsx(Qz,{label:"Website",url:t.website_url,icon:Su}),t.instagram_handle&&e.jsx(Qz,{label:t.instagram_handle,url:`https://instagram.com/${t.instagram_handle.replace("@","")}`,icon:Cu}),e.jsx(Qz,{label:"Facebook",url:t.facebook_url,icon:ku})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No social profiles added yet"})}),e.jsx(ks,{value:"personal",className:"mt-3",children:Y?e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(Yp,{label:"Birthday",value:t.birthday?ps(new Date(t.birthday+"T00:00:00"),"MMMM d, yyyy"):null,icon:No}),e.jsx(Yp,{label:"Spouse / Partner",value:t.spouse_name,icon:ii}),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(S4s,{prospectId:t.id,prospectName:`${t.first_name} ${t.last_name||""}`,brokerageId:r}),e.jsx(sl,{}),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:()=>b(!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(Ys,{value:p.type,onValueChange:J=>f(te=>({...te,type:J})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:vze.map(J=>e.jsx(Mt,{value:J.value,children:J.label},J.value))})]}),e.jsx(ze,{placeholder:"Subject / Title",value:p.title,onChange:J=>f(te=>({...te,title:J.target.value}))}),e.jsx(Er,{placeholder:"Details (optional)",value:p.description,onChange:J=>f(te=>({...te,description:J.target.value})),rows:2}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"Cancel"}),e.jsx(K,{size:"sm",onClick:R,disabled:!p.title.trim(),children:"Save"})]})]}),e.jsx("div",{className:"space-y-3",children:(()=>{const J=[...i.map(te=>({type:"manual",data:te,date:te.created_at})),...u.map(te=>({type:"campaign_email",data:te,date:te.sent_at||te.created_at}))].sort((te,X)=>new Date(X.date).getTime()-new Date(te.date).getTime());return J.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No activity logged yet"}):J.map(te=>{if(te.type==="manual"){const ce=te.data,ne=vze.find(le=>le.value===ce.activity_type),re=(ne==null?void 0:ne.icon)||En;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:ps(new Date(ce.created_at),"MMM d, yyyy h:mm a")})]})]},`activity-${ce.id}`)}const X=te.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(Rn,{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 #",X.email_number]}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:X.subject}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[X.status==="failed"?e.jsx(tt,{variant:"destructive",className:"text-[10px] px-1.5 py-0 h-4",children:"Failed"}):e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-green-500 text-green-600",children:[e.jsx(Rn,{className:"h-2.5 w-2.5 mr-0.5"})," Sent"]}),X.opened_at?e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-blue-500 text-blue-600",children:[e.jsx(qn,{className:"h-2.5 w-2.5 mr-0.5"})," Opened ",ps(new Date(X.opened_at),"MMM d, h:mm a")]}):X.status!=="failed"?e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 text-muted-foreground",children:"Not opened"}):null,X.clicked_at&&e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4 border-purple-500 text-purple-600",children:[e.jsx(bh,{className:"h-2.5 w-2.5 mr-0.5"})," Clicked ",ps(new Date(X.clicked_at),"MMM d, h:mm a")]})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:ps(new Date(X.sent_at||X.created_at),"MMM d, yyyy h:mm a")})]})]},`send-${X.id}`)})})()})]})]})})})})}const M4s=["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 Plt({open:t,onOpenChange:s,brokerageId:r,stages:n}){var V;const{toast:a}=qa(),o=es(),l=k.useRef(null),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState({}),[b,_]=k.useState(((V=n[0])==null?void 0:V.id)||""),[j,w]=k.useState(!1),[N,C]=k.useState("upload"),[M,I]=k.useState(0),L=()=>{c([]),p([]),g({}),C("upload"),I(0)},R=Y=>{var X;const J=(X=Y.target.files)==null?void 0:X[0];if(!J)return;const te=new FileReader;te.onload=ce=>{var fe;const re=((fe=ce.target)==null?void 0:fe.result).split(/\r?\n/).filter(we=>we.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 le=q(re[0]);p(le);const pe={},xe=new Set;le.forEach((we,Ie)=>{const Ne=we.toLowerCase().replace(/[^a-z0-9]/g,"");let Ae=null;/^firstname$/.test(Ne)||Ne==="first"?Ae="first_name":/^lastname$/.test(Ne)||Ne==="last"?Ae="last_name":/^email$/.test(Ne)||Ne==="emailaddress"?Ae="email":/^mobile$|^phone$|^cellphone$|^mobilephone$/.test(Ne)?Ae="phone":/officename|currentbrokerage|brokerage|company/.test(Ne)?Ae="current_brokerage":/membernumber|licensenumber|license/.test(Ne)?Ae="license_number":/experienceyears|yearsexperience/.test(Ne)?Ae="experience_years":/^totalvolume$|annualproduction/.test(Ne)?Ae="annual_production":/^address$/.test(Ne)?Ae="address":/^city$/.test(Ne)?Ae="city":/^state$/.test(Ne)?Ae="state":/^postalcode$|^zip$|^zipcode$/.test(Ne)?Ae="zip_code":/listsidevolume|lastyearvolume/.test(Ne)?Ae="last_year_volume":/^totalcount$|lastyeartransactions/.test(Ne)?Ae="last_year_transactions":/avgsaleprice|averageprice/.test(Ne)?Ae="avg_sale_price":/linkedin/.test(Ne)?Ae="linkedin_url":/website/.test(Ne)?Ae="website_url":/specialt/.test(Ne)?Ae="specialties":/referr/.test(Ne)?Ae="referred_by":/^notes$|^note$/.test(Ne)&&(Ae="notes"),Ae&&!xe.has(Ae)&&(pe[String(Ie)]=Ae,xe.add(Ae))}),g(pe);const _e=re.slice(1).map(we=>{const Ie=q(we),Ne={};return le.forEach((Ae,Fe)=>{Ne[String(Fe)]=Ie[Fe]||""}),Ne});c(_e),C("map")},te.readAsText(J)},q=Y=>{const J=[];let te="",X=!1;for(const ce of Y)ce==='"'?X=!X:ce===","&&!X?(J.push(te.trim()),te=""):te+=ce;return J.push(te.trim()),J},U=async()=>{w(!0);try{const{data:{user:Y}}=await H.auth.getUser();if(!Y)throw new Error("Not authenticated");const J=i.map(X=>{const ce={brokerage_id:r,created_by:Y.id,stage_id:b,source:"csv_import",first_name:"Unknown"};return Object.entries(f).forEach(([ne,re])=>{var pe;const le=(pe=X[ne])==null?void 0:pe.trim();le&&(re==="experience_years"||re==="last_year_transactions"?ce[re]=parseInt(le.replace(/[^0-9.-]/g,""))||null:re==="annual_production"||re==="last_year_volume"||re==="avg_sale_price"?ce[re]=le.replace(/[^0-9.$,.-]/g,""):ce[re]=le)}),ce});let te=0;for(let X=0;X{const Y=`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`,J=new Blob([Y],{type:"text/csv"}),te=URL.createObjectURL(J),X=document.createElement("a");X.href=te,X.download="recruit-prospects-template.csv",X.click(),URL.revokeObjectURL(te)};return e.jsx(xs,{open:t,onOpenChange:Y=>{Y||L(),s(Y)},children:e.jsxs(fs,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Import Prospects from CSV"})}),N==="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(s1,{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:R}),e.jsxs(K,{onClick:()=>{var Y;return(Y=l.current)==null?void 0:Y.click()},children:[e.jsx(oi,{className:"h-4 w-4 mr-2"})," Choose File"]})]}),e.jsx(K,{variant:"link",className:"text-xs",onClick:B,children:"Download CSV template"})]}),N==="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(Ys,{value:b,onValueChange:_,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{})}),e.jsx(Ks,{children:n.map(Y=>e.jsx(Mt,{value:Y.id,children:Y.name},Y.id))})]})]})]}),e.jsx("div",{className:"border rounded-lg overflow-hidden",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[140px]",children:"CSV Column"}),e.jsx(kt,{className:"w-[160px]",children:"Map To"}),e.jsx(kt,{children:"Preview"})]})}),e.jsx(On,{children:u.map((Y,J)=>{var te;return e.jsxs(Ss,{children:[e.jsx(dt,{className:"font-medium text-xs",children:Y}),e.jsx(dt,{children:e.jsxs(Ys,{value:f[String(J)]||"skip",onValueChange:X=>g(ce=>({...ce,[String(J)]:X==="skip"?"":X})),children:[e.jsx(Gs,{className:"h-8 text-xs",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"skip",children:"— Skip —"}),M4s.map(X=>e.jsx(Mt,{value:X,children:X.replace(/_/g," ")},X))]})]})}),e.jsx(dt,{className:"text-xs text-muted-foreground truncate max-w-[200px]",children:((te=i[0])==null?void 0:te[String(J)])||"—"})]},J)})})]})}),!Object.values(f).includes("first_name")&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-600 text-sm",children:[e.jsx(Nl,{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:()=>{L()},children:"Back"}),e.jsx(K,{onClick:U,disabled:j||!Object.values(f).includes("first_name"),children:j?"Importing...":`Import ${i.length} Prospects`})]})]}),N==="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(fa,{className:"h-6 w-6 text-green-600"})}),e.jsxs("p",{className:"font-semibold",children:[M," prospects imported successfully!"]}),e.jsx(K,{onClick:()=>{L(),s(!1)},children:"Close"})]})]})})}function Ilt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=xme(t),[i,c]=k.useState(!1),[u,p]=k.useState(),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,C]=k.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),I=(B,V)=>{C(V),B.dataTransfer.effectAllowed="move"},L=B=>{B.preventDefault(),B.dataTransfer.dropEffect="move"},R=(B,V)=>{B.preventDefault(),N&&(o.mutate({id:N,stage_id:V}),C(null))},q=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:()=>w(!0),children:[e.jsx(oi,{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(Gi,{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:L,onDrop:Y=>R(Y,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(tt,{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:()=>q(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(Y=>e.jsx(Pe,{className:"p-3 cursor-pointer hover:shadow-md transition-shadow border-l-4 group",style:{borderLeftColor:B.color},draggable:!0,onDragStart:J=>I(J,Y.id),onClick:()=>U(Y),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Ju,{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(to,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs("span",{className:"font-medium text-sm truncate",children:[Y.first_name," ",Y.last_name]})]}),Y.current_brokerage&&e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[e.jsx(wa,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Y.current_brokerage})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[Y.email&&e.jsx(dr,{className:"h-3 w-3 text-muted-foreground"}),Y.phone&&e.jsx(Un,{className:"h-3 w-3 text-muted-foreground"}),Y.experience_years!=null&&e.jsxs(tt,{variant:"secondary",className:"text-[10px] h-4 px-1",children:[Y.experience_years,"yr"]})]})]})]})},Y.id))})]},B.id)})}),e.jsx(tue,{orientation:"horizontal"})]}),e.jsx(Mlt,{open:i,onOpenChange:c,stages:s,defaultStageId:u,onSubmit:B=>a.mutate(B),isSubmitting:a.isPending}),e.jsx(Elt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:B=>{o.mutate(B),g(V=>V?{...V,...B}:null)},onDelete:B=>l.mutate(B)}),e.jsx(Plt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function Jce({brokerageId:t}){const{stages:s,prospects:r,isLoading:n,addProspect:a,updateProspect:o,deleteProspect:l}=xme(t),{user:i}=Rs(),c=es(),[u,p]=k.useState(!1),[f,g]=k.useState(null),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,C]=k.useState(""),[M,I]=k.useState("all"),[L,R]=k.useState("all"),[q,U]=k.useState("all"),[B,V]=k.useState(null),[Y,J]=k.useState("asc"),[te,X]=k.useState(new Set),[ce,ne]=k.useState(!1),[re,le]=k.useState(""),pe=k.useMemo(()=>{const Te=new Set;return r.forEach(ft=>{ft.current_brokerage&&Te.add(ft.current_brokerage)}),Array.from(Te).sort()},[r]),{data:xe=[]}=mt({queryKey:["recruit-campaigns-list",t],queryFn:async()=>{const{data:Te,error:ft}=await H.from("recruit_campaigns").select("id, name, warmth_level").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("name");if(ft)throw ft;return Te}}),{data:_e=[]}=mt({queryKey:["recruit-campaign-assignments-lookup",t],queryFn:async()=>{const{data:Te,error:ft}=await H.from("recruit_campaign_assignments").select("prospect_id, campaign_id, status").eq("brokerage_id",t);if(ft)throw ft;return Te}}),fe=k.useMemo(()=>{const Te=new Map;return _e.forEach(ft=>{Te.has(ft.prospect_id)||Te.set(ft.prospect_id,new Set),Te.get(ft.prospect_id).add(ft.campaign_id)}),Te},[_e]),we=Te=>{B===Te?J(ft=>ft==="asc"?"desc":"asc"):(V(Te),J("asc"))},Ie=({column:Te})=>B!==Te?e.jsx(yd,{className:"h-3.5 w-3.5 ml-1 text-muted-foreground/50"}):Y==="asc"?e.jsx(Nu,{className:"h-3.5 w-3.5 ml-1 text-primary"}):e.jsx(Hh,{className:"h-3.5 w-3.5 ml-1 text-primary"}),Ne=Te=>s.find(ft=>ft.id===Te),Ae=k.useMemo(()=>{let Te=r.filter(ft=>{var Se,rt,Ge;const me=!N||`${ft.first_name} ${ft.last_name}`.toLowerCase().includes(N.toLowerCase())||((Se=ft.email)==null?void 0:Se.toLowerCase().includes(N.toLowerCase()))||((rt=ft.current_brokerage)==null?void 0:rt.toLowerCase().includes(N.toLowerCase())),Ve=M==="all"||ft.stage_id===M,nt=L==="all"||ft.current_brokerage===L;let et=!0;return q==="in_campaign"?et=fe.has(ft.id):q==="not_in_campaign"?et=!fe.has(ft.id):q!=="all"&&(et=((Ge=fe.get(ft.id))==null?void 0:Ge.has(q))??!1),me&&Ve&&nt&&et});return B&&(Te=[...Te].sort((ft,me)=>{var Se,rt;let Ve=null,nt=null;switch(B){case"name":Ve=`${ft.first_name} ${ft.last_name||""}`.toLowerCase(),nt=`${me.first_name} ${me.last_name||""}`.toLowerCase();break;case"stage":Ve=((Se=Ne(ft.stage_id))==null?void 0:Se.sort_order)??999,nt=((rt=Ne(me.stage_id))==null?void 0:rt.sort_order)??999;break;case"brokerage":Ve=(ft.current_brokerage||"").toLowerCase(),nt=(me.current_brokerage||"").toLowerCase();break;case"experience":Ve=ft.experience_years??-1,nt=me.experience_years??-1;break;case"production":Ve=(ft.annual_production||"").toLowerCase(),nt=(me.annual_production||"").toLowerCase();break;case"source":Ve=(ft.source||"").toLowerCase(),nt=(me.source||"").toLowerCase();break;default:return 0}if(Ve===nt)return 0;if(Ve==null)return 1;if(nt==null)return-1;const et=Ve0&&Ae.every(Te=>te.has(Te.id)),Ce=Ae.some(Te=>te.has(Te.id)),Me=()=>{X(Fe?new Set:new Set(Ae.map(Te=>Te.id)))},$e=Te=>{X(ft=>{const me=new Set(ft);return me.has(Te)?me.delete(Te):me.add(Te),me})},ct=Lt({mutationFn:async()=>{if(!re||!(i!=null&&i.id))throw new Error("Select a campaign");const Te=new Set(_e.filter(Ve=>Ve.campaign_id===re).map(Ve=>Ve.prospect_id)),ft=Array.from(te).filter(Ve=>!Te.has(Ve)).map(Ve=>({prospect_id:Ve,campaign_id:re,brokerage_id:t,assigned_by:i.id,status:"active",current_email_number:0}));if(ft.length===0)throw new Error("All selected prospects are already in this campaign");const{error:me}=await H.from("recruit_campaign_assignments").insert(ft);if(me)throw me;return ft.length},onSuccess:Te=>{he.success(`${Te} prospect(s) added to campaign`),ne(!1),X(new Set),le(""),c.invalidateQueries({queryKey:["recruit-campaign-assignments-lookup"]})},onError:Te=>he.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(hn,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(ze,{placeholder:"Search prospects...",value:N,onChange:Te=>C(Te.target.value),className:"pl-8"})]}),e.jsxs("div",{className:"flex gap-2",children:[te.size>0&&e.jsxs(K,{variant:"secondary",onClick:()=>ne(!0),className:"gap-1.5",children:[e.jsx(Rn,{className:"h-4 w-4"})," Add ",te.size," to Campaign"]}),e.jsxs(K,{variant:"outline",onClick:()=>w(!0),children:[e.jsx(oi,{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(Yg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ys,{value:M,onValueChange:I,children:[e.jsx(Gs,{className:"w-[160px] h-8 text-xs",children:e.jsx(Qs,{placeholder:"All stages"})}),e.jsxs(Ks,{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(Ys,{value:L,onValueChange:R,children:[e.jsxs(Gs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(wa,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Qs,{placeholder:"All brokerages"})]}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All brokerages"}),pe.map(Te=>e.jsx(Mt,{value:Te,children:Te},Te))]})]}),e.jsxs(Ys,{value:q,onValueChange:U,children:[e.jsxs(Gs,{className:"w-[200px] h-8 text-xs",children:[e.jsx(dr,{className:"h-3.5 w-3.5 mr-1.5"}),e.jsx(Qs,{placeholder:"Campaign status"})]}),e.jsxs(Ks,{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"}),xe.map(Te=>e.jsxs(Mt,{value:Te.id,children:["In: ",Te.name]},Te.id))]})]}),(M!=="all"||L!=="all"||q!=="all")&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 text-xs text-muted-foreground",onClick:()=>{I("all"),R("all"),U("all")},children:"Clear filters"})]}),e.jsx("div",{className:"rounded-md border",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{className:"w-[40px]",children:e.jsx(Lo,{checked:Fe,onCheckedChange:Me,"aria-label":"Select all",...Ce&&!Fe?{"data-state":"indeterminate"}:{}})}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>we("name"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Name ",e.jsx(Ie,{column:"name"})]})}),e.jsx(kt,{className:"cursor-pointer select-none",onClick:()=>we("stage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Stage ",e.jsx(Ie,{column:"stage"})]})}),e.jsx(kt,{className:"hidden md:table-cell cursor-pointer select-none",onClick:()=>we("brokerage"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Brokerage ",e.jsx(Ie,{column:"brokerage"})]})}),e.jsx(kt,{className:"hidden md:table-cell",children:"Contact"}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>we("experience"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Experience ",e.jsx(Ie,{column:"experience"})]})}),e.jsx(kt,{className:"hidden lg:table-cell cursor-pointer select-none",onClick:()=>we("production"),children:e.jsxs("span",{className:"inline-flex items-center",children:["Production ",e.jsx(Ie,{column:"production"})]})}),e.jsx(kt,{className:"hidden lg:table-cell",children:"Campaigns"}),e.jsx(kt,{className:"w-[50px]"})]})}),e.jsx(On,{children:Ae.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center text-muted-foreground py-8",children:"No prospects found"})}):Ae.map(Te=>{const ft=Ne(Te.stage_id),me=fe.get(Te.id),Ve=(me==null?void 0:me.size)??0;return e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>{g(Te),_(!0)},children:[e.jsx(dt,{onClick:nt=>nt.stopPropagation(),children:e.jsx(Lo,{checked:te.has(Te.id),onCheckedChange:()=>$e(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:ft?e.jsxs(tt,{variant:"outline",className:"text-xs gap-1 whitespace-nowrap",style:{borderColor:ft.color,color:ft.color,backgroundColor:`${ft.color}10`},children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full inline-block",style:{backgroundColor:ft.color}}),ft.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(wa,{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(dr,{className:"h-3.5 w-3.5 text-muted-foreground"}),Te.phone&&e.jsx(Un,{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:Ve>0?e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[Ve," campaign",Ve>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:nt=>{nt.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:[te.size>0&&e.jsxs("span",{className:"font-medium text-foreground",children:[te.size," selected · "]}),Ae.length," of ",r.length," prospects"]}),e.jsx(xs,{open:ce,onOpenChange:ne,children:e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{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:te.size})," selected prospect(s) to a recruiting campaign drip."]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Campaign"}),e.jsxs(Ys,{value:re,onValueChange:le,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a campaign..."})}),e.jsx(Ks,{children:xe.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(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>ne(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>ct.mutate(),disabled:!re||ct.isPending,children:ct.isPending?"Adding...":"Add to Campaign"})]})]})}),e.jsx(Mlt,{open:u,onOpenChange:p,stages:s,onSubmit:Te=>a.mutate(Te),isSubmitting:a.isPending}),e.jsx(Elt,{prospect:f,stages:s,brokerageId:t,open:b,onOpenChange:_,onUpdate:Te=>{o.mutate(Te),g(ft=>ft?{...ft,...Te}:null)},onDelete:Te=>l.mutate(Te)}),e.jsx(Plt,{open:j,onOpenChange:w,brokerageId:t,stages:s})]})}function Llt({brokerageId:t}){const{stages:s,prospects:r,isLoading:n}=xme(t),a=k.useMemo(()=>{if(!s.length||!r.length)return null;const o=r.length,l=s.find(N=>N.name==="Signed"),i=s.find(N=>N.name==="Onboarded"),c=r.filter(N=>N.stage_id===(l==null?void 0:l.id)||N.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((N,C)=>N+iy(p,new Date(C.created_at)),0)/o):0,g=s.map(N=>({...N,count:r.filter(C=>C.stage_id===N.id).length})),b={};r.forEach(N=>{const C=N.source||"unknown";b[C]=(b[C]||0)+1});const _=Object.entries(b).sort((N,C)=>C[1]-N[1]),j=new Date;j.setDate(j.getDate()-30);const w=r.filter(N=>new Date(N.created_at)>=j).length;return{total:o,signed:c,conversionRate:u,avgDays:f,byStage:g,bySrc:_,recentCount:w}},[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(Pe,{children:e.jsx(Re,{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(mr,{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(Pe,{children:e.jsx(Re,{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(Ol,{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(Pe,{children:e.jsx(Re,{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(mn,{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(Pe,{children:e.jsx(Re,{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(Rm,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Pipeline Breakdown"})}),e.jsx(Re,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Lead Sources"})}),e.jsxs(Re,{className:"space-y-3",children:[a.bySrc.map(([o,l])=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(tt,{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 Dlt({brokerageId:t}){const{toast:s}=qa(),[r,n]=k.useState(null),[a,o]=k.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(dr,{className:"h-4 w-4"})," ",c]}),bze.filter(u=>u.category===c).map(u=>e.jsxs(Pe,{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(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:u.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Subject: ",u.subject]})]}),e.jsx(tt,{variant:"secondary",className:"text-[10px]",children:u.category})]})}),a===u.id&&e.jsxs(Re,{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(fa,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{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(fa,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(gi,{className:"h-3.5 w-3.5 mr-1"}),"Copy Body"]})]})]})]},u.id))]},c))]})}const _ze={call:Un,email:dr,text:io,meeting:cn,note:En};function Olt({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(b=>b.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(b=>b.created_by),...(l||[]).map(b=>b.created_by)])],{data:u}=await H.from("profiles").select("id, name, email").in("id",c),p=Object.fromEntries((u||[]).map(b=>[b.id,b])),f=die(new Date,30);return{recruiters:c.map(b=>{var C,M;const _=(l||[]).filter(I=>I.created_by===b),j=_.filter(I=>new Date(I.created_at)>=f),w={};j.forEach(I=>{w[I.activity_type]=(w[I.activity_type]||0)+1});const N=n.filter(I=>I.created_by===b).length;return{id:b,name:((C=p[b])==null?void 0:C.name)||"Unknown",email:((M=p[b])==null?void 0:M.email)||"",totalActivities:_.length,recentActivities:j.length,byType:w,prospectsCreated:N}}).sort((b,_)=>_.recentActivities-b.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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Recruiter Leaderboard (Last 30 Days)"})}),e.jsx(Re,{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(to,{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]||En;return e.jsxs(tt,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Recent Activity"})}),e.jsx(Re,{className:"space-y-3",children:s.recentActivities.map(n=>{const a=_ze[n.activity_type]||En;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:ps(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 Rlt({brokerageId:t}){const{toast:s}=qa(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),{data:i=[],isLoading:c}=mt({queryKey:["recruit-referrals",t],queryFn:async()=>{const{data:w,error:N}=await H.from("recruit_referrals").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(N)throw N;return w}}),u=[...new Set(i.map(w=>w.referred_by))],{data:p=[]}=mt({queryKey:["referral-profiles",u],queryFn:async()=>{if(!u.length)return[];const{data:w}=await H.from("profiles").select("id, name, email").in("id",u);return w||[]},enabled:u.length>0}),f=Object.fromEntries(p.map(w=>[w.id,w])),g=Lt({mutationFn:async w=>{const{data:{user:N}}=await H.auth.getUser();if(!N)throw new Error("Not authenticated");const{error:C}=await H.from("recruit_referrals").insert({brokerage_id:t,referred_by:N.id,referee_first_name:w.first_name,referee_last_name:w.last_name||null,referee_email:w.email||null,referee_phone:w.phone||null,referee_current_brokerage:w.current_brokerage||null,notes:w.notes||null});if(C)throw C},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-referrals",t]}),s({title:"Referral submitted!"}),l({first_name:"",last_name:"",email:"",phone:"",current_brokerage:"",notes:""}),a(!1)},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),b=Lt({mutationFn:async({id:w,status:N,incentive_status:C})=>{const M={updated_at:new Date().toISOString()};N&&(M.status=N),C&&(M.incentive_status=C);const{error:I}=await H.from("recruit_referrals").update(M).eq("id",w);if(I)throw I},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-referrals",t]})}),_=w=>w==="approved"||w==="signed"?e.jsx(fa,{className:"h-3 w-3"}):w==="rejected"?e.jsx(xc,{className:"h-3 w-3"}):e.jsx(mn,{className:"h-3 w-3"}),j=w=>w==="approved"||w==="signed"||w==="paid"?"bg-green-500/10 text-green-600 border-green-200":w==="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(Pe,{className:"py-12 text-center",children:[e.jsx(rc,{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(w=>{var N;return e.jsx(Pe,{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:[w.referee_first_name," ",w.referee_last_name]}),e.jsxs(tt,{variant:"outline",className:j(w.status),children:[_(w.status)," ",w.status]}),w.incentive_status&&e.jsxs(tt,{variant:"outline",className:j(w.incentive_status),children:[e.jsx(No,{className:"h-3 w-3 mr-1"})," ",w.incentive_status]})]}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[w.referee_email&&e.jsx("p",{children:w.referee_email}),w.referee_phone&&e.jsx("p",{children:w.referee_phone}),w.referee_current_brokerage&&e.jsxs("p",{children:["Currently at: ",w.referee_current_brokerage]}),e.jsxs("p",{children:["Referred by: ",((N=f[w.referred_by])==null?void 0:N.name)||"Unknown"," • ",ps(new Date(w.created_at),"MMM d, yyyy")]})]}),w.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1 italic",children:w.notes})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(Ys,{value:w.status,onValueChange:C=>b.mutate({id:w.id,status:C}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(Ys,{value:w.incentive_status||"pending",onValueChange:C=>b.mutate({id:w.id,incentive_status:C}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[100px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"pending",children:"Unpaid"}),e.jsx(Mt,{value:"paid",children:"Paid"}),e.jsx(Mt,{value:"n/a",children:"N/A"})]})]})]})]})},w.id)})}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Submit a Recruit Referral"})}),e.jsxs("form",{onSubmit:w=>{w.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(ye,{children:"First Name *"}),e.jsx(ze,{required:!0,value:o.first_name,onChange:w=>l(N=>({...N,first_name:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Last Name"}),e.jsx(ze,{value:o.last_name,onChange:w=>l(N=>({...N,last_name:w.target.value}))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Email"}),e.jsx(ze,{type:"email",value:o.email,onChange:w=>l(N=>({...N,email:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(ze,{value:o.phone,onChange:w=>l(N=>({...N,phone:w.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Current Brokerage"}),e.jsx(ze,{value:o.current_brokerage,onChange:w=>l(N=>({...N,current_brokerage:w.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Notes"}),e.jsx(Er,{value:o.notes,onChange:w=>l(N=>({...N,notes:w.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 Flt({brokerageId:t}){const{toast:s}=qa(),r=es(),[n,a]=k.useState(!1),{data:o}=mt({queryKey:["brokerage-recruit-form",t],queryFn:async()=>{const{data:g,error:b}=await H.from("brokerages").select("id, name, recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(b)throw b;return g}}),{data:l=[]}=mt({queryKey:["recruit-interest-submissions",t],queryFn:async()=>{const{data:g,error:b}=await H.from("recruit_interest_submissions").select("*").eq("brokerage_id",t).order("created_at",{ascending:!1});if(b)throw b;return g}}),i=Lt({mutationFn:async g=>{const{error:b}=await H.from("brokerages").update({recruit_form_enabled:g}).eq("id",t);if(b)throw b},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:b})=>{const{error:_}=await H.from("recruit_interest_submissions").update({status:b}).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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Public Interest Form"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{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($r,{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(fa,{className:"h-3.5 w-3.5"}):e.jsx(gi,{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(an,{className:"h-3.5 w-3.5"})})})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base",children:["Interest Submissions (",l.length,")"]})}),e.jsx(Re,{children:l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(rc,{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(tt,{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(dr,{className:"h-3 w-3"}),g.email]}),g.phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{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:ps(new Date(g.created_at),"MMM d, yyyy h:mm a")})]}),e.jsxs(Ys,{value:g.status,onValueChange:b=>c.mutate({id:g.id,status:b}),children:[e.jsx(Gs,{className:"h-7 text-xs w-[110px]",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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 zlt({brokerageId:t}){const{toast:s}=qa(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState({prospect_id:"",title:"",description:"",due_date:ps(Tl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),[i,c]=k.useState("pending"),{data:u=[]}=mt({queryKey:["recruit-prospects-list",t],queryFn:async()=>{const{data:L,error:R}=await H.from("recruit_prospects").select("id, first_name, last_name").eq("brokerage_id",t).order("first_name");if(R)throw R;return L}}),{data:p=[],isLoading:f}=mt({queryKey:["recruit-follow-ups",t],queryFn:async()=>{const L=u.map(U=>U.id);if(!L.length)return[];const{data:R,error:q}=await H.from("recruit_follow_ups").select("*").in("prospect_id",L).order("due_date");if(q)throw q;return R},enabled:u.length>0}),g=Object.fromEntries(u.map(L=>[L.id,L])),b=Lt({mutationFn:async L=>{const{data:{user:R}}=await H.auth.getUser();if(!R)throw new Error("Not authenticated");const{error:q}=await H.from("recruit_follow_ups").insert({prospect_id:L.prospect_id,assigned_to:R.id,title:L.title,description:L.description||null,due_date:new Date(L.due_date).toISOString()});if(q)throw q},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-follow-ups",t]}),s({title:"Follow-up scheduled"}),l({prospect_id:"",title:"",description:"",due_date:ps(Tl(new Date,1),"yyyy-MM-dd'T'HH:mm")}),a(!1)},onError:L=>s({title:"Error",description:L.message,variant:"destructive"})}),_=Lt({mutationFn:async({id:L,completed:R})=>{const{error:q}=await H.from("recruit_follow_ups").update({completed_at:R?new Date().toISOString():null}).eq("id",L);if(q)throw q},onSuccess:()=>r.invalidateQueries({queryKey:["recruit-follow-ups",t]})}),j=p.filter(L=>i==="pending"?!L.completed_at:i==="completed"?!!L.completed_at:!0),w=j.filter(L=>!L.completed_at&&y0(new Date(L.due_date))&&!vu(new Date(L.due_date))),N=j.filter(L=>!L.completed_at&&vu(new Date(L.due_date))),C=j.filter(L=>!L.completed_at&&!y0(new Date(L.due_date))&&!vu(new Date(L.due_date))),M=j.filter(L=>!!L.completed_at),I=L=>{const R=g[L.prospect_id],q=!L.completed_at&&y0(new Date(L.due_date))&&!vu(new Date(L.due_date));return e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Lo,{checked:!!L.completed_at,onCheckedChange:U=>_.mutate({id:L.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 ${L.completed_at?"line-through text-muted-foreground":""}`,children:L.title}),L.description&&e.jsx("p",{className:"text-xs text-muted-foreground",children:L.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground",children:[R&&e.jsxs(tt,{variant:"secondary",className:"text-[10px]",children:[R.first_name," ",R.last_name]}),e.jsxs("span",{className:`flex items-center gap-1 ${q?"text-destructive font-medium":""}`,children:[q?e.jsx(Nl,{className:"h-3 w-3"}):e.jsx(cn,{className:"h-3 w-3"}),ps(new Date(L.due_date),"MMM d, h:mm a")]}),L.is_automated&&e.jsx(tt,{variant:"outline",className:"text-[10px]",children:"Auto"})]})]})]},L.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(L=>e.jsxs(K,{size:"sm",variant:i===L?"default":"outline",onClick:()=>c(L),className:"capitalize text-xs",children:[L," ",L==="pending"&&w.length+N.length+C.length>0&&`(${w.length+N.length+C.length})`]},L))}),e.jsxs(K,{size:"sm",onClick:()=>a(!0),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Add Follow-up"]})]}),i!=="completed"&&w.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(Nl,{className:"h-3.5 w-3.5"})," Overdue (",w.length,")"]}),w.map(I)]}),i!=="completed"&&N.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(mn,{className:"h-3.5 w-3.5"})," Today (",N.length,")"]}),N.map(I)]}),i!=="completed"&&C.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(cn,{className:"h-3.5 w-3.5"})," Upcoming (",C.length,")"]}),C.map(I)]}),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(fa,{className:"h-3.5 w-3.5"})," Completed (",M.length,")"]}),M.map(I)]}),j.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(_s,{children:e.jsx(bs,{children:"Schedule Follow-up"})}),e.jsxs("form",{onSubmit:L=>{L.preventDefault(),b.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ye,{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:L=>l(R=>({...R,prospect_id:L.target.value})),children:[e.jsx("option",{value:"",children:"Select prospect..."}),u.map(L=>e.jsxs("option",{value:L.id,children:[L.first_name," ",L.last_name]},L.id))]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Task *"}),e.jsx(ze,{required:!0,value:o.title,onChange:L=>l(R=>({...R,title:L.target.value})),placeholder:"e.g. Follow-up call"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Details"}),e.jsx(Er,{value:o.description,onChange:L=>l(R=>({...R,description:L.target.value})),rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Due Date *"}),e.jsx(ze,{type:"datetime-local",required:!0,value:o.due_date,onChange:L=>l(R=>({...R,due_date:L.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:b.isPending,children:"Schedule"})]})]})]})})]})}const T4s=[{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 Blt({brokerageId:t}){const{toast:s}=qa(),r=es(),[n,a]=k.useState(null),{data:o,isLoading:l}=mt({queryKey:["recruit-landing-settings",t],queryFn:async()=>{const{data:w,error:N}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",t).maybeSingle();if(N)throw N;return w}}),[i,c]=k.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:T4s,testimonials:[],gallery_images:[]});k.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 w={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:N}=await H.from("recruit_landing_page_settings").update(w).eq("id",i.id);if(N)throw N}else{const{error:N}=await H.from("recruit_landing_page_settings").insert(w);if(N)throw N}},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-landing-settings",t]}),s({title:"Landing page saved!"})},onError:w=>s({title:"Error",description:w.message,variant:"destructive"})}),p=async(w,N)=>{const C=w.name.split(".").pop(),M=`${t}/${N}-${Date.now()}.${C}`,{error:I}=await H.storage.from("recruit-landing").upload(M,w);if(I)throw I;const{data:{publicUrl:L}}=H.storage.from("recruit-landing").getPublicUrl(M);return L},f=async(w,N)=>{var M;const C=(M=w.target.files)==null?void 0:M[0];if(C){a(N);try{const I=await p(C,N);c(L=>({...L,[N]:I})),s({title:"Image uploaded!"})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},g=async w=>{var C;const N=(C=w.target.files)==null?void 0:C[0];if(N){a("gallery");try{const M=await p(N,"gallery");c(I=>({...I,gallery_images:[...I.gallery_images,M]})),s({title:"Gallery image added!"})}catch(M){s({title:"Upload failed",description:M.message,variant:"destructive"})}finally{a(null)}}},b=async(w,N)=>{var M;const C=(M=w.target.files)==null?void 0:M[0];if(C){a(`testimonial-${N}`);try{const I=await p(C,`testimonial-${N}`);c(L=>{const R=[...L.testimonials];return R[N]={...R[N],photo_url:I},{...L,testimonials:R}})}catch(I){s({title:"Upload failed",description:I.message,variant:"destructive"})}finally{a(null)}}},{data:_}=mt({queryKey:["brokerage-slug-for-landing",t],queryFn:async()=>{const{data:w,error:N}=await H.from("brokerages").select("recruit_form_slug, recruit_form_enabled").eq("id",t).single();if(N)throw N;return w}}),j=`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:j}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsxs("a",{href:j,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(an,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Branding"})}),e.jsx(Re,{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(ye,{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(oi,{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:w=>f(w,"logo_url")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(ye,{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:w=>c(N=>({...N,primary_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.primary_color,onChange:w=>c(N=>({...N,primary_color:w.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{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:w=>c(N=>({...N,accent_color:w.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:i.accent_color,onChange:w=>c(N=>({...N,accent_color:w.target.value})),className:"font-mono text-xs"})]})]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Headline"}),e.jsx(ze,{value:i.hero_headline,onChange:w=>c(N=>({...N,hero_headline:w.target.value})),placeholder:"Join Our Team"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Subtext"}),e.jsx(Er,{value:i.hero_subtext,onChange:w=>c(N=>({...N,hero_subtext:w.target.value})),rows:2,placeholder:"Take your career to the next level..."})]}),e.jsxs("div",{children:[e.jsx(ye,{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(oi,{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:w=>f(w,"hero_image_url")})]}),i.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(w=>({...w,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Benefits / Why Join Us"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,benefits:[...w.benefits,{title:"",description:"",icon:"✨"}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.benefits.map((w,N)=>e.jsxs("div",{className:"flex items-start gap-3 p-3 border rounded-lg",children:[e.jsx(Ju,{className:"h-4 w-4 mt-2 text-muted-foreground"}),e.jsx(ze,{value:w.icon,onChange:C=>{const M=[...i.benefits];M[N]={...w,icon:C.target.value},c(I=>({...I,benefits:M}))},className:"w-14 text-center"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(ze,{value:w.title,onChange:C=>{const M=[...i.benefits];M[N]={...w,title:C.target.value},c(I=>({...I,benefits:M}))},placeholder:"Benefit title"}),e.jsx(ze,{value:w.description,onChange:C=>{const M=[...i.benefits];M[N]={...w,description:C.target.value},c(I=>({...I,benefits:M}))},placeholder:"Short description"})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(C=>({...C,benefits:C.benefits.filter((M,I)=>I!==N)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)),i.benefits.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No benefits added yet"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{className:"text-base",children:"Testimonials"}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>c(w=>({...w,testimonials:[...w.testimonials,{name:"",role:"",quote:""}]})),children:[e.jsx(qs,{className:"h-3.5 w-3.5 mr-1"})," Add"]})]}),e.jsxs(Re,{className:"space-y-3",children:[i.testimonials.map((w,N)=>{var C;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:[w.photo_url?e.jsx("img",{src:w.photo_url,alt:w.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:((C=w.name)==null?void 0:C[0])||"?"}),e.jsxs("label",{className:"cursor-pointer",children:[e.jsx("span",{className:"text-[10px] text-primary hover:underline",children:n===`testimonial-${N}`?"...":"Photo"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:M=>b(M,N)})]})]}),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:w.name,onChange:M=>{const I=[...i.testimonials];I[N]={...w,name:M.target.value},c(L=>({...L,testimonials:I}))},placeholder:"Name"}),e.jsx(ze,{value:w.role,onChange:M=>{const I=[...i.testimonials];I[N]={...w,role:M.target.value},c(L=>({...L,testimonials:I}))},placeholder:"Role / Title"})]}),e.jsx(Er,{value:w.quote,onChange:M=>{const I=[...i.testimonials];I[N]={...w,quote:M.target.value},c(L=>({...L,testimonials:I}))},placeholder:"What they say about working here...",rows:2})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>c(M=>({...M,testimonials:M.testimonials.filter((I,L)=>L!==N)})),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]},N)}),i.testimonials.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No testimonials added yet"})]})]}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{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(fl,{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(Re,{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((w,N)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:w,alt:`Gallery ${N+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(C=>({...C,gallery_images:C.gallery_images.filter((M,I)=>I!==N)})),children:e.jsx(Nr,{className:"h-3 w-3"})})]},N))}):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(ed,{className:"h-4 w-4 mr-2"}),u.isPending?"Saving...":"Save Landing Page"]})})]})}function A4s(t){if(!t)return"—";const s=Math.floor(t/60),r=t%60;return s>0?`${s}m ${r}s`:`${r}s`}function E4s({video:t}){return t.cta_clicked_at?e.jsx(tt,{className:"bg-emerald-500/10 text-emerald-600 border-emerald-200",children:"CTA Clicked"}):t.view_count>0?e.jsxs(tt,{className:"bg-blue-500/10 text-blue-600 border-blue-200",children:[e.jsx(qn,{className:"h-3 w-3 mr-1"}),t.view_count," views"]}):t.sent_at?e.jsxs(tt,{variant:"secondary",children:[e.jsx(Rn,{className:"h-3 w-3 mr-1"}),"Sent"]}):e.jsxs(tt,{variant:"outline",children:[e.jsx(mn,{className:"h-3 w-3 mr-1"}),"Draft"]})}function $lt({brokerageId:t}){const{data:s=[],isLoading:r}=_4s(t),{data:n=[]}=Alt(t),a=N4s(),o=k4s(),l=Tlt(),[i,c]=k.useState(""),[u,p]=k.useState(!1),[f,g]=k.useState({title:"",script_text:"",category:"general"}),b=s.filter(C=>{var I,L,R,q;return i?`${((I=C.prospect)==null?void 0:I.first_name)||""} ${((L=C.prospect)==null?void 0:L.last_name)||""}`.toLowerCase().includes(i.toLowerCase())||((q=(R=C.video)==null?void 0:R.title)==null?void 0:q.toLowerCase().includes(i.toLowerCase())):!0}),_={total:s.length,sent:s.filter(C=>C.sent_at).length,viewed:s.filter(C=>C.view_count>0).length,ctaClicked:s.filter(C=>C.cta_clicked_at).length},j=k.useCallback(C=>{if(!C)return;const M=`${window.location.origin}/recruit-video/${C}`;navigator.clipboard.writeText(M),he.success("Share link copied")},[]),w=k.useCallback((C,M)=>{l.mutate({id:C,sent_via:M})},[l]),N=()=>{!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:Rn,color:"text-blue-500"},{label:"Viewed",value:_.viewed,icon:qn,color:"text-amber-500"},{label:"CTA Clicked",value:_.ctaClicked,icon:la,color:"text-emerald-500"}].map(C=>e.jsx(Pe,{children:e.jsxs(Re,{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 ${C.color}`,children:e.jsx(C.icon,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-2xl font-bold",children:C.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:C.label})]})]})},C.label))}),e.jsxs(ja,{defaultValue:"videos",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"videos",children:[e.jsx(Cn,{className:"h-4 w-4 mr-1.5"}),"All Videos"]}),e.jsxs(us,{value:"scripts",children:[e.jsx(En,{className:"h-4 w-4 mr-1.5"}),"Script Library"]}),e.jsxs(us,{value:"analytics",children:[e.jsx(Ro,{className:"h-4 w-4 mr-1.5"}),"Engagement"]})]}),e.jsx(ks,{value:"videos",children:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{className:"text-lg",children:"Video Outreach"}),e.jsxs("div",{className:"relative w-64",children:[e.jsx(hn,{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:C=>c(C.target.value),className:"pl-9"})]})]})}),e.jsx(Re,{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"})}):b.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:b.map(C=>{var M,I,L,R,q,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=C.video)!=null&&M.thumbnail_url?e.jsx("img",{src:C.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:A4s(((I=C.video)==null?void 0:I.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:[(L=C.prospect)==null?void 0:L.first_name," ",(R=C.prospect)==null?void 0:R.last_name]}),e.jsx(E4s,{video:C})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:((q=C.video)==null?void 0:q.title)||"Untitled video"}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ps(new Date(C.created_at),"MMM d, yyyy"),((U=C.prospect)==null?void 0:U.current_brokerage)&&` · ${C.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:()=>j(C.share_token),title:"Copy share link",children:e.jsx(gi,{className:"h-4 w-4"})}),!C.sent_at&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>w(C.id,"email"),title:"Mark as sent",children:e.jsx(Rn,{className:"h-4 w-4"})}),C.share_token&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>window.open(`/recruit-video/${C.share_token}`,"_blank"),title:"Preview landing page",children:e.jsx(an,{className:"h-4 w-4"})})]})]},C.id)})})})]})}),e.jsx(ks,{value:"scripts",children:e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(zt,{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(_s,{children:e.jsx(bs,{children:"Create Recruiting Script"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Title"}),e.jsx(ze,{value:f.title,onChange:C=>g(M=>({...M,title:C.target.value})),placeholder:"e.g., Why Switch to Our Brokerage"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Category"}),e.jsxs(Ys,{value:f.category,onValueChange:C=>g(M=>({...M,category:C})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:iwe.map(C=>e.jsx(Mt,{value:C.value,children:C.label},C.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Script"}),e.jsx(Er,{value:f.script_text,onChange:C=>g(M=>({...M,script_text:C.target.value})),placeholder:"Hi [Name], I noticed you've been doing great work at [Brokerage]...",rows:8})]}),e.jsx(K,{onClick:N,disabled:!f.title.trim()||!f.script_text.trim(),className:"w-full",children:"Save Script"})]})]})]})]})}),e.jsx(Re,{children:n.length===0?e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(En,{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(C=>{var I;const M=((I=iwe.find(L=>L.value===C.category))==null?void 0:I.label)||C.category;return e.jsx(Pe,{className:"relative group",children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(tt,{variant:"outline",className:"text-[10px] mb-2",children:M}),e.jsx("h4",{className:"font-medium text-sm",children:C.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(C.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:C.script_text}),C.is_global&&e.jsx(tt,{variant:"secondary",className:"mt-2 text-[10px]",children:"Template"})]})},C.id)})})})]})}),e.jsx(ks,{value:"analytics",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"Engagement Funnel"})}),e.jsxs(Re,{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(C=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{children:C.label}),e.jsxs("span",{className:"font-medium",children:[C.count," (",C.pct,"%)"]})]}),e.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${C.color} rounded-full transition-all`,style:{width:`${C.pct}%`}})})]},C.label))}),s.filter(C=>C.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(C=>C.view_count>0).sort((C,M)=>M.view_count-C.view_count).slice(0,5).map(C=>{var M,I;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=C.prospect)==null?void 0:M.first_name," ",(I=C.prospect)==null?void 0:I.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(qn,{className:"h-3.5 w-3.5"})," ",C.view_count]}),C.cta_clicked_at&&e.jsx(la,{className:"h-4 w-4 text-emerald-500"})]})]},C.id)})})]})]})]})})]})]})}function qlt({brokerageId:t}){const{toast:s}=qa(),r=es(),{stages:n,prospects:a}=xme(t),[o,l]=k.useState(!1),[i,c]=k.useState({title:"",target_count:"10",target_stage_id:"",period_start:ps(new Date,"yyyy-MM-dd"),period_end:ps(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:j}=await H.from("recruit_goals").select("*").eq("brokerage_id",t).order("period_end",{ascending:!1});if(j)throw j;return _}}),f=Lt({mutationFn:async _=>{const{data:{user:j}}=await H.auth.getUser();if(!j)throw new Error("Not authenticated");const{error:w}=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:j.id});if(w)throw w},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:j}=await H.from("recruit_goals").delete().eq("id",_);if(j)throw j},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-goals",t]}),s({title:"Goal removed"})}}),b=_=>{const j=n.find(N=>N.id===_.target_stage_id);return{count:a.filter(N=>Og(new Date(N.created_at),{start:new Date(_.period_start),end:new Date(_.period_end)})?_.target_stage_id?N.stage_id===_.target_stage_id:!0:!1).length,stage:j}};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(Pe,{className:"py-12 text-center",children:[e.jsx(Rm,{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:j,stage:w}=b(_),N=Math.min(100,j/_.target_count*100),C=Og(new Date,{start:new Date(_.period_start),end:new Date(_.period_end)});return e.jsxs(Pe,{className:C?"":"opacity-60",children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{className:"text-sm",children:_.title}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:[ps(new Date(_.period_start),"MMM d")," – ",ps(new Date(_.period_end),"MMM d, yyyy")]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[C?e.jsx(tt,{className:"text-[10px]",children:"Active"}):e.jsx(tt,{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(Re,{className:"space-y-2",children:[w&&e.jsxs(tt,{variant:"outline",className:"text-[10px]",style:{borderColor:w.color,color:w.color},children:["Stage: ",w.name]}),e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"font-bold text-lg",children:j}),e.jsxs("span",{className:"text-muted-foreground",children:["/ ",_.target_count]})]}),e.jsx(Bi,{value:N,className:"h-2"}),e.jsxs("p",{className:"text-xs text-muted-foreground text-right",children:[N.toFixed(0),"% complete"]})]})]},_.id)})}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Create Recruiting Goal"})}),e.jsxs("form",{onSubmit:_=>{_.preventDefault(),f.mutate(i)},className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Goal Title *"}),e.jsx(ze,{required:!0,value:i.title,onChange:_=>c(j=>({...j,title:_.target.value})),placeholder:"e.g. Q2 Recruiting Target"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Target Count *"}),e.jsx(ze,{type:"number",min:"1",required:!0,value:i.target_count,onChange:_=>c(j=>({...j,target_count:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{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(j=>({...j,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(ye,{children:"Start Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_start,onChange:_=>c(j=>({...j,period_start:_.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"End Date"}),e.jsx(ze,{type:"date",required:!0,value:i.period_end,onChange:_=>c(j=>({...j,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 P4s={first_name:"Sarah",brokerage_name:"ABC Realty",city:"Austin",sender_name:"Jeremy"};function I4s({email:t,mergeValues:s=P4s,onClose:r}){var a,o;const n=l=>l.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");return e.jsx(xs,{open:!0,onOpenChange:()=>r(),children:e.jsxs(fs,{className:"max-w-2xl max-h-[85vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(bs,{className:"text-base",children:["Email #",t.email_number," — ",t.title]}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[e.jsxs(tt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),t.email_number===1?"Sent immediately":`Day ${t.delay_days}`]}),((a=t.subject_line_options)==null?void 0:a.length)>1&&e.jsxs(tt,{variant:"secondary",className:"text-xs",children:[t.subject_line_options.length," subject variants"]})]})]}),e.jsxs("div",{className:"space-y-0",children:[((o=t.subject_line_options)==null?void 0:o.length)>0&&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:t.subject_line_options.map((l,i)=>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 ${i===0?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:i===0?"Primary":`Alt ${i}`}),e.jsx("span",{className:"text-sm",children:n(l)})]},i))})]}),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.jsx("span",{children:"Jeremy "})]}),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.jsx("span",{children:"Sarah "})]}),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:n(t.subject_line)})]})]}),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:n(t.body_html)}})})]})]})})}function cCe({brokerageId:t}){const s=es(),[r,n]=k.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}});k.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]}),he.success("Recruiting email settings saved!")},onError:c=>he.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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ed,{className:"h-4 w-4 mr-1"})," Save Settings"]})]})}const L4s=oy.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",$c(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()}}}),wze=[{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 mh({onClick:t,active:s,disabled:r,icon:n,tooltip:a}){return e.jsxs(Oc,{children:[e.jsx(Rc,{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(gc,{side:"bottom",className:"text-xs",children:a})]})}function D4s({content:t,onChange:s}){const r=tke({extensions:[rke.configure({heading:{levels:[1,2,3]}}),L4s,mke.configure({openOnClick:!1,HTMLAttributes:{class:"text-primary underline cursor-pointer"}}),pke.configure({types:["heading","paragraph"]}),fke,vat],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())}});k.useEffect(()=>{r&&t!==r.getHTML()&&r.commands.setContent(t)},[t,r]);const n=k.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=k.useCallback(o=>{r&&r.chain().focus().insertContent(`{{${o}}}`).run()},[r]);return r?e.jsx(F1,{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(mh,{onClick:()=>r.chain().focus().toggleBold().run(),active:r.isActive("bold"),icon:W4,tooltip:"Bold"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleItalic().run(),active:r.isActive("italic"),icon:Q4,tooltip:"Italic"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleUnderline().run(),active:r.isActive("underline"),icon:PL,tooltip:"Underline"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleStrike().run(),active:r.isActive("strike"),icon:CL,tooltip:"Strikethrough"}),e.jsx(sl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleHeading({level:1}).run(),active:r.isActive("heading",{level:1}),icon:kM,tooltip:"Heading 1"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleHeading({level:2}).run(),active:r.isActive("heading",{level:2}),icon:SM,tooltip:"Heading 2"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleHeading({level:3}).run(),active:r.isActive("heading",{level:3}),icon:oL,tooltip:"Heading 3"}),e.jsx(sl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleBulletList().run(),active:r.isActive("bulletList"),icon:Ch,tooltip:"Bullet List"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleOrderedList().run(),active:r.isActive("orderedList"),icon:h0,tooltip:"Numbered List"}),e.jsx(mh,{onClick:()=>r.chain().focus().toggleBlockquote().run(),active:r.isActive("blockquote"),icon:U_,tooltip:"Blockquote"}),e.jsx(mh,{onClick:()=>r.chain().focus().setHorizontalRule().run(),icon:m0,tooltip:"Divider"}),e.jsx(sl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(mh,{onClick:()=>r.chain().focus().setTextAlign("left").run(),active:r.isActive({textAlign:"left"}),icon:U4,tooltip:"Align Left"}),e.jsx(mh,{onClick:()=>r.chain().focus().setTextAlign("center").run(),active:r.isActive({textAlign:"center"}),icon:q4,tooltip:"Align Center"}),e.jsx(mh,{onClick:()=>r.chain().focus().setTextAlign("right").run(),active:r.isActive({textAlign:"right"}),icon:V4,tooltip:"Align Right"}),e.jsx(sl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(mh,{onClick:n,active:r.isActive("link"),icon:zo,tooltip:"Insert Link"}),e.jsx(sl,{orientation:"vertical",className:"mx-1 h-6"}),e.jsx(mh,{onClick:()=>r.chain().focus().undo().run(),disabled:!r.can().undo(),icon:dS,tooltip:"Undo"}),e.jsx(mh,{onClick:()=>r.chain().focus().redo().run(),disabled:!r.can().redo(),icon:oS,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(au,{children:[e.jsx(iu,{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(qM,{className:"h-3.5 w-3.5"}),"Merge Tags"]})}),e.jsx(zd,{align:"end",className:"w-56",children:wze.map(o=>e.jsxs(Ca,{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(JNe,{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:"}),wze.map(o=>e.jsx(tt,{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 jze={cold:{icon:r0,color:"text-blue-500",bg:"bg-blue-50 dark:bg-blue-950/30",label:"Cold — Curiosity"},warm:{icon:h1,color:"text-amber-500",bg:"bg-amber-50 dark:bg-amber-950/30",label:"Warm — Growth"},hot:{icon:Qu,color:"text-red-500",bg:"bg-red-50 dark:bg-red-950/30",label:"Hot — Private Invite"}};function Ult({brokerageId:t}){var xe,_e,fe,we;const{user:s}=Rs(),r=es(),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState("editor"),[j,w]=k.useState(null),[N,C]=k.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:Ie,error:Ne}=await H.from("brokerages").select("name, city, state").eq("id",t).single();if(Ne)throw Ne;return Ie}}),{data:I}=mt({queryKey:["brokerage-recruit-settings",t],queryFn:async()=>{const{data:Ie,error:Ne}=await H.from("brokerage_recruit_settings").select("*").eq("brokerage_id",t).maybeSingle();if(Ne)throw Ne;return Ie}}),L={first_name:"Sarah",brokerage_name:((xe=I==null?void 0:I.merge_fields)==null?void 0:xe.brokerage_name)||(M==null?void 0:M.name)||"Your Brokerage",city:((_e=I==null?void 0:I.merge_fields)==null?void 0:_e.city)||(M==null?void 0:M.city)||"Your City",sender_name:((fe=I==null?void 0:I.merge_fields)==null?void 0:fe.sender_name)||(I==null?void 0:I.sender_name)||"Your Name"},R=Ie=>Ie.replace(/\{\{first_name\}\}/g,L.first_name).replace(/\{\{brokerage_name\}\}/g,L.brokerage_name).replace(/\{\{city\}\}/g,L.city).replace(/\{\{sender_name\}\}/g,L.sender_name),{data:q=[],isLoading:U}=mt({queryKey:["recruit-campaigns",t],queryFn:async()=>{const{data:Ie,error:Ne}=await H.from("recruit_campaigns").select("*").or(`brokerage_id.is.null,brokerage_id.eq.${t}`).order("sort_order");if(Ne)throw Ne;return Ie}}),{data:B={}}=mt({queryKey:["recruit-campaign-emails",t],enabled:q.length>0,queryFn:async()=>{const Ie=q.map(Ce=>Ce.id),{data:Ne,error:Ae}=await H.from("recruit_campaign_emails").select("*").in("campaign_id",Ie).order("email_number");if(Ae)throw Ae;const Fe={};return Ne.forEach(Ce=>{Fe[Ce.campaign_id]||(Fe[Ce.campaign_id]=[]),Fe[Ce.campaign_id].push(Ce)}),Fe}}),V=Lt({mutationFn:async Ie=>{const{error:Ne}=await H.from("recruit_campaign_emails").update({title:Ie.title,subject_line:Ie.subject_line,subject_line_options:Ie.subject_line_options,body_html:Ie.body_html,body_text:Ie.body_text,delay_days:Ie.delay_days,updated_at:new Date().toISOString()}).eq("id",Ie.id);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Email template saved!"),l(null)},onError:Ie=>he.error(Ie.message)}),Y=Lt({mutationFn:async()=>{const Ie=N.name.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),{data:Ne,error:Ae}=await H.from("recruit_campaigns").insert({name:N.name,slug:Ie,description:N.description||null,theme:N.theme||null,goal:N.goal||null,primary_cta:N.primary_cta||"Learn more",warmth_level:N.warmth_level,brokerage_id:t,created_by:s==null?void 0:s.id,sender_name:N.sender_name||null,sender_email:N.sender_email||null,reply_to_email:N.reply_to_email||null,is_active:!0,sort_order:q.length+1}).select().single();if(Ae)throw Ae;const Fe=[{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:Ce}=await H.from("recruit_campaign_emails").insert(Fe.map(Me=>({campaign_id:Ne.id,...Me,body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",subject_line_options:[],is_active:!0})));if(Ce)throw Ce;return Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Campaign created with 4 starter emails!"),g(!1),C({name:"",description:"",theme:"",goal:"",primary_cta:"Learn more",warmth_level:"warm",sender_name:"",sender_email:"",reply_to_email:""})},onError:Ie=>he.error(Ie.message)}),J=Lt({mutationFn:async Ie=>{const{error:Ne}=await H.from("recruit_campaigns").update({name:Ie.name,description:Ie.description,theme:Ie.theme,goal:Ie.goal,primary_cta:Ie.primary_cta,warmth_level:Ie.warmth_level,sender_name:Ie.sender_name,sender_email:Ie.sender_email,reply_to_email:Ie.reply_to_email,updated_at:new Date().toISOString()}).eq("id",Ie.id);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),he.success("Campaign settings saved!"),w(null)},onError:Ie=>he.error(Ie.message)}),te=Lt({mutationFn:async Ie=>{var $e,ct;const{data:Ne}=await H.from("recruit_campaign_emails").select("email_number, delay_days").eq("campaign_id",Ie).order("email_number",{ascending:!1}).limit(1),Ae=(($e=Ne==null?void 0:Ne[0])==null?void 0:$e.email_number)??0,Fe=((ct=Ne==null?void 0:Ne[0])==null?void 0:ct.delay_days)??0,Ce=Ae+1,{error:Me}=await H.from("recruit_campaign_emails").insert({campaign_id:Ie,email_number:Ce,title:`Email ${Ce}`,subject_line:"Hey {{first_name}}",subject_line_options:[],body_html:"

Hi {{first_name}},

Write your message here...

Best,
{{sender_name}}

",body_text:"",delay_days:Fe+7,is_active:!0});if(Me)throw Me},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Email added to campaign!")},onError:Ie=>he.error(Ie.message)}),X=Lt({mutationFn:async Ie=>{const{error:Ne}=await H.from("recruit_campaigns").delete().eq("id",Ie);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaigns"]}),r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Campaign deleted")},onError:Ie=>he.error(Ie.message)}),ce=Lt({mutationFn:async Ie=>{const{error:Ne}=await H.from("recruit_campaign_emails").delete().eq("id",Ie);if(Ne)throw Ne},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Email removed from campaign")},onError:Ie=>he.error(Ie.message)}),ne=Lt({mutationFn:async({emailId:Ie,delay_days:Ne})=>{const{error:Ae}=await H.from("recruit_campaign_emails").update({delay_days:Ne,updated_at:new Date().toISOString()}).eq("id",Ie);if(Ae)throw Ae},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-emails"]}),he.success("Send delay updated")},onError:Ie=>he.error(Ie.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 re=q.filter(Ie=>!Ie.brokerage_id),le=q.filter(Ie=>Ie.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(Yo,{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(Pe,{className:"border-primary/20 bg-primary/5",children:e.jsx(Re,{className:"py-3",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(un,{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(Yo,{className:"inline h-3.5 w-3.5"})," icon on any campaign to customize."]})]})]})})}),le.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(cL,{className:"h-4 w-4"})," Your Custom Campaigns"]}),e.jsx("div",{className:"space-y-3",children:le.map(Ie=>pe(Ie,!0))})]}),re.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(un,{className:"h-4 w-4"})," System Campaigns"]}),e.jsx("div",{className:"space-y-3",children:re.map(Ie=>pe(Ie,!1))})]}),q.length===0&&e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(dr,{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(I4s,{email:i,mergeValues:L,onClose:()=>c(null)}),e.jsx(xs,{open:!!o,onOpenChange:Ie=>!Ie&&l(null),children:e.jsxs(fs,{className:"max-w-4xl max-h-[90vh] overflow-y-auto p-0",children:[e.jsxs(_s,{className:"px-6 pt-6 pb-4 border-b",children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(z_,{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(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Title"}),e.jsx(ze,{value:o.title,onChange:Ie=>l({...o,title:Ie.target.value}),className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{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:Ie=>l({...o,delay_days:parseInt(Ie.target.value)||7}),className:"h-9"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Subject Line"}),e.jsx(ze,{value:o.subject_line,onChange:Ie=>l({...o,subject_line:Ie.target.value}),placeholder:"e.g. Hey {{first_name}}, quick question...",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(ye,{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(Er,{value:((we=o.subject_line_options)==null?void 0:we.join(` `))||"",onChange:Ie=>l({...o,subject_line_options:Ie.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(ye,{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Email Body"}),e.jsx(ja,{value:b,onValueChange:Ie=>_(Ie),children:e.jsxs(ga,{className:"h-7",children:[e.jsx(us,{value:"editor",className:"text-xs px-3 h-6",children:"Editor"}),e.jsx(us,{value:"preview",className:"text-xs px-3 h-6",children:"Preview"})]})})]}),b==="editor"?e.jsx(D4s,{content:o.body_html,onChange:Ie=>l({...o,body_html:Ie})}):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:[L.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:[L.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:R(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:R(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:()=>V.mutate(o),disabled:V.isPending,className:"gap-1.5",children:[e.jsx(ed,{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(_s,{children:[e.jsxs(bs,{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(ye,{className:"text-xs font-medium",children:"Campaign Name *"}),e.jsx(ze,{value:N.name,onChange:Ie=>C({...N,name:Ie.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(ye,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ys,{value:N.warmth_level,onValueChange:Ie=>C({...N,warmth_level:Ie}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{className:"text-xs font-medium",children:"Primary CTA"}),e.jsx(ze,{value:N.primary_cta,onChange:Ie=>C({...N,primary_cta:Ie.target.value}),placeholder:"Learn more"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Description"}),e.jsx(Er,{value:N.description,onChange:Ie=>C({...N,description:Ie.target.value}),placeholder:"What is this campaign about?",rows:2})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:N.goal,onChange:Ie=>C({...N,goal:Ie.target.value}),placeholder:"e.g. Convert warm leads to meetings"})]}),e.jsxs(gf,{children:[e.jsx(yf,{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(dr,{className:"h-3.5 w-3.5"})," Email Settings Override"]}),e.jsx(To,{className:"h-3.5 w-3.5"})]})}),e.jsxs(vf,{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(ye,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:N.sender_name,onChange:Ie=>C({...N,sender_name:Ie.target.value}),placeholder:"e.g. Jeremy at LevelUp"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:N.sender_email,onChange:Ie=>C({...N,sender_email:Ie.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(ye,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:N.reply_to_email,onChange:Ie=>C({...N,reply_to_email:Ie.target.value}),placeholder:"e.g. jeremy@mybrokerage.com"})]})]})]}),e.jsxs(K,{className:"w-full",disabled:!N.name.trim()||Y.isPending,onClick:()=>Y.mutate(),children:[e.jsx(qs,{className:"h-4 w-4 mr-1"})," Create Campaign"]})]})]})}),e.jsx(xs,{open:!!j,onOpenChange:Ie=>!Ie&&w(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Yo,{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."})]}),j&&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(ye,{className:"text-xs font-medium",children:"Campaign Name"}),e.jsx(ze,{value:j.name,onChange:Ie=>w({...j,name:Ie.target.value})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Warmth Level"}),e.jsxs(Ys,{value:j.warmth_level,onValueChange:Ie=>w({...j,warmth_level:Ie}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{className:"text-xs font-medium",children:"Goal"}),e.jsx(ze,{value:j.goal||"",onChange:Ie=>w({...j,goal:Ie.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(dr,{className:"h-4 w-4 text-primary"})," Email Sender Override"]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Name"}),e.jsx(ze,{value:j.sender_name||"",onChange:Ie=>w({...j,sender_name:Ie.target.value}),placeholder:"Uses brokerage default"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs",children:"Sender Email"}),e.jsx(ze,{value:j.sender_email||"",onChange:Ie=>w({...j,sender_email:Ie.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(ye,{className:"text-xs",children:"Reply-To Email"}),e.jsx(ze,{value:j.reply_to_email||"",onChange:Ie=>w({...j,reply_to_email:Ie.target.value}),placeholder:"Uses brokerage default"})]})]}),e.jsxs(K,{className:"w-full",onClick:()=>J.mutate(j),disabled:J.isPending,children:[e.jsx(ed,{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(_s,{children:[e.jsx(bs,{children:"Default Recruiting Email Settings"}),e.jsx(Wr,{children:"These defaults apply to campaigns without their own overrides."})]}),e.jsx(cCe,{brokerageId:t})]})})]});function pe(Ie,Ne){const Ae=jze[Ie.warmth_level]||jze.cold,Fe=Ae.icon,Ce=B[Ie.id]||[],Me=n===Ie.id,$e=!!(Ie.sender_name||Ie.sender_email||Ie.reply_to_email);return e.jsxs(Pe,{className:"overflow-hidden transition-shadow hover:shadow-md",children:[e.jsx(Dt,{className:"cursor-pointer hover:bg-muted/40 transition-colors py-4",onClick:()=>a(Me?null:Ie.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 ${Ae.bg} flex items-center justify-center`,children:e.jsx(Fe,{className:`h-5 w-5 ${Ae.color}`})}),e.jsxs("div",{children:[e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[Ie.name,e.jsx(tt,{variant:Ie.is_active?"default":"secondary",className:"text-[10px] px-1.5",children:Ie.is_active?"Active":"Draft"}),Ne&&e.jsx(tt,{variant:"outline",className:"text-[10px] px-1.5",children:"Custom"}),$e&&e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 border-primary/30 text-primary",children:[e.jsx(dr,{className:"h-2.5 w-2.5 mr-0.5"})," Custom Sender"]})]}),e.jsx(xr,{className:"text-xs mt-0.5",children:Ie.theme||Ie.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:ct=>{ct.stopPropagation(),w({...Ie})},children:e.jsx(Yo,{className:"h-4 w-4 text-muted-foreground"})}),Ne&&e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-destructive hover:text-destructive hover:bg-destructive/10",onClick:ct=>{ct.stopPropagation(),confirm("Delete this campaign and all its emails? This cannot be undone.")&&X.mutate(Ie.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(dr,{className:"h-3.5 w-3.5"}),e.jsxs("span",{children:[Ce.length," emails"]})]}),e.jsx("div",{className:"h-7 w-7 rounded-md flex items-center justify-center",children:Me?e.jsx(pf,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(To,{className:"h-4 w-4 text-muted-foreground"})})]})]})}),Me&&e.jsxs(Re,{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:Ie.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:Ie.primary_cta||"—"})]})]}),$e&&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(dr,{className:"h-3 w-3"})," Campaign Sender Override"]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs text-muted-foreground",children:[Ie.sender_name&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Name:"})," ",Ie.sender_name]}),Ie.sender_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Email:"})," ",Ie.sender_email]}),Ie.reply_to_email&&e.jsxs("p",{children:[e.jsx("span",{className:"font-medium",children:"Reply-To:"})," ",Ie.reply_to_email]})]})]}),e.jsx("div",{className:"relative",children:Ce.map((ct,Te)=>e.jsxs("div",{className:"relative flex gap-4 pb-4 last:pb-0",children:[Teft.stopPropagation(),onBlur:ft=>{const me=parseInt(ft.target.value)||0;me!==ct.delay_days&&ne.mutate({emailId:ct.id,delay_days:me})},onKeyDown:ft=>{ft.key==="Enter"&&ft.target.blur()}}),"days"]})]}):e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),ct.email_number===1?"Sent immediately":`Day ${ct.delay_days}`]}),e.jsx("span",{className:"text-border",children:"•"}),e.jsxs("span",{className:"truncate",children:["Subject: ",ct.subject_line]})]})]}),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(ct),children:e.jsx(qn,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>{l({...ct}),_("editor")},children:e.jsx(Da,{className:"h-4 w-4"})}),Ne&&Ce.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?")&&ce.mutate(ct.id)},children:e.jsx(Nr,{className:"h-4 w-4"})})]})]})})]},ct.id))}),Ne&&e.jsxs(K,{variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>te.mutate(Ie.id),disabled:te.isPending,children:[e.jsx(qs,{className:"h-3.5 w-3.5"})," Add Email to Sequence"]})]})]},Ie.id)}}const Nze={active:{icon:rl,color:"bg-green-500/10 text-green-600",label:"Active"},paused:{icon:Dm,color:"bg-amber-500/10 text-amber-600",label:"Paused"},completed:{icon:xi,color:"bg-blue-500/10 text-blue-600",label:"Completed"},cancelled:{icon:xc,color:"bg-red-500/10 text-red-600",label:"Cancelled"}},kze={sent:{icon:dr,color:"text-blue-500"},opened:{icon:qn,color:"text-amber-500"},clicked:{icon:Xg,color:"text-green-500"},failed:{icon:Gu,color:"text-destructive"}};function Vlt({brokerageId:t}){const{user:s}=Rs(),r=es(),[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(new Set),[u,p]=k.useState("assignments"),{data:f=[],isLoading:g}=mt({queryKey:["recruit-campaign-assignments",t],queryFn:async()=>{const{data:Y,error:J}=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});if(J)throw J;return Y}}),{data:b=[]}=mt({queryKey:["recruit-campaign-sends",t],queryFn:async()=>{const{data:Y,error:J}=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(J)throw J;return Y}}),{data:_=[]}=mt({queryKey:["recruit-campaigns"],queryFn:async()=>{const{data:Y,error:J}=await H.from("recruit_campaigns").select("id, name, warmth_level").eq("is_active",!0).order("sort_order");if(J)throw J;return Y}}),{data:j=[]}=mt({queryKey:["recruit-prospects-for-assign",t],queryFn:async()=>{const{data:Y,error:J}=await H.from("recruit_prospects").select("id, first_name, last_name, email").eq("brokerage_id",t).order("first_name");if(J)throw J;return Y}}),w=new Set(f.map(Y=>`${Y.prospect_id}-${Y.campaign_id}`)),N=Lt({mutationFn:async()=>{if(!o||i.size===0)throw new Error("Select a campaign and at least one prospect");const Y=new Date,J=Array.from(i).filter(X=>!w.has(`${X}-${o}`)).map(X=>({prospect_id:X,campaign_id:o,brokerage_id:t,assigned_by:s.id,status:"active",current_email_number:0,next_send_at:Y.toISOString(),started_at:Y.toISOString()}));if(J.length===0)throw new Error("All selected prospects are already assigned to this campaign");const{error:te}=await H.from("recruit_campaign_assignments").insert(J);if(te)throw te},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),he.success(`Campaign assigned to ${i.size} prospect(s)!`),a(!1),l(""),c(new Set)},onError:Y=>he.error(Y.message)}),C=Lt({mutationFn:async({id:Y,newStatus:J})=>{const{error:te}=await H.from("recruit_campaign_assignments").update({status:J,updated_at:new Date().toISOString()}).eq("id",Y);if(te)throw te},onSuccess:()=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),he.success("Assignment updated")}}),M=Lt({mutationFn:async()=>{const{data:Y,error:J}=await H.functions.invoke("ses-recruit-drip",{body:{action:"process_drips"}});if(J)throw J;return Y},onSuccess:Y=>{r.invalidateQueries({queryKey:["recruit-campaign-assignments",t]}),r.invalidateQueries({queryKey:["recruit-campaign-sends",t]}),he.success(`Wave sent! ${Y.sent} emails delivered, ${Y.skipped} skipped, ${Y.failed} failed`)},onError:Y=>he.error(`Send failed: ${Y.message}`)}),I=f.filter(Y=>Y.status==="active").length;f.filter(Y=>Y.status==="completed").length;const L=f.filter(Y=>Y.status==="active"&&Y.next_send_at&&new Date(Y.next_send_at)<=new Date).length,R=b.length,q=b.filter(Y=>Y.opened_at).length,U=b.filter(Y=>Y.clicked_at).length,B=R>0?Math.round(q/R*100):0,V=R>0?Math.round(U/R*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:[L>0&&e.jsxs(K,{variant:"outline",onClick:()=>M.mutate(),disabled:M.isPending,className:"border-amber-500/50 text-amber-600 hover:bg-amber-500/10",children:[e.jsx(Fm,{className:"h-4 w-4 mr-1"}),M.isPending?"Sending...":`Send Next Wave (${L})`]}),e.jsxs(K,{onClick:()=>a(!0),children:[e.jsx(Rn,{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(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(mr,{className:"h-7 w-7 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:f.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Assigned"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(rl,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:I}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(dr,{className:"h-7 w-7 text-blue-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xl font-bold",children:R}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Emails Sent"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(qn,{className:"h-7 w-7 text-amber-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[B,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Open Rate"})]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-3 pb-2 flex items-center gap-3",children:[e.jsx(Xg,{className:"h-7 w-7 text-green-500"}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-xl font-bold",children:[V,"%"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Click Rate"})]})]})})]}),e.jsxs(ja,{value:u,onValueChange:p,children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"assignments",children:["Active Drips (",I,")"]}),e.jsxs(us,{value:"history",children:["Send History (",R,")"]})]}),e.jsx(ks,{value:"assignments",className:"mt-4",children:g?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"})}):f.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(Rn,{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:f.map(Y=>{var ce,ne,re,le;const J=Nze[Y.status]||Nze.active,te=J.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.jsxs(tt,{className:`text-xs ${J.color} border-0`,children:[e.jsx(te,{className:"h-3 w-3 mr-1"}),J.label]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm",children:[(ce=Y.prospect)==null?void 0:ce.first_name," ",(ne=Y.prospect)==null?void 0:ne.last_name,e.jsx("span",{className:"text-muted-foreground font-normal ml-2",children:(re=Y.prospect)==null?void 0:re.email})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(le=Y.campaign)==null?void 0:le.name," · Email ",Y.current_email_number,"/",4,Y.next_send_at&&Y.status==="active"&&e.jsxs(e.Fragment,{children:[" ","· ",e.jsx(mn,{className:"h-3 w-3 inline"})," Next: ",ps(new Date(Y.next_send_at),"MMM d, h:mm a"),new Date(Y.next_send_at)<=new Date&&e.jsx(tt,{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:[Y.status==="active"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>C.mutate({id:Y.id,newStatus:"paused"}),children:e.jsx(Dm,{className:"h-3.5 w-3.5"})}),Y.status==="paused"&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>C.mutate({id:Y.id,newStatus:"active"}),children:e.jsx(rl,{className:"h-3.5 w-3.5"})}),(Y.status==="active"||Y.status==="paused")&&e.jsx(K,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>C.mutate({id:Y.id,newStatus:"cancelled"}),children:e.jsx(xc,{className:"h-3.5 w-3.5"})})]})]},Y.id)})})}),e.jsx(ks,{value:"history",className:"mt-4",children:b.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(dr,{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:b.map(Y=>{var X,ce;const J=kze[Y.status]||kze.sent,te=J.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(te,{className:`h-4 w-4 flex-shrink-0 ${J.color}`}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-medium text-sm truncate",children:[(X=Y.prospect)==null?void 0:X.first_name," ",(ce=Y.prospect)==null?void 0:ce.last_name,e.jsxs("span",{className:"text-muted-foreground font-normal ml-2",children:["Email #",Y.email_number]})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Y.subject})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground flex-shrink-0",children:[Y.opened_at&&e.jsxs("span",{className:"flex items-center gap-1 text-amber-500",children:[e.jsx(qn,{className:"h-3 w-3"})," ",ps(new Date(Y.opened_at),"MMM d")]}),Y.clicked_at&&e.jsxs("span",{className:"flex items-center gap-1 text-green-500",children:[e.jsx(Xg,{className:"h-3 w-3"})," ",ps(new Date(Y.clicked_at),"MMM d")]}),Y.status==="failed"&&e.jsx("span",{className:"text-destructive text-xs",children:"Failed"}),e.jsx("span",{children:ps(new Date(Y.sent_at),"MMM d, h:mm a")})]})]},Y.id)})})})]}),e.jsx(xs,{open:n,onOpenChange:a,children:e.jsxs(fs,{className:"max-w-lg max-h-[80vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Assign Campaign to Prospects"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Select Campaign"}),e.jsxs(Ys,{value:o,onValueChange:l,children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Choose a campaign"})}),e.jsx(Ks,{children:_.map(Y=>e.jsx(Mt,{value:Y.id,children:Y.name},Y.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"text-sm font-medium",children:["Select Prospects (",i.size," selected)"]}),e.jsxs("div",{className:"border rounded-lg max-h-60 overflow-y-auto divide-y",children:[j.map(Y=>{const J=o&&w.has(`${Y.id}-${o}`);return e.jsxs("label",{className:`flex items-center gap-3 p-3 hover:bg-muted/50 cursor-pointer ${J?"opacity-50":""}`,children:[e.jsx(Lo,{checked:i.has(Y.id),disabled:!!J,onCheckedChange:te=>{const X=new Set(i);te?X.add(Y.id):X.delete(Y.id),c(X)}}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium",children:[Y.first_name," ",Y.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Y.email}),J&&e.jsx("p",{className:"text-xs text-amber-600",children:"Already assigned"})]})]},Y.id)}),j.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No prospects found for this brokerage"})]})]}),o&&i.size>0&&e.jsx(Pe,{className:"bg-muted/50",children:e.jsxs(Re,{className:"pt-3 pb-2 text-xs text-muted-foreground",children:[e.jsxs("p",{children:["📬 ",e.jsxs("strong",{children:[i.size," prospect(s)"]})," will start receiving the campaign."]}),e.jsx("p",{children:'Emails are sent automatically every 7 days via SES using brokerage sender settings. You can also trigger sends manually with "Send Next Wave".'})]})})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>a(!1),children:"Cancel"}),e.jsxs(K,{onClick:()=>N.mutate(),disabled:N.isPending||!o||i.size===0,children:[e.jsx(Rn,{className:"h-4 w-4 mr-1"}),"Assign & Start (",i.size,")"]})]})]})})]})}function O4s(){var i;const[t,s]=k.useState(""),[r,n]=k.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(Ys,{value:l,onValueChange:s,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(wa,{className:"mr-2 h-4 w-4"}),e.jsx(Qs,{placeholder:"Select brokerage"})]}),e.jsx(Ks,{children:a.map(c=>e.jsx(Mt,{value:c.id,children:c.name},c.id))})]})]}),l?e.jsxs(ja,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(ga,{className:"flex-wrap h-auto gap-1",children:[e.jsx(us,{value:"pipeline",children:"Pipeline"}),e.jsxs(us,{value:"contacts",children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(us,{value:"video-outreach",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(us,{value:"follow-ups",children:"Follow-ups"}),e.jsx(us,{value:"referrals",children:"Referrals"}),e.jsx(us,{value:"interest",children:"Interest Form"}),e.jsx(us,{value:"landing-page",children:"Landing Page"}),e.jsx(us,{value:"goals",children:"Goals"}),e.jsx(us,{value:"metrics",children:"Metrics"}),e.jsx(us,{value:"templates",children:"Email Templates"}),e.jsxs(us,{value:"campaigns",children:[e.jsx(dr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(us,{value:"drip-assignments",children:[e.jsx(Rn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(us,{value:"activity",children:"Recruiter Activity"}),e.jsxs(us,{value:"email-settings",children:[e.jsx(Yo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]})]}),e.jsxs(ks,{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($M,{className:"h-3.5 w-3.5"})," Table"]})]})}),r==="board"?e.jsx(Ilt,{brokerageId:l}):e.jsx(Jce,{brokerageId:l})]}),e.jsx(ks,{value:"contacts",children:e.jsx(Jce,{brokerageId:l})}),e.jsx(ks,{value:"video-outreach",children:e.jsx($lt,{brokerageId:l})}),e.jsx(ks,{value:"follow-ups",children:e.jsx(zlt,{brokerageId:l})}),e.jsx(ks,{value:"referrals",children:e.jsx(Rlt,{brokerageId:l})}),e.jsx(ks,{value:"interest",children:e.jsx(Flt,{brokerageId:l})}),e.jsx(ks,{value:"landing-page",children:e.jsx(Blt,{brokerageId:l})}),e.jsx(ks,{value:"goals",children:e.jsx(qlt,{brokerageId:l})}),e.jsx(ks,{value:"metrics",children:e.jsx(Llt,{brokerageId:l})}),e.jsx(ks,{value:"templates",children:e.jsx(Dlt,{brokerageId:l})}),e.jsx(ks,{value:"campaigns",children:e.jsx(Ult,{brokerageId:l})}),e.jsx(ks,{value:"drip-assignments",children:e.jsx(Vlt,{brokerageId:l})}),e.jsx(ks,{value:"activity",children:e.jsx(Olt,{brokerageId:l})}),e.jsx(ks,{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(cCe,{brokerageId:l})]})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(wa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found. Create a brokerage first."})]})]})})}function R4s(){var l;const{managedBrokerages:t,selectedBrokerageId:s,setSelectedBrokerageId:r}=Rs(),[n,a]=k.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(wa,{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(Ys,{value:o,onValueChange:r,children:[e.jsxs(Gs,{className:"w-[280px]",children:[e.jsx(wa,{className:"mr-2 h-4 w-4"}),e.jsx(Qs,{placeholder:"Select brokerage"})]}),e.jsx(Ks,{children:t.map(i=>e.jsx(Mt,{value:i.id,children:i.name},i.id))})]})]}),o?e.jsxs(ja,{defaultValue:"pipeline",className:"space-y-4",children:[e.jsxs(ga,{className:"flex-wrap h-auto gap-1",children:[e.jsx(us,{value:"pipeline",children:"Pipeline"}),e.jsxs(us,{value:"contacts",children:[e.jsx(mr,{className:"h-3.5 w-3.5 mr-1"}),"Contacts"]}),e.jsxs(us,{value:"video-outreach",children:[e.jsx(Cn,{className:"h-3.5 w-3.5 mr-1"}),"Video Outreach"]}),e.jsx(us,{value:"follow-ups",children:"Follow-ups"}),e.jsx(us,{value:"referrals",children:"Referrals"}),e.jsx(us,{value:"interest",children:"Interest Form"}),e.jsx(us,{value:"landing-page",children:"Landing Page"}),e.jsx(us,{value:"goals",children:"Goals"}),e.jsx(us,{value:"metrics",children:"Metrics"}),e.jsx(us,{value:"templates",children:"Email Templates"}),e.jsxs(us,{value:"campaigns",children:[e.jsx(dr,{className:"h-3.5 w-3.5 mr-1"}),"Campaigns"]}),e.jsxs(us,{value:"drip-assignments",children:[e.jsx(Rn,{className:"h-3.5 w-3.5 mr-1"}),"Drip Assignments"]}),e.jsx(us,{value:"activity",children:"Recruiter Activity"}),e.jsxs(us,{value:"email-settings",children:[e.jsx(Yo,{className:"h-3.5 w-3.5 mr-1"}),"Email Settings"]})]}),e.jsxs(ks,{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($M,{className:"h-3.5 w-3.5"})," Table"]})]})}),n==="board"?e.jsx(Ilt,{brokerageId:o}):e.jsx(Jce,{brokerageId:o})]}),e.jsx(ks,{value:"contacts",children:e.jsx(Jce,{brokerageId:o})}),e.jsx(ks,{value:"video-outreach",children:e.jsx($lt,{brokerageId:o})}),e.jsx(ks,{value:"follow-ups",children:e.jsx(zlt,{brokerageId:o})}),e.jsx(ks,{value:"referrals",children:e.jsx(Rlt,{brokerageId:o})}),e.jsx(ks,{value:"interest",children:e.jsx(Flt,{brokerageId:o})}),e.jsx(ks,{value:"landing-page",children:e.jsx(Blt,{brokerageId:o})}),e.jsx(ks,{value:"goals",children:e.jsx(qlt,{brokerageId:o})}),e.jsx(ks,{value:"metrics",children:e.jsx(Llt,{brokerageId:o})}),e.jsx(ks,{value:"templates",children:e.jsx(Dlt,{brokerageId:o})}),e.jsx(ks,{value:"campaigns",children:e.jsx(Ult,{brokerageId:o})}),e.jsx(ks,{value:"drip-assignments",children:e.jsx(Vlt,{brokerageId:o})}),e.jsx(ks,{value:"activity",children:e.jsx(Olt,{brokerageId:o})}),e.jsx(ks,{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(cCe,{brokerageId:o})]})})]}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx(wa,{className:"h-12 w-12 mx-auto mb-4 opacity-50"}),e.jsx("p",{children:"No brokerages found."})]})]})})}function F4s(){const[t,s]=k.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(b=>{const _=p.filter(N=>N.brokerage_id===b.id),j=f.filter(N=>N.brokerage_id===b.id),w=_.length>0?_.reduce((N,C)=>C.created_at>N?C.created_at:N,_[0].created_at):null;return{brokerage_id:b.id,brokerage_name:b.name,total_items:_.length,videos:_.filter(N=>N.content_type==="video").length,pdfs:_.filter(N=>N.content_type==="pdf").length,links:_.filter(N=>N.content_type==="link"||N.content_type==="canva_link").length,events:_.filter(N=>N.content_type==="event").length,graphics:_.filter(N=>N.content_type==="graphic").length,latest_item_date:w,categories:j.length}});return g.sort((b,_)=>_.total_items-b.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(ah,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Active Brokerages"})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Content Items"})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsx(zt,{className:"text-sm font-medium text-muted-foreground",children:"Total Brokerages"})}),e.jsxs(Re,{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(hn,{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(Pe,{children:e.jsx(Re,{className:"p-0",children:e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Brokerage"}),e.jsx(kt,{className:"text-center",children:"Total"}),e.jsx(kt,{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(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(En,{className:"h-3 w-3"})," PDFs"]})}),e.jsx(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(cl,{className:"h-3 w-3"})," Links"]})}),e.jsx(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(Dd,{className:"h-3 w-3"})," Events"]})}),e.jsx(kt,{className:"text-center",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx(fl,{className:"h-3 w-3"})," Graphics"]})}),e.jsx(kt,{className:"text-center",children:"Categories"}),e.jsx(kt,{children:"Last Upload"})]})}),e.jsx(On,{children:n?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"Loading..."})}):a.length===0?e.jsx(Ss,{children:e.jsx(dt,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:"No brokerages found"})}):a.map(i=>e.jsxs(Ss,{className:i.total_items===0?"opacity-50":"",children:[e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wa,{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(tt,{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:ps(new Date(i.latest_item_date),"MMM d, yyyy")}):e.jsx("span",{className:"text-muted-foreground",children:"–"})})]},i.brokerage_id))})]})})})]})})}function z4s(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 B4s=(()=>{let t=0;const s=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${s()}${t}`)})();function sw(t){const s=[];for(let r=0,n=t.length;rXp||t.height>Xp)&&(t.width>Xp&&t.height>Xp?t.width>t.height?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp):t.width>Xp?(t.height*=Xp/t.width,t.width=Xp):(t.width*=Xp/t.height,t.height=Xp))}function tde(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 H4s(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(s=>`data:image/svg+xml;charset=utf-8,${s}`)}async function W4s(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),H4s(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 G4s(t){const s=t.getPropertyValue("content");return`${t.cssText} content: '${s.replace(/'|"/g,"")}';`}function K4s(t,s){return Hlt(s).map(r=>{const n=t.getPropertyValue(r),a=t.getPropertyPriority(r);return`${r}: ${n}${a?" !important":""};`}).join(" ")}function Z4s(t,s,r,n){const a=`.${t}:${s}`,o=r.cssText?G4s(r):K4s(r,n);return document.createTextNode(`${a}{${o}}`)}function Sze(t,s,r,n){const a=window.getComputedStyle(t,r),o=a.getPropertyValue("content");if(o===""||o==="none")return;const l=B4s();try{s.className=`${s.className} ${l}`}catch{return}const i=document.createElement("style");i.appendChild(Z4s(l,r,a,n)),s.appendChild(i)}function Y4s(t,s,r){Sze(t,s,":before",r),Sze(t,s,":after",r)}const Cze="application/font-woff",Mze="image/jpeg",X4s={woff:Cze,woff2:Cze,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Mze,jpeg:Mze,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Q4s(t){const s=/\.([^./]*?)$/g.exec(t);return s?s[1]:""}function dCe(t){const s=Q4s(t).toLowerCase();return X4s[s]||""}function J4s(t){return t.split(/,/)[1]}function owe(t){return t.search(/^(data:)/)!==-1}function eSs(t,s){return`data:${s};base64,${t}`}async function Glt(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 kye={};function tSs(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 uCe(t,s,r){const n=tSs(t,s,r.includeQueryParams);if(kye[n]!=null)return kye[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let a;try{const o=await Glt(t,r.fetchRequestInit,({res:l,result:i})=>(s||(s=l.headers.get("Content-Type")||""),J4s(i)));a=eSs(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 kye[n]=a,a}async function sSs(t){const s=t.toDataURL();return s==="data:,"?t.cloneNode(!1):tde(s)}async function rSs(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 tde(i)}const r=t.poster,n=dCe(r),a=await uCe(r,n,s);return tde(a)}async function nSs(t,s){var r;try{if(!((r=t==null?void 0:t.contentDocument)===null||r===void 0)&&r.body)return await gme(t.contentDocument.body,s,!0)}catch{}return t.cloneNode(!1)}async function aSs(t,s){return Ap(t,HTMLCanvasElement)?sSs(t):Ap(t,HTMLVideoElement)?rSs(t,s):Ap(t,HTMLIFrameElement)?nSs(t,s):t.cloneNode(Klt(t))}const iSs=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",Klt=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function oSs(t,s,r){var n,a;if(Klt(s))return s;let o=[];return iSs(t)&&t.assignedNodes?o=sw(t.assignedNodes()):Ap(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?o=sw(t.contentDocument.body.childNodes):o=sw(((a=t.shadowRoot)!==null&&a!==void 0?a:t).childNodes),o.length===0||Ap(t,HTMLVideoElement)||await o.reduce((l,i)=>l.then(()=>gme(i,r)).then(c=>{c&&s.appendChild(c)}),Promise.resolve()),s}function lSs(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):Hlt(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 cSs(t,s){Ap(t,HTMLTextAreaElement)&&(s.innerHTML=t.value),Ap(t,HTMLInputElement)&&s.setAttribute("value",t.value)}function dSs(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)&&(lSs(t,s,r),Y4s(t,s,r),cSs(t,s),dSs(t,s)),s}async function hSs(t,s){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let o=0;oaSs(n,s)).then(n=>oSs(t,n,s)).then(n=>uSs(t,n,s)).then(n=>hSs(n,s))}const Zlt=/url\((['"]?)([^'"]+?)\1\)/g,mSs=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,pSs=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function fSs(t){const s=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${s})(['"]?\\))`,"g")}function xSs(t){const s=[];return t.replace(Zlt,(r,n,a)=>(s.push(a),r)),s.filter(r=>!owe(r))}async function gSs(t,s,r,n,a){try{const o=r?z4s(s,r):s,l=dCe(s);let i;return a||(i=await uCe(o,l,n)),t.replace(fSs(s),`$1${i}$3`)}catch{}return t}function ySs(t,{preferredFontFormat:s}){return s?t.replace(pSs,r=>{for(;;){const[n,,a]=mSs.exec(r)||[];if(!a)return"";if(a===s)return`src: ${n};`}}):t}function Ylt(t){return t.search(Zlt)!==-1}async function Xlt(t,s,r){if(!Ylt(t))return t;const n=ySs(t,r);return xSs(n).reduce((o,l)=>o.then(i=>gSs(i,l,s,r)),Promise.resolve(n))}async function A5(t,s,r){var n;const a=(n=s.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(a){const o=await Xlt(a,null,r);return s.style.setProperty(t,o,s.style.getPropertyPriority(t)),!0}return!1}async function vSs(t,s){await A5("background",t,s)||await A5("background-image",t,s),await A5("mask",t,s)||await A5("-webkit-mask",t,s)||await A5("mask-image",t,s)||await A5("-webkit-mask-image",t,s)}async function bSs(t,s){const r=Ap(t,HTMLImageElement);if(!(r&&!owe(t.src))&&!(Ap(t,SVGImageElement)&&!owe(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,a=await uCe(n,dCe(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 _Ss(t,s){const n=sw(t.childNodes).map(a=>Qlt(a,s));await Promise.all(n).then(()=>t)}async function Qlt(t,s){Ap(t,Element)&&(await vSs(t,s),await bSs(t,s),await _Ss(t,s))}function wSs(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 Tze={};async function Aze(t){let s=Tze[t];if(s!=null)return s;const n=await(await fetch(t)).text();return s={url:t,cssText:n},Tze[t]=s,s}async function Eze(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),Glt(i,s.fetchRequestInit,({result:c})=>(r=r.replace(l,`url(${c})`),[l,c]))});return Promise.all(o).then(()=>r)}function Pze(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 jSs(t,s){const r=[],n=[];return t.forEach(a=>{if("cssRules"in a)try{sw(a.cssRules||[]).forEach((o,l)=>{if(o.type===CSSRule.IMPORT_RULE){let i=l+1;const c=o.href,u=Aze(c).then(p=>Eze(p,s)).then(p=>Pze(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(Aze(a.href).then(i=>Eze(i,s)).then(i=>Pze(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{sw(a.cssRules||[]).forEach(o=>{r.push(o)})}catch(o){console.error(`Error while reading CSS rules from ${a.href}`,o)}}),r))}function NSs(t){return t.filter(s=>s.type===CSSRule.FONT_FACE_RULE).filter(s=>Ylt(s.style.getPropertyValue("src")))}async function kSs(t,s){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=sw(t.ownerDocument.styleSheets),n=await jSs(r,s);return NSs(n)}function Jlt(t){return t.trim().replace(/["']/g,"")}function SSs(t){const s=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(o=>{s.add(Jlt(o))}),Array.from(n.children).forEach(o=>{o instanceof HTMLElement&&r(o)})}return r(t),s}async function CSs(t,s){const r=await kSs(t,s),n=SSs(t);return(await Promise.all(r.filter(o=>n.has(Jlt(o.style.fontFamily))).map(o=>{const l=o.parentStyleSheet?o.parentStyleSheet.href:null;return Xlt(o.cssText,l,s)}))).join(` `)}async function MSs(t,s){const r=s.fontEmbedCSS!=null?s.fontEmbedCSS:s.skipFonts?null:await CSs(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 TSs(t,s={}){const{width:r,height:n}=Wlt(t,s),a=await gme(t,s,!0);return await MSs(a,s),await Qlt(a,s),wSs(a,s),await W4s(a,r,n)}async function ASs(t,s={}){const{width:r,height:n}=Wlt(t,s),a=await TSs(t,s),o=await tde(a),l=document.createElement("canvas"),i=l.getContext("2d"),c=s.pixelRatio||U4s(),u=s.canvasWidth||r,p=s.canvasHeight||n;return l.width=u*c,l.height=p*c,s.skipAutoScale||V4s(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 ESs(t,s={}){return(await ASs(t,s)).toDataURL()}const PA=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),yme={"just-listed":"JUST LISTED","just-sold":"JUST SOLD","open-house":"OPEN HOUSE","price-drop":"PRICE DROP"},Jz={"instagram-square":{width:1080,height:1080},"instagram-story":{width:1080,height:1920},"facebook-post":{width:1200,height:630}},PSs=({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})]})]}),ect=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=yme[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:PA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.028,color:"#C9A84C",marginBottom:l.w*.01},children:["Sold for ",PA(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(PSs,{branding:n,dim:l})]})]})]})});ect.displayName="LuxuryDarkTemplate";const ISs=({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})]})]}),tct=ht.forwardRef(({listing:t,postType:s,format:r,branding:n,selectedPhotoIndex:a},o)=>{var b;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=(b=t.photos)==null?void 0:b[a],u=yme[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:PA(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(ISs,{branding:n,dim:l,accentColor:g})]})]})});tct.displayName="ModernCleanTemplate";const LSs=({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})]})]}),sct=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=yme[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:PA(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(LSs,{branding:n,dim:l})]})]})]})});sct.displayName="BoldColorfulTemplate";const DSs=({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})]})]}),rct=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=yme[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:PA(t.price)}),s==="just-sold"&&t.soldPrice&&e.jsxs("div",{style:{fontSize:l.w*.02,color:"#8B7355",marginBottom:l.w*.01},children:["Sold: ",PA(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(DSs,{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"}})]})]})})});rct.displayName="EditorialTemplate";const OSs=[{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:"📉"}],Ize=[{value:"instagram-square",label:"Instagram Post",dimensions:"1080×1080",icon:e.jsx(Cu,{className:"h-4 w-4"})},{value:"instagram-story",label:"Instagram Story",dimensions:"1080×1920",icon:e.jsx(Cu,{className:"h-4 w-4"})},{value:"facebook-post",label:"Facebook Post",dimensions:"1200×630",icon:e.jsx(ku,{className:"h-4 w-4"})}],RSs=[{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:"📰"}],Lze=t=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t),Dze={"luxury-dark":ect,"modern-clean":tct,"bold-colorful":sct,editorial:rct};function FSs(){const[t,s]=k.useState(""),[r,n]=k.useState("address"),[a,o]=k.useState(!1),[l,i]=k.useState([]),[c,u]=k.useState(null),[p,f]=k.useState(0),[g,b]=k.useState("just-listed"),[_,j]=k.useState(["instagram-square"]),[w,N]=k.useState("luxury-dark"),[C,M]=k.useState(!1),[I,L]=k.useState(""),[R,q]=k.useState(""),[U,B]=k.useState(""),[V,Y]=k.useState(!1),[J,te]=k.useState(!1),[X,ce]=k.useState([]),[ne,re]=k.useState("search"),le=k.useRef({});k.useEffect(()=>{(async()=>{const{data:{user:Ce}}=await H.auth.getUser();if(!Ce)return;const{data:Me}=await H.from("profiles").select("name, avatar_url, brokerages(name)").eq("id",Ce.id).single();if(Me){L(Me.name||""),B(Me.avatar_url||"");const $e=Me.brokerages;q(($e==null?void 0:$e.name)||"")}})()},[]);const pe=async()=>{var Fe;if(t.trim()){o(!0),i([]);try{const{data:Ce,error:Me}=await H.functions.invoke("repliers-mls-search",{body:{searchType:r,query:t.trim()}});if(Me)throw Me;if(Ce.error)throw new Error(Ce.error);i(Ce.listings||[]),((Fe=Ce.listings)==null?void 0:Fe.length)===0&&he.info("No listings found. Try a different search.")}catch(Ce){he.error(Ce.message||"Search failed")}finally{o(!1)}}},xe=Fe=>{var Ce;u(Fe),f(0),re("customize"),Fe.soldDate||(Ce=Fe.status)!=null&&Ce.toLowerCase().includes("sold")?b("just-sold"):b("just-listed")},_e=Fe=>{j(Ce=>Ce.includes(Fe)?Ce.filter(Me=>Me!==Fe):[...Ce,Fe])},fe=k.useCallback(async()=>{if(!(!c||_.length===0)){Y(!0),ce([]),re("generate");try{await new Promise(Ce=>setTimeout(Ce,500));const Fe=[];for(const Ce of _){const Me=`${w}-${Ce}`,$e=le.current[Me];if(!$e)continue;const ct=Jz[Ce],Te=await ESs($e,{width:ct.width,height:ct.height,pixelRatio:1,cacheBust:!0,style:{transform:"none",transformOrigin:"top left"}});Fe.push({format:Ce,imageUrl:Te})}ce(Fe),he.success(`Generated ${Fe.length} social post${Fe.length>1?"s":""}!`)}catch(Fe){he.error(Fe.message||"Generation failed")}finally{Y(!1)}}},[c,_,w,p,C,I,R,U,g]),we=async()=>{if(!(!c||_.length===0)){Y(!0),ce([]),re("generate");try{const Fe={...c,photos:c.photos.length>0?[c.photos[p]]:[]},Ce=[];for(const Me of _){const{data:$e,error:ct}=await H.functions.invoke("generate-listing-social-post",{body:{listing:Fe,postType:g,format:Me,branding:C?{enabled:!0,agentName:I,brokerage:R}:{enabled:!1}}});if(ct)throw ct;if($e.error)throw new Error($e.error);Ce.push({format:Me,imageUrl:$e.imageUrl})}ce(Ce),he.success(`Generated ${Ce.length} AI post${Ce.length>1?"s":""}!`)}catch(Fe){he.error(Fe.message||"AI generation failed")}finally{Y(!1)}}},Ie=()=>J?we():fe(),Ne=(Fe,Ce)=>{var $e;const Me=document.createElement("a");Me.href=Fe,Me.download=`${(($e=c==null?void 0:c.address)==null?void 0:$e.replace(/\s+/g,"-"))||"listing"}-${g}-${Ce}.png`,document.body.appendChild(Me),Me.click(),document.body.removeChild(Me)},Ae=c?{listing:c,postType:g,format:"instagram-square",branding:C?{enabled:!0,agentName:I,brokerage:R,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(ah,{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(hn,{className:"h-3.5 w-3.5"})," 1. Find Listing"]}),e.jsx(xa,{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(un,{className:"h-3.5 w-3.5"})," 2. Customize"]}),e.jsx(xa,{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(fl,{className:"h-3.5 w-3.5"})," 3. Generate"]})]}),ne==="search"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(hn,{className:"h-5 w-5 text-primary"})," Search MLS Listings ",e.jsx(tXe,{})]}),e.jsx(xr,{children:"Find a listing by MLS number or property address using Repliers.io"})]}),e.jsxs(Re,{className:"space-y-4",children:[e.jsx(ja,{value:r,onValueChange:Fe=>n(Fe),children:e.jsxs(ga,{children:[e.jsxs(us,{value:"address",children:[e.jsx(Ba,{className:"h-4 w-4 mr-1.5"})," Address"]}),e.jsxs(us,{value:"mls",children:[e.jsx(Om,{className:"h-4 w-4 mr-1.5"})," MLS #"]})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(ze,{value:t,onChange:Fe=>s(Fe.target.value),placeholder:r==="mls"?"Enter MLS number...":"Enter property address...",className:"flex-1",onKeyDown:Fe=>Fe.key==="Enter"&&pe()}),e.jsxs(K,{onClick:pe,disabled:a||!t.trim(),children:[a?e.jsx(ws,{className:"h-4 w-4 animate-spin"}):e.jsx(hn,{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((Fe,Ce)=>{var Me;return e.jsx(Pe,{className:"cursor-pointer hover:border-primary/50 hover:shadow-md transition-all group",onClick:()=>xe(Fe),children:e.jsx(Re,{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:(Me=Fe.photos)!=null&&Me[0]?e.jsx("img",{src:Fe.photos[0],alt:Fe.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(Sn,{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:Lze(Fe.price)}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:Fe.address}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[Fe.city,", ",Fe.state," ",Fe.zip]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[Fe.bedrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(H4,{className:"h-3 w-3"})," ",Fe.bedrooms]}),Fe.bathrooms>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Nh,{className:"h-3 w-3"})," ",Fe.bathrooms]}),Fe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(rS,{className:"h-3 w-3"})," ",Fe.sqft.toLocaleString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Fe.mlsNumber}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Fe.status})]})]})]})})},Fe.mlsNumber||Ce)})})]})]}),ne==="customize"&&c&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(Pe,{className:"lg:col-span-1",children:[e.jsx(Dt,{className:"pb-3",children:e.jsx(zt,{className:"text-base",children:"Selected Listing"})}),e.jsxs(Re,{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(Fe=>Math.max(0,Fe-1)),disabled:p===0,children:e.jsx(ll,{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(Fe=>Math.min(c.photos.length-1,Fe+1)),disabled:p===c.photos.length-1,children:e.jsx(xa,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-lg",children:Lze(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(c1,{className:"h-3.5 w-3.5 mr-1.5"})," Choose Different Listing"]})]})]}),e.jsxs(Pe,{className:"lg:col-span-2",children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(un,{className:"h-5 w-5 text-primary"})," Customize Your Post"]}),e.jsx(xr,{children:"Choose template, post type, format, and branding"})]}),e.jsxs(Re,{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(sc,{className:"h-4 w-4 text-primary"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:J?"AI Custom Generation":"Template-Based (Free)"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:J?"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($r,{checked:J,onCheckedChange:te}),J&&e.jsx(zv,{className:"h-4 w-4 text-purple-500"})]})]}),!J&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(sc,{className:"h-4 w-4"})," Template Style"]}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:RSs.map(Fe=>e.jsxs("button",{onClick:()=>N(Fe.value),className:`flex flex-col items-center gap-1 px-3 py-3 rounded-lg border-2 transition-all text-center ${w===Fe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-2xl",children:Fe.preview}),e.jsx("span",{className:"text-sm font-medium",children:Fe.label}),e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Fe.description})]},Fe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Post Type"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2",children:OSs.map(Fe=>e.jsxs("button",{onClick:()=>b(Fe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm font-medium ${g===Fe.value?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("span",{className:"text-lg",children:Fe.icon})," ",Fe.label]},Fe.value))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{className:"text-sm font-medium",children:"Output Formats"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-2",children:Ize.map(Fe=>e.jsxs("button",{onClick:()=>_e(Fe.value),className:`flex items-center gap-2 px-3 py-2.5 rounded-lg border-2 transition-all text-sm ${_.includes(Fe.value)?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[Fe.icon,e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"font-medium",children:Fe.label}),e.jsx("p",{className:"text-[10px] text-muted-foreground",children:Fe.dimensions})]})]},Fe.value))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(to,{className:"h-4 w-4"})," Agent Branding"]}),e.jsx($r,{checked:C,onCheckedChange:M})]}),C&&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(ye,{className:"text-xs text-muted-foreground",children:"Agent Name"}),e.jsx(ze,{value:I,onChange:Fe=>L(Fe.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ye,{className:"text-xs text-muted-foreground",children:"Brokerage (optional)"}),e.jsx(ze,{value:R,onChange:Fe=>q(Fe.target.value),placeholder:"XYZ Realty"})]})]})]})]}),!J&&Ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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*(Jz[_[0]||"instagram-square"].height/Jz[_[0]||"instagram-square"].width)},children:(()=>{const Fe=Dze[w],Ce=_[0]||"instagram-square";return e.jsx(Fe,{...Ae,format:Ce})})()})})]}),e.jsx(K,{onClick:Ie,disabled:_.length===0||V,size:"lg",className:"w-full gap-2",children:V?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 animate-spin"})," Generating ",_.length," post",_.length>1?"s":"","..."]}):e.jsxs(e.Fragment,{children:[J?e.jsx(zv,{className:"h-5 w-5"}):e.jsx(un,{className:"h-5 w-5"}),"Generate ",_.length," Social Post",_.length>1?"s":"",J&&e.jsx(tt,{variant:"outline",className:"ml-2 text-[10px]",children:"Uses Credits"})]})})]})]})]}),ne==="generate"&&e.jsxs("div",{className:"space-y-4",children:[V&&e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(ws,{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:J?"AI is creating your unique designs":"Rendering templates to high-res images"})]})}),X.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(c1,{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:X.map((Fe,Ce)=>{const Me=Ize.find($e=>$e.value===Fe.format);return e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsx("div",{className:"bg-muted/30 p-1",children:e.jsx("img",{src:Fe.imageUrl,alt:`${Fe.format} social post`,className:"w-full rounded"})}),e.jsxs(Re,{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:[Me==null?void 0:Me.icon,e.jsx("span",{className:"text-sm font-medium",children:Me==null?void 0:Me.label})]}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:Me==null?void 0:Me.dimensions})]}),e.jsxs(K,{size:"sm",className:"w-full gap-1.5",onClick:()=>Ne(Fe.imageUrl,Fe.format),children:[e.jsx(Ci,{className:"h-3.5 w-3.5"})," Download"]})]})]},Ce)})})]})]}),ne==="generate"&&!J&&c&&Ae&&e.jsx("div",{style:{position:"absolute",left:"-9999px",top:0},"aria-hidden":!0,children:_.map(Fe=>{const Ce=Dze[w],Me=Jz[Fe];return e.jsx("div",{style:{width:Me.width,height:Me.height},children:e.jsx(Ce,{ref:$e=>{le.current[`${w}-${Fe}`]=$e},...Ae,format:Fe})},`${w}-${Fe}`)})})]})})}function zSs(){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 BSs(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 $Ss(){const t=es();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 nct(){const t=es();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 qSs(){const t=es();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 USs(){const t=es();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 VSs(){const t=es();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 HSs(){const t=es();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 WSs(){const t=es();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 GSs(){const t=es();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 KSs(){const t=es();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 ZSs(){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 YSs(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 act(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 XSs(){const t=es();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 QSs(){const{user:t}=Rs(),s=pr(),{data:r,isLoading:n}=zSs(),a=$Ss(),o=nct(),l=qSs(),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(!0),j=async()=>{if(!(!u.trim()||!t))try{const C=await a.mutateAsync({title:u.trim(),description:f.trim()||void 0,is_sequential:b,created_by:t.id});he.success("Course created"),c(!1),p(""),g(""),_(!0),s(`/admin/lms/${C.id}`)}catch{he.error("Failed to create course")}},w=async C=>{try{await o.mutateAsync({id:C.id,is_published:!C.is_published}),he.success(C.is_published?"Course unpublished":"Course published")}catch{he.error("Failed to update course")}},N=async C=>{if(confirm("Delete this course and all its modules? This cannot be undone."))try{await l.mutateAsync(C),he.success("Course deleted")}catch{he.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(Gh,{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(Ro,{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(C=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Dt,{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"})]})},C))}):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(C=>{var R,q;const M=((q=(R=C.modules)==null?void 0:R[0])==null?void 0:q.count)??0,I=C.access||[],L=I.length===0?"No access set":I.some(U=>U.access_type==="all")?"All agents":`${I.length} rule(s)`;return e.jsxs(Pe,{className:"group hover:shadow-md transition-all hover:border-primary/50 cursor-pointer",onClick:()=>s(`/admin/lms/${C.id}`),children:[e.jsx(Dt,{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(zt,{className:"text-base truncate",children:C.title}),C.description&&e.jsx(xr,{className:"mt-1 line-clamp-2",children:C.description})]}),e.jsx(tt,{variant:C.is_published?"default":"secondary",className:"ml-2 shrink-0",children:C.is_published?"Published":"Draft"})]})}),e.jsxs(Re,{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(kh,{className:"h-3.5 w-3.5"}),M," module",M!==1?"s":""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[C.is_sequential?e.jsx(h0,{className:"h-3.5 w-3.5"}):e.jsx(lS,{className:"h-3.5 w-3.5"}),C.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mr,{className:"h-3.5 w-3.5"}),L]})]}),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(),w(C)},children:[C.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(qn,{className:"h-3.5 w-3.5 mr-1"}),C.is_published?"Unpublish":"Publish"]}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:U=>{U.stopPropagation(),N(C.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"flex-1"}),e.jsx(fi,{className:"h-4 w-4 text-muted-foreground"})]})]})]},C.id)})}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(kh,{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(_s,{children:[e.jsx(bs,{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(ye,{children:"Course Title"}),e.jsx(ze,{value:u,onChange:C=>p(C.target.value),placeholder:"e.g. LevelUp Onboarding"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:f,onChange:C=>g(C.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($r,{checked:b,onCheckedChange:_})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:j,disabled:!u.trim()||a.isPending,children:a.isPending?"Creating...":"Create Course"})]})]})})]})}function JSs(){const{courseId:t}=yo(),s=pr(),{data:r,isLoading:n}=BSs(t),a=nct(),o=USs(),l=VSs(),i=HSs(),c=WSs(),u=GSs(),p=KSs(),{data:f}=mt({queryKey:["all-brokerages"],queryFn:async()=>{const{data:qe}=await H.from("brokerages").select("id, name").order("name");return qe||[]}}),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),[C,M]=k.useState(null),[I,L]=k.useState({title:"",resource_type:"link",url:""}),[R,q]=k.useState(new Set),[U,B]=k.useState(null),[V,Y]=k.useState(0),[J,te]=k.useState(!1),X=k.useRef(null),ce=k.useRef(null),[ne,re]=k.useState(!1),[le,pe]=k.useState(""),[xe,_e]=k.useState(""),[fe,we]=k.useState(""),[Ie,Ne]=k.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(ri,{className:"h-4 w-4 mr-2"})," Back to Courses"]})]})});const Ae=r.modules||[],Fe=r.access||[],Ce=Fe.some(qe=>qe.access_type==="all"),Me=Fe.filter(qe=>qe.access_type==="brokerage").map(qe=>qe.brokerage_id),$e=(f||[]).filter(qe=>qe.name.toLowerCase().includes(le.toLowerCase())),ct=qe=>{const Ze=new Set(R);Ze.has(qe)?Ze.delete(qe):Ze.add(qe),q(Ze)},Te=async()=>{if(!U)return null;te(!0),Y(0);try{const{data:qe,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:He}=qe,{data:Qe,error:at}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:Je,libraryId:He}});if(at)throw new Error(at.message);const It=new XMLHttpRequest;return await new Promise((Ut,hs)=>{It.upload.onprogress=Yt=>{Yt.lengthComputable&&Y(Math.round(Yt.loaded/Yt.total*100))},It.onload=()=>It.status>=200&&It.status<300?Ut():hs(new Error(`Upload failed: ${It.status}`)),It.onerror=()=>hs(new Error("Upload failed")),It.open("PUT",Qe.uploadUrl),It.setRequestHeader("AccessKey",Qe.apiKey),It.send(U)}),`https://iframe.mediadelivery.net/embed/${He}/${Je}`}catch(qe){return console.error("Bunny upload error:",qe),he.error("Video upload failed"),null}finally{te(!1),Y(0)}},ft=async()=>{if(w.title.trim())try{let qe=w.video_url.trim()||void 0;if(U){const Ze=await Te();if(!Ze)return;qe=Ze}await o.mutateAsync({course_id:r.id,title:w.title.trim(),description:w.description.trim()||void 0,video_url:qe,text_content:w.text_content.trim()||void 0,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):void 0,sort_order:Ae.length}),he.success("Module added"),j(!1),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""}),B(null)}catch{he.error("Failed to add module")}},me=async()=>{if(g)try{let qe=w.video_url.trim()||null;if(U){const Ze=await Te();if(!Ze)return;qe=Ze}await l.mutateAsync({id:g.id,title:w.title.trim(),description:w.description.trim()||null,video_url:qe,text_content:w.text_content.trim()||null,duration_minutes:w.duration_minutes?parseInt(w.duration_minutes):null}),he.success("Module updated"),b(null),B(null)}catch{he.error("Failed to update")}},Ve=async qe=>{if(confirm("Delete this module?"))try{await i.mutateAsync(qe),he.success("Module deleted")}catch{he.error("Failed to delete")}},nt=async qe=>{if(I.title.trim())try{await c.mutateAsync({module_id:qe,title:I.title.trim(),resource_type:I.resource_type,url:I.url.trim()||void 0}),he.success("Resource added"),M(null),L({title:"",resource_type:"link",url:""})}catch{he.error("Failed to add resource")}},et=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[{access_type:"all"}]}),he.success("Access updated: All brokerages / all agents")}catch{he.error("Failed to update access")}},Se=async qe=>{const Ze=Fe.filter(at=>at.access_type==="brokerage").map(at=>at.brokerage_id),Je=Ze.includes(qe);let He;Je?He=Ze.filter(at=>at!==qe):He=[...Ze,qe];const Qe=He.map(at=>({access_type:"brokerage",brokerage_id:at}));try{await p.mutateAsync({courseId:r.id,accessRules:Qe}),he.success(Je?"Brokerage removed":"Brokerage added")}catch{he.error("Failed to update access")}},rt=async()=>{try{await p.mutateAsync({courseId:r.id,accessRules:[]}),he.success("Access cleared")}catch{he.error("Failed")}},Ge=async(qe,Ze)=>{const Je=Ze==="up"?qe-1:qe+1;if(!(Je<0||Je>=Ae.length))try{await Promise.all([l.mutateAsync({id:Ae[qe].id,sort_order:Je}),l.mutateAsync({id:Ae[Je].id,sort_order:qe})])}catch{he.error("Failed to reorder")}},lt=async()=>{try{await a.mutateAsync({id:r.id,title:xe,description:fe||null}),he.success("Course updated"),Ne(!1)}catch{he.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(ri,{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(tt,{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(h0,{className:"h-3.5 w-3.5"}):e.jsx(lS,{className:"h-3.5 w-3.5"}),r.is_sequential?"Sequential":"Free order"]}),e.jsxs("span",{children:[Ae.length," module",Ae.length!==1?"s":""]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>{_e(r.title),we(r.description||""),Ne(!0)},children:[e.jsx(Da,{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(()=>he.success(r.is_published?"Unpublished":"Published")),children:[r.is_published?e.jsx(kp,{className:"h-3.5 w-3.5 mr-1"}):e.jsx(qn,{className:"h-3.5 w-3.5 mr-1"}),r.is_published?"Unpublish":"Publish"]})]})]}),e.jsxs(ja,{defaultValue:"modules",className:"w-full",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"modules",children:"Modules"}),e.jsx(us,{value:"access",children:"Access & Permissions"}),e.jsx(us,{value:"settings",children:"Settings"})]}),e.jsxs(ks,{value:"modules",className:"mt-6 space-y-4",children:[Ae.map((qe,Ze)=>e.jsxs(Pe,{className:"overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-3 p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>ct(qe.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(),Ge(Ze,"up")},disabled:Ze===0,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(pf,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:Je=>{Je.stopPropagation(),Ge(Ze,"down")},disabled:Ze===Ae.length-1,className:"hover:text-foreground disabled:opacity-30",children:e.jsx(To,{className:"h-3.5 w-3.5"})})]})}),e.jsx(tt,{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:qe.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mt-0.5",children:[qe.video_url&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(Cn,{className:"h-3 w-3"})," Video"]}),qe.text_content&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(En,{className:"h-3 w-3"})," Text"]}),qe.duration_minutes&&e.jsxs("span",{children:[qe.duration_minutes," min"]}),qe.resources&&qe.resources.length>0&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(cl,{className:"h-3 w-3"})," ",qe.resources.length," resource(s)"]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{size:"sm",variant:"ghost",onClick:Je=>{var He;Je.stopPropagation(),b(qe),N({title:qe.title,description:qe.description||"",video_url:qe.video_url||"",text_content:qe.text_content||"",duration_minutes:((He=qe.duration_minutes)==null?void 0:He.toString())||""})},children:e.jsx(Da,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"ghost",className:"text-destructive",onClick:Je=>{Je.stopPropagation(),Ve(qe.id)},children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]}),R.has(qe.id)&&e.jsxs("div",{className:"border-t bg-muted/30 p-4 space-y-3",children:[qe.description&&e.jsx("p",{className:"text-sm text-muted-foreground",children:qe.description}),qe.video_url&&e.jsxs("div",{className:"text-xs",children:[e.jsx("span",{className:"text-muted-foreground",children:"Video: "}),e.jsx("a",{href:qe.video_url,target:"_blank",rel:"noreferrer",className:"text-primary hover:underline break-all",children:qe.video_url})]}),qe.text_content&&e.jsx("div",{className:"text-sm bg-background rounded-md p-3 border max-h-40 overflow-auto whitespace-pre-wrap",children:qe.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(qe.id),L({title:"",resource_type:"link",url:""})},children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add Resource"]})]}),qe.resources&&qe.resources.length>0?e.jsx("div",{className:"space-y-1",children:qe.resources.map(Je=>e.jsxs("div",{className:"flex items-center gap-2 text-sm bg-background rounded p-2 border",children:[e.jsx(tt,{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(Or,{className:"h-3 w-3"})})]},Je.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"No resources yet"})]})]})]},qe.id)),e.jsxs(K,{variant:"outline",className:"w-full border-dashed",onClick:()=>{j(!0),N({title:"",description:"",video_url:"",text_content:"",duration_minutes:""})},children:[e.jsx(qs,{className:"h-4 w-4 mr-2"})," Add Module"]})]}),e.jsx(ks,{value:"access",className:"mt-6 space-y-4",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Who can access this course?"})}),e.jsxs(Re,{className:"space-y-5",children:[e.jsxs("div",{className:Pt("flex items-center gap-3 p-4 rounded-xl border-2 cursor-pointer transition-all",Ce?"border-primary bg-primary/5":"border-muted hover:border-muted-foreground/30"),onClick:et,children:[e.jsx("div",{className:Pt("h-10 w-10 rounded-full flex items-center justify-center shrink-0",Ce?"bg-primary/15 text-primary":"bg-muted text-muted-foreground"),children:e.jsx(Su,{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($r,{checked:Ce,onCheckedChange:et})]}),!Ce&&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:Me.length===0?"No brokerages selected — agents won't see this course":`${Me.length} brokerage${Me.length!==1?"s":""} selected`})]}),Me.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:le,onChange:qe=>pe(qe.target.value),className:"h-9"}),e.jsx("div",{className:"border rounded-lg divide-y max-h-[360px] overflow-auto",children:$e.length===0?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"No brokerages found"}):$e.map(qe=>{const Ze=Me.includes(qe.id);return e.jsxs("div",{className:Pt("flex items-center gap-3 px-3 py-2.5 cursor-pointer transition-colors",Ze?"bg-primary/5":"hover:bg-muted/50"),onClick:()=>Se(qe.id),children:[e.jsx("div",{className:Pt("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(wa,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm flex-1 truncate",children:qe.name}),Ze&&e.jsx(tt,{variant:"secondary",className:"text-[10px] shrink-0",children:"Active"})]},qe.id)})})]})]})]})}),e.jsxs(ks,{value:"settings",className:"mt-6 space-y-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Course Thumbnail"})}),e.jsx(Re,{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(()=>he.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(Or,{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(n1,{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 qe=>{var Je;const Ze=(Je=qe.target.files)==null?void 0:Je[0];if(!(!Ze||!r)){re(!0);try{const He=Ze.name.split(".").pop(),Qe=`${r.id}/thumbnail.${He}`,{error:at}=await H.storage.from("lms-thumbnails").upload(Qe,Ze,{upsert:!0});if(at)throw at;const{data:It}=H.storage.from("lms-thumbnails").getPublicUrl(Qe),Ut=`${It.publicUrl}?t=${Date.now()}`;await a.mutateAsync({id:r.id,thumbnail_url:Ut}),he.success("Thumbnail uploaded")}catch{he.error("Failed to upload thumbnail")}finally{re(!1),ce.current&&(ce.current.value="")}}}}),e.jsxs(K,{variant:"outline",size:"sm",disabled:ne,onClick:()=>{var qe;return(qe=ce.current)==null?void 0:qe.click()},children:[ne?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(oi,{className:"h-4 w-4 mr-2"}),ne?"Uploading...":"Upload Thumbnail"]})]})]})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Course Settings"})}),e.jsxs(Re,{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($r,{checked:r.is_sequential,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_sequential:qe}).then(()=>he.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($r,{checked:r.is_published,onCheckedChange:qe=>a.mutateAsync({id:r.id,is_published:qe}).then(()=>he.success("Updated"))})]})]})]})]})]})]}),e.jsx(xs,{open:_||!!g,onOpenChange:qe=>{qe||(j(!1),b(null))},children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Title"}),e.jsx(ze,{value:w.title,onChange:qe=>N(Ze=>({...Ze,title:qe.target.value})),placeholder:"Module title"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:w.description,onChange:qe=>N(Ze=>({...Ze,description:qe.target.value})),placeholder:"Brief description",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Video"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:Pt("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 qe;return(qe=X.current)==null?void 0:qe.click()},children:[e.jsx("input",{ref:X,type:"file",accept:"video/*",className:"hidden",onChange:qe=>{var Je;const Ze=(Je=qe.target.files)==null?void 0:Je[0];Ze&&(B(Ze),N(He=>({...He,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:qe=>{qe.stopPropagation(),B(null)},children:e.jsx(Or,{className:"h-3 w-3"})})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1 text-muted-foreground",children:[e.jsx(oi,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Click to upload a video file"})]})]}),J&&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(ws,{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:w.video_url,onChange:qe=>N(Ze=>({...Ze,video_url:qe.target.value})),placeholder:"YouTube, Vimeo, or Bunny.net URL"})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Text Content"}),e.jsx(Er,{value:w.text_content,onChange:qe=>N(Ze=>({...Ze,text_content:qe.target.value})),placeholder:"Additional text content, instructions, notes...",rows:4})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Duration (minutes)"}),e.jsx(ze,{type:"number",value:w.duration_minutes,onChange:qe=>N(Ze=>({...Ze,duration_minutes:qe.target.value})),placeholder:"e.g. 15"})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>{j(!1),b(null),B(null)},children:"Cancel"}),e.jsxs(K,{onClick:g?me:ft,disabled:!w.title.trim()||J,children:[J?e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}):e.jsx(ed,{className:"h-4 w-4 mr-2"}),J?"Uploading...":g?"Save Changes":"Add Module"]})]})]})}),e.jsx(xs,{open:!!C,onOpenChange:qe=>{qe||M(null)},children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Title"}),e.jsx(ze,{value:I.title,onChange:qe=>L(Ze=>({...Ze,title:qe.target.value})),placeholder:"Resource title"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Type"}),e.jsxs(Ys,{value:I.resource_type,onValueChange:qe=>L(Ze=>({...Ze,resource_type:qe})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{children:"URL"}),e.jsx(ze,{value:I.url,onChange:qe=>L(Ze=>({...Ze,url:qe.target.value})),placeholder:"https://..."})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>M(null),children:"Cancel"}),e.jsx(K,{onClick:()=>C&&nt(C),disabled:!I.title.trim(),children:"Add Resource"})]})]})}),e.jsx(xs,{open:Ie,onOpenChange:Ne,children:e.jsxs(fs,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(ye,{children:"Title"}),e.jsx(ze,{value:xe,onChange:qe=>_e(qe.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:fe,onChange:qe=>we(qe.target.value),rows:3})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>Ne(!1),children:"Cancel"}),e.jsx(K,{onClick:lt,disabled:!xe.trim(),children:"Save"})]})]})})]})}function eCs(){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 tCs(){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 sCs(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 rCs(){const t=pr(),{data:s,isLoading:r}=eCs(),{data:n,isLoading:a}=tCs(),[o,l]=k.useState(null),{data:i,isLoading:c}=sCs(o),[u,p]=k.useState(""),f=n==null?void 0:n.find(_=>_.course_id===o),g=i==null?void 0:i.filter(_=>{var j,w;return!u||((j=_.agent_name)==null?void 0:j.toLowerCase().includes(u.toLowerCase()))||((w=_.email)==null?void 0:w.toLowerCase().includes(u.toLowerCase()))}),b=[{label:"Total Courses",value:(s==null?void 0:s.total_courses)??0,icon:kh,color:"text-primary"},{label:"Published",value:(s==null?void 0:s.published_courses)??0,icon:la,color:"text-emerald-500"},{label:"Enrolled Agents",value:(s==null?void 0:s.total_enrollments)??0,icon:mr,color:"text-blue-500"},{label:"Modules Completed",value:(s==null?void 0:s.total_completions)??0,icon:xo,color:"text-amber-500"},{label:"Active (30d)",value:(s==null?void 0:s.active_learners)??0,icon:Ol,color:"text-violet-500"},{label:"Total Modules",value:(s==null?void 0:s.total_modules)??0,icon:Ro,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(ri,{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(Gh,{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:b.map(_=>e.jsx(Pe,{className:Pt("transition-all",r&&"animate-pulse"),children:e.jsxs(Re,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(_.icon,{className:Pt("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(Ro,{className:"h-5 w-5 text-primary"}),"Course Breakdown"]}),a?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(_=>e.jsx(Pe,{className:"animate-pulse",children:e.jsx(Re,{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 j=o===_.course_id;return e.jsx(Pe,{className:Pt("cursor-pointer transition-all hover:shadow-md",j?"border-primary ring-1 ring-primary/30 shadow-md":"hover:border-primary/40"),onClick:()=>l(j?null:_.course_id),children:e.jsxs(Re,{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(tt,{variant:_.is_published?"default":"secondary",className:"shrink-0 text-[10px] px-1.5 py-0",children:_.is_published?"Live":"Draft"})]})}),e.jsx(xa,{className:Pt("h-4 w-4 text-muted-foreground transition-transform shrink-0 ml-2",j&&"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(Pe,{className:"border-dashed",children:e.jsx(Re,{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(V_,{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(hn,{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(Pe,{className:"animate-pulse",children:e.jsx(Re,{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((_,j)=>{const w=_.completion_pct>=100;return e.jsx(Pe,{className:Pt("transition-all",w&&"border-emerald-200 bg-emerald-50/30 dark:border-emerald-900/40 dark:bg-emerald-950/10"),children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:Pt("flex items-center justify-center w-7 h-7 rounded-full text-xs font-bold shrink-0",j===0?"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400":j===1?"bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-400":j===2?"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400":"bg-muted text-muted-foreground"),children:j+1}),e.jsxs(_n,{className:"h-9 w-9 shrink-0",children:[e.jsx(za,{src:_.avatar_url||void 0}),e.jsx(wn,{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}),w&&e.jsxs(tt,{variant:"default",className:"text-[10px] px-1.5 py-0 bg-emerald-500 hover:bg-emerald-600 shrink-0",children:[e.jsx(la,{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(mn,{className:"h-3 w-3"}),ps(new Date(_.last_activity),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"text-right shrink-0 w-20",children:[e.jsxs("p",{className:Pt("text-sm font-bold",w?"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(Pe,{className:"border-dashed",children:e.jsx(Re,{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(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"py-16 text-center",children:[e.jsx(mr,{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 nCs(){const{user:t}=Rs(),s=pr(),{data:r,isLoading:n}=ZSs();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(Gh,{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(Pe,{className:"animate-pulse",children:e.jsxs(Re,{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(aCs,{course:a,userId:t==null?void 0:t.id,onClick:()=>s(`/levelup-u/${a.id}`)},a.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(kh,{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 aCs({course:t,userId:s,onClick:r}){var i;const n=((i=t.modules)==null?void 0:i.length)??0,{data:a}=act(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(Pe,{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(Gh,{className:"h-10 w-10 text-primary/40"})}),e.jsxs(Re,{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(kh,{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(h0,{className:"h-3.5 w-3.5"}):e.jsx(lS,{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(xa,{className:"h-3.5 w-3.5"})]})})]})]})}function iCs(){const{courseId:t}=yo(),s=pr(),{user:r}=Rs(),{data:n,isLoading:a}=YSs(t),{data:o}=act(t),l=XSs(),[i,c]=k.useState(null),u=(n==null?void 0:n.modules)||[],p=new Set((o==null?void 0:o.filter(C=>C.completed).map(C=>C.module_id))||[]),f=p.size,g=u.length>0?Math.round(f/u.length*100):0;k.useEffect(()=>{if(u.length>0&&!i){const C=u.find(M=>!p.has(M.id));c((C==null?void 0:C.id)||u[0].id)}},[u,i,p]);const b=u.find(C=>C.id===i),_=u.findIndex(C=>C.id===i),j=(C,M)=>{if(!(n!=null&&n.is_sequential)||M===0)return!1;for(let I=0;I{if(!(!b||!r||!t))try{await l.mutateAsync({courseId:t,moduleId:b.id,userId:r.id}),he.success("Module completed! 🎉"),_{const M=C.match(/(?:youtube\.com\/(?:watch\?v=|embed\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/);if(M)return`https://www.youtube.com/embed/${M[1]}`;const I=C.match(/vimeo\.com\/(\d+)/);if(I)return`https://player.vimeo.com/video/${I[1]}`;const L=C.match(/(?:iframe\.mediadelivery\.net|video\.bunnycdn\.com)\/(?:play|embed)\/(\d+)\/([a-f0-9-]+)/);return L?`https://iframe.mediadelivery.net/embed/${L[1]}/${L[2]}?responsive=true`:C};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(ri,{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(Pe,{className:"lg:sticky lg:top-4",children:e.jsxs(Re,{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(Gi,{className:"max-h-[calc(100vh-280px)]",children:e.jsx("div",{className:"p-1",children:u.map((C,M)=>{const I=j(C,M),L=p.has(C.id),R=C.id===i;return e.jsxs("button",{disabled:I,onClick:()=>!I&&c(C.id),className:Pt("w-full flex items-center gap-3 p-3 rounded-lg text-left transition-all text-sm",R?"bg-primary/10 text-primary":"hover:bg-muted/50",I&&"opacity-50 cursor-not-allowed"),children:[e.jsx("div",{className:"shrink-0",children:I?e.jsx(Mh,{className:"h-4 w-4 text-muted-foreground"}):L?e.jsx(la,{className:"h-4 w-4 text-green-500"}):e.jsx(vd,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:Pt("font-medium truncate",R&&"text-primary"),children:[M+1,". ",C.title]}),C.duration_minutes&&e.jsxs("span",{className:"text-[11px] text-muted-foreground flex items-center gap-0.5 mt-0.5",children:[e.jsx(mn,{className:"h-3 w-3"})," ",C.duration_minutes," min"]})]})]},C.id)})})})]})}),e.jsx("div",{className:"space-y-4",children:b?e.jsxs(e.Fragment,{children:[b.video_url&&e.jsx(Pe,{className:"overflow-hidden",children:e.jsx("div",{className:"aspect-video bg-black",children:e.jsx("iframe",{src:N(b.video_url),className:"w-full h-full",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})}),e.jsx(Pe,{children:e.jsxs(Re,{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:b.title}),b.description&&e.jsx("p",{className:"text-muted-foreground mt-1",children:b.description})]}),p.has(b.id)?e.jsxs(tt,{className:"bg-green-500/15 text-green-600 border-green-500/30 shrink-0",children:[e.jsx(la,{className:"h-3.5 w-3.5 mr-1"})," Completed"]}):e.jsxs(K,{size:"sm",onClick:w,disabled:l.isPending,children:[e.jsx(la,{className:"h-4 w-4 mr-1"}),"Mark Complete"]})]}),b.text_content&&e.jsx("div",{className:"prose prose-sm max-w-none text-foreground border-t pt-4 whitespace-pre-wrap",children:b.text_content}),b.resources&&b.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:b.resources.map(C=>e.jsxs("a",{href:C.url||C.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:[C.resource_type==="pdf"?e.jsx(En,{className:"h-4 w-4 text-red-500 shrink-0"}):C.resource_type==="template"?e.jsx(Gh,{className:"h-4 w-4 text-purple-500 shrink-0"}):e.jsx(cl,{className:"h-4 w-4 text-blue-500 shrink-0"}),e.jsx("span",{className:"flex-1 truncate",children:C.title}),e.jsx(an,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"})]},C.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(ri,{className:"h-3.5 w-3.5 mr-1"})," Previous"]}),_c(u[_+1].id),children:["Next ",e.jsx(xa,{className:"h-3.5 w-3.5 ml-1"})]}):g===100&&e.jsx(tt,{className:"bg-green-500/15 text-green-600 border-green-500/30 text-sm px-3 py-1.5",children:"🎉 Course Complete!"})]})]})})]}):e.jsx(Pe,{children:e.jsx(Re,{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(ri,{className:"h-4 w-4 mr-2"})," Back"]})]})})}function oCs({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(Ws.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(Ws.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(Ws.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(Ws.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(Ws.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(fi,{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(Ws.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 yw({children:t,className:s="",delay:r=0,direction:n="up"}){const a=k.useRef(null),o=xEt(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(Ws.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 lCs({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(yw,{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(yw,{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 cCs({images:t,primaryColor:s,accentColor:r}){const[n,a]=k.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(yw,{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(mr,{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(yw,{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(Or,{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 dCs({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(yw,{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(yw,{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(U_,{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 uCs({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(yw,{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(yw,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{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(ye,{className:"text-gray-700 text-sm font-medium",children:"Why are you interested?"}),e.jsx(Er,{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(fi,{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(Th,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Your information is confidential and will not be shared."})]})]})})]})]})}function hCs(){const{slug:t}=yo(),{toast:s}=qa(),[r,n]=k.useState(!1),[a,o]=k.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:I}=await H.from("brokerages").select("id, name, recruit_form_enabled").eq("recruit_form_slug",t).single();if(I)throw I;return M},enabled:!!t}),{data:u}=mt({queryKey:["recruit-landing-public",l==null?void 0:l.id],queryFn:async()=>{const{data:M,error:I}=await H.from("recruit_landing_page_settings").select("*").eq("brokerage_id",l.id).single();if(I&&I.code!=="PGRST116")throw I;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:I}=await H.from("recruit_interest_submissions").insert(M);if(I)throw I;H.functions.invoke("recruit-lead-notify",{body:{lead:M,brokerage_id:l.id}}).catch(L=>console.error("Lead notification error:",L))},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(wa,{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",b=(f==null?void 0:f.accent_color)||"#2a4c64",_=(f==null?void 0:f.benefits)||[],j=(f==null?void 0:f.testimonials)||[],w=(f==null?void 0:f.gallery_images)||[],N=(f==null?void 0:f.hero_headline)||`Join ${l.name}`,C=(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(Ws.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}, ${b})`},children:e.jsx(fa,{className:"h-10 w-10 text-white"})}),e.jsx("h2",{className:"text-3xl font-bold mb-3 tracking-tight",style:{color:b},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:b},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":b},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:b},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}, ${b})`},children:["Apply Now ",e.jsx(fi,{className:"h-3.5 w-3.5"})]})]})}),e.jsx(oCs,{headline:N,subtext:C,primaryColor:g,accentColor:b,heroImageUrl:f==null?void 0:f.hero_image_url,logoUrl:f==null?void 0:f.logo_url,brokerageName:l.name}),e.jsx(lCs,{benefits:_,accentColor:b,primaryColor:g}),e.jsx(cCs,{images:w,primaryColor:g,accentColor:b}),e.jsx(dCs,{testimonials:j,primaryColor:g,accentColor:b}),e.jsx(uCs,{form:a,setForm:o,onSubmit:()=>p.mutate(),isPending:p.isPending,primaryColor:g,accentColor:b}),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 mCs(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 pCs(){var g,b,_,j;const{shareToken:t}=yo(),s=k.useRef(!1),{data:r,isLoading:n,error:a}=mt({queryKey:["public-recruit-video",t],queryFn:async()=>{var L;if(!t)throw new Error("No token");const{data:w,error:N}=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(N)throw N;const{data:C}=await H.from("profiles").select("name, avatar_url, title").eq("id",(L=w.video)==null?void 0:L.owner_user_id).single(),{data:M}=await H.from("brokerages").select("name").eq("id",w.brokerage_id).single(),{data:I}=await H.from("recruit_landing_page_settings").select("logo_url, primary_color, accent_color, hero_headline").eq("brokerage_id",w.brokerage_id).maybeSingle();return{rv:w,profile:C,brokerage:M,settings:I}},enabled:!!t});if(k.useEffect(()=>{var w;!((w=r==null?void 0:r.rv)!=null&&w.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=((b=o.prospect)==null?void 0:b.first_name)||"there",f=(_=o.video)!=null&&_.playback_url?mCs(o.video.playback_url):null;return e.jsxs(e.Fragment,{children:[e.jsx(rd,{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:((j=l==null?void 0:l.name)==null?void 0:j.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(cn,{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 fCs(){const t=pr(),s=es(),{isAdmin:r}=Rs(),[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState(null),{data:u,isLoading:p}=mt({queryKey:["my-social-accounts"],queryFn:async()=>{const{data:{user:L},error:R}=await H.auth.getUser();if(R)throw R;if(!L)return[];const{data:q,error:U}=await H.from("social_accounts").select("*").eq("user_id",L.id).order("created_at",{ascending:!1});if(U)throw U;return q}}),f=Lt({mutationFn:async L=>{const{data:{user:R},error:q}=await H.auth.getUser();if(q)throw q;if(!R)throw new Error("Not authenticated");const{error:U}=await H.from("social_accounts").delete().eq("id",L).eq("user_id",R.id);if(U)throw U},onSuccess:()=>{s.invalidateQueries({queryKey:["my-social-accounts"]}),s.invalidateQueries({queryKey:["social-accounts-for-post"]}),he.success("Account disconnected successfully")},onError:()=>{he.error("Failed to disconnect account")}}),g=async()=>{a(!0);try{const{data:L,error:R}=await H.functions.invoke("meta-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/callback"}});if(R)throw R;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),he.error("Failed to start connection. Please try again."),a(!1)}},b=async()=>{a(!0);try{const{data:L,error:R}=await H.functions.invoke("linkedin-oauth",{body:{action:"get_auth_url",callbackPath:"/social-connections/linkedin-callback"}});if(R)throw R;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),he.error("Failed to start LinkedIn connection. Please try again."),a(!1)}},_=async()=>{a(!0);try{const{data:L,error:R}=await H.functions.invoke("google-business-oauth",{body:{action:"get_auth_url"}});if(R)throw R;if(L!=null&&L.authUrl)window.location.href=L.authUrl;else throw new Error("Failed to get Google authorization URL")}catch(L){console.error("Google OAuth error:",L),he.error("Failed to start Google connection. Please try again."),a(!1)}},j=(u==null?void 0:u.filter(L=>L.platform==="facebook"))||[],w=(u==null?void 0:u.filter(L=>L.platform==="instagram"))||[],N=(u==null?void 0:u.filter(L=>L.platform==="linkedin"))||[],C=(u==null?void 0:u.filter(L=>L.platform==="google_business"))||[],M=((u==null?void 0:u.length)||0)>0,I=async(L,R)=>{l(L),c(null);try{const{data:q,error:U}=await H.functions.invoke("meta-api-test",{body:{testType:"all",accountId:L}});if(U)throw U;c(q.results||[]),he.success(q.summary||"API tests completed")}catch(q){console.error("Meta API test error:",q),he.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(tt,{variant:"secondary",className:"bg-white/20 text-white border-0 backdrop-blur-sm",children:[e.jsx(un,{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(ri,{className:"h-4 w-4"}),"Back to Social Swag"]}),!r&&e.jsx(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-800",children:e.jsxs(Re,{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(mn,{className:"h-10 w-10 text-amber-600 dark:text-amber-400"})}),e.jsx(tt,{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(Pe,{className:"border-green-200 bg-green-50 dark:bg-green-950/20 dark:border-green-900",children:e.jsxs(Re,{className:"flex items-center gap-4 p-4",children:[e.jsx("div",{className:"rounded-full bg-green-500 p-2",children:e.jsx(xi,{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(Pe,{children:[e.jsx(Dt,{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(ku,{className:"h-6 w-6 text-blue-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Facebook"}),e.jsx(xr,{children:"Connect your Facebook Pages"})]})]})}),e.jsxs(Re,{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(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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:L.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(ku,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Facebook Page"}),e.jsx(tt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Facebook?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.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: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 Page":"Connect Facebook Page"]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{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(Cu,{className:"h-6 w-6 text-pink-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Instagram"}),e.jsx(xr,{children:"Connect Instagram Business accounts"})]})]})}),e.jsxs(Re,{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(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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:L.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Cu,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["@",L.platform_username||"Instagram Account"]}),e.jsx(tt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Instagram?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.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: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 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(Pe,{children:[e.jsx(Dt,{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(zt,{className:"text-lg",children:"LinkedIn"}),e.jsx(xr,{children:"Connect your LinkedIn profile"})]})]})}),e.jsxs(Re,{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"})}):N.length>0?e.jsx("div",{className:"space-y-3",children:N.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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:L.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Mp,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.platform_username||"LinkedIn Account"}),e.jsx(tt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect LinkedIn?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No LinkedIn account connected yet"}),e.jsxs(K,{onClick:b,disabled:n,className:"w-full gap-2",variant:N.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),N.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(Pe,{className:`relative overflow-hidden ${r?"":"opacity-75"}`,children:[!r&&e.jsx("div",{className:"absolute top-3 right-3 z-10",children:e.jsx(tt,{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(tt,{variant:"secondary",className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Admin Testing"})}),e.jsx(Dt,{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(Ba,{className:"h-6 w-6 text-red-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Google Business"}),e.jsx(xr,{children:"Connect your Google Business Profile"})]})]})}),e.jsxs(Re,{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"})}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.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(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:L.profile_picture_url||""}),e.jsx(wn,{children:e.jsx(Ba,{className:"h-5 w-5"})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:L.page_name||L.platform_username||"Google Business"}),e.jsx(tt,{variant:L.is_active?"default":"secondary",className:"text-xs",children:L.is_active?"Connected":"Inactive"})]})]}),e.jsxs(_c,{children:[e.jsx(Sm,{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(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Disconnect Google Business?"}),e.jsx(Jl,{children:"This will remove the connection. You'll need to reconnect to post content."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>f.mutate(L.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Disconnect"})]})]})]})]},L.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:C.length>0?"outline":"default",children:[n?e.jsx(Wo,{className:"h-4 w-4 animate-spin"}):e.jsx(qs,{className:"h-4 w-4"}),C.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&&(j.length>0||w.length>0)&&e.jsxs(Pe,{className:"border-amber-200 bg-amber-50 dark:bg-amber-950/20 dark:border-amber-900",children:[e.jsx(Dt,{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(F_,{className:"h-6 w-6 text-amber-600"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-lg",children:"Meta API Testing (Admin Only)"}),e.jsx(xr,{children:"Run API tests to trigger all required permissions for Meta App Review"})]})]})}),e.jsxs(Re,{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:[j.map(L=>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(ku,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium",children:L.page_name||"Facebook Page"})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(F_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-fb-${L.id}`)),w.map(L=>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-pink-600"}),e.jsxs("span",{className:"font-medium",children:["@",L.platform_username||"Instagram"]})]}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>I(L.id),disabled:o===L.id,children:o===L.id?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Testing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(F_,{className:"h-4 w-4 mr-2"}),"Run Tests"]})})]},`test-ig-${L.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((L,R)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[L.status==="success"?e.jsx(la,{className:"h-4 w-4 text-green-600 mt-0.5 shrink-0"}):L.status==="pending"?e.jsx(ws,{className:"h-4 w-4 text-amber-600 mt-0.5 shrink-0"}):e.jsx(xc,{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:L.test}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:L.details})]})]},R))})]}),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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-lg",children:"How it works"})}),e.jsx(Re,{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 xCs(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Processing your connection...");return k.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"),he.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),he.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("meta-oauth",{body:{action:"exchange_code",code:i,state:p,callbackPath:"/social-connections/callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||0} account(s)!`),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(xc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/mission-control/integrations"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function gCs(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your Google Business Profile...");return k.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"),he.error("Connection failed: "+(u||c));return}if(!i){n("error"),o("No authorization code received"),he.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!"),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{className:"text-center",children:[r==="loading"&&e.jsx(ws,{className:"h-12 w-12 animate-spin mx-auto text-primary"}),r==="success"&&e.jsx(xi,{className:"h-12 w-12 mx-auto text-green-500"}),r==="error"&&e.jsx(xc,{className:"h-12 w-12 mx-auto text-destructive"}),e.jsxs(zt,{className:"mt-4",children:[r==="loading"&&"Connecting...",r==="success"&&"Connected!",r==="error"&&"Connection Failed"]}),e.jsx(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:r!=="loading"&&e.jsx(K,{onClick:()=>s("/social-connections"),children:r==="success"?"View Connected Accounts":"Try Again"})})]})})}function yCs(){const[t]=qc(),s=pr(),[r,n]=k.useState("loading"),[a,o]=k.useState("Connecting your LinkedIn account...");return k.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"),he.error(p||"Failed to connect LinkedIn");return}if(!i){n("error"),o("No authorization code received"),he.error("No authorization code received");return}try{const{data:g,error:b}=await H.functions.invoke("linkedin-oauth",{body:{action:"exchange_code",code:i,state:c,callbackPath:"/social-connections/linkedin-callback"}});if(b)throw b;if(g!=null&&g.success)n("success"),o(`Successfully connected ${((f=g.accounts)==null?void 0:f.length)||1} LinkedIn account`),he.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"),he.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(Pe,{className:"w-full max-w-md",children:[e.jsxs(Dt,{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(ws,{className:"h-8 w-8 animate-spin text-blue-600"}),r==="success"&&e.jsx(xi,{className:"h-8 w-8 text-green-600"}),r==="error"&&e.jsx(xc,{className:"h-8 w-8 text-red-600"})]}),e.jsxs(zt,{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(xr,{children:a})]}),e.jsx(Re,{className:"flex justify-center",children:e.jsx(K,{onClick:()=>s("/social-connections"),disabled:r==="loading",children:r==="success"?"Continue":"Back to Connections"})})]})})}function vCs(){const t=pr(),[s,r]=k.useState(null),{data:n,isLoading:a}=klt(s||void 0,!0),{data:o,isLoading:l}=lCe(!0),{cartItems:i}=gue(),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(yp,{className:"h-4 w-4 mr-2"}),"Cart",c>0&&e.jsx(tt,{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(Pe,{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(Cl,{className:"h-12 w-12 text-muted-foreground"})}),p.category&&e.jsx(tt,{className:"absolute top-2 left-2",variant:"secondary",children:p.category.name})]}),e.jsxs(Re,{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(Cl,{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 ict=k.forwardRef(({...t},s)=>e.jsx("nav",{ref:s,"aria-label":"breadcrumb",...t}));ict.displayName="Breadcrumb";const oct=k.forwardRef(({className:t,...s},r)=>e.jsx("ol",{ref:r,className:Pt("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...s}));oct.displayName="BreadcrumbList";const Iie=k.forwardRef(({className:t,...s},r)=>e.jsx("li",{ref:r,className:Pt("inline-flex items-center gap-1.5",t),...s}));Iie.displayName="BreadcrumbItem";const lwe=k.forwardRef(({asChild:t,className:s,...r},n)=>{const a=t?o2e:"a";return e.jsx(a,{ref:n,className:Pt("transition-colors hover:text-foreground",s),...r})});lwe.displayName="BreadcrumbLink";const lct=k.forwardRef(({className:t,...s},r)=>e.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Pt("font-normal text-foreground",t),...s}));lct.displayName="BreadcrumbPage";const cwe=({children:t,className:s,...r})=>e.jsx("li",{role:"presentation","aria-hidden":"true",className:Pt("[&>svg]:size-3.5",s),...r,children:t??e.jsx(xa,{})});cwe.displayName="BreadcrumbSeparator";function bCs(){var te,X;const{productId:t}=yo(),s=pr(),{data:r,isLoading:n}=Tks(t||""),{addToCart:a,cartItems:o}=gue(),[l,i]=k.useState(null),[c,u]=k.useState(1),[p,f]=k.useState(0),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState(!1),C=(te=r==null?void 0:r.variants)==null?void 0:te.find(ce=>ce.id===l),M=((X=r==null?void 0:r.variants)==null?void 0:X.filter(ce=>ce.is_active))||[],I=Number((r==null?void 0:r.base_price)||0),L=C?Number(C.price_adjustment):0,R=I+L,q=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;j(!0);const ne=ce.target.files[0],re=ne.name.split(".").pop(),le=`artwork/${Date.now()}-${Math.random().toString(36).substring(7)}.${re}`;try{const{error:pe}=await H.storage.from("marketplace").upload(le,ne);if(pe)throw pe;const{data:{publicUrl:xe}}=H.storage.from("marketplace").getPublicUrl(le);b(xe),he.success("Artwork uploaded successfully")}catch(pe){he.error("Failed to upload artwork: "+pe.message)}finally{j(!1)}},V=()=>{if(r){if(M.length>0&&!l){he.error("Please select an option");return}a(r,C||void 0,c,g||void 0),N(!0),he.success("Added to cart!"),setTimeout(()=>N(!1),2e3)}},Y=()=>{r!=null&&r.images&&f(ce=>(ce+1)%r.images.length)},J=()=>{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(ict,{className:"mb-6",children:e.jsxs(oct,{children:[e.jsx(Iie,{children:e.jsx(lwe,{asChild:!0,children:e.jsx(Ei,{to:"/marketplace",children:"Marketplace"})})}),r.category&&e.jsxs(e.Fragment,{children:[e.jsx(cwe,{}),e.jsx(Iie,{children:e.jsx(lwe,{asChild:!0,children:e.jsx(Ei,{to:`/marketplace?category=${r.category.id}`,children:r.category.name})})})]}),e.jsx(cwe,{}),e.jsx(Iie,{children:e.jsx(lct,{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:J,children:e.jsx(ll,{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:Y,children:e.jsx(xa,{className:"h-6 w-6"})})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Cl,{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(Pe,{children:e.jsxs(Re,{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(tt,{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:["$",R.toFixed(2)]}),q>0&&e.jsxs("span",{className:"text-muted-foreground",children:["+ $",q.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(ye,{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(ye,{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:()=>b(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(oi,{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(ye,{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:w,children:w?e.jsxs(e.Fragment,{children:[e.jsx(fa,{className:"h-5 w-5 mr-2"}),"Added!"]}):e.jsxs(e.Fragment,{children:[e.jsx(yp,{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(yp,{className:"h-5 w-5"}),U>0&&e.jsx(tt,{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(Cl,{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 _Cs(){const t=pr(),{cartItems:s,removeFromCart:r,updateQuantity:n,getItemPrice:a,getSubtotal:o,getShippingTotal:l,getTotal:i,clearCart:c}=gue(),[u,p]=k.useState(!1),[f,g]=k.useState(""),b=async()=>{if(s.length===0){he.error("Your cart is empty");return}p(!0);try{const{data:_,error:j}=await H.functions.invoke("marketplace-checkout",{body:{items:s.map(w=>{var N;return{product_id:w.product.id,variant_id:((N=w.variant)==null?void 0:N.id)||null,quantity:w.quantity,artwork_url:w.artworkUrl||null}}),notes:f.trim()||null}});if(j)throw j;if(_!=null&&_.url)c(),window.open(_.url,"_blank");else throw new Error("No checkout URL received")}catch(_){he.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(f0,{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 j,w;return e.jsx(Pe,{children:e.jsx(Re,{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:((j=_.product.images.find(N=>N.is_primary))==null?void 0:j.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(f0,{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 N;return r(_.product.id,(N=_.variant)==null?void 0:N.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 N;return n(_.product.id,(N=_.variant)==null?void 0:N.id,_.quantity-1)},disabled:_.quantity<=1,children:e.jsx(m0,{className:"h-3 w-3"})}),e.jsx(ze,{type:"number",value:_.quantity,onChange:N=>{var C;return n(_.product.id,(C=_.variant)==null?void 0:C.id,parseInt(N.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 N;return n(_.product.id,(N=_.variant)==null?void 0:N.id,_.quantity+1)},children:e.jsx(qs,{className:"h-3 w-3"})})]})]})]})})},`${_.product.id}-${((w=_.variant)==null?void 0:w.id)||"base"}`)}),e.jsx(K,{variant:"ghost",className:"text-destructive",onClick:c,children:"Clear Cart"})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{children:["Subtotal (",s.reduce((_,j)=>_+j.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(sl,{}),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(sl,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{htmlFor:"orderNotes",children:"Order Notes (Optional)"}),e.jsx(Er,{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:b,disabled:u,children:u?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-5 w-5 mr-2 animate-spin"}),"Processing..."]}):e.jsxs(e.Fragment,{children:["Checkout",e.jsx(fi,{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 wCs(){const t=pr(),{data:s,isLoading:r}=Bks();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(Cl,{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(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow",onClick:()=>t(`/marketplace/orders/${n.id}`),children:e.jsxs(Re,{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:ps(new Date(n.created_at),"MMM d, yyyy")})]}),e.jsx(tt,{className:oCe[n.status],children:cT[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(an,{className:"h-4 w-4 mr-1"}),"Track"]}),e.jsx(xa,{className:"h-5 w-5 text-muted-foreground"})]})]})]})},n.id)})})})}const Oze=["order_submitted","awaiting_proof_approval","proof_approved","processing","in_production","shipped","completed"];function jCs({currentStatus:t,statusHistory:s}){const r=Oze.indexOf(t);return e.jsx("div",{className:"space-y-3",children:Oze.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(la,{className:"h-4 w-4"}):i?e.jsx(mn,{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:cT[n]}),o&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[ps(new Date(o.created_at),"MMM d, yyyy h:mm a"),o.notes&&` — ${o.notes}`]})]})]},n)})})}function NCs(){var N;const{orderId:t}=yo(),s=pr(),{data:r,isLoading:n,refetch:a}=$ks(t||""),o=Vks(),l=Hks(),[i,c]=k.useState(!1),[u,p]=k.useState(null),[f,g]=k.useState(""),[b,_]=k.useState(null),j=async C=>{_(C);try{await o.mutateAsync({orderId:t,itemId:C}),he.success("Proof approved!"),a()}catch{he.error("Failed to approve proof")}finally{_(null)}},w=async()=>{if(u){_(u);try{await l.mutateAsync({orderId:t,itemId:u,reason:f}),he.success("Revision requested"),c(!1),g(""),p(null),a()}catch{he.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsx(zt,{children:"Order Status"}),e.jsx(tt,{className:oCe[r.status],children:cT[r.status]})]}),e.jsx(Re,{children:e.jsx(jCs,{currentStatus:r.status,statusHistory:r.status_history})})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Items"})}),e.jsx(Re,{className:"space-y-4",children:(N=r.items)==null?void 0:N.map(C=>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:C.product_name}),C.variant_name&&e.jsx("p",{className:"text-sm text-muted-foreground",children:C.variant_name}),e.jsxs("p",{className:"text-sm",children:["Qty: ",C.quantity," × $",Number(C.unit_price).toFixed(2)]})]}),e.jsxs("p",{className:"font-semibold",children:["$",(Number(C.unit_price)*C.quantity).toFixed(2)]})]}),C.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:C.artwork_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline",children:[e.jsx(R_,{className:"h-4 w-4"}),"View Artwork",e.jsx(an,{className:"h-3 w-3"})]})]}),C.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:C.proof_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-primary hover:underline mb-3",children:[e.jsx(R_,{className:"h-4 w-4"}),"View Proof",e.jsx(an,{className:"h-3 w-3"})]}),C.proof_status==="pending"&&e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(K,{size:"sm",onClick:()=>j(C.id),disabled:b===C.id,children:[b===C.id?e.jsx(ws,{className:"h-4 w-4 mr-1 animate-spin"}):e.jsx(eh,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{p(C.id),c(!0)},disabled:b===C.id,children:[e.jsx(TL,{className:"h-4 w-4 mr-1"}),"Request Changes"]})]}),C.proof_status==="approved"&&e.jsxs(tt,{className:"bg-green-100 text-green-800",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Proof Approved"]}),C.proof_status==="rejected"&&C.proof_notes&&e.jsxs("div",{className:"mt-2",children:[e.jsx(tt,{variant:"destructive",className:"mb-2",children:"Revision Requested"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:C.proof_notes})]})]})]},C.id))})]}),r.shipping_name&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(EL,{className:"h-5 w-5"}),"Shipping"]})}),e.jsxs(Re,{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(an,{className:"h-3 w-3 ml-1"})]})]})]})]})]}),e.jsx("div",{children:e.jsxs(Pe,{className:"sticky top-4",children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Order Summary"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:["Placed on ",ps(new Date(r.created_at),"MMMM d, yyyy")]}),e.jsx(sl,{}),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(sl,{}),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(sl,{}),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(_s,{children:[e.jsx(bs,{children:"Request Changes"}),e.jsx(Wr,{children:"Please describe what changes you'd like made to the proof."})]}),e.jsx(Er,{placeholder:"Describe the changes needed...",value:f,onChange:C=>g(C.target.value),rows:4}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsxs(K,{onClick:w,disabled:!f.trim()||b!==null,children:[b?e.jsx(ws,{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(Cl,{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 kCs(){const t=pr(),[s]=qc();return s.get("session_id"),k.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(Pe,{children:e.jsxs(Re,{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(la,{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(Cl,{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(fi,{className:"h-4 w-4 ml-2"})]}),e.jsx(K,{variant:"outline",className:"flex-1",onClick:()=>t("/marketplace"),children:"Continue Shopping"})]})]})})})})}function SCs(){const{user:t}=Rs(),[s,r]=k.useState("store"),[n,a]=k.useState(null),[o,l]=k.useState(null),[i,c]=k.useState(!1),[u,p]=k.useState(5),[f,g]=k.useState(""),[b,_]=k.useState(!1),[j,w]=k.useState(!1),[N,C]=k.useState(""),[M,I]=k.useState(null),[L,R]=k.useState(!1),{hasSubmittedReview:q,submitReview:U,markPostedToGoogle:B}=PYe(),{data:V}=Clt(),{data:Y,isLoading:J}=Slt(),{data:te,isLoading:X}=Qks(n),{data:ce,isLoading:ne}=Jks(t==null?void 0:t.id),{data:re=0}=t4s(t==null?void 0:t.id),le=s4s(),pe=new Set((ce==null?void 0:ce.map(Ae=>Ae.item_id))||[]),xe=async()=>{if(o)try{const Ae=await le.mutateAsync(o.id);o.item_type==="reelflow_credits"?he.success(`🎬 ${o.max_quantity} ReelFlow credits added to your balance!`):he.success(`Successfully purchased "${o.name}"!`),l(null)}catch(Ae){he.error(Ae.message||"Failed to purchase item")}},_e=async()=>{if(!f.trim()){he.error("Please write a review");return}_(!0);const Ae=await U(u,f);_(!1),Ae.success?(he.success("Thank you for your review! You earned 25 points!"),C(f),w(!0),g(""),p(5)):he.error(Ae.error||"Failed to submit review")},fe=()=>{navigator.clipboard.writeText(N),he.success("Review copied to clipboard!")},we=()=>{B(),window.open("https://g.page/r/CT8bqTBTm7nJEBM/review","_blank")},Ie=()=>{w(!1),c(!1),C("")};return J||X||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(Ae=>e.jsx(vs,{className:"h-64"},Ae))})]})}):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(Pe,{className:"bg-gradient-to-r from-primary/10 to-primary/5 border-primary/20",children:e.jsx(Re,{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(xo,{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(Qu,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{children:"Streak bonuses add extra points!"})]})]})]})})}),e.jsx(gf,{open:L,onOpenChange:R,children:e.jsxs(Pe,{className:"border-primary/20",children:[e.jsx(yf,{asChild:!0,children:e.jsx(Dt,{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(xo,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"How to Earn Points"}),e.jsx(xr,{children:"See all the ways you can earn spendable points"})]})]}),L?e.jsx(pf,{className:"h-5 w-5 text-muted-foreground"}):e.jsx(To,{className:"h-5 w-5 text-muted-foreground"})]})})}),e.jsx(vf,{children:e.jsx(Re,{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(Ae=>Ae.is_active).map(Ae=>{const Fe=Ce=>{switch(Ce){case"event_attendance":return e.jsx(cn,{className:"h-5 w-5"});case"leave_review":return e.jsx(Jn,{className:"h-5 w-5"});case"add_listing":return e.jsx(Sn,{className:"h-5 w-5"});case"first_contact":return e.jsx(mr,{className:"h-5 w-5"});case"first_video":return e.jsx(Cn,{className:"h-5 w-5"});case"first_community_post":return e.jsx(io,{className:"h-5 w-5"});default:return e.jsx(No,{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:Fe(Ae.action_key)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:Ae.action_name}),Ae.description&&e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:Ae.description})]}),e.jsxs(tt,{variant:"secondary",className:"font-bold shrink-0",children:["+",Ae.points]})]},Ae.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(Qu,{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(tt,{variant:"outline",className:"font-bold shrink-0 border-orange-500/50 text-orange-600",children:"+Bonus"})]})]})})})]})}),!q&&e.jsx(Pe,{className:"bg-gradient-to-r from-yellow-500/10 to-orange-500/10 border-yellow-500/20",children:e.jsx(Re,{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(io,{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(ja,{value:s,onValueChange:r,children:[e.jsxs(ga,{children:[e.jsxs(us,{value:"store",className:"flex items-center gap-2",children:[e.jsx(f0,{className:"h-4 w-4"}),"Store"]}),e.jsxs(us,{value:"my-rewards",className:"flex items-center gap-2",children:[e.jsx(Cl,{className:"h-4 w-4"}),"My Rewards",ce&&ce.length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1",children:ce.length})]})]}),e.jsxs(ks,{value:"store",className:"mt-6",children:[Y&&Y.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"}),Y.map(Ae=>e.jsxs(K,{variant:n===Ae.id?"default":"outline",size:"sm",onClick:()=>a(Ae.id),children:[Ae.icon&&`${Ae.icon} `,Ae.name]},Ae.id))]}),!te||te.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(No,{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:te.map(Ae=>{const Fe=Ae.item_type==="reelflow_credits",Ce=!Fe&&pe.has(Ae.id),Me=!Fe&&Ae.max_quantity!==null&&Ae.current_quantity===0,$e=re>=Ae.points_cost;return e.jsxs(Pe,{className:`overflow-hidden transition-all cursor-pointer hover:shadow-lg ${Ce?"ring-2 ring-green-500/50 bg-green-500/5":""}`,onClick:()=>I(Ae),children:[Ae.preview_image_url?e.jsxs("div",{className:"aspect-video relative overflow-hidden bg-muted",children:[e.jsx("img",{src:Ae.preview_image_url,alt:Ae.name,className:"w-full h-full object-cover"}),Ce&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Owned"]})}),Me&&!Ce&&e.jsx("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center",children:e.jsx(tt,{variant:"destructive",children:"Sold Out"})})]}):e.jsxs("div",{className:"aspect-video bg-muted flex items-center justify-center relative",children:[e.jsx(No,{className:"h-12 w-12 text-muted-foreground/50"}),Ce&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsxs(tt,{className:"bg-green-500 text-white",children:[e.jsx(la,{className:"h-3 w-3 mr-1"}),"Owned"]})})]}),e.jsxs(Dt,{className:"pb-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(zt,{className:"text-lg",children:Ae.name}),e.jsxs(tt,{variant:"secondary",className:"font-bold shrink-0",children:[e.jsx(Jn,{className:"h-3 w-3 mr-1"}),Ae.points_cost]})]}),Ae.category&&e.jsxs(tt,{variant:"outline",className:"w-fit",children:[Ae.category.icon&&`${Ae.category.icon} `,Ae.category.name]})]}),e.jsxs(Re,{children:[e.jsx(xr,{className:"mb-4 line-clamp-2",children:Ae.description||"No description available"}),Ae.max_quantity!==null&&!Ce&&!Fe&&e.jsxs("p",{className:"text-xs text-muted-foreground mb-3",children:[Ae.current_quantity," of ",Ae.max_quantity," remaining"]}),Fe&&e.jsxs("p",{className:"text-xs text-violet-600 font-medium mb-3",children:["🎬 Grants ",Ae.max_quantity," ReelFlow credits per purchase"]}),Ce?e.jsx(K,{className:"w-full",onClick:ct=>{ct.stopPropagation(),Ae.file_url&&Nye(Ae.file_url,Ae.name)},disabled:!Ae.file_url,children:Ae.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Access"]})}):e.jsx(K,{className:"w-full",onClick:ct=>{ct.stopPropagation(),l(Ae)},disabled:Me||!$e,children:Me?"Sold Out":$e?e.jsxs(e.Fragment,{children:[e.jsx(f0,{className:"h-4 w-4 mr-2"}),"Purchase"]}):`Need ${Ae.points_cost-re} more pts`})]})]},Ae.id)})})]}),e.jsx(ks,{value:"my-rewards",className:"mt-6",children:!ce||ce.length===0?e.jsx(Pe,{children:e.jsx(Re,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(Cl,{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(Ae=>{var Fe,Ce,Me,$e,ct,Te,ft;return e.jsxs(Pe,{className:"overflow-hidden",children:[(Fe=Ae.item)!=null&&Fe.preview_image_url?e.jsx("div",{className:"aspect-video relative overflow-hidden bg-muted",children:e.jsx("img",{src:Ae.item.preview_image_url,alt:((Ce=Ae.item)==null?void 0:Ce.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(No,{className:"h-12 w-12 text-muted-foreground/50"})}),e.jsxs(Dt,{className:"pb-2",children:[e.jsx(zt,{className:"text-lg",children:((Me=Ae.item)==null?void 0:Me.name)||"Unknown Item"}),e.jsxs(xr,{className:"text-xs",children:["Purchased for ",Ae.points_spent," points • ",new Date(Ae.purchased_at).toLocaleDateString()]})]}),e.jsx(Re,{children:(($e=Ae.item)==null?void 0:$e.item_type)==="reelflow_credits"?e.jsxs(K,{className:"w-full",variant:"outline",disabled:!0,children:[e.jsx(la,{className:"h-4 w-4 mr-2 text-green-500"}),(ct=Ae.item)==null?void 0:ct.max_quantity," Credits Applied"]}):e.jsx(K,{className:"w-full",onClick:()=>{var me,Ve;(me=Ae.item)!=null&&me.file_url&&Nye(Ae.item.file_url,(Ve=Ae.item)==null?void 0:Ve.name)},disabled:!((Te=Ae.item)!=null&&Te.file_url),children:((ft=Ae.item)==null?void 0:ft.item_type)==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Access"]})})})]},Ae.id)})})})]})]}),e.jsx(_c,{open:!!o,onOpenChange:()=>l(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Confirm Purchase"}),e.jsxs(Jl,{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(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:xe,disabled:le.isPending,children:le.isPending?"Purchasing...":"Confirm Purchase"})]})]})}),e.jsx(xs,{open:i,onOpenChange:Ae=>{!Ae&&j?Ie():c(Ae)},children:e.jsx(fs,{children:j?e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(la,{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:['"',N,'"']})]}),e.jsxs(K,{variant:"outline",className:"w-full",onClick:fe,children:[e.jsx(gi,{className:"h-4 w-4 mr-2"}),"Copy Review to Clipboard"]})]}),e.jsxs(zn,{className:"flex-col sm:flex-row gap-2",children:[e.jsx(K,{variant:"outline",onClick:Ie,children:"Maybe Later"}),e.jsxs(K,{onClick:we,className:"bg-blue-600 hover:bg-blue-700",children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Leave Google Review"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_s,{children:[e.jsx(bs,{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(Ae=>e.jsx("button",{type:"button",onClick:()=>p(Ae),className:"focus:outline-none",children:e.jsx(Jn,{className:`h-8 w-8 transition-colors ${u>=Ae?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400"}`})},Ae))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Your Review"}),e.jsx(Er,{placeholder:"What do you love about LevelUp? How has it helped your business?",value:f,onChange:Ae=>g(Ae.target.value),rows:4})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(K,{onClick:_e,disabled:b,className:"bg-yellow-600 hover:bg-yellow-700",children:b?"Submitting...":"Submit & Earn 25 Points"})]})]})})}),e.jsx(xs,{open:!!M,onOpenChange:()=>I(null),children:e.jsxs(fs,{className:"max-w-lg",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[M==null?void 0:M.name,e.jsxs(tt,{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(tt,{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&&!pe.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(zn,{children:M&&M.item_type!=="reelflow_credits"&&pe.has(M.id)?e.jsx(K,{className:"w-full",onClick:()=>{M.file_url&&Nye(M.file_url,M.name)},disabled:!M.file_url,children:M.item_type==="file"?e.jsxs(e.Fragment,{children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Download"]}):e.jsxs(e.Fragment,{children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Access"]})}):M&&e.jsx(K,{className:"w-full",onClick:()=>{I(null),l(M)},disabled:M.item_type!=="reelflow_credits"&&M.max_quantity!==null&&M.current_quantity===0||re{const{user:t}=Rs(),s=es(),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"]}),he.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"]}),he.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"]}),he.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}},CCs=()=>{const t=pr(),{presentations:s,isLoading:r,archivePresentation:n,saveAsTemplate:a}=cct(),o=i=>i.status==="draft"?e.jsx(tt,{variant:"outline",className:"text-xs",children:"Draft"}):i.view_count>1?e.jsx(tt,{className:"text-xs bg-emerald-100 text-emerald-700 border-emerald-200",children:"Revisited"}):i.view_count===1?e.jsx(tt,{className:"text-xs bg-blue-100 text-blue-700 border-blue-200",children:"Opened"}):e.jsx(tt,{variant:"secondary",className:"text-xs",children:"Not Opened"}),l=i=>{const c=`https://presentations.relevelup.com/${i}`;navigator.clipboard.writeText(c),he.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(Pe,{children:e.jsxs(Re,{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(Qg,{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(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsx(Re,{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(En,{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 ",ps(new Date(i.created_at),"MMM d, yyyy")]}),i.view_count>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(qn,{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(gi,{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(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",children:[i.status==="published"&&i.share_token&&e.jsxs(Ca,{onClick:()=>window.open(`https://presentations.relevelup.com/${i.share_token}`,"_blank"),children:[e.jsx(an,{className:"h-4 w-4 mr-2"}),"Preview Link"]}),e.jsxs(Ca,{onClick:()=>a.mutate(i),children:[e.jsx(En,{className:"h-4 w-4 mr-2"}),"Save as Template"]}),e.jsxs(Ca,{onClick:()=>n.mutate(i.id),className:"text-destructive",children:[e.jsx(vM,{className:"h-4 w-4 mr-2"}),"Archive"]})]})]})]})]})})]})})},i.id))})]})})},Rze={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."}]},MCs=[{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 TCs(t){const s=Rze[t];if(s)return s;const r=t.toLowerCase();for(const[n,a]of Object.entries(Rze))if(r.includes(n.toLowerCase())||n.toLowerCase().includes(r))return a;return MCs}function ACs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState("script"),[i,c]=k.useState(0),[u,p]=k.useState(0),{canRecord:f}=zat(),g=_C(),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(!0),[M,I]=k.useState(!1),[L,R]=k.useState(null),q=TCs(t),U=()=>{l("script"),c(0),p(0),_(""),w(!1),C(!0),I(!1),R(null)},B=X=>{!X&&(o==="uploading"||o==="processing")||(a(X),X||U())},V=X=>{R(X),_(q[X].text),w(!1)},Y=()=>{l("record"),C(b.trim().length>0)},J=()=>{_(""),C(!1),l("record")},te=k.useCallback(async(X,ce)=>{l("uploading");try{const ne=t||"Presentation Video",{videoId:re,uploadUrl:le,libraryId:pe}=await hR(ne),{apiKey:xe}=await mR(re),_e=new XMLHttpRequest;_e.upload.onprogress=Ae=>{Ae.lengthComputable&&c(Ae.loaded/Ae.total*100)},await new Promise((Ae,Fe)=>{_e.onload=()=>_e.status>=200&&_e.status<300?Ae():Fe(new Error("Upload failed")),_e.onerror=()=>Fe(new Error("Upload failed")),_e.open("PUT",le),_e.setRequestHeader("AccessKey",xe),_e.send(X)}),l("processing");let fe=0;const we=Date.now(),Ie=9e4;let Ne=null;for(;fe<4;){if(await new Promise(Fe=>setTimeout(Fe,3e3)),Date.now()-we>Ie){const Fe=X.size/1048576,Ce=`https://iframe.mediadelivery.net/embed/${pe}/${re}?responsive=true`;await g.mutateAsync({bunny_video_id:re,playback_url:Ce,file_size_mb:Fe,title:ne,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(Ce),he.success("Video saved — still encoding. It will be ready shortly."),l("done"),setTimeout(()=>a(!1),1500);return}const Ae=await bA(re);if(fe=Ae.status,p(Ae.encodeProgress||0),fe===4)Ne={playbackUrl:Ae.directPlayUrl,thumbnailUrl:Ae.thumbnailUrl,previewUrl:Ae.previewUrl||null,duration:Ae.length||ce,fileSizeMb:(Ae.storageSize||X.size)/(1024*1024)};else if(fe===5||fe===6)throw new Error("Video processing failed")}if(!Ne)throw new Error("No video data");await g.mutateAsync({bunny_video_id:re,contact_id:s||void 0,playback_url:Ne.playbackUrl,thumbnail_url:Ne.thumbnailUrl,preview_url:Ne.previewUrl,duration_seconds:Ne.duration,file_size_mb:Ne.fileSizeMb,title:ne,status:"ready",touch_type:"presentation"}),r(Ne.playbackUrl),he.success("Video recorded, saved to library & attached!"),l("done"),setTimeout(()=>a(!1),1500)}catch(ne){console.error("Recording upload error:",ne),he.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(_s,{children:e.jsxs(bs,{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:q.map((X,ce)=>e.jsxs("button",{onClick:()=>V(ce),className:Pt("text-left p-3 rounded-lg border transition-all hover:bg-accent/50",L===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(En,{className:"h-3.5 w-3.5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm font-medium",children:X.label})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 ml-5.5",children:X.text})]},ce))})]}),b&&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"}),!j&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>w(!0),className:"h-7 text-xs gap-1",children:[e.jsx(Da,{className:"h-3 w-3"}),"Edit"]})]}),j?e.jsx(Er,{value:b,onChange:X=>_(X.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:b})]}),!b&&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(Er,{value:b,onChange:X=>{_(X.target.value),R(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:J,className:"text-muted-foreground",children:"Skip — no teleprompter"}),e.jsx(K,{onClick:Y,disabled:!1,children:b.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(Gu,{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 60 seconds. Saved to your library & auto-attached."}),b.trim()&&e.jsxs(K,{variant:"ghost",size:"sm",onClick:()=>C(!N),className:"h-7 text-xs gap-1",children:[N?e.jsx(kp,{className:"h-3 w-3"}):e.jsx(qn,{className:"h-3 w-3"}),N?"Hide Script":"Show Script"]})]}),e.jsx(fme,{maxDurationSeconds:60,onRecordingComplete:te,onRecordingStateChange:I,onError:X=>he.error(X),teleprompterContent:b.trim()?e.jsx(slt,{text:b,isVisible:N,onToggleVisibility:()=>C(!N),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(ws,{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(ws,{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(xi,{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 ECs({sectionTitle:t,contactId:s,onVideoReady:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(null),[i,c]=k.useState("idle"),[u,p]=k.useState(0),f=k.useRef(null),g=_C(),{data:b}=Uhe(),_=(b==null?void 0:b.total_storage_mb)||0,w=((b==null?void 0:b.max_storage_mb)||1024)-_,N=()=>{l(null),c("idle"),p(0)},C=q=>{!q&&i!=="idle"&&i!=="done"||(a(q),q||N())},M=q=>{var V;const U=(V=q.target.files)==null?void 0:V[0];if(!U)return;if(!U.type.startsWith("video/")){he.error("Please select a video file");return}const B=U.size/(1024*1024);if(B>500){he.error("Video file must be less than 500MB");return}if(B>w){he.error(`Not enough storage. You have ${w.toFixed(1)} MB remaining.`);return}l(U)},I=k.useCallback(async()=>{if(o){c("creating"),p(0);try{const q=t||o.name,{data:U,error:B}=await H.functions.invoke("bunny-upload",{body:{action:"create",title:q,isAgentVideo:!0}});if(B)throw new Error(B.message);const{videoId:V,libraryId:Y}=U;c("uploading");const{data:J,error:te}=await H.functions.invoke("bunny-upload",{body:{action:"upload-url",videoId:V,isAgentVideo:!0}});if(te)throw new Error(te.message);await new Promise((ne,re)=>{const le=new XMLHttpRequest;le.upload.addEventListener("progress",pe=>{pe.lengthComputable&&p(Math.round(pe.loaded/pe.total*100))}),le.addEventListener("load",()=>le.status>=200&&le.status<300?ne():re(new Error(`Upload failed (${le.status})`))),le.addEventListener("error",()=>re(new Error("Upload failed"))),le.open("PUT",J.uploadUrl),le.setRequestHeader("AccessKey",J.apiKey),le.send(o)}),c("processing");const X=o.size/(1024*1024),ce=`https://iframe.mediadelivery.net/embed/${Y}/${V}`;await g.mutateAsync({bunny_video_id:V,playback_url:ce,file_size_mb:X,title:q,contact_id:s||void 0,status:"processing",touch_type:"presentation"}),r(ce),c("done"),he.success("Video uploaded & attached to section!"),setTimeout(()=>a(!1),1200)}catch(q){console.error("Upload error:",q),he.error(q instanceof Error?q.message:"Failed to upload video"),c("idle")}}},[o,t,s,r,g]),L=()=>{switch(i){case"creating":return"Preparing upload...";case"uploading":return`Uploading... ${u}%`;case"processing":return"Saving video...";case"done":return"Done!";default:return""}},R=i!=="idle"&&i!=="done";return e.jsxs(xs,{open:n,onOpenChange:C,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(oi,{className:"h-3.5 w-3.5"}),"Upload"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsxs(bs,{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"]})]}),!R&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>l(null),children:e.jsx(Or,{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 q;return(q=f.current)==null?void 0:q.click()},children:[e.jsx(oi,{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:R}),R&&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(ws,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:L()})]}),e.jsx(Bi,{value:i==="uploading"?u:i==="processing"?100:10})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>C(!1),disabled:R,children:"Cancel"}),e.jsx(K,{onClick:I,disabled:!o||R,children:R?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 mr-2 animate-spin"}),"Uploading..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-4 w-4 mr-2"}),"Upload & Attach"]})})]})]})]})}const Fze=[{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"}],zze=()=>{const t=pr(),{id:s}=yo(),{user:r}=Rs(),{templates:n,templatesLoading:a,createPresentation:o,updatePresentation:l,publishPresentation:i}=cct(),{isGmailConnected:c,gmailEmail:u}=$0(),[p,f]=k.useState(!1),[g,b]=k.useState("client"),[_,j]=k.useState(!1),[w,N]=k.useState(""),[C,M]=k.useState([]),[I,L]=k.useState(!1),[R,q]=k.useState(null),[U,B]=k.useState(!1),[V,Y]=k.useState(""),[J,te]=k.useState(""),[X,ce]=k.useState(""),[ne,re]=k.useState("buyer"),[le,pe]=k.useState(""),[xe,_e]=k.useState(null),[fe,we]=k.useState(""),[Ie,Ne]=k.useState([]),[Ae,Fe]=k.useState("schedule_call"),[Ce,Me]=k.useState("Schedule a Call"),[$e,ct]=k.useState(""),[Te,ft]=k.useState(""),[me,Ve]=k.useState(null),[nt,et]=k.useState(s||null),[Se,rt]=k.useState(null),[Ge,lt]=k.useState(!1),qe=async(Ct,As)=>{if(!r)return;const Us=5*1024*1024;if(Ct.size>Us){he.error("Image must be under 5MB");return}if(!Ct.type.startsWith("image/")){he.error("Please upload an image file");return}Ve(As);try{const kr=Ct.name.split(".").pop()||"jpg",ta=`${r.id}/${Date.now()}.${kr}`,{error:ka}=await H.storage.from("listing-photos").upload(ta,Ct);if(ka)throw ka;const{data:{publicUrl:Li}}=H.storage.from("listing-photos").getPublicUrl(ta);It(As,{image_url:Li}),he.success("Image uploaded")}catch{he.error("Failed to upload image")}finally{Ve(null)}};k.useEffect(()=>{s&&Ze(s)},[s]);const Ze=async Ct=>{const{data:As,error:Us}=await H.from("smart_presentations").select("*").eq("id",Ct).single();if(Us||!As)return;const kr=As;if(j(!0),we(kr.title),Y(kr.client_name||""),pe(kr.property_address||""),Ne(kr.sections||[]),Fe(kr.cta_type||"schedule_call"),Me(kr.cta_label||"Schedule a Call"),ct(kr.cta_url||""),ft(kr.heading||""),rt(kr.share_token),lt(kr.status==="published"),et(kr.id),b("builder"),kr.contact_id){const{data:ta}=await H.from("innercircle_contacts").select("id, first_name, last_name, email, phone").eq("id",kr.contact_id).maybeSingle();ta&&(q(ta),te(ta.email||""),ce(ta.phone||""))}};k.useEffect(()=>{if(!r||w.length<1){M([]);return}const Ct=setTimeout(async()=>{L(!0);const{data:As}=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.%${w}%,last_name.ilike.%${w}%,email.ilike.%${w}%`).limit(10);M(As||[]),L(!1)},300);return()=>clearTimeout(Ct)},[w,r]);const Je=Ct=>{q(Ct),Y(`${Ct.first_name} ${Ct.last_name||""}`.trim()),te(Ct.email||""),ce(Ct.phone||""),B(!1)},He=async()=>{if(!V.trim()){he.error("Client name is required");return}const Ct=V.trim().split(" "),As=Ct[0],Us=Ct.slice(1).join(" ")||null,{data:kr,error:ta}=await H.from("innercircle_contacts").insert({owner_user_id:r.id,first_name:As,last_name:Us,email:J||null,phone:X||null,lead_source:"Smart Presentation"}).select().single();if(ta){he.error("Failed to create client");return}q(kr),he.success("Client created & saved to Agent OS"),b("template")},Qe=Ct=>{_e(Ct);const As=(Ct.sections||[]).map(Us=>({...Us,is_visible:!0,video_url:"",text:""}));if(Ne(As),we(Ct.name+(V?` for ${V}`:"")),Ct.cta_config){const Us=Ct.cta_config;Fe(Us.type||"schedule_call"),Me(Us.label||"Schedule a Call")}b("builder")},at=()=>{Ne([{title:"Welcome",description:"A personal welcome",type:"video",icon:"👋",is_visible:!0}]),we(V?`Presentation for ${V}`:"New Presentation"),b("builder")},It=(Ct,As)=>{Ne(Us=>Us.map((kr,ta)=>ta===Ct?{...kr,...As}:kr))},Ut=Ct=>{It(Ct,{is_visible:!Ie[Ct].is_visible})},hs=()=>{Ne(Ct=>[...Ct,{title:"New Section",description:"",type:"video",icon:"📝",is_visible:!0}])},Yt=Ct=>{Ne(As=>As.filter((Us,kr)=>kr!==Ct))},ts=async()=>{if(!fe.trim()){he.error("Title is required");return}try{if(nt){const Ct=await l.mutateAsync({id:nt,title:fe,sections:Ie,client_name:V,property_address:le||null,cta_type:Ae,cta_label:Ce,cta_url:$e||null,heading:Te||null});he.success("Saved")}else{const Ct=await o.mutateAsync({title:fe,contact_id:(R==null?void 0:R.id)||void 0,client_name:V,property_address:le||void 0,template_id:(xe==null?void 0:xe.id)||void 0,sections:Ie,cta_type:Ae,cta_label:Ce,cta_url:$e||void 0,heading:Te||void 0});et(Ct.id),rt(Ct.share_token),he.success("Presentation created!")}}catch(Ct){console.error("Failed to save presentation:",Ct);const As=(Ct==null?void 0:Ct.message)||(Ct==null?void 0:Ct.toString())||"Unknown error";he.error(`Failed to save: ${As}`)}},Ds=async()=>{try{await ts();const Ct=nt;if(Ct){const As=await i.mutateAsync(Ct);rt(As.share_token),lt(!0),b("share")}}catch(Ct){console.error("Failed to publish presentation:",Ct),he.error(`Failed to publish: ${(Ct==null?void 0:Ct.message)||"Unknown error"}`)}},vr=Se?`https://presentations.relevelup.com/${Se}`:"";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(ri,{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((Ct,As)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:Pt("w-8 h-8 rounded-full flex items-center justify-center text-sm font-medium transition-colors",g===Ct?"bg-primary text-primary-foreground":As<["client","template","builder","share"].indexOf(g)?"bg-emerald-100 text-emerald-700":"bg-muted text-muted-foreground"),children:As<["client","template","builder","share"].indexOf(g)?e.jsx(fa,{className:"h-4 w-4"}):As+1}),e.jsx("span",{className:"text-sm font-medium capitalize hidden sm:inline",children:Ct}),As<3&&e.jsx("div",{className:"w-8 h-px bg-border"})]},Ct))}),g==="client"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>{q(null),Y(""),te(""),ce(""),B(!1),b("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(Rn,{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(fi,{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(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(hn,{className:"h-4 w-4 text-muted-foreground"}),"Select Existing Client"]})}),e.jsxs(Re,{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:w,onChange:Ct=>N(Ct.target.value),className:"pl-10"})]}),e.jsxs("div",{className:"space-y-2 max-h-56 overflow-y-auto",children:[I&&e.jsx(vs,{className:"h-12 w-full"}),C.map(Ct=>e.jsxs("button",{onClick:()=>Je(Ct),className:Pt("w-full text-left p-3 rounded-lg border transition-colors",(R==null?void 0:R.id)===Ct.id?"border-primary bg-primary/5":"border-border hover:border-primary/50"),children:[e.jsxs("p",{className:"font-medium text-sm",children:[Ct.first_name," ",Ct.last_name]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:Ct.email||Ct.phone||"No contact info"})]},Ct.id)),!w&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"Start typing to search your contacts"}),w&&C.length===0&&!I&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No clients found"})]}),R&&e.jsxs(K,{onClick:()=>b("template"),className:"w-full gap-2",children:["Continue with ",R.first_name,e.jsx(fi,{className:"h-4 w-4"})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(rc,{className:"h-4 w-4 text-muted-foreground"}),"Add New Client"]})}),e.jsxs(Re,{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(ye,{className:"text-xs",children:"Name *"}),e.jsx(ze,{value:V,onChange:Ct=>{Y(Ct.target.value),B(!0),q(null)},placeholder:"Sarah & Mike Johnson"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Email"}),e.jsx(ze,{value:J,onChange:Ct=>te(Ct.target.value),placeholder:"Optional",type:"email"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Phone"}),e.jsx(ze,{value:X,onChange:Ct=>ce(Ct.target.value),placeholder:"Optional"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Client Type"}),e.jsxs(Ys,{value:ne,onValueChange:re,children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsxs(Ks,{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(ye,{className:"text-xs",children:"Property Address"}),e.jsx(ze,{value:le,onChange:Ct=>pe(Ct.target.value),placeholder:"Optional"})]})]}),U&&V&&e.jsxs(K,{onClick:He,className:"w-full gap-2",children:["Create Client & Continue",e.jsx(fi,{className:"h-4 w-4"})]})]})]})]})]}),g==="template"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs(ja,{defaultValue:"system",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"mine",children:"My Core Templates"}),e.jsx(us,{value:"system",children:"LevelUp Smart Templates"}),e.jsx(us,{value:"blank",children:"+ Start Blank"})]}),e.jsx(ks,{value:"mine",className:"mt-4",children:a?e.jsx("div",{className:"grid grid-cols-2 gap-4",children:[1,2].map(Ct=>e.jsx(vs,{className:"h-32"},Ct))}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Ct=>!Ct.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(Ct=>!Ct.is_system).map(Ct=>e.jsx(Bze,{template:Ct,onSelect:Qe},Ct.id))})}),e.jsx(ks,{value:"system",className:"mt-4",children:e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:n.filter(Ct=>Ct.is_system).map(Ct=>e.jsx(Bze,{template:Ct,onSelect:Qe},Ct.id))})}),e.jsx(ks,{value:"blank",className:"mt-4",children:e.jsx(Pe,{children:e.jsxs(Re,{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:at,children:"Start from Scratch"})]})})})]}),e.jsxs(K,{variant:"outline",onClick:()=>b("client"),className:"gap-2",children:[e.jsx(ri,{className:"h-4 w-4"}),"Back"]})]}),g==="builder"&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Presentation Title"}),e.jsx(ze,{value:fe,onChange:Ct=>we(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Page Heading"}),e.jsx(ze,{value:Te,onChange:Ct=>ft(Ct.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(ye,{children:"Client Name"}),e.jsx(ze,{value:V,onChange:Ct=>Y(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Property Address"}),e.jsx(ze,{value:le,onChange:Ct=>pe(Ct.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:Ie.map((Ct,As)=>e.jsx(Pe,{className:Pt(!Ct.is_visible&&"opacity-50"),children:e.jsx(Re,{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(Ju,{className:"h-4 w-4 text-muted-foreground cursor-grab"}),e.jsx("span",{className:"text-lg",children:Ct.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:Ct.title,onChange:Us=>It(As,{title:Us.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:()=>Ut(As),children:Ct.is_visible?e.jsx(qn,{className:"h-4 w-4"}):e.jsx(kp,{className:"h-4 w-4"})}),e.jsx(K,{variant:"ghost",size:"icon",onClick:()=>Yt(As),className:"text-destructive hover:text-destructive",children:e.jsx(Nr,{className:"h-4 w-4"})})]})]}),e.jsx(ze,{value:Ct.description||"",onChange:Us=>It(As,{description:Us.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(ye,{className:"text-xs",children:"Video URL"}),e.jsx(ze,{value:Ct.video_url||"",onChange:Us=>It(As,{video_url:Us.target.value}),placeholder:"Paste a YouTube or video URL...",className:"text-sm"})]}),e.jsx(ACs,{sectionTitle:Ct.title,contactId:R==null?void 0:R.id,onVideoReady:Us=>It(As,{video_url:Us})}),e.jsx(ECs,{sectionTitle:Ct.title,contactId:R==null?void 0:R.id,onVideoReady:Us=>It(As,{video_url:Us})}),e.jsx(nCe,{userId:r==null?void 0:r.id,onSelect:Us=>It(As,{video_url:Us})})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Image (optional — shown if no video is set)"}),Ct.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:Ct.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:()=>It(As,{image_url:""}),children:e.jsx(Or,{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:[me===As?e.jsx(ws,{className:"h-4 w-4 animate-spin text-muted-foreground"}):e.jsx(n1,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:me===As?"Uploading...":"Click to upload an image"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",disabled:me===As,onChange:Us=>{var ta;const kr=(ta=Us.target.files)==null?void 0:ta[0];kr&&qe(kr,As),Us.target.value=""}})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Text (optional)"}),e.jsx(hy,{content:Ct.text||"",onChange:Us=>It(As,{text:Us}),placeholder:"Add supporting text...",minHeight:"80px",compact:!0})]})]})]})})},As))})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Call to Action"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"CTA Type"}),e.jsxs(Ys,{value:Ae,onValueChange:Ct=>{Fe(Ct);const As=Fze.find(Us=>Us.value===Ct);As&&Me(As.label)},children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:Fze.map(Ct=>e.jsx(Mt,{value:Ct.value,children:Ct.label},Ct.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Button Label"}),e.jsx(ze,{value:Ce,onChange:Ct=>Me(Ct.target.value)})]}),e.jsxs("div",{children:[e.jsxs(ye,{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:$e,onChange:Ct=>ct(Ct.target.value),placeholder:"https://calendly.com/..."}),!$e&&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:()=>b("template"),className:"gap-2",children:[e.jsx(ri,{className:"h-4 w-4"}),"Back"]}),e.jsxs("div",{className:"flex gap-3 ml-auto",children:[e.jsx(K,{variant:"outline",onClick:ts,disabled:o.isPending||l.isPending,children:"Save Draft"}),e.jsxs(K,{onClick:Ds,disabled:i.isPending,className:"gap-2",children:[e.jsx(Rn,{className:"h-4 w-4"}),Ge?"Update & Reshare":"Publish & Share"]})]})]})]}),g==="share"&&Se&&e.jsxs("div",{className:"space-y-6",children:[e.jsx(Pe,{children:e.jsxs(Re,{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(fa,{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:vr,readOnly:!0,className:"text-center font-mono text-sm"}),e.jsx(K,{onClick:()=>{navigator.clipboard.writeText(vr),he.success("Link copied!")},children:e.jsx(gi,{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 Ct=`Hi ${V||""}! I put together something for you — check it out: ${vr}`;navigator.clipboard.writeText(Ct),he.success("Message copied!")},children:[e.jsx(io,{className:"h-4 w-4"}),"Copy Text Message"]}),e.jsxs(K,{variant:"outline",className:"gap-2",onClick:()=>{c?f(!0):window.open(`mailto:${J||""}?subject=${encodeURIComponent(fe)}&body=${encodeURIComponent(`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${vr} Looking forward to connecting!`)}`)},children:[e.jsx(dr,{className:"h-4 w-4"}),"Send Email"]})]}),c&&e.jsx(jE,{open:p,onOpenChange:f,contact:R?{id:R.id,first_name:R.first_name,last_name:R.last_name,email:J||R.email||""}:J?{id:"",first_name:(V==null?void 0:V.split(" ")[0])||"",last_name:(V==null?void 0:V.split(" ").slice(1).join(" "))||"",email:J}:void 0,defaultSubject:fe,defaultBody:`Hi ${(R==null?void 0:R.first_name)||(V==null?void 0:V.split(" ")[0])||""}, I put together a personalized presentation for you: ${vr} Looking forward to connecting!`,gmailEmail:u})]})}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(K,{variant:"outline",onClick:()=>b("builder"),children:[e.jsx(ri,{className:"h-4 w-4 mr-2"}),"Edit Presentation"]}),e.jsx(K,{onClick:()=>t("/mission-control/presentations"),children:"Done"})]})]})]})})},Bze=({template:t,onSelect:s})=>e.jsx(Pe,{className:"hover:shadow-sm transition-shadow",children:e.jsxs(Re,{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(tt,{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"})]})}),PCs=()=>{var j;const{shareToken:t}=yo(),[s,r]=k.useState(null),[n,a]=k.useState(!0),[o,l]=k.useState(0),[i,c]=k.useState(!1);k.useEffect(()=>(document.body.classList.add("presentation-page"),()=>{document.body.classList.remove("presentation-page")}),[]),k.useEffect(()=>{t&&u()},[t]);const u=async()=>{const{data:w,error:N}=await H.from("smart_presentations").select("*").eq("share_token",t).eq("status","published").single();if(N||!w){c(!0),a(!1);return}const{data:C}=await H.from("profiles").select("name, email, phone, avatar_url, title, brokerage_id").eq("id",w.owner_user_id).single();let M;if(C!=null&&C.brokerage_id){const{data:L}=await H.from("brokerages").select("name").eq("id",C.brokerage_id).single();M=(L==null?void 0:L.name)||void 0}let I=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();I=L}r({...w,owner_name:C==null?void 0:C.name,owner_email:C==null?void 0:C.email,owner_phone:C==null?void 0:C.phone,owner_avatar:C==null?void 0:C.avatar_url,owner_title:(C==null?void 0:C.title)||void 0,brokerage_name:M,contact_name:I?[I.first_name,I.last_name].filter(Boolean).join(" "):void 0,contact_email:(I==null?void 0:I.email)||void 0,contact_phone:(I==null?void 0:I.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")}};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(w=>w.is_visible!==!1),g=f[o],b=w=>{const N=w.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9_-]+)/);if(N)return`https://www.youtube.com/embed/${N[1]}?rel=0`;if(w.includes("iframe.mediadelivery.net/play/")){const I=w.replace("/play/","/embed/"),L=I.includes("?")?"&":"?";return`${I}${L}responsive=true`}if(w.includes("iframe.mediadelivery.net")){if(w.match(/\/embed\/(\d+)\/([a-f0-9-]+)/)){const L=w.includes("?")?"&":"?";return`${w}${L}responsive=true`}return""}const C=w.match(/loom\.com\/share\/([a-zA-Z0-9]+)/);if(C)return`https://www.loom.com/embed/${C[1]}`;const M=w.match(/video\.bunnycdn\.com\/play\/(\d+)\/([a-f0-9-]+)/);return M?`https://iframe.mediadelivery.net/embed/${M[1]}/${M[2]}?responsive=true`:w},_=!!((j=s.cta_url)!=null&&j.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&&b(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:b(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((w,N)=>e.jsx("button",{onClick:()=>l(N),className:Pt("w-full text-left p-4 rounded-xl border transition-all",o===N?"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(N+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})]})]})},N))})]}),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(an,{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(nGe,{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 ICs({openHouseId:t,enableSurvey:s,onToggleSurvey:r}){const{data:n,isLoading:a}=zkt(t),o=Ukt(),l=Vkt(),i=Hkt(),c=Wkt(),[u,p]=k.useState(""),[f,g]=k.useState("rating"),b=async N=>{r(N),N&&(!n||n.length===0)&&await c.mutateAsync(t)},_=async()=>{if(!u.trim())return;const N=(n==null?void 0:n.reduce((C,M)=>Math.max(C,M.sort_order),0))??0;await o.mutateAsync({open_house_id:t,question_type:f,question_text:u.trim(),sort_order:N+1}),p("")},j=async N=>{await l.mutateAsync({id:N.id,open_house_id:t,is_active:!N.is_active})},w=async N=>{await i.mutateAsync({id:N.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(ye,{className:"text-sm font-medium flex items-center gap-2",children:[e.jsx(O_,{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($r,{checked:s,onCheckedChange:b})]}),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(ws,{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(N=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg border border-border bg-muted/20",children:[e.jsx(Ju,{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:N.question_text}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:N.question_type.replace("_"," ")})]}),e.jsx($r,{checked:N.is_active,onCheckedChange:()=>j(N),className:"scale-75"}),e.jsx(K,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:text-destructive",onClick:()=>w(N),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]},N.id))}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(ye,{className:"text-xs text-muted-foreground",children:"Add Question"}),e.jsx(ze,{value:u,onChange:N=>p(N.target.value),placeholder:"e.g. How did you hear about this listing?",className:"mt-1 h-9 text-sm",onKeyDown:N=>N.key==="Enter"&&_()})]}),e.jsxs(Ys,{value:f,onValueChange:g,children:[e.jsx(Gs,{className:"w-28 h-9 text-xs",children:e.jsx(Qs,{})}),e.jsxs(Ks,{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 LCs({open:t,onOpenChange:s,openHouse:r}){const n=iGe(),{user:a}=Rs(),o=k.useRef(null),[l,i]=k.useState(r.auto_forward_to_card??!1),[c,u]=k.useState(r.disclosure_pdf_url??""),[p,f]=k.useState(r.enable_survey??!1),[g,b]=k.useState(!1),[_,j]=k.useState(!1),w=async M=>{var U;const I=(U=M.target.files)==null?void 0:U[0];if(!I||!a)return;if(I.size>20*1024*1024){vn({title:"File must be under 20MB",variant:"destructive"});return}if(I.type!=="application/pdf"){vn({title:"Only PDF files are accepted",variant:"destructive"});return}b(!0);const L=`${a.id}/disclosures/${r.id}-${Date.now()}.pdf`,{error:R}=await H.storage.from("open-house-photos").upload(L,I,{upsert:!0});if(R){vn({title:"Upload failed",description:R.message,variant:"destructive"}),b(!1);return}const{data:q}=H.storage.from("open-house-photos").getPublicUrl(L);u(q.publicUrl),b(!1),vn({title:"PDF uploaded!"})},N=()=>{u(""),o.current&&(o.current.value="")},C=async()=>{j(!0);try{await n.mutateAsync({id:r.id,auto_forward_to_card:l,disclosure_pdf_url:c||null,enable_survey:p}),vn({title:"Settings saved!"}),s(!1)}catch{vn({title:"Failed to save",variant:"destructive"})}finally{j(!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(_s,{children:[e.jsx(bs,{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(ye,{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($r,{checked:l,onCheckedChange:i})]})}),!l&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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:w,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(En,{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:N,children:e.jsx(Or,{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(ws,{className:"h-5 w-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs",children:"Upload PDF (max 20MB)"})]})})]}),e.jsx(ICs,{openHouseId:r.id,enableSurvey:p,onToggleSurvey:f}),e.jsx(K,{onClick:C,disabled:_,className:"w-full",children:_?"Saving...":"Save Settings"})]})]})})}const dct={5:"Excellent",4:"Good",3:"Neutral",2:"Bad",1:"Very Bad"};function DCs({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:dct[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 OCs({openHouseId:t}){const{data:s,isLoading:r}=qkt(t),{data:n}=aGe(t),a=k.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(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(O_,{className:"h-4 w-4"}),"Survey Results"]})}),e.jsx(Re,{children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"No survey responses yet."})})]}):e.jsxs(Pe,{children:[e.jsx(Dt,{className:"pb-3",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(O_,{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(Re,{children:e.jsxs(ja,{defaultValue:"summary",children:[e.jsxs(ga,{className:"mb-4",children:[e.jsxs(us,{value:"summary",className:"text-xs gap-1",children:[e.jsx(Ro,{className:"h-3.5 w-3.5"})," Summary"]}),e.jsxs(us,{value:"individual",className:"text-xs gap-1",children:[e.jsx(to,{className:"h-3.5 w-3.5"})," Per Visitor"]})]}),e.jsxs(ks,{value:"summary",className:"space-y-6",children:[i.map(f=>e.jsx(DCs,{question:f,responses:l},f.id)),c.map(f=>{const g=l.filter(b=>b.question_id===f.id&&b.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(b=>{const _=a[b.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:b.text_value})]},b.id)})})]},f.id)})]}),e.jsx(ks,{value:"individual",className:"space-y-4",children:u.map(f=>{const g=a[f],b=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:b.map(_=>{const j=o.find(w=>w.id===_.question_id);return j?e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:j.question_text}),e.jsx("span",{className:"font-medium",children:_.rating_value!=null?dct[_.rating_value]||_.rating_value:_.text_value})]},_.id):null})})]},f)})})]})})]})}const dwe="guestbook.relevelup.com";function RCs(){const{data:t,isLoading:s}=Dkt(),r=Okt(),n=iGe(),a=Rkt(),[o,l]=k.useState(!1),[i,c]=k.useState(null),{user:u}=Rs(),p=li(),[f,g]=k.useState(null),[b,_]=k.useState(null),[j,w]=k.useState(!1),N=k.useRef(null),[C,M]=k.useState({property_address:"",city:"",state:"",zip:"",event_date:ps(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),I=U=>{var V;const B=(V=U.target.files)==null?void 0:V[0];if(B){if(B.size>5*1024*1024){vn({title:"Photo must be under 5MB",variant:"destructive"});return}g(B),_(URL.createObjectURL(B))}},L=()=>{g(null),_(null),N.current&&(N.current.value="")},R=async()=>{if(!C.property_address){vn({title:C.event_type==="community"?"Event name is required":"Address is required",variant:"destructive"});return}let U;if(f&&u){w(!0);const B=f.name.split(".").pop(),V=`${p}/${Date.now()}.${B}`,{error:Y}=await H.storage.from("open-house-photos").upload(V,f,{upsert:!0});if(Y){vn({title:"Photo upload failed",description:Y.message,variant:"destructive"}),w(!1);return}const{data:J}=H.storage.from("open-house-photos").getPublicUrl(V);U=J.publicUrl,w(!1)}await r.mutateAsync({...C,photo_url:U}),l(!1),M({property_address:"",city:"",state:"",zip:"",event_date:ps(new Date,"yyyy-MM-dd"),start_time:"10:00",end_time:"14:00",agent_greeting:"Welcome! Please sign in below.",event_type:"property"}),L()},q=U=>{navigator.clipboard.writeText(`https://${dwe}/${U}`),vn({title:"Link copied!"})};return e.jsxs(Ts,{title:"Guest Book",children:[e.jsx(rd,{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(_s,{children:[e.jsx(bs,{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 ${C.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 ${C.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(ye,{children:C.event_type==="community"?"Event Name *":"Property Address *"}),e.jsx(ze,{value:C.property_address,onChange:U=>M(B=>({...B,property_address:U.target.value})),placeholder:C.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(ye,{children:"City"}),e.jsx(ze,{value:C.city,onChange:U=>M(B=>({...B,city:U.target.value})),placeholder:"Austin"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"State"}),e.jsx(ze,{value:C.state,onChange:U=>M(B=>({...B,state:U.target.value})),placeholder:"TX",maxLength:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"ZIP"}),e.jsx(ze,{value:C.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(ye,{children:"Date"}),e.jsx(ze,{type:"date",value:C.event_date,onChange:U=>M(B=>({...B,event_date:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Start Time"}),e.jsx(ze,{type:"time",value:C.start_time,onChange:U=>M(B=>({...B,start_time:U.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"End Time"}),e.jsx(ze,{type:"time",value:C.end_time,onChange:U=>M(B=>({...B,end_time:U.target.value}))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Welcome Message"}),e.jsx(Er,{value:C.agent_greeting,onChange:U=>M(B=>({...B,agent_greeting:U.target.value})),placeholder:"Welcome! Please sign in below."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:C.event_type==="community"?"Event Photo":"Property Photo"}),e.jsx("input",{ref:N,type:"file",accept:"image/*",onChange:I,className:"hidden"}),b?e.jsxs("div",{className:"relative mt-1 rounded-xl overflow-hidden border border-border",children:[e.jsx("img",{src:b,alt:"Property preview",className:"w-full h-40 object-cover"}),e.jsx("button",{type:"button",onClick:L,className:"absolute top-2 right-2 bg-black/60 hover:bg-black/80 text-white rounded-full p-1 transition-colors",children:e.jsx(Or,{className:"h-4 w-4"})})]}):e.jsxs("button",{type:"button",onClick:()=>{var U;return(U=N.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(n1,{className:"h-6 w-6"}),e.jsxs("span",{className:"text-sm",children:["Add a ",C.event_type==="community"?"cover":"property"," photo"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Max 5MB"})]})]}),e.jsx(K,{onClick:R,disabled:r.isPending||j,className:"w-full",children:j?"Uploading photo...":r.isPending?"Creating...":C.event_type==="community"?"Create Community Event":"Create Open House"})]})]})]})]}),s?e.jsx("div",{className:"grid gap-4",children:[1,2].map(U=>e.jsx(Pe,{className:"animate-pulse",children:e.jsxs(Dt,{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(FCs,{openHouse:U,isExpanded:i===U.id,onToggle:()=>c(i===U.id?null:U.id),onCopyLink:()=>q(U.slug||""),onToggleActive:()=>n.mutate({id:U.id,is_active:!U.is_active}),onDelete:()=>a.mutate(U.id)},U.id))}):e.jsx(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(o1,{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 FCs({openHouse:t,isExpanded:s,onToggle:r,onCopyLink:n,onToggleActive:a,onDelete:o}){const{data:l}=aGe(s?t.id:void 0),[i,c]=k.useState(!1),[u,p]=k.useState(!1),[f,g]=k.useState(!1),b=k.useRef(null),_=`https://${dwe}/${t.slug}`,j=I=>{if(!I)return"";const[L,R]=I.split(":"),q=parseInt(L),U=q>=12?"PM":"AM";return`${q>12?q-12:q||12}:${R} ${U}`},w=()=>{if(!(l!=null&&l.length))return;const I=["First Name","Last Name","Email","Phone","Intent","Wants Market Updates","Message","Signed In"],L=l.map(V=>[V.first_name,V.last_name||"",V.email||"",V.phone||"",V.visitor_intent||"",V.wants_market_updates?"Yes":"No",(V.message||"").replace(/"/g,'""'),ps(new Date(V.created_at),"MM/dd/yyyy h:mm a")]),R=[I,...L].map(V=>V.map(Y=>`"${Y}"`).join(",")).join(` `),q=new Blob([R],{type:"text/csv"}),U=URL.createObjectURL(q),B=document.createElement("a");B.href=U,B.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-visitors.csv`,B.click(),URL.revokeObjectURL(U)},N=k.useCallback(()=>{if(!b.current)return;const I=b.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R=document.createElement("canvas");R.width=1024,R.height=1024;const q=R.getContext("2d"),U=new Image;U.onload=()=>{q==null||q.drawImage(U,0,0,1024,1024);const B=document.createElement("a");B.download=`${t.property_address.replace(/[^a-zA-Z0-9]/g,"-")}-qr.png`,B.href=R.toDataURL("image/png"),B.click()},U.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L)))},[t.property_address]),C=k.useCallback(()=>{if(!b.current)return;const I=b.current.querySelector("svg");if(!I)return;const L=new XMLSerializer().serializeToString(I),R="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(L))),q=ps(new Date(t.event_date+"T00:00:00"),"EEEE, MMMM d, yyyy"),U=t.start_time?`${j(t.start_time)}${t.end_time?" – "+j(t.end_time):""}`:"",B=[t.city,t.state].filter(Boolean).join(", "),V=t.agent_greeting||"Welcome! Please sign in below.",Y=window.open("","_blank");Y&&(Y.document.write(` Open House – ${t.property_address}
${t.event_type==="community"?"Community Event":"Open House"}
${t.property_address}
${B?`
${B}${t.zip?" "+t.zip:""}
`:""}
Date
${q}
${U?`
Time
${U}
`:""}
${V}
QR Code
Scan to Sign In
Point your phone camera at the QR code
`),Y.document.close(),setTimeout(()=>{Y.focus(),Y.print()},500))},[t,_]),M=async()=>{g(!0);try{const{error:I}=await H.functions.invoke("guestbook-email-link",{body:{openHouseId:t.id}});if(I)throw I;vn({title:"Email sent!",description:"Check your inbox for the guest book link."})}catch(I){vn({title:"Failed to send",description:I.message,variant:"destructive"})}finally{g(!1)}};return e.jsxs(Pe,{className:`transition-all ${t.is_active?"border-primary/30":"opacity-75"}`,children:[e.jsx(Dt,{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(zt,{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(tt,{variant:t.is_active?"default":"secondary",className:"shrink-0 text-[11px]",children:t.is_active?"Active":"Inactive"}),t.agent_name&&e.jsxs(tt,{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(to,{className:"h-3 w-3"}),t.agent_name]}),t.event_type==="community"&&e.jsxs(tt,{variant:"outline",className:"shrink-0 gap-1 text-[11px]",children:[e.jsx(wa,{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(pf,{className:"h-4 w-4"}):e.jsx(To,{className:"h-4 w-4"})})]}),e.jsxs(xr,{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(Ba,{className:"h-3 w-3"}),t.city,t.state?`, ${t.state}`:""]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(cn,{className:"h-3 w-3"}),ps(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(mn,{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(mr,{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(l1,{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(gi,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs(K,{variant:"outline",size:"sm",onClick:()=>c(!0),title:"QR Code",className:"shrink-0 gap-1.5 h-8 text-xs",children:[e.jsx(o1,{className:"h-3.5 w-3.5"}),"QR"]}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>p(!0),title:"Settings",className:"shrink-0 h-8 text-xs",children:e.jsx(Yo,{className:"h-3.5 w-3.5"})}),e.jsx(K,{variant:"outline",size:"sm",onClick:()=>window.open(_,"_blank"),title:"Preview",className:"shrink-0 h-8 text-xs",children:e.jsx(an,{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(qn,{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(Re,{className:"pt-0",children:[e.jsx(sl,{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://",dwe,"/",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:w,className:"h-7 text-xs gap-1",children:[e.jsx(Ci,{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(I=>e.jsxs("tr",{className:"border-t border-border/50",children:[e.jsxs("td",{className:"p-2 font-medium",children:[I.first_name,I.last_name?` ${I.last_name}`:""]}),e.jsxs("td",{className:"p-2 text-muted-foreground hidden sm:table-cell",children:[I.email&&e.jsx("div",{className:"truncate max-w-[180px]",children:I.email}),I.phone&&e.jsx("div",{className:"text-xs",children:I.phone})]}),e.jsx("td",{className:"p-2 hidden md:table-cell",children:I.visitor_intent&&e.jsx(tt,{variant:"outline",className:"text-xs capitalize",children:I.visitor_intent})}),e.jsx("td",{className:"p-2 text-xs text-muted-foreground",children:ps(new Date(I.created_at),"h:mm a")})]},I.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(OCs,{openHouseId:t.id})})]}),e.jsx(xs,{open:i,onOpenChange:c,children:e.jsxs(fs,{className:"sm:max-w-sm",children:[e.jsxs(_s,{children:[e.jsx(bs,{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:b,className:"bg-white p-4 rounded-xl",children:e.jsx(jR,{value:_,size:240,level:"H"})}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:_}),e.jsxs("div",{className:"flex gap-2 w-full",children:[e.jsxs(K,{variant:"outline",className:"flex-1",onClick:N,children:[e.jsx(Ci,{className:"h-4 w-4 mr-2"}),"Download"]}),e.jsxs(K,{variant:"outline",className:"flex-1",onClick:C,children:[e.jsx(yL,{className:"h-4 w-4 mr-2"}),"Print Flyer"]})]}),e.jsxs(K,{variant:"default",className:"w-full",onClick:M,disabled:f,children:[e.jsx(dr,{className:"h-4 w-4 mr-2"}),f?"Sending...":"Email Link to Me"]})]})]})}),e.jsx(LCs,{open:u,onOpenChange:p,openHouse:t})]})}function zCs(){const{slug:t}=yo();return t?e.jsx(PZe,{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 uct({photoUrl:t,videoUrl:s,onPhotoChange:r,onVideoChange:n,contactId:a}){const{user:o}=Rs(),l=_C(),i=k.useRef(null),c=k.useRef(null),[u,p]=k.useState(!1),[f,g]=k.useState(!1),[b,_]=k.useState(0),j=async N=>{if(o){p(!0);try{const C=N.name.split(".").pop()||"jpg",M=`${o.id}/card-${Date.now()}.${C}`,{error:I}=await H.storage.from("listing-photos").upload(M,N);if(I)throw I;const{data:{publicUrl:L}}=H.storage.from("listing-photos").getPublicUrl(M);r(L),he.success("Photo uploaded")}catch(C){he.error(C.message||"Failed to upload photo")}finally{p(!1)}}},w=async N=>{if(o){if(N.size>500*1024*1024){he.error("Video must be under 500MB");return}g(!0),_(0);try{const{videoId:C,libraryId:M}=await hR(`Card Video - ${Date.now()}`),{uploadUrl:I,apiKey:L}=await mR(C);await new Promise((U,B)=>{const V=new XMLHttpRequest;V.upload.addEventListener("progress",Y=>{Y.lengthComputable&&_(Math.round(Y.loaded/Y.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",I),V.setRequestHeader("AccessKey",L),V.send(N)});const R=`https://iframe.mediadelivery.net/embed/${M}/${C}`;n(R);const q=parseFloat((N.size/(1024*1024)).toFixed(2));await l.mutateAsync({bunny_video_id:C,playback_url:`https://iframe.mediadelivery.net/play/${M}/${C}`,file_size_mb:q,title:"Card Video",status:"processing",touch_type:"video",contact_id:a||void 0}),he.success("Video uploaded & added to your library")}catch(C){he.error(C.message||"Failed to upload video")}finally{g(!1),_(0)}}};return e.jsxs("div",{className:"space-y-3",children:[e.jsx(ye,{children:"Media (optional)"}),e.jsxs(ja,{defaultValue:"photo",className:"w-full",children:[e.jsxs(ga,{className:"grid w-full grid-cols-2",children:[e.jsxs(us,{value:"photo",className:"gap-1.5 text-xs",children:[e.jsx(fl,{className:"h-3.5 w-3.5"}),"Photo"]}),e.jsxs(us,{value:"video",className:"gap-1.5 text-xs",children:[e.jsx(Cn,{className:"h-3.5 w-3.5"}),"Video"]})]}),e.jsxs(ks,{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(Or,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=i.current)==null?void 0:N.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(ws,{className:"h-6 w-6 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(kx,{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:N=>{var M;const C=(M=N.target.files)==null?void 0:M[0];C&&j(C),N.target.value=""}})]}),e.jsxs(ks,{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(Or,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{onClick:()=>{var N;return(N=c.current)==null?void 0:N.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(ws,{className:"h-6 w-6 animate-spin"}),e.jsxs("span",{className:"text-xs",children:["Uploading... ",b,"%"]}),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:`${b}%`}})})]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{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(aCe,{contactId:a,onVideoReady:N=>n(N)})}),e.jsx("input",{ref:c,type:"file",accept:"video/*",className:"hidden",onChange:N=>{var M;const C=(M=N.target.files)==null?void 0:M[0];C&&w(C),N.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 BCs=[{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 $Cs({onSelect:t}){return e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:BCs.map((s,r)=>e.jsxs(Ws.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 RE={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 $ze({initialOpen:t,initialCardType:s,initialContactId:r,initialRecipientName:n,initialAddress:a,initialDate:o,onOpenChange:l}){const{user:i}=Rs(),c=es(),[u,p]=k.useState(!1),[f,g]=k.useState("type"),[b,_]=k.useState(""),[j,w]=k.useState(null),[N,C]=k.useState(!1),[M,I]=k.useState("home_anniversary"),[L,R]=k.useState(""),[q,U]=k.useState(""),[B,V]=k.useState(""),[Y,J]=k.useState(""),[te,X]=k.useState("elegant"),[ce,ne]=k.useState(null),[re,le]=k.useState(null),pe=k.useState(!1);!pe[0]&&t&&s&&(pe[1](!0),p(!0),I(s),r&&w(r),n&&R(n),a&&U(a),o&&V(o),g(n?"details":"contact"));const{data:xe}=mt({queryKey:["contacts-for-card",i==null?void 0:i.id,b],queryFn:async()=>{let $e=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);b&&($e=$e.or(`first_name.ilike.%${b}%,last_name.ilike.%${b}%`));const{data:ct,error:Te}=await $e;if(Te)throw Te;return ct},enabled:!!(i!=null&&i.id)&&u}),{data:_e}=mt({queryKey:["agent-profile-card",i==null?void 0:i.id],queryFn:async()=>{const{data:$e,error:ct}=await H.from("profiles").select("name, email, phone, avatar_url, brokerage:brokerages(name)").eq("id",i.id).single();if(ct)throw ct;return $e},enabled:!!(i!=null&&i.id)}),fe=$e=>{w($e.id),R(`${$e.first_name}${$e.last_name?" "+$e.last_name:""}`),U([$e.address,$e.city,$e.state].filter(Boolean).join(", ")),V($e.home_anniversary||""),g("details")},we=$e=>{I($e),g("contact")},Ie=async()=>{var $e;if(!(!i||!_e)){C(!0);try{const ct={owner_user_id:i.id,contact_id:j,card_type:M,template:te,recipient_name:L,property_address:q||null,home_anniversary_date:B||null,custom_message:Y||null,property_photo_url:ce||null,video_url:re||null,agent_name:_e.name||"Agent",agent_photo_url:_e.avatar_url,agent_phone:_e.phone,agent_email:_e.email,agent_brokerage:(($e=_e.brokerage)==null?void 0:$e.name)||null},{error:Te}=await H.from("sendable_cards").insert(ct);if(Te)throw Te;he.success("Card created! Copy the link to share it."),c.invalidateQueries({queryKey:["sendable-cards"]}),Ne()}catch(ct){he.error(ct.message||"Failed to create card")}finally{C(!1)}}},Ne=()=>{p(!1),g("type"),I("home_anniversary"),_(""),w(null),R(""),U(""),V(""),J(""),X("elegant"),ne(null),le(null)},Ae={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"},Fe=RE[M],Ce=M==="home_anniversary",Me=["home_anniversary","just_listed","just_sold"].includes(M);return e.jsxs(xs,{open:u,onOpenChange:$e=>{$e?p(!0):(Ne(),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(_s,{children:e.jsx(bs,{children:f==="type"?"What type of card?":f==="contact"?`${Ae[M]} — Choose a Contact`:`${Ae[M]} — Customize`})}),f==="type"&&e.jsx($Cs,{onSelect:we}),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(ri,{className:"h-3.5 w-3.5"})," Back to card types"]}),e.jsxs("div",{className:"relative",children:[e.jsx(hn,{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:b,onChange:$e=>_($e.target.value),className:"pl-9"})]}),e.jsxs("div",{className:"space-y-1 max-h-64 overflow-y-auto",children:[xe==null?void 0:xe.map($e=>e.jsxs("button",{onClick:()=>fe($e),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(to,{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:[$e.first_name," ",$e.last_name]}),$e.address&&e.jsxs("p",{className:"text-xs text-muted-foreground truncate flex items-center gap-1",children:[e.jsx(Sn,{className:"h-3 w-3"}),$e.address]})]}),$e.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"})]},$e.id)),(xe==null?void 0:xe.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(ri,{className:"h-3.5 w-3.5"})," Back"]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Recipient Name"}),e.jsx(ze,{value:L,onChange:$e=>R($e.target.value),placeholder:"John & Jane Smith"})]}),Me&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Address"}),e.jsx(ze,{value:q,onChange:$e=>U($e.target.value),placeholder:"123 Main St, Austin, TX"})]}),Ce&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:B,onChange:$e=>V($e.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Message (optional)"}),e.jsx(Er,{value:Y,onChange:$e=>J($e.target.value),placeholder:Fe.defaultMessage,rows:3})]}),e.jsx(uct,{photoUrl:ce,videoUrl:re,onPhotoChange:ne,onVideoChange:le,contactId:j}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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:$e,label:ct,gradient:Te})=>e.jsxs("button",{onClick:()=>X($e),className:`p-2 rounded-lg border-2 transition-all text-center ${te===$e?"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:ct})]},$e))})]}),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:Ie,disabled:!L||N,className:"flex-1 gap-2",children:N?"Creating...":"Create Card"})]})]})]})]})}const qCs={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 UCs({card:t}){const{user:s}=Rs(),{isGmailConnected:r}=$0(),n=es(),[a,o]=k.useState(!1),[l,i]=k.useState("");k.useEffect(()=>{a&&t.contact_id&&!l&&H.from("innercircle_contacts").select("email").eq("id",t.contact_id).maybeSingle().then(({data:j})=>{j!=null&&j.email&&i(j.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]=k.useState(c[t.card_type]||`A Special Card for ${t.recipient_name}!`),[f,g]=k.useState(""),b=`https://cardstudio.relevelup.com/c/${t.share_token}`,_=Lt({mutationFn:async()=>{var M;if(!l)throw new Error("Recipient email is required");const j=`
${f?`

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


`:""}

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

${t.property_address?`

${t.property_address}

`:""}
`,{data:w}=await H.auth.getSession(),N=(M=w==null?void 0:w.session)==null?void 0:M.access_token,C=await fetch("https://relzejiswnotikjgvjhz.supabase.co/functions/v1/gmail-send",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N}`},body:JSON.stringify({to:l,subject:u,body:j,contactId:t.contact_id||void 0})});if(!C.ok){const I=await C.json();throw new Error(I.error||"Failed to send")}return C.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"]}),he.success(`Card sent to ${l}!`),o(!1)},onError:j=>{he.error(j.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(Rn,{className:"h-3 w-3"})})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Send Card via Gmail"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"To"}),e.jsx(ze,{type:"email",value:l,onChange:j=>i(j.target.value),placeholder:"recipient@email.com"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Subject"}),e.jsx(ze,{value:u,onChange:j=>p(j.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Note (optional)"}),e.jsx(Er,{value:f,onChange:j=>g(j.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:b})]}),e.jsx(K,{onClick:()=>_.mutate(),disabled:!l||_.isPending,className:"w-full gap-2",children:_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Sending..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{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(Rn,{className:"h-3 w-3"})})}function VCs({card:t}){const s=es(),[r,n]=k.useState(!1),[a,o]=k.useState(!1),[l,i]=k.useState(t.recipient_name),[c,u]=k.useState(t.property_address||""),[p,f]=k.useState(t.home_anniversary_date||""),[g,b]=k.useState(t.custom_message||""),[_,j]=k.useState(t.template),[w,N]=k.useState(t.property_photo_url),[C,M]=k.useState(t.video_url||null),I=R=>{R&&(i(t.recipient_name),u(t.property_address||""),f(t.home_anniversary_date||""),b(t.custom_message||""),j(t.template),N(t.property_photo_url),M(t.video_url||null)),n(R)},L=async()=>{if(!l.trim()){he.error("Recipient name is required");return}o(!0);try{const{error:R}=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:w||null,video_url:C||null}).eq("id",t.id);if(R)throw R;s.invalidateQueries({queryKey:["sendable-cards"]}),he.success("Card updated"),n(!1)}catch(R){he.error(R.message||"Failed to update card")}finally{o(!1)}};return e.jsxs(xs,{open:r,onOpenChange:I,children:[e.jsx(qi,{asChild:!0,children:e.jsx(K,{variant:"outline",size:"sm",className:"gap-1 text-xs",children:e.jsx(Da,{className:"h-3 w-3"})})}),e.jsxs(fs,{className:"sm:max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(_s,{children:e.jsx(bs,{children:"Edit Card"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Recipient Name"}),e.jsx(ze,{value:l,onChange:R=>i(R.target.value),placeholder:"John & Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Property Address"}),e.jsx(ze,{value:c,onChange:R=>u(R.target.value),placeholder:"123 Main St, Austin, TX"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Home Anniversary Date"}),e.jsx(ze,{type:"date",value:p,onChange:R=>f(R.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Personal Message (optional)"}),e.jsx(Er,{value:g,onChange:R=>b(R.target.value),placeholder:"Wishing you many more happy years in your beautiful home!",rows:3})]}),e.jsx(uct,{photoUrl:w,videoUrl:C,onPhotoChange:N,onVideoChange:M,contactId:t.contact_id}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{children:"Template Style"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["elegant","bold","warm"].map(R=>e.jsxs("button",{onClick:()=>j(R),className:`p-3 rounded-lg border-2 transition-all text-center ${_===R?"border-primary bg-primary/5":"border-border hover:border-primary/30"}`,children:[e.jsx("div",{className:`h-12 rounded-md mb-2 ${R==="elegant"?"bg-gradient-to-br from-slate-100 to-slate-200 dark:from-slate-800 dark:to-slate-700":R==="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:R})]},R))})]}),e.jsx(K,{onClick:L,disabled:!l.trim()||a,className:"w-full gap-2",children:a?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"})," Saving..."]}):"Save Changes"})]})]})]})}function HCs(){const{user:t}=Rs(),s=es(),[r,n]=k.useState(""),[a,o]=qc(),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:b}=mt({queryKey:["sendable-cards",t==null?void 0:t.id],queryFn:async()=>{const{data:M,error:I}=await H.from("sendable_cards").select("*").eq("owner_user_id",t.id).order("created_at",{ascending:!1});if(I)throw I;return M},enabled:!!(t!=null&&t.id)}),_=Lt({mutationFn:async M=>{const{error:I}=await H.from("sendable_cards").delete().eq("id",M);if(I)throw I},onSuccess:()=>{s.invalidateQueries({queryKey:["sendable-cards"]}),he.success("Card deleted")}}),j=M=>{const I=`https://cardstudio.relevelup.com/c/${M}`;navigator.clipboard.writeText(I),he.success("Share link copied!")},w=g==null?void 0:g.filter(M=>{var I;return!r||M.recipient_name.toLowerCase().includes(r.toLowerCase())||((I=M.property_address)==null?void 0:I.toLowerCase().includes(r.toLowerCase()))}),N={elegant:"Elegant",bold:"Bold",warm:"Warm"},C={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($ze,{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(hn,{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"})]}),b?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(Pe,{className:"animate-pulse",children:e.jsxs(Re,{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))}):w!=null&&w.length?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:w.map(M=>e.jsxs(Pe,{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:C[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(tt,{variant:M.template==="bold"?"outline":"secondary",className:`text-[10px] ${M.template==="bold"?"border-white/30 text-white/80":""}`,children:N[M.template]||M.template})})]}),e.jsxs(Re,{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(qn,{className:"h-3 w-3"}),M.view_count," views"]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:_d(new Date(M.created_at),{addSuffix:!0})})]}),M.sent_at&&e.jsxs("p",{className:"text-[10px] text-emerald-600 mb-2",children:["Sent ",ps(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:()=>j(M.share_token),children:[e.jsx(gi,{className:"h-3 w-3"}),"Copy Link"]}),e.jsx(VCs,{card:M}),e.jsx(UCs,{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(an,{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(Pe,{className:"border-dashed",children:e.jsxs(Re,{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(dr,{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($ze,{initialOpen:f,initialCardType:l,initialContactId:i||void 0,initialRecipientName:c||void 0,initialAddress:u||void 0,initialDate:p||void 0,onOpenChange:()=>o({})})]})})]})})}function dI({delay:t,x:s,y:r,size:n}){return e.jsx(Ws.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 WCs(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,b=RE[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(Ws.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(Ws.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(dI,{delay:0,x:"15%",y:"20%",size:8}),e.jsx(dI,{delay:1,x:"80%",y:"30%",size:6}),e.jsx(dI,{delay:2,x:"60%",y:"70%",size:10}),e.jsx(dI,{delay:.5,x:"25%",y:"80%",size:7}),e.jsx(dI,{delay:1.5,x:"70%",y:"15%",size:5})]}),e.jsxs(Ws.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(Ws.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(Ws.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(Ws.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(Ws.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:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Ws.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(Ws.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:b.title[0]}),b.title[1]&&e.jsx(Ws.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:b.title[1]}),e.jsxs(Ws.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(Ws.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(Ws.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(Ws.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(Ws.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||b.defaultMessage}),e.jsxs(Ws.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(Ws.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(Ws.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(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Ws.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(dr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Ws.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 Sye({delay:t,x:s,y:r,color:n,size:a}){return e.jsx(Ws.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 uI({delay:t,x:s,y:r}){return e.jsx(Ws.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 qze={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 GCs(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,b=RE[s],_=qze[s]||qze.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(Sye,{delay:0,x:"10%",y:"10%",color:_.orbs[0],size:200}),e.jsx(Sye,{delay:1,x:"70%",y:"60%",color:_.orbs[1],size:180}),e.jsx(Sye,{delay:2,x:"50%",y:"20%",color:_.orbs[2],size:150}),e.jsx(uI,{delay:0,x:"20%",y:"25%"}),e.jsx(uI,{delay:.8,x:"75%",y:"15%"}),e.jsx(uI,{delay:1.6,x:"85%",y:"65%"}),e.jsx(uI,{delay:2.4,x:"10%",y:"75%"}),e.jsx(uI,{delay:.4,x:"45%",y:"85%"}),e.jsxs(Ws.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(Ws.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(Ws.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(Ws.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(Ws.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:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Ws.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(Ws.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(Ws.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:b.title[0]}),b.title[1]&&e.jsx(Ws.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:b.title[1]}),e.jsx(Ws.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:b.emojis.slice(0,3).join("")}),e.jsxs(Ws.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(Sn,{className:"h-3.5 w-3.5"}),n]})]}),f&&e.jsx(Ws.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(Ws.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(Ws.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||b.defaultMessage})}),e.jsxs(Ws.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(Ws.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(Ws.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(Un,{className:"h-3.5 w-3.5"})," Call Me"]}),u&&e.jsxs(Ws.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(dr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Ws.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 KCs({emoji:t,delay:s,x:r,duration:n}){return e.jsx(Ws.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 Uze={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 ZCs(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,b=RE[s],_=Uze[s]||Uze.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:[b.emojis.map((j,w)=>e.jsx(KCs,{emoji:j,delay:w*1.2,x:`${15+w*14}%`,duration:5+w%3},w)),e.jsx(Ws.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(Ws.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(Ws.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(Ws.div,{className:`h-28 bg-gradient-to-r ${_.header} relative overflow-hidden`,children:[e.jsx(Ws.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(Ws.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:b.emojis[0]}),e.jsx(Ws.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:b.emojis[1]}),e.jsx(Ws.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:b.emojis[2]})]}),e.jsxs("div",{className:"px-8 py-8 text-center -mt-10 relative",children:[e.jsx(Ws.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(Ws.div,{animate:{scale:[1,1.2,1]},transition:{duration:1.5,repeat:1/0,ease:"easeInOut"},children:e.jsx("span",{className:"text-3xl",children:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsx(Ws.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(Ws.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(Ws.h1,{className:`text-3xl font-bold ${_.accent} mb-1`,initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:.9},children:[b.title.join(" ")," ",b.emojis[4]]}),e.jsxs(Ws.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(Ba,{className:"h-3 w-3"}),n]})]}),f&&e.jsx(Ws.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(Ws.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(Ws.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||b.defaultMessage,'"']})}),e.jsxs(Ws.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(Ws.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(Ws.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(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Ws.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(dr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Ws.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 e9({delay:t,x:s,y:r,size:n,color:a}){return e.jsx(Ws.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 Cye({delay:t,x:s,y:r,size:n}){return e.jsx(Ws.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 Vze={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 YCs(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,b=RE[s],_=Vze[s]||Vze.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(e9,{delay:0,x:"5%",y:"10%",size:300,color:_.mesh[0]}),e.jsx(e9,{delay:2,x:"60%",y:"50%",size:250,color:_.mesh[1]}),e.jsx(e9,{delay:4,x:"30%",y:"70%",size:200,color:_.mesh[2]}),e.jsx(e9,{delay:1,x:"80%",y:"15%",size:180,color:_.mesh[0]}),e.jsx(Cye,{delay:0,x:"15%",y:"20%",size:100}),e.jsx(Cye,{delay:3,x:"70%",y:"60%",size:140}),e.jsx(Cye,{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(Ws.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(Ws.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(Ws.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(Ws.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(Ws.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(Ws.span,{className:"text-5xl",animate:{scale:[1,1.08,1]},transition:{duration:2,repeat:1/0,ease:"easeInOut"},children:b.icon})]}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Ws.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(Ws.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(Ws.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:b.title[0]}),b.title[1]&&e.jsx(Ws.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:b.title[1]}),e.jsxs(Ws.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(Ba,{className:"h-3 w-3"})," ",n]})]}),e.jsx(Ws.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(Ws.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(Ws.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(Ws.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||b.defaultMessage,'"']})}),e.jsxs(Ws.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(Ws.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(Ws.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(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Ws.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(dr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})]}),e.jsx(Ws.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 Mye({delay:t,x:s,angle:r,color:n}){return e.jsx(Ws.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 t9({delay:t,x:s}){return e.jsx(Ws.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 Hze={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 XCs(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,b=RE[s],_=Hze[s]||Hze.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(Mye,{delay:0,x:"20%",angle:15,color:_.stripe}),e.jsx(Mye,{delay:2,x:"75%",angle:-12,color:_.stripe}),e.jsx(Mye,{delay:4,x:"50%",angle:5,color:_.stripe}),e.jsx(t9,{delay:0,x:"30%"}),e.jsx(t9,{delay:1.5,x:"60%"}),e.jsx(t9,{delay:3,x:"45%"}),e.jsx(t9,{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(Ws.div,{className:"w-full max-w-md relative z-10",initial:{opacity:0},animate:{opacity:1},transition:{duration:1.2},children:[e.jsx(Ws.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(Ws.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(Ws.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:b.icon})})}),s==="home_anniversary"&&a!==null&&a>0&&e.jsxs(Ws.div,{className:"mb-6",initial:{opacity:0},animate:{opacity:1},transition:{delay:.7},children:[e.jsx(Ws.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(Ws.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:b.title[0]})}),b.title[1]&&e.jsx("div",{className:"overflow-hidden mb-8",children:e.jsx(Ws.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:b.title[1]})}),e.jsxs(Ws.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(Ba,{className:"h-3 w-3"})," ",n]})]}),e.jsxs(Ws.div,{className:"flex items-center justify-center gap-3 my-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1.2},children:[e.jsx(Ws.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(Ws.span,{className:"text-white/10 text-xs",animate:{rotate:[0,360]},transition:{duration:20,repeat:1/0,ease:"linear"},children:"✦"}),e.jsx(Ws.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(Ws.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(Ws.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(Ws.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||b.defaultMessage}),e.jsxs(Ws.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(Ws.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(Ws.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(Un,{className:"h-3.5 w-3.5"})," Call"]}),u&&e.jsxs(Ws.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(dr,{className:"h-3.5 w-3.5"})," Email"]})]})]})]})}),e.jsx(Ws.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 hct(){const{shareToken:t}=yo(),{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(k.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()-Il(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(GCs,{...o});case"warm":return e.jsx(ZCs,{...o});case"glass":return e.jsx(YCs,{...o});case"cinematic":return e.jsx(XCs,{...o});case"elegant":default:return e.jsx(WCs,{...o})}}function QCs(){const t=li();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 JCs(){const t=li(),s=es();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 e3s(){const t=pr(),{isGmailConnected:s,gmailEmail:r}=$0(),{data:n,isLoading:a}=QCs(),o=JCs(),[l,i]=k.useState(!1),[c,u]=k.useState(!0),[p,f]=k.useState(!1);k.useEffect(()=>{n&&(i(n.is_globally_enabled),u(n.append_signature))},[n]);const g=async _=>{if(_&&!s){he.error("Connect your Gmail account first before enabling Smart Drips");return}i(_);try{await o.mutateAsync({is_globally_enabled:_}),he.success(_?"Smart Drips enabled globally":"Smart Drips paused globally")}catch{i(!_),he.error("Failed to update settings")}},b=async _=>{u(_);try{await o.mutateAsync({append_signature:_}),he.success(_?"Signature will be appended to drip emails":"Signature disabled for drip emails")}catch{u(!_),he.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(Yo,{className:"h-3.5 w-3.5"}),"Settings"]})}),e.jsxs(fs,{className:"sm:max-w-md",children:[e.jsxs(_s,{children:[e.jsxs(bs,{className:"flex items-center gap-2",children:[e.jsx(Yo,{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(dr,{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(tt,{variant:"outline",className:"gap-1 text-emerald-600 border-emerald-200 bg-emerald-500/10 text-[10px]",children:[e.jsx(la,{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(an,{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(sl,{}),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(gL,{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($r,{checked:l,onCheckedChange:g,disabled:a||o.isPending})]}),e.jsx(sl,{}),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(Qy,{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($r,{checked:c,onCheckedChange:b,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(Qy,{className:"h-3 w-3 mr-1"}),"Edit your email signature in Profile settings"]})]})]})]})}function t3s(){const t=li();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 s3s(){const t=li();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 r3s(){const t=li(),s=es();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 n3s(){const t=es();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 a3s(){const t=es();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 i3s(){const t=li(),s=es();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 o3s=[{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 l3s(){const t=li(),{data:s,isLoading:r}=t3s(),{data:n,isLoading:a}=s3s(),o=r3s(),l=n3s(),i=a3s(),c=i3s(),[u,p]=k.useState(null),[f,g]=k.useState(null),b=(s==null?void 0:s.filter(L=>!L.is_starter&&L.owner_user_id===t))||[],_=(s==null?void 0:s.filter(L=>L.is_starter))||[],j=L=>b.filter(R=>R.stage_id===L),w=async L=>{try{await l.mutateAsync({id:L.id,is_enabled:!L.is_enabled}),he.success(L.is_enabled?"Drip disabled":"Drip enabled")}catch{he.error("Failed to update")}},N=async L=>{try{const R=n==null?void 0:n.find(q=>q.id===L);await o.mutateAsync({stage_id:L,title:`${(R==null?void 0:R.name)||"Stage"} follow-up`,subject:"",body:"",channel:"email",delay_type:"instant",delay_minutes:0}),p(L),he.success("Drip template created")}catch{he.error("Failed to create template")}},C=async L=>{try{await i.mutateAsync(L),he.success("Template deleted")}catch{he.error("Failed to delete")}},M=async L=>{if(!n||n.length===0){he.error("No pipeline stages found");return}const R=n[0].id;try{await c.mutateAsync({templateId:L,stageId:R}),he.success("Template copied to your drips!")}catch{he.error("Failed to copy template")}},I=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(Fm,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-bold",children:"Smart Drips"}),e.jsx(tt,{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(e3s,{})]}),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(lL,{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(ja,{defaultValue:"my-drips",children:[e.jsxs(ga,{className:"grid grid-cols-2 w-full max-w-xs mb-6",children:[e.jsx(us,{value:"my-drips",children:"My Drips"}),e.jsxs(us,{value:"starters",children:["Starter Templates",_.length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1.5 text-[10px] px-1.5 py-0",children:_.length})]})]}),e.jsx(ks,{value:"my-drips",children:I?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(L=>e.jsx(vs,{className:"h-16 w-full rounded-xl"},L))}):!n||n.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(Fm,{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(L=>!L.is_won_stage&&!L.is_lost_stage).map(L=>{const R=j(L.id),q=u===L.id,U=R.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden",children:[e.jsxs("button",{onClick:()=>p(q?null:L.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:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(tt,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(To,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.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:()=>N(L.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:[R.map(B=>e.jsx(Wze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>C(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)}),n.filter(L=>L.is_won_stage||L.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(L=>L.is_won_stage||L.is_lost_stage).map(L=>{const R=j(L.id),q=u===L.id,U=R.some(B=>B.is_enabled);return e.jsxs("div",{className:"border rounded-xl overflow-hidden mb-2",children:[e.jsxs("button",{onClick:()=>p(q?null:L.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:L.color||"#94A3B8"}}),e.jsx("span",{className:"font-medium text-sm flex-1",children:L.name}),R.length>0&&e.jsxs(tt,{variant:"outline",className:`text-[10px] ${U?"bg-emerald-500/10 text-emerald-600 border-emerald-200":"text-muted-foreground"}`,children:[R.length," drip",R.length!==1?"s":"",U&&" · Active"]}),q?e.jsx(To,{className:"h-4 w-4 text-muted-foreground"}):e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]}),q&&e.jsx("div",{className:"border-t bg-muted/10 p-4 space-y-3",children:R.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:()=>N(L.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:[R.map(B=>e.jsx(Wze,{template:B,isEditing:f===B.id,onToggleEdit:()=>g(f===B.id?null:B.id),onToggleEnabled:()=>w(B),onUpdate:V=>l.mutateAsync({id:B.id,...V}),onDelete:()=>C(B.id),userId:t||""},B.id)),e.jsxs(K,{variant:"ghost",size:"sm",className:"w-full text-xs text-muted-foreground",onClick:()=>N(L.id),children:[e.jsx(qs,{className:"h-3 w-3 mr-1"})," Add another drip"]})]})})]},L.id)})]})]})}),e.jsx(ks,{value:"starters",children:_.length===0?e.jsxs("div",{className:"text-center py-12 border border-dashed rounded-xl",children:[e.jsx(un,{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(L=>e.jsx(c3s,{template:L,onCopy:()=>M(L.id),isCopying:c.isPending},L.id))})})]})]})})}function Wze({template:t,isEditing:s,onToggleEdit:r,onToggleEnabled:n,onUpdate:a,onDelete:o,userId:l}){const[i,c]=k.useState(t.title),[u,p]=k.useState(t.subject),[f,g]=k.useState(t.body),[b,_]=k.useState(t.video_url||""),[j,w]=k.useState(t.channel),[N,C]=k.useState(t.delay_type),[M,I]=k.useState(t.delay_minutes),[L,R]=k.useState(!1),q=async()=>{R(!0);try{await a({title:i,subject:u,body:f,video_url:b||null,channel:j,delay_type:N,delay_minutes:M}),he.success("Drip saved"),r()}catch{he.error("Failed to save")}finally{R(!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(io,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(dr,{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($r,{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(ye,{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(ye,{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:()=>w(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 ${j===B?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[B==="sms"?e.jsx(io,{className:"h-3 w-3"}):e.jsx(dr,{className:"h-3 w-3"}),B==="sms"?"SMS":"Email"]},B))})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx(ye,{className:"text-xs font-medium",children:"Timing"}),e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx("button",{onClick:()=>C("instant"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="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:()=>C("scheduled"),className:`flex-1 px-3 py-1.5 rounded-md text-xs font-medium border transition-colors ${N==="scheduled"?"bg-primary text-primary-foreground border-primary":"bg-background text-muted-foreground border-input hover:border-primary/50"}`,children:[e.jsx(mn,{className:"h-3 w-3 mr-1 inline"}),"Delay"]})]})]})]}),N==="scheduled"&&e.jsxs("div",{children:[e.jsx(ye,{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;I(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"?I(30):B.label==="Hours"?I(60):I(1440)},children:B.label},B.label))})]})]}),j==="email"&&e.jsxs("div",{children:[e.jsx(ye,{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(ye,{className:"text-xs font-medium",children:j==="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..."}),o3s.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:j==="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(ye,{className:"text-xs font-medium",children:"Attached Video"}),b?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"}),b.length>50?b.slice(0,50)+"...":b]}),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(aCe,{onVideoReady:B=>_(B)}),e.jsx(nCe,{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(zo,{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:q,disabled:L,children:L?"Saving...":"Save Drip"})]})]})]})]})}function c3s({template:t,onCopy:s,isCopying:r}){const[n,a]=k.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(tt,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:l}),e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",children:[t.channel==="sms"?e.jsx(io,{className:"h-3 w-3"}):e.jsx(dr,{className:"h-3 w-3"}),t.channel==="sms"?"SMS":"Email"]}),e.jsxs(tt,{variant:"outline",className:"text-[10px] gap-1",children:[e.jsx(mn,{className:"h-3 w-3"}),t.delay_type==="instant"?"Instant":i.replace("Sends ","")]}),n?e.jsx(To,{className:"h-4 w-4 text-muted-foreground ml-1"}):e.jsx(xa,{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(mn,{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(gi,{className:"h-3.5 w-3.5"}),"Use This Template"]})]})]})}const mct=()=>{const t=nu();return k.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 d3s(){return k.useEffect(()=>(document.body.classList.add("cardstudio-page"),()=>{document.body.classList.remove("cardstudio-page")}),[]),e.jsxs(P2e,{children:[e.jsx(Cs,{path:"/c/:shareToken",element:e.jsx(hct,{})}),e.jsx(Cs,{path:"*",element:e.jsx(mct,{})})]})}const Tye={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function pct({slugOverride:t}){const s=yo(),r=t||s.slug,[n,a]=k.useState("types"),[o,l]=k.useState(null),[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState(new Date),[b,_]=k.useState({name:"",email:"",phone:"",message:""}),[j,w]=k.useState(!1),{data:N,isLoading:C}=mt({queryKey:["public-booking-settings",r],queryFn:async()=>{const{data:X,error:ce}=await H.from("agent_booking_settings").select("*").eq("slug",r).eq("is_active",!0).single();if(ce)throw ce;return X},enabled:!!r}),{data:M}=mt({queryKey:["public-booking-profile",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ce}=await H.from("profiles").select("name, avatar_url, email, phone, title, bio").eq("id",N.user_id).single();if(ce)throw ce;return X},enabled:!!(N!=null&&N.user_id)}),{data:I=[]}=mt({queryKey:["public-booking-types",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ce}=await H.from("agent_booking_types").select("id, name, description, duration_minutes, color, icon, qualification_enabled").eq("user_id",N.user_id).eq("is_active",!0).order("sort_order");if(ce)throw ce;return X},enabled:!!(N!=null&&N.user_id)}),{data:L=[]}=mt({queryKey:["public-availability",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ce}=await H.from("agent_availability_slots").select("day_of_week, start_time, end_time").eq("user_id",N.user_id).eq("is_active",!0);if(ce)throw ce;return X},enabled:!!(N!=null&&N.user_id)}),{data:R=[]}=mt({queryKey:["public-blocked-dates",N==null?void 0:N.user_id],queryFn:async()=>{const{data:X,error:ce}=await H.from("agent_blocked_dates").select("blocked_date").eq("user_id",N.user_id);if(ce)throw ce;return X.map(ne=>ne.blocked_date)},enabled:!!(N!=null&&N.user_id)}),{data:q=[]}=mt({queryKey:["public-existing-bookings",N==null?void 0:N.user_id,i],queryFn:async()=>{if(!i)return[];const X=ps(i,"yyyy-MM-dd"),{data:ce,error:ne}=await H.from("bookings").select("start_time, end_time").eq("agent_user_id",N.user_id).eq("booking_date",X).eq("status","confirmed");if(ne)throw ne;return ce},enabled:!!(N!=null&&N.user_id)&&!!i}),U=k.useMemo(()=>[...new Set(L.map(X=>X.day_of_week))],[L]),B=X=>{const ce=Bm(new Date),ne=Tl(ce,(N==null?void 0:N.max_advance_days)||30),re=Tl(ce,0);return FS(X,re)||RS(X,ne)||R.includes(ps(X,"yyyy-MM-dd"))?!1:U.includes(X.getDay())},V=k.useMemo(()=>{if(!i||!o||!N)return[];const X=L.filter(xe=>xe.day_of_week===i.getDay()),ce=o.duration_minutes,ne=N.buffer_minutes||0,re=[],le=new Date,pe=(N.min_notice_hours||2)*60*60*1e3;for(const xe of X){const[_e,fe]=xe.start_time.split(":").map(Number),[we,Ie]=xe.end_time.split(":").map(Number);let Ne=qL($L(i,_e),fe);const Ae=qL($L(i,we),Ie);for(;eM(Ne,ce)<=Ae;){const Fe=ps(Ne,"HH:mm"),Ce=ps(eM(Ne,ce),"HH:mm");Ne.getTime()-le.getTime()>=pe&&(q.some($e=>{const ct=$e.start_time.slice(0,5),Te=$e.end_time.slice(0,5);return Fect})||re.push(Fe)),Ne=eM(Ne,ce+ne)}}return re},[i,o,L,N,q]),Y=k.useMemo(()=>{const X=f.getFullYear(),ce=f.getMonth(),ne=new Date(X,ce,1),re=new Date(X,ce+1,0),le=ne.getDay(),pe=[];for(let xe=0;xe{if(!(!o||!i||!u||!b.name||!N)){w(!0);try{const X=ps(eM(qL($L(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:N.user_id,booking_type_id:o.id,booking_date:ps(i,"yyyy-MM-dd"),start_time:u,end_time:X,guest_name:b.name,guest_email:b.email||null,guest_phone:b.phone||null,guest_message:b.message||null});if(ce)throw ce;H.functions.invoke("booking-notify",{body:{agentUserId:N.user_id,guestName:b.name,guestEmail:b.email||null,guestPhone:b.phone||null,guestMessage:b.message||null,bookingTypeName:o.name,bookingDate:ps(i,"yyyy-MM-dd"),startTime:u,endTime:X,durationMinutes:o.duration_minutes,meetingLink:N.meeting_link||null}}).catch(ne=>console.error("Booking notify error:",ne)),a("confirmed")}catch(X){he.error("Failed to book: "+X.message)}finally{w(!1)}}},te=X=>{const[ce,ne]=X.split(":").map(Number),re=ce>=12?"PM":"AM";return`${ce%12||12}:${ne.toString().padStart(2,"0")} ${re}`};return C?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..."})]})}):N?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(to,{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(Un,{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(dr,{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:I.map(X=>e.jsx("button",{onClick:()=>{l(X),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:X.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:Tye[X.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:X.name}),X.description&&e.jsx("p",{className:"text-xs text-slate-500 mt-0.5 line-clamp-2",children:X.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(mn,{className:"h-3 w-3"}),X.duration_minutes,"m"]})]})})},X.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(ri,{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:Tye[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(mn,{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:ps(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(ll,{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(xa,{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(X=>e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-slate-400 font-semibold py-2",children:X},X)),Y.map((X,ce)=>{if(!X)return e.jsx("div",{},`pad-${ce}`);const ne=B(X),re=i&&Sl(X,i),le=Sl(X,new Date);return e.jsx("button",{disabled:!ne,onClick:()=>{c(X),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"} ${le&&!re?"ring-1 ring-[#406E71]/40":""}`,children:X.getDate()},X.toISOString())})]})]}),i&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Dd,{className:"h-4 w-4 text-[#406E71]"}),e.jsx("h3",{className:"font-semibold text-sm text-slate-800",children:ps(i,"EEEE, MMMM d")})]}),V.length===0?e.jsxs("div",{className:"text-center py-8 space-y-2",children:[e.jsx(mn,{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(X=>{const ce=u===X;return e.jsx("button",{onClick:()=>p(X),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:te(X)},X)})}),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(ri,{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:Tye[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(Dd,{className:"h-3.5 w-3.5 text-[#406E71]"}),ps(i,"EEE, MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{className:"h-3.5 w-3.5 text-[#406E71]"}),te(u)," · ",o.duration_minutes," min"]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(ye,{className:"text-xs font-semibold text-slate-700",children:"Full Name *"}),e.jsx(ze,{value:b.name,onChange:X=>_({...b,name:X.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(ye,{className:"text-xs font-semibold text-slate-700",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(dr,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"email",value:b.email,onChange:X=>_({...b,email:X.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(ye,{className:"text-xs font-semibold text-slate-700",children:"Phone"}),e.jsxs("div",{className:"relative",children:[e.jsx(Un,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400"}),e.jsx(ze,{type:"tel",value:b.phone,onChange:X=>_({...b,phone:X.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(ye,{className:"text-xs font-semibold text-slate-700",children:"Message (optional)"}),e.jsx(Er,{value:b.message,onChange:X=>_({...b,message:X.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:J,disabled:!b.name||j,children:j?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(la,{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&&ps(i,"EEEE, MMMM d, yyyy")}),e.jsxs("p",{className:"text-slate-500",children:[u&&te(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(Un,{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(dr,{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(Dd,{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 u3s(){const s=nu().pathname.slice(1).split("/")[0];return k.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(pct,{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 h3s(){const s=nu().pathname.slice(1);return k.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(OYe,{slugOverride:s})}function fct({slugOverride:t}){const{slug:s}=yo(),r=t||s,[n,a]=k.useState(!1),[o,l]=k.useState({}),[i,c]=k.useState(0),[u,p]=k.useState(!1),{data:f,isLoading:g}=mt({queryKey:["public-landing-page",r],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_pages").select("*").eq("slug",r).eq("is_published",!0).single();if(U)throw U;return q},enabled:!!r}),{data:b=[]}=mt({queryKey:["public-landing-page-fields",f==null?void 0:f.id],queryFn:async()=>{const{data:q,error:U}=await H.from("landing_page_fields").select("*").eq("page_id",f.id).order("sort_order");if(U)throw U;return q},enabled:!!(f!=null&&f.id)});k.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 q=b.find(X=>X.field_type==="text"&&X.label.toLowerCase().includes("name")),U=b.find(X=>X.field_type==="email"),B=b.find(X=>X.field_type==="phone"),V=q?String(o[q.label]||""):null,Y=U?String(o[U.label]||""):null,J=B?String(o[B.label]||""):null,{error:te}=await H.from("landing_page_submissions").insert([{page_id:f.id,answers:JSON.parse(JSON.stringify(o)),contact_name:V,contact_email:Y,contact_phone:J,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(te)throw te;H.functions.invoke("landing-page-lead-notify",{body:{page_id:f.id,contact_name:V,contact_email:Y,contact_phone:J,answers:o}}).catch(X=>console.error("Landing page lead notification error:",X))},onSuccess:()=>a(!0)}),j=q=>{q.preventDefault(),!(b.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 w=f.primary_color||"#406E71",N=f.accent_color||"#2a4c64",C=f,M=f.page_type==="lead_magnet",I=f.page_type==="just_listed"||f.page_type==="just_sold",L=Array.isArray(C.property_photos)?C.property_photos:[],R=C.lead_magnet_file_url||C.lead_magnet_external_url;if(n)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",style:{background:`linear-gradient(135deg, ${w}, ${N})`},children:e.jsxs("div",{className:"bg-white rounded-2xl shadow-2xl p-8 max-w-md mx-4 text-center",children:[e.jsx(la,{className:"h-16 w-16 mx-auto mb-4",style:{color:w}}),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&&R&&e.jsxs("a",{href:R,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:w},children:[e.jsx(Ci,{className:"h-5 w-5"}),"Download ",C.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:w},children:[e.jsx(Un,{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:w},children:[e.jsx(dr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})});if(I){const q=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&&L.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(Or,{className:"h-8 w-8"})}),e.jsx("button",{onClick:U=>{U.stopPropagation(),c(B=>B===0?L.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(ll,{className:"h-6 w-6"})}),e.jsx("img",{src:L[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===L.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(xa,{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," / ",L.length]})]}),L.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:C.property_status==="just_sold"?"#e74c3c":w},children:C.property_status==="just_sold"?"🎉 Just Sold":"🏡 Just Listed"}),L.length===1?e.jsxs("div",{className:"rounded-2xl overflow-hidden cursor-pointer group",onClick:()=>{c(0),p(!0)},children:[e.jsx("img",{src:L[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(H_,{className:"h-4 w-4"})," View"]})]}):L.length===2?e.jsx("div",{className:"grid grid-cols-2 gap-2 rounded-2xl overflow-hidden",children:L.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:L[0],alt:"Property main",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}),L.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&&L.length>5&&e.jsxs("div",{className:"absolute inset-0 bg-black/50 flex items-center justify-center text-white font-bold text-lg",children:["+",L.length-5," more"]})]},B))]}),L.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(H_,{className:"h-4 w-4"})," View all ",L.length," photos"]})]}),L.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, ${w}, ${N})`},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:[C.property_price&&e.jsx("p",{className:"text-3xl md:text-4xl font-bold mb-2",style:{color:w},children:q(C.property_price)}),C.property_address&&e.jsxs("p",{className:"text-gray-600 flex items-center gap-1.5 mb-5 text-lg",children:[e.jsx(Ba,{className:"h-5 w-5 shrink-0"})," ",C.property_address]}),e.jsxs("div",{className:"flex gap-6 mb-5 py-4 border-y border-gray-100",children:[C.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(Np,{className:"h-5 w-5",style:{color:w}})," ",C.property_beds]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bedrooms"})]}),C.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(Nh,{className:"h-5 w-5",style:{color:w}})," ",C.property_baths]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Bathrooms"})]}),C.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(d1,{className:"h-5 w-5",style:{color:w}})," ",Number(C.property_sqft).toLocaleString()]}),e.jsx("p",{className:"text-xs text-gray-500 mt-0.5",children:"Sq Ft"})]})]}),C.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:C.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:w},children:C.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(Un,{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(dr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[b.map(U=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-xs font-medium",children:[U.label,U.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Gze(U,o,l)]},U.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},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, ${w}, ${N})`},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&&C.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(Ci,{className:"h-4 w-4"}),"Free Download: ",C.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(Un,{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(dr,{className:"h-3 w-3"})," ",f.agent_email]})]})]})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[b.map(q=>e.jsxs("div",{children:[e.jsxs(ye,{className:"text-sm font-medium",children:[q.label,q.is_required&&e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),Gze(q,o,l)]},q.id)),e.jsx(K,{type:"submit",className:"w-full text-white",style:{backgroundColor:w},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 Gze(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(Er,{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(Ys,{value:String(a),onValueChange:l=>r(i=>({...i,[t.label]:l})),children:[e.jsx(Gs,{className:"mt-1",children:e.jsx(Qs,{placeholder:"Select..."})}),e.jsx(Ks,{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(Lo,{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($r,{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 m3s(){const s=nu().pathname.slice(1).split("/")[0];return k.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 xct=[{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}],CMs={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"};function p3s(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:xct,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 f3s(){const s=window.location.hostname.match(/^([^.]+)\.thelocalmove\.com$/i);return s?s[1]:null}function x3s(){const t=f3s(),{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=p3s(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 hCe(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 gct=k.createContext(null);function vme(){const t=k.useContext(gct);if(!t)throw new Error("useLeadSiteAuth must be used within LeadSiteAuthProvider");return t}function g3s({siteConfig:t,children:s}){const[r,n]=k.useState(null),[a,o]=k.useState(null),[l,i]=k.useState(!0);k.useEffect(()=>{const{data:{subscription:f}}=H.auth.onAuthStateChange(async(g,b)=>{const _=(b==null?void 0:b.user)??null;if(n(_),_){const{data:j}=await H.from("lead_site_consumer_profiles").select("id, name, phone").eq("user_id",_.id).eq("lead_site_id",t.id).maybeSingle();j&&o({...j,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:b})=>{b&&o({...b,email:g.user.email||""}),i(!1)}):i(!1)}),()=>f.unsubscribe()},[t.id]);const c=k.useCallback(async f=>{const g=f.email.toLowerCase().trim(),b=f.phone.replace(/\D/g,""),{data:_,error:j}=await H.auth.signUp({email:g,password:b,options:{data:{full_name:f.name,consumer_site_id:t.id},emailRedirectTo:window.location.origin}});if(j){if(j.message.includes("already registered")){await u(g,b);return}throw j}if(_.user){const{error:w}=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()});w&&console.warn("Consumer profile insert error:",w);const{error:N}=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}});N&&console.error("Lead insert error (CRM sync may not trigger):",N),hCe(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=k.useCallback(async(f,g)=>{const b=g.replace(/\D/g,""),{error:_}=await H.auth.signInWithPassword({email:f.toLowerCase().trim(),password:b});if(_)throw _},[]),p=k.useCallback(async()=>{await H.auth.signOut(),n(null),o(null)},[]);return e.jsx(gct.Provider,{value:{user:r,profile:a,isLoading:l,signUp:c,signIn:u,signOut:p},children:s})}function yct({open:t,mode:s,siteConfig:r,onComplete:n,onSkip:a}){var R;const{signUp:o,signIn:l}=vme(),[i,c]=k.useState(!1),[u,p]=k.useState(""),[f,g]=k.useState(""),[b,_]=k.useState(""),[j,w]=k.useState(!1),[N,C]=k.useState(""),M=s==="required",I=((R=r.agent)==null?void 0:R.full_name)||"the agent",L=async q=>{var B;if(q.preventDefault(),C(""),!f.trim()||!b.trim()){C("Email and phone number are required.");return}if(!i&&!u.trim()){C("Name is required.");return}if(b.replace(/\D/g,"").length<7){C("Please enter a valid phone number.");return}w(!0);try{i?await l(f,b):await o({name:u,email:f,phone:b}),n()}catch(V){(B=V==null?void 0:V.message)!=null&&B.includes("Invalid login")?C("Invalid email or phone number. Please try again."):C((V==null?void 0:V.message)||"Something went wrong. Please try again.")}finally{w(!1)}};return e.jsx(xs,{open:t,onOpenChange:M?void 0:q=>{q||a()},children:e.jsxs(fs,{className:"sm:max-w-md",onPointerDownOutside:M?q=>q.preventDefault():void 0,onEscapeKeyDown:M?q=>q.preventDefault():void 0,children:[e.jsxs(_s,{children:[e.jsx(bs,{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 ${I}.`})]}),e.jsxs("form",{onSubmit:L,className:"space-y-3 mt-2",children:[!i&&e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:u,onChange:q=>p(q.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:q=>g(q.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:b,onChange:q=>_(q.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"})]}),N&&e.jsx("p",{className:"text-red-600 text-sm",children:N}),e.jsx("button",{type:"submit",disabled:j,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:j?i?"Signing in...":"Creating account...":i?"Sign In":"Create Account"}),e.jsx("button",{type:"button",onClick:()=>{c(!i),C("")},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 vct({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(rd,{children:[e.jsx("script",{type:"application/ld+json",children:JSON.stringify(a)}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify(o)})]})}function mCe({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(rd,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function y3s({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(rd,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(n)})})}function v3s({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(rd,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(s)})})}function b3s({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(rd,{children:e.jsx("script",{type:"application/ld+json",children:JSON.stringify(c)})})}function _3s({children:t,siteConfig:s}){var Y,J,te,X,ce,ne,re,le,pe;const r=nu(),n=pr(),[a,o]=k.useState(!1),[l,i]=k.useState(!1),[c,u]=k.useState(!1),[p,f]=k.useState([]),g=k.useRef(null),{user:b,profile:_,signOut:j}=vme(),w=((Y=s.agent)==null?void 0:Y.full_name)||"Agent",N=s.siteTitle||`${w} Real Estate`,C=r.pathname==="/search",M=r.pathname==="/",I=s.leadRegistrationMode!=="disabled";k.useEffect(()=>{(async()=>{const{data:_e}=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(_e||[])})()},[s.id]),k.useEffect(()=>{const xe=_e=>{g.current&&!g.current.contains(_e.target)&&u(!1)};return document.addEventListener("mousedown",xe),()=>document.removeEventListener("mousedown",xe)},[]);const L=[{to:"/",label:"Home"},{to:"/search",label:"Search"},{to:"/blog",label:"Blog"},{to:"/community",label:"Community"},{to:"/about",label:"About"},{to:"/contact",label:"Contact"}],R=M?"bg-transparent text-white":"bg-white/95 backdrop-blur text-gray-900 border-b border-gray-100 shadow-sm",q=s.siteTitle||`${w} - Real Estate`,U=s.siteTagline||`Browse homes and listings with ${w}`,B=s.ogImageUrl||((J=s.agent)==null?void 0:J.avatar_url)||"",V=`https://${s.subdomainSlug||""}.thelocalmove.com`;return e.jsxs("div",{className:`flex flex-col ${C?"h-screen overflow-hidden":"min-h-screen"} bg-white`,children:[e.jsx(vct,{siteConfig:s,pagePath:r.pathname}),e.jsxs(rd,{children:[e.jsx("title",{children:q}),e.jsx("meta",{name:"description",content:U}),e.jsx("meta",{property:"og:title",content:q}),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:q}),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}`})]}),e.jsxs("header",{className:`${M?"absolute":"sticky"} top-0 left-0 right-0 z-50 transition-all ${R}`,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(Ei,{to:"/",className:"flex items-center gap-3",children:[((te=s.agent)==null?void 0:te.avatar_url)&&e.jsx("img",{src:s.agent.avatar_url,alt:w,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:N})})]}),e.jsxs("nav",{className:"hidden md:flex items-center gap-1",children:[L.map(xe=>e.jsx(Ei,{to:xe.to,className:`px-4 py-2 rounded-lg text-sm font-medium tracking-wide transition-colors ${r.pathname===xe.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:xe.label},xe.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(To,{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(xe=>e.jsx("button",{onClick:()=>{n(`/homes-for-sale-in-${xe.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:xe.city_name},xe.city_slug))})]}),b?e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[e.jsxs(Ei,{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(ii,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:"Saved"})]}),e.jsxs(Ei,{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(to,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden lg:inline",children:((X=_==null?void 0:_.name)==null?void 0:X.split(" ")[0])||"Account"})]})]}):I?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(Or,{className:"h-5 w-5"}):e.jsx(IM,{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:[L.map(xe=>e.jsx(Ei,{to:xe.to,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===xe.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:xe.label},xe.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(xe=>e.jsx(Ei,{to:`/homes-for-sale-in-${xe.city_slug}`,onClick:()=>o(!1),className:`block px-3 py-2.5 rounded-lg text-sm font-medium ${r.pathname===`/homes-for-sale-in-${xe.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:xe.city_name},xe.city_slug))]}),b?e.jsxs(e.Fragment,{children:[e.jsx(Ei,{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 j(),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"})]}):I?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}),!C&&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:w,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:w}),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(Un,{className:"h-3.5 w-3.5"})," ",s.agent.phone]})}),((le=s.agent)==null?void 0:le.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(dr,{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:L.map(xe=>e.jsx("li",{children:e.jsx(Ei,{to:xe.to,className:"hover:text-white transition-colors",children:xe.label})},xe.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(Ei,{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:[w," · ",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()," ",w,". Powered by LevelUp."]})]})]})]})}),!C&&((pe=s.agent)==null?void 0:pe.avatar_url)&&e.jsx(w3s,{agent:s.agent}),l&&e.jsx(yct,{open:l,mode:"optional",siteConfig:s,onComplete:()=>i(!1),onSkip:()=>i(!1)})]})}function w3s({agent:t}){var a;const[s,r]=k.useState(!1),n=pr();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(Un,{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(dr,{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(Or,{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}const j3s={city:{icon:Ba,label:"City"},zip:{icon:z_,label:"ZIP Code"},county:{icon:PM,label:"County"}};function bct({suggestions:t,cities:s,value:r,onChange:n,onSelect:a,placeholder:o,className:l,inputClassName:i}){const[c,u]=k.useState(!1),p=k.useRef(null),f=t.length>0?t:(s||[]).map(w=>({label:w,type:"city"})),g=r.trim()?f.filter(w=>w.label.toLowerCase().includes(r.toLowerCase())).slice(0,10):f.slice(0,10),b=g.reduce((w,N)=>(w[N.type]||(w[N.type]=[]),w[N.type].push(N),w),{}),_=c&&g.length>0;k.useEffect(()=>{const w=N=>{p.current&&!p.current.contains(N.target)&&u(!1)};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);const j=["city","zip","county"];return e.jsxs("div",{ref:p,className:`relative ${l||""}`,children:[e.jsx("input",{type:"text",value:r,onChange:w=>{n(w.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:j.map(w=>{const N=b[w];if(!N||N.length===0)return null;const C=j3s[w],M=C.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:[C.label,"s"]}),N.map(I=>e.jsxs("button",{type:"button",onMouseDown:L=>{L.preventDefault(),a(I.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:I.label})]},`${w}-${I.label}`))]},w)})})]})}function N3s({siteId:t,accentColor:s}){const r=pr(),{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(Ws.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(Ba,{className:"h-4 w-4"}),"View Properties",e.jsx(fi,{className:"h-4 w-4 group-hover:translate-x-1 transition-transform"})]})})]})]},o.id))})]})})}function Aye({siteConfig:t,accentColor:s,sectionTitle:r,cities:n,count:a=12,mode:o}){const l=pr(),[i,c]=k.useState([]),[u,p]=k.useState(!0),f=k.useRef(null),[g,b]=k.useState(!1),[_,j]=k.useState(!1);k.useEffect(()=>{(async()=>{var L;try{const R="https://relzejiswnotikjgvjhz.supabase.co/functions/v1/lead-site-search",q={leadSiteId:t.id,pageSize:a};if(n){const B=n.split(",").map(V=>V.trim()).filter(Boolean);B.length>0&&(q.query=B[0],q.filterCities=B)}o==="open_houses"&&(q.openHousesOnly=!0),o==="my_listings"&&(q.agentListings=!0,q.agentId=t.agentId),o==="new_listings"&&(q.sortBy="newest");const U=await fetch(R,{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJlbHplamlzd25vdGlramd2amh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjE5NTAzNDQsImV4cCI6MjA3NzUyNjM0NH0.dzIkIr_oFSbFE3oWS0ktIr83iKHHkZxt40Gc7SpC_mM"},body:JSON.stringify(q),signal:AbortSignal.timeout(15e3)});if(U.ok){const B=await U.json();c(((L=B.listings)==null?void 0:L.slice(0,a))||[])}}catch{}finally{p(!1)}})()},[t.id,n,a,o,t.agentId]);const w=()=>{const I=f.current;I&&(b(I.scrollLeft>10),j(I.scrollLeft{const I=f.current;if(I)return w(),I.addEventListener("scroll",w,{passive:!0}),window.addEventListener("resize",w),()=>{I.removeEventListener("scroll",w),window.removeEventListener("resize",w)}},[i]);const N=I=>{const L=f.current;if(!L)return;const R=340;L.scrollBy({left:I==="left"?-R*2:R*2,behavior:"smooth"})},C={new_listings:"New on the Market",open_houses:"Open Houses",my_listings:"My Active Listings"},M={new_listings:"The latest properties just listed",open_houses:"Tour these homes in person",my_listings:"Properties I'm currently representing"};return u?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",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 bg-gray-200 rounded mx-auto mb-3 animate-pulse"}),e.jsx("div",{className:"h-8 w-72 bg-gray-200 rounded mx-auto mb-2 animate-pulse"}),e.jsx("div",{className:"h-4 w-56 bg-gray-200 rounded mx-auto animate-pulse"})]}),e.jsx("div",{className:"flex gap-5",children:[1,2,3,4].map(I=>e.jsxs("div",{className:"min-w-[320px] rounded-2xl overflow-hidden bg-gray-100",children:[e.jsx("div",{className:"h-56 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-40 animate-pulse"})]})]},I))})]})}):i.length?e.jsx("section",{className:"py-16 md:py-20 overflow-hidden",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(Ws.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:s},children:o==="open_houses"?"Open Houses":o==="my_listings"?"My Listings":"Just Listed"}),e.jsx(Ws.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:r||C[o]}),e.jsx(Ws.p,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},transition:{delay:.1},className:"text-gray-500 mt-1.5",children:M[o]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsx("button",{onClick:()=>N("left"),disabled:!g,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(ll,{className:"h-5 w-5"})}),e.jsx("button",{onClick:()=>N("right"),disabled:!_,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(xa,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"relative -mx-6",children:[e.jsxs("div",{ref:f,className:"flex gap-5 overflow-x-auto scrollbar-hide px-6 snap-x snap-mandatory",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:[i.map((I,L)=>{var R,q,U,B;return e.jsx(Ws.div,{initial:{opacity:0,y:20},whileInView:{opacity:1,y:0},viewport:{once:!0},transition:{duration:.4,delay:L*.05},onClick:()=>l(`/listing/${I.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:((R=I.photos)==null?void 0:R[0])||"https://images.unsplash.com/photo-1560448204-e02f11c3d0e2?w=600&q=75",alt:I.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":I.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:["$",(q=I.price)==null?void 0:q.toLocaleString()]})}),((U=I.photos)==null?void 0:U.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:[I.photos.length," photos"]})]}),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:I.address}),e.jsxs("p",{className:"text-gray-500 text-sm mb-3 truncate",children:[I.city,", ",I.state," ",I.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(Np,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:I.bedrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(Nh,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"text-sm font-medium",children:I.bathrooms})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx(rS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(B=I.sqft)==null?void 0:B.toLocaleString()," sqft"]})]})]})]})]})},I.mlsNumber)}),e.jsx(Ws.div,{initial:{opacity:0},whileInView:{opacity:1},viewport:{once:!0},onClick:()=>l("/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(fi,{className:"h-6 w-6",style:{color:s}})}),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 k3s({siteId:t,accentColor:s,sectionTitle:r}){const n=pr(),[a,o]=k.useState([]),[l,i]=k.useState(!0);if(k.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(Ws.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(Ws.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(fi,{className:"h-5 w-5 text-white"})})]})]},u.city_slug))})]})})}function S3s({siteConfig:t,themeConfig:s}){var p;const r=pr(),[n,a]=k.useState(""),o=((p=t.agent)==null?void 0:p.full_name)||"Your Agent",l=(s==null?void 0:s.homepageModules)??xct,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 b=f.config||{};switch(f.type){case"hero":return e.jsx(M3s,{agentName:o,tagline:b.headline||t.siteTagline,subtitle:b.subtitle,heroImageUrl:s==null?void 0:s.heroImageUrl,brandColor:i,accentColor:c,searchQuery:n,setSearchQuery:a,onSearch:u,searchPlaceholder:b.searchPlaceholder,themeConfig:s},g);case"featured_listings":return e.jsx(T3s,{siteConfig:t,accentColor:c,sectionTitle:b.sectionTitle,count:b.count},g);case"featured_areas":return e.jsx(N3s,{siteId:t.id,accentColor:c},g);case"about":return e.jsx(A3s,{siteConfig:t,accentColor:c,config:b},g);case"testimonials":return e.jsx(E3s,{testimonials:b.testimonials||(s==null?void 0:s.testimonials)||[],brandColor:i,sectionTitle:b.sectionTitle},g);case"cta_banner":return e.jsx(P3s,{agentName:o,accentColor:c,brandColor:i,config:b},g);case"new_listings":return e.jsx(Aye,{siteConfig:t,accentColor:c,mode:"new_listings",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"open_houses":return e.jsx(Aye,{siteConfig:t,accentColor:c,mode:"open_houses",sectionTitle:b.sectionTitle,cities:b.cities,count:b.count},g);case"my_listings":return e.jsx(Aye,{siteConfig:t,accentColor:c,mode:"my_listings",sectionTitle:b.sectionTitle,count:b.count},g);case"city_pages":return e.jsx(k3s,{siteId:t.id,accentColor:c,sectionTitle:b.sectionTitle},g);default:return null}})})}function C3s(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 M3s({agentName:t,tagline:s,subtitle:r,heroImageUrl:n,brandColor:a,accentColor:o,searchQuery:l,setSearchQuery:i,onSearch:c,searchPlaceholder:u,themeConfig:p}){const f=pr(),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(Ws.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(Ws.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(Ws.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(Ws.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(hn,{className:"absolute left-4 top-1/2 -translate-y-1/2 h-5 w-5 text-white/50 z-10"}),(()=>{const b=C3s(p);return b.length>0?e.jsx(bct,{suggestions:b,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(Ws.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((b,_)=>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:b},b))})]})]})}function T3s({siteConfig:t,accentColor:s,sectionTitle:r,count:n}){const a=pr(),[o,l]=k.useState([]),[i,c]=k.useState(!0);return k.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 b=await g.json();l(((p=b.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(Ws.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(fi,{className:"h-4 w-4"})]})})]})}):null}function A3s({siteConfig:t,accentColor:s,config:r}){const n=pr(),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(Ws.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(Ws.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 E3s({testimonials:t,brandColor:s,sectionTitle:r}){const[n,a]=k.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(U_,{className:"h-10 w-10 text-white/20 mx-auto mb-6"}),e.jsxs(Ws.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(ll,{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(xa,{className:"h-5 w-5"})})]})]})}):null}function P3s({agentName:t,accentColor:s,brandColor:r,config:n}){const a=pr();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 I3s=t=>t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${t}`,s9=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},L3s=t=>[t.address,t.city,t.state,t.zip].filter(Boolean).join(", ");function _ct({listings:t,onListingClick:s,hoveredMlsNumber:r}){const n=k.useRef(null),a=k.useRef(null),o=k.useRef(new Map),l=k.useRef(null),i=k.useRef(new Map),[c,u]=k.useState(null),[p,f]=k.useState({});k.useEffect(()=>{(async()=>{const{data:j}=await H.from("settings").select("value").eq("key","mapbox_public_token").maybeSingle();j!=null&&j.value&&u(j.value)})()},[]),k.useEffect(()=>{if(!(!n.current||!c||a.current))return xl.accessToken=c,a.current=new xl.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",zoom:4,center:[-98.5795,39.8283]}),a.current.addControl(new xl.NavigationControl,"top-right"),()=>{var _;(_=a.current)==null||_.remove(),a.current=null}},[c]);const g=k.useMemo(()=>t.map(_=>{var N,C;const j=s9(_.latitude)??((N=p[_.mlsNumber])==null?void 0:N.lat)??null,w=s9(_.longitude)??((C=p[_.mlsNumber])==null?void 0:C.lng)??null;return j===null||w===null?null:{listing:_,latitude:j,longitude:w}}).filter(_=>_!==null),[t,p]);k.useEffect(()=>{if(!c||t.length===0)return;const _=t.filter(N=>!(s9(N.latitude)!==null&&s9(N.longitude)!==null)&&!i.current.has(N.mlsNumber));if(_.length===0)return;let j=!1;return(async()=>{const N=await Promise.all(_.map(async M=>{var L,R;const I=L3s(M);if(!I)return{mlsNumber:M.mlsNumber,coords:null};try{const q=await fetch(`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(I)}.json?access_token=${encodeURIComponent(c)}&limit=1&country=US&types=address,place,postcode`);if(!q.ok)return{mlsNumber:M.mlsNumber,coords:null};const U=await q.json(),[B,V]=((R=(L=U==null?void 0:U.features)==null?void 0:L[0])==null?void 0:R.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(j)return;const C={};N.forEach(({mlsNumber:M,coords:I})=>{i.current.set(M,I),I&&(C[M]=I)}),Object.keys(C).length>0&&f(M=>({...M,...C}))})(),()=>{j=!0}},[t,c]);const b=k.useCallback(_=>{var N;const j=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(_.price),w=(N=_.photos)!=null&&N[0]?``:`
`;return`
${w}
${j}
${_.address}
${_.bedrooms} bd ${_.bathrooms} ba ${_.sqft>0?`${_.sqft.toLocaleString()} sqft`:""}
`},[]);return k.useEffect(()=>{if(!a.current||!c||(o.current.forEach(j=>j.remove()),o.current.clear(),g.length===0))return;const _=new xl.LngLatBounds;g.forEach(({listing:j,latitude:w,longitude:N})=>{const C=document.createElement("div");C.style.cssText="cursor: pointer;";const M=document.createElement("div");M.className="lead-site-map-pill",M.setAttribute("data-mls",j.mlsNumber),M.innerHTML=`${I3s(j.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!==j.mlsNumber&&(M.style.background="white",M.style.color="#1e3a5f",M.style.transform="scale(1)")}),C.appendChild(M);const I=new xl.Marker({element:C,anchor:"bottom"}).setLngLat([N,w]).addTo(a.current);C.addEventListener("click",L=>{var q;L.stopPropagation(),(q=l.current)==null||q.remove();const R=new xl.Popup({offset:25,closeButton:!0,maxWidth:"240px",className:"lead-site-map-popup"}).setLngLat([N,w]).setHTML(b(j)).addTo(a.current);setTimeout(()=>{const U=R.getElement(),B=U==null?void 0:U.querySelector("[data-mls]");B&&(B.addEventListener("click",()=>{s(j.mlsNumber)}),B.style.cursor="pointer")},50),l.current=R}),o.current.set(j.mlsNumber,I),_.extend([N,w])});try{_.isEmpty()||a.current.fitBounds(_,{padding:60,maxZoom:14})}catch{}},[g,c,b,s]),k.useEffect(()=>{o.current.forEach((_,j)=>{const w=_.getElement().querySelector(".lead-site-map-pill");w&&(j===r?(w.style.background="#2563eb",w.style.color="white",w.style.transform="scale(1.15)",w.style.zIndex="10"):(w.style.background="white",w.style.color="#1e3a5f",w.style.transform="scale(1)",w.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(D3s,{className:"h-10 w-10 mx-auto mb-2"}),e.jsx("p",{className:"text-sm",children:"Map not configured"})]})})}function D3s({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 O3s=50;function R3s({siteConfig:t}){var _e;const s=t.themeConfig||{},r=[...(s.searchCities||[]).map(fe=>({label:fe,type:"city"})),...(s.searchZipCodes||[]).map(fe=>({label:fe,type:"zip"})),...(s.searchCounties||[]).map(fe=>({label:fe,type:"county"}))],n=pr(),[a,o]=qc(),[l,i]=k.useState(!1),[c,u]=k.useState("list"),[p,f]=k.useState(null),g=a.get("q")||"",b=a.get("county")||"",_=a.get("minPrice")||"",j=a.get("maxPrice")||"",w=a.get("beds")||"",N=a.get("baths")||"",C=a.get("propertyType")||"",M=a.get("minSqft")||"",I=a.get("maxSqft")||"",[L,R]=k.useState(g),[q,U]=k.useState(!0),{data:B,isLoading:V,fetchNextPage:Y,hasNextPage:J,isFetchingNextPage:te}=rUe({queryKey:["lead-site-search",t.id,g,b,_,j,w,N,C,M,I,q],queryFn:async({pageParam:fe=1})=>{const{data:we,error:Ie}=await H.functions.invoke("lead-site-search",{body:{leadSiteId:t.id,query:g||void 0,county:b||void 0,minPrice:_?parseInt(_):void 0,maxPrice:j?parseInt(j):void 0,minBeds:w?parseInt(w):void 0,minBaths:N?parseInt(N):void 0,propertyType:C||void 0,minSqft:M?parseInt(M):void 0,maxSqft:I?parseInt(I):void 0,limit:O3s,page:fe}});if(Ie)throw Ie;return we},getNextPageParam:(fe,we)=>{if(we.reduce((Ne,Ae)=>Ne+Ae.listings.length,0)fe.listings))??[],ce=((_e=B==null?void 0:B.pages[0])==null?void 0:_e.total)??0,ne=k.useCallback(fe=>{fe.preventDefault();const we=new URLSearchParams;L&&we.set("q",L),b&&we.set("county",b),_&&we.set("minPrice",_),j&&we.set("maxPrice",j),w&&we.set("beds",w),N&&we.set("baths",N),C&&we.set("propertyType",C),M&&we.set("minSqft",M),I&&we.set("maxSqft",I),o(we),U(!0)},[L,b,_,j,w,N,C,M,I,o]),re=k.useCallback((fe,we)=>{const Ie=new URLSearchParams(a);we?Ie.set(fe,we):Ie.delete(fe),o(Ie),U(!0)},[a,o]),le=fe=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(fe),pe=k.useCallback(fe=>{n(`/listing/${fe}`)},[n]),xe=X.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(hn,{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(bct,{suggestions:r,value:L,onChange:R,onSelect:fe=>{R(fe);const we=new URLSearchParams(a);we.set("q",fe),o(we),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:L,onChange:fe=>R(fe.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(FM,{className:"h-4 w-4"})})]}),l&&e.jsxs("div",{className:"mt-3 flex flex-wrap gap-3 pb-1",children:[e.jsx("input",{value:b,onChange:fe=>re("county",fe.target.value),placeholder:"County",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm min-w-[140px]"}),e.jsxs("select",{value:w,onChange:fe=>re("beds",fe.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:N,onChange:fe=>re("baths",fe.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:C,onChange:fe=>re("propertyType",fe.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:fe=>re("minPrice",fe.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:j,onChange:fe=>re("maxPrice",fe.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:fe=>re("minSqft",fe.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:I,onChange:fe=>re("maxSqft",fe.target.value),placeholder:"Max sqft",className:"px-3 py-2 border border-gray-300 rounded-lg text-sm w-[120px]"})]}),xe&&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(Ch,{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(PM,{className:"h-3.5 w-3.5"})," Map"]})]})]})}),e.jsx("div",{className:"flex-1 min-h-0",children:q?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..."})]})}):xe?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 ",X.length," of ",ce]})]}),e.jsx("div",{className:"p-3 grid grid-cols-1 sm:grid-cols-2 gap-3",children:X.map(fe=>{var we;return e.jsxs("button",{onClick:()=>n(`/listing/${fe.mlsNumber}`),onMouseEnter:()=>f(fe.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===fe.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:[(we=fe.photos)!=null&&we[0]?e.jsx("img",{src:fe.photos[0],alt:fe.address,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-300",onError:Ie=>{const Ne=Ie.target;Ne.style.display="none"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-gray-400",children:e.jsx(Ba,{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:fe.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:le(fe.price)}),e.jsxs("p",{className:"text-xs text-white/90 mt-0.5 truncate drop-shadow-sm",children:[fe.address,", ",fe.city,", ",fe.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(Np,{className:"h-3.5 w-3.5"})," ",fe.bedrooms," bd"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nh,{className:"h-3.5 w-3.5"})," ",fe.bathrooms," ba"]}),fe.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(d1,{className:"h-3.5 w-3.5"})," ",fe.sqft.toLocaleString()," sqft"]})]})]},fe.mlsNumber)})}),J&&e.jsx("div",{className:"flex justify-center py-6",children:e.jsx("button",{onClick:()=>Y(),disabled:te,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:te?e.jsxs(e.Fragment,{children:[e.jsx(ws,{className:"h-4 w-4 animate-spin"}),"Loading more..."]}):`Load More Listings (${X.length} of ${ce})`})})]}),e.jsx("div",{className:` lg:w-[35%] min-w-0 ${c==="list"?"hidden lg:block":"block w-full"} `,children:e.jsx(_ct,{listings:X,onListingClick:pe,hoveredMlsNumber:p})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Or,{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(hn,{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 Eye="ls_visitor_";function F3s(t,s){const[r,n]=k.useState(0),[a,o]=k.useState(!1),[l,i]=k.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;k.useEffect(()=>{if(!c)return;const j=parseInt(localStorage.getItem(`${Eye}views_${c}`)||"0",10);n(j)},[c]);const f=k.useCallback((j,w)=>{if(!c||u==="disabled")return;const N=r+1;n(N),localStorage.setItem(`${Eye}views_${c}`,String(N)),H.from("lead_site_property_views").insert({lead_site_id:c,mls_number:j,auth_user_id:w||null,visitor_fingerprint:localStorage.getItem(`${Eye}fp_${c}`)||null}).then(),!s&&!l&&N>=p&&o(!0)},[c,u,r,s,l,p]);k.useEffect(()=>{s&&a&&o(!1)},[s,a]);const g=k.useCallback(()=>{o(!1),i(!0)},[]),b=k.useCallback(()=>{o(!1)},[]),_=u==="required"&&!s&&r>=p;return{viewCount:r,showRegistration:a,isGated:_,mode:u,recordView:f,dismissRegistration:g,completeRegistration:b,setShowRegistration:o}}function z3s({photos:t}){const[s,r]=k.useState(!1),[n,a]=k.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(tL,{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(Or,{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(ll,{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(xa,{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 B3s({listing:t}){var n,a;const s=[];t.lotSize&&s.push({label:"Lot Size",value:t.lotSize,icon:e.jsx(m1,{className:"h-4 w-4"})}),t.garageSpaces&&s.push({label:"Garage",value:`${t.garageSpaces} spaces`,icon:e.jsx(_M,{className:"h-4 w-4"})}),t.stories&&s.push({label:"Stories",value:`${t.stories}`,icon:e.jsx(MM,{className:"h-4 w-4"})}),t.heating&&s.push({label:"Heating",value:t.heating,icon:e.jsx(ML,{className:"h-4 w-4"})}),t.cooling&&s.push({label:"Cooling",value:t.cooling,icon:e.jsx(r0,{className:"h-4 w-4"})}),t.fireplace&&s.push({label:"Fireplace",value:"Yes",icon:e.jsx(Qu,{className:"h-4 w-4"})}),t.pool&&s.push({label:"Pool",value:t.pool,icon:e.jsx(OL,{className:"h-4 w-4"})}),t.basement&&s.push({label:"Basement",value:t.basement,icon:e.jsx(MM,{className:"h-4 w-4"})}),t.parking&&s.push({label:"Parking",value:t.parking,icon:e.jsx(_M,{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(wc,{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 $3s({latitude:t,longitude:s,address:r}){const n=k.useRef(null),a=k.useRef(null),o=k.useMemo(()=>{const l=Number(t),i=Number(s);return!Number.isFinite(l)||!Number.isFinite(i)?null:{lat:l,lng:i}},[t,s]);return k.useEffect(()=>{if(!n.current||a.current||!o)return;xl.accessToken="pk.eyJ1IjoibGV2ZWx1cHJlIiwiYSI6ImNtOGZwMGNrYzBjNjIyanF5c2RwNTFhOXMifQ.sTe5rOhf_2nkqgr8Z_0e4Q";const l=new xl.Map({container:n.current,style:"mapbox://styles/mapbox/streets-v12",center:[o.lng,o.lat],zoom:14,interactive:!0});return l.addControl(new xl.NavigationControl({showCompass:!1}),"top-right"),new xl.Marker({color:"#2563eb"}).setLngLat([o.lng,o.lat]).setPopup(new xl.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 q3s({listPrice:t}){const[s,r]=k.useState(20),[n,a]=k.useState(6.5),[o,l]=k.useState(30),i=k.useMemo(()=>{const f=t*(1-s/100),g=n/100/12,b=o*12;return g===0?f/b:f*g*Math.pow(1+g,b)/(Math.pow(1+g,b)-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(ZI,{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 U3s({siteConfig:t,currentListing:s}){const r=pr(),{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(xa,{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(Np,{className:"h-3.5 w-3.5"})," ",o.bedrooms]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Nh,{className:"h-3.5 w-3.5"})," ",o.bathrooms]}),o.sqft>0&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(d1,{className:"h-3.5 w-3.5"})," ",o.sqft.toLocaleString()]})]})]})]},o.mlsNumber)})})]})}function V3s({siteConfig:t}){var I,L,R;const{mlsNumber:s}=yo(),r=pr(),[n,a]=k.useState(!1),[o,l]=k.useState({name:"",email:"",phone:"",message:""}),[i,c]=k.useState(!1),{user:u}=vme(),p=F3s(t,!!u),[f,g]=k.useState(!1);k.useEffect(()=>{s&&t&&p.recordView(s,u==null?void 0:u.id)},[s,t==null?void 0:t.id]),k.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:q})=>g(!!q))},[u,s,t.id]);const b=async()=>{!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),he.success("Removed from saved")):(await H.from("lead_site_saved_listings").insert({user_id:u.id,lead_site_id:t.id,mls_number:s}),g(!0),he.success("Saved to favorites")))},{data:_,isLoading:j,error:w}=mt({queryKey:["lead-site-listing",t.id,s],queryFn:async()=>{const q=new AbortController,U=window.setTimeout(()=>q.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:q.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=async q=>{q.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}}),hCe(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}),he.success("Message sent! The agent will be in touch."),l({name:"",email:"",phone:"",message:""}),a(!1)}catch{he.error("Something went wrong. Please try again.")}finally{c(!1)}},C=async()=>{const q=window.location.href;if(navigator.share)try{await navigator.share({title:(_==null?void 0:_.address)||"Property Listing",url:q})}catch{}else await navigator.clipboard.writeText(q),he.success("Link copied to clipboard")},M=q=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(q);return j?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(y3s,{listing:_,siteConfig:t}),e.jsx(mCe,{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(ri,{className:"h-4 w-4"})," Back"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:C,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(bd,{className:"h-4 w-4"})," Share"]}),u&&e.jsxs("button",{onClick:b,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(ii,{className:`h-4 w-4 ${f?"fill-current":""}`}),f?"Saved":"Save"]})]})]}),e.jsx(z3s,{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(Ba,{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(Np,{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(Nh,{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(d1,{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(cn,{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(Sn,{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(an,{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(B3s,{listing:_}),_.latitude&&_.longitude&&e.jsx($3s,{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:[((I=t.agent)==null?void 0:I.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:(L=t.agent)==null?void 0:L.full_name}),e.jsx("p",{className:"text-sm text-gray-500",children:((R=t.agent)==null?void 0:R.title)||"Real Estate Agent"})]})]}),n?e.jsxs("form",{onSubmit:N,className:"space-y-3",children:[e.jsx("input",{type:"text",required:!0,placeholder:"Your name",value:o.name,onChange:q=>l(U=>({...U,name:q.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:q=>l(U=>({...U,email:q.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:q=>l(U=>({...U,phone:q.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:q=>l(U=>({...U,message:q.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(q3s,{listPrice:_.price})]})]}),e.jsx("div",{className:"mt-12 mb-6",children:e.jsx(U3s,{siteConfig:t,currentListing:_})})]}),e.jsx(yct,{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:w?"Error loading listing":"Listing not found"}),w&&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 H3s({siteConfig:t}){const s=pr(),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 W3s({siteConfig:t}){const[s,r]=k.useState({name:"",email:"",phone:"",message:""}),[n,a]=k.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"}),hCe(t.id,{name:s.name,email:s.email,phone:s.phone||null,message:s.message,lead_type:"contact",source_page:"/contact"}),he.success("Message sent! We'll be in touch soon."),r({name:"",email:"",phone:"",message:""})}catch{he.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(dr,{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(Un,{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 G3s({siteConfig:t}){const s=pr(),{user:r,profile:n,signOut:a}=vme(),[o,l]=k.useState("saved"),[i,c]=k.useState([]),[u,p]=k.useState([]),[f,g]=k.useState({name:"",phone:"",email:""}),[b,_]=k.useState(!1);k.useEffect(()=>{if(!r){s("/");return}j(),n&&g({name:n.name,phone:n.phone||"",email:n.email})},[r,n]);const j=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:I}=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),L=new Set,R=(I||[]).filter(q=>L.has(q.mls_number)?!1:(L.add(q.mls_number),!0));p(R)},w=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(I=>I.filter(L=>L.mls_number!==M)),he.success("Removed from saved")},N=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),he.success("Profile updated")}catch{he.error("Failed to update profile")}finally{_(!1)}};if(!r)return null;const C=[{key:"saved",label:"Saved Listings",icon:ii,count:i.length},{key:"viewed",label:"Recently Viewed",icon:mn,count:u.length},{key:"profile",label:"My Profile",icon:to}];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(sS,{className:"h-4 w-4"})," Sign Out"]})]}),e.jsx("div",{className:"flex gap-1 border-b border-gray-200 mb-6",children:C.map(M=>{const I=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(I,{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(ii,{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(xa,{className:"h-4 w-4 text-gray-400 ml-auto"})]}),e.jsx("button",{onClick:()=>w(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(mn,{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(xa,{className:"h-4 w-4 text-gray-400"})]},M.id))})}),o==="profile"&&e.jsx("div",{className:"max-w-md",children:e.jsxs("form",{onSubmit:N,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(I=>({...I,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(I=>({...I,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:b,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:b?"Saving...":"Save Changes"})]})})]})}function Kze({siteConfig:t}){var p;const s=pr(),{slug:r}=yo(),[n,a]=k.useState("all"),{data:o,isLoading:l}=mt({queryKey:["public-blog-posts",t.id,n],queryFn:async()=>{let f=H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("published_at",{ascending:!1});n!=="all"&&(f=f.eq("post_type",n));const{data:g,error:b}=await f;if(b)throw b;return g},enabled:!r}),{data:i,isLoading:c}=mt({queryKey:["public-blog-post",t.id,r],queryFn:async()=>{const{data:f,error:g}=await H.from("lead_site_blog_posts").select("*").eq("lead_site_id",t.id).eq("slug",r).eq("is_published",!0).maybeSingle();if(g)throw g;return f},enabled:!!r});if(r)return c?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"h-6 w-6 animate-spin rounded-full border-2 border-gray-900 border-t-transparent"})}):i?e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(b3s,{title:i.title,description:i.excerpt||i.title,publishedAt:i.published_at||i.created_at,imageUrl:i.cover_image_url,slug:i.slug,siteConfig:t}),e.jsx(mCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Blog",path:"/blog"},{name:i.title,path:`/blog/${i.slug}`}]}),i.cover_image_url&&e.jsxs("div",{className:"h-72 md:h-96 w-full relative",children:[e.jsx("img",{src:i.cover_image_url,alt:i.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:()=>s("/blog"),className:"flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-900 mb-6 transition-colors",children:[e.jsx(ri,{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 ${i.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:i.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),i.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ba,{className:"h-3 w-3"})," ",i.neighborhood]})]}),e.jsx("h1",{className:"text-3xl md:text-4xl font-bold text-gray-900 mb-4",children:i.title}),i.published_at&&e.jsx("p",{className:"text-sm text-gray-400 mb-8",children:new Date(i.published_at).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}),e.jsx("div",{className:"prose prose-lg max-w-none prose-headings:text-gray-900 prose-p:text-gray-700 prose-a:text-blue-600",dangerouslySetInnerHTML:{__html:i.content}})]})]}):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-900 mb-2",children:"Post Not Found"}),e.jsx("button",{onClick:()=>s("/blog"),className:"text-blue-600 hover:underline",children:"← Back to blog"})]})});const u=((p=t.agent)==null?void 0:p.full_name)||"Your Agent";return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Local Insights"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Neighborhood guides, market insights, and local expertise from ",u,"."]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 -mt-6 mb-8",children:e.jsx("div",{className:"bg-white rounded-2xl shadow-lg p-2 flex gap-1",children:[{value:"all",label:"All Posts"},{value:"blog_post",label:"Blog"},{value:"neighborhood_guide",label:"Neighborhoods"}].map(f=>e.jsx("button",{onClick:()=>a(f.value),className:`flex-1 py-2.5 px-4 rounded-xl text-sm font-medium transition-all ${n===f.value?"bg-gray-900 text-white shadow-md":"text-gray-600 hover:bg-gray-100"}`,children:f.label},f.value))})}),e.jsx("div",{className:"max-w-4xl mx-auto px-6 pb-20",children:l?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"})}):o!=null&&o.length?e.jsx("div",{className:"grid gap-6",children:o.map((f,g)=>e.jsx(Ws.article,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:g*.05},onClick:()=>s(`/blog/${f.slug}`),className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-xl transition-all cursor-pointer group border border-gray-100",children:e.jsxs("div",{className:"flex flex-col sm:flex-row",children:[f.cover_image_url&&e.jsx("div",{className:"sm:w-64 h-48 sm:h-auto flex-shrink-0",children:e.jsx("img",{src:f.cover_image_url,alt:f.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 ${f.post_type==="neighborhood_guide"?"bg-emerald-50 text-emerald-700":"bg-blue-50 text-blue-700"}`,children:f.post_type==="neighborhood_guide"?"📍 Neighborhood Guide":"📝 Blog"}),f.neighborhood&&e.jsxs("span",{className:"text-xs text-gray-500 flex items-center gap-1",children:[e.jsx(Ba,{className:"h-3 w-3"})," ",f.neighborhood]})]}),e.jsx("h2",{className:"text-xl font-bold text-gray-900 group-hover:text-blue-600 transition-colors mb-2",children:f.title}),f.excerpt&&e.jsx("p",{className:"text-gray-600 text-sm line-clamp-2 mb-3",children:f.excerpt}),f.published_at&&e.jsx("p",{className:"text-xs text-gray-400",children:new Date(f.published_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})]})]})},f.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 K3s({siteConfig:t}){var a;const s=((a=t.agent)==null?void 0:a.full_name)||"Your Agent",{data:r}=mt({queryKey:["public-lead-site-events",t.id],queryFn:async()=>{const{data:o,error:l}=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(l)throw l;return o}}),{data:n}=mt({queryKey:["public-lead-site-businesses",t.id],queryFn:async()=>{const{data:o,error:l}=await H.from("lead_site_businesses").select("*").eq("lead_site_id",t.id).eq("is_published",!0).order("sort_order",{ascending:!0});if(l)throw l;return o}});return e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-gradient-to-br from-gray-900 to-gray-800 text-white py-20 px-6",children:e.jsxs("div",{className:"max-w-4xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Community"}),e.jsxs("p",{className:"text-lg text-gray-300 max-w-2xl mx-auto",children:["Local events, favorite spots, and everything that makes this area special — curated by ",s,"."]})]})}),e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-16 space-y-20",children:[r&&r.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 bg-blue-100 flex items-center justify-center",children:e.jsx(cn,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-gray-900",children:"Upcoming Events"}),e.jsx("p",{className:"text-sm text-gray-500",children:"What's happening in the community"})]})]}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2",children:r.map((o,l)=>e.jsxs(Ws.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url&&e.jsx("div",{className:"h-40 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.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 bg-blue-50 flex flex-col items-center justify-center",children:[e.jsx("span",{className:"text-[10px] font-bold text-blue-600 uppercase leading-none",children:ps(new Date(o.event_date),"MMM")}),e.jsx("span",{className:"text-xl font-bold text-blue-600 leading-none mt-0.5",children:ps(new Date(o.event_date),"d")})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-bold text-gray-900 text-lg mb-1",children:o.title}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-2",children:o.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:[o.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ba,{className:"h-3 w-3"})," ",o.location]}),e.jsx("span",{children:ps(new Date(o.event_date),"h:mm a")})]}),o.external_url&&e.jsxs("a",{href:o.external_url,target:"_blank",rel:"noopener",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-700 mt-3 font-medium",children:["Learn More ",e.jsx(an,{className:"h-3 w-3"})]})]})]})})]},o.id))})]}),n&&n.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 bg-amber-100 flex items-center justify-center",children:e.jsx(zM,{className:"h-5 w-5 text-amber-600"})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-2xl font-bold text-gray-900",children:[s,"'s Local Picks"]}),e.jsx("p",{className:"text-sm 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:n.map((o,l)=>e.jsxs(Ws.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:l*.05},className:"bg-white rounded-2xl overflow-hidden shadow-sm hover:shadow-lg transition-all border border-gray-100 group",children:[o.image_url?e.jsx("div",{className:"h-36 overflow-hidden",children:e.jsx("img",{src:o.image_url,alt:o.name,className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"})}):e.jsx("div",{className:"h-24 bg-gradient-to-br from-amber-50 to-orange-50 flex items-center justify-center",children:e.jsx(zM,{className:"h-8 w-8 text-amber-300"})}),e.jsxs("div",{className:"p-4",children:[o.category&&e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-amber-600 mb-1 block",children:o.category}),e.jsx("h3",{className:"font-bold text-gray-900 mb-1",children:o.name}),o.description&&e.jsx("p",{className:"text-sm text-gray-600 line-clamp-2 mb-3",children:o.description}),e.jsx("div",{className:"flex flex-wrap items-center gap-3 text-xs text-gray-500",children:o.address&&e.jsxs("span",{className:"flex items-center gap-1 truncate",children:[e.jsx(Ba,{className:"h-3 w-3 flex-shrink-0"})," ",o.address]})}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[o.phone&&e.jsxs("a",{href:`tel:${o.phone}`,className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"})," Call"]}),o.website_url&&e.jsxs("a",{href:o.website_url,target:"_blank",rel:"noopener",className:"text-xs text-blue-600 hover:text-blue-700 flex items-center gap-1",children:[e.jsx(Su,{className:"h-3 w-3"})," Website"]})]})]})]},o.id))})]}),(!r||r.length===0)&&(!n||n.length===0)&&e.jsx("div",{className:"text-center py-20",children:e.jsx("p",{className:"text-gray-400 text-lg",children:"Community content coming soon!"})})]})]})}function Z3s(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 Y3s({city:t,state:s="",agentName:r,accentColor:n="#3b82f6"}){const a=Z3s(t,s,r),[o,l]=k.useState(null);return e.jsxs("section",{className:"py-16 bg-gray-50",children:[e.jsx(v3s,{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(pf,{className:"h-5 w-5 text-gray-400 flex-shrink-0"}):e.jsx(To,{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 X3s({cityName:t,citySlug:s,agentName:r,total:n,medianPrice:a,avgDom:o,accentColor:l,heroImageUrl:i}){const c=pr();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(Ei,{to:"/",className:"hover:text-white transition-colors",children:"Home"}),e.jsx("span",{children:"›"}),e.jsx(Ei,{to:"/search",className:"hover:text-white transition-colors",children:"Search"}),e.jsx("span",{children:"›"}),e.jsx("span",{className:"text-white",children:t})]}),e.jsxs(Ws.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(Ws.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(Ws.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(Ws.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(hn,{className:"h-5 w-5"}),"Search All ",t," Listings"]})]})]})}function Q3s({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(Ws.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(Ws.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(Ws.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 J3s({listings:t,cityName:s,accentColor:r}){const n=pr(),a=k.useRef(null),[o,l]=k.useState(!1),[i,c]=k.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(Ws.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(Ws.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(Ws.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(ll,{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(xa,{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 b,_,j;return e.jsx(Ws.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:((b=f.photos)==null?void 0:b[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(Np,{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(Nh,{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(rS,{className:"h-3.5 w-3.5"}),e.jsxs("span",{className:"text-sm font-medium",children:[(j=f.sqft)==null?void 0:j.toLocaleString()," sqft"]})]})]})]})]})},f.mlsNumber)}),e.jsx(Ws.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(fi,{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 e5s({listings:t,cityName:s,accentColor:r}){const n=pr(),[a,o]=k.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(Ws.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(Ws.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(_ct,{listings:t,onListingClick:i=>n(`/listing/${i}`),hoveredMlsNumber:a})})]})})}function t5s({cityName:t,total:s,medianPrice:r,avgDom:n,pricePerSqft:a,accentColor:o}){if(s===0&&!r)return null;const l=[{icon:Sn,label:"Active Listings",value:s>0?s.toLocaleString():"—",sublabel:"Currently on market"},{icon:wc,label:"Median Price",value:r?`$${(r/1e3).toFixed(0)}K`:"—",sublabel:"Active listings"},{icon:mn,label:"Avg Days on Market",value:n?Math.round(n).toString():"—",sublabel:"Time to sell"},{icon:Ol,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(Ws.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(Ws.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 s5s({cityName:t,agentName:s,accentColor:r}){const n=pr();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 r5s({siteConfig:t,citySlugOverride:s}){var M;const r=yo(),n=s||r.citySlug;pr();const[a,o]=k.useState([]),[l,i]=k.useState(!0),[c,u]=k.useState(0),[p,f]=k.useState(null),g=k.useMemo(()=>(n||"").split("-").map(I=>I.charAt(0).toUpperCase()+I.slice(1)).join(" "),[n]),b=((M=t.agent)==null?void 0:M.full_name)||"Your Agent",_=t.accentColor||"#3b82f6",j=`https://${t.subdomainSlug}.thelocalmove.com`,w=`Homes for Sale in ${g} | ${b}`,N=`Browse ${g} homes for sale with ${b}. View listings, pricing, photos, and neighborhood info. Your trusted local real estate expert.`;k.useEffect(()=>{n&&(async()=>{const{data:L}=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();L&&f({description:L.description,highlights:Array.isArray(L.highlights)?L.highlights:[],hero_image_url:L.hero_image_url})})()},[t.id,n]),k.useEffect(()=>{g&&(async()=>{i(!0);try{const R=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(R.ok){const q=await R.json();o(q.listings||[]),u(q.total||0)}}catch{}finally{i(!1)}})()},[g,t.id]);const C=k.useMemo(()=>{if(!a.length)return{medianPrice:null,avgDom:null,pricePerSqft:null};const I=a.map(V=>V.price).filter(V=>!!V&&V>0).sort((V,Y)=>V-Y),L=I.length>0?I[Math.floor(I.length/2)]:null,R=a.map(V=>V.dom||V.daysOnMarket).filter(V=>typeof V=="number"&&V>=0),q=R.length>0?R.reduce((V,Y)=>V+Y,0)/R.length:null,U=a.filter(V=>V.price&&V.sqft&&V.sqft>0),B=U.length>0?U.reduce((V,Y)=>V+Y.price/Y.sqft,0)/U.length:null;return{medianPrice:L,avgDom:q,pricePerSqft:B}},[a]);return e.jsxs("div",{className:"min-h-screen bg-white",children:[e.jsx(vct,{siteConfig:t,pagePath:`/homes-for-sale-in-${n}`}),e.jsx(mCe,{siteConfig:t,items:[{name:"Home",path:"/"},{name:"Search",path:"/search"},{name:`${g} Homes`,path:`/homes-for-sale-in-${n}`}]}),e.jsxs(rd,{children:[e.jsx("title",{children:w}),e.jsx("meta",{name:"description",content:N}),e.jsx("link",{rel:"canonical",href:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:title",content:w}),e.jsx("meta",{property:"og:description",content:N}),e.jsx("meta",{property:"og:url",content:`${j}/homes-for-sale-in-${n}`}),e.jsx("meta",{property:"og:type",content:"website"}),e.jsx("meta",{property:"og:site_name",content:t.siteTitle||b}),((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:w}),e.jsx("meta",{name:"twitter:description",content:N}),((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(X3s,{cityName:g,citySlug:n||"",agentName:b,total:c,medianPrice:C.medianPrice,avgDom:C.avgDom,accentColor:_,heroImageUrl:(p==null?void 0:p.hero_image_url)||void 0}),e.jsx(Q3s,{cityName:g,description:(p==null?void 0:p.description)||null,highlights:(p==null?void 0:p.highlights)||[],agentName:b,accentColor:_}),e.jsx(t5s,{cityName:g,total:c,medianPrice:C.medianPrice,avgDom:C.avgDom,pricePerSqft:C.pricePerSqft,accentColor:_}),!l&&e.jsx(J3s,{listings:a.slice(0,12),cityName:g,accentColor:_}),!l&&a.length>0&&e.jsx(e5s,{listings:a,cityName:g,accentColor:_}),e.jsx(Y3s,{city:g,agentName:b,accentColor:_}),e.jsx(s5s,{cityName:g,agentName:b,accentColor:_})]})}function n5s(){const{siteConfig:t,themeConfig:s,isLoading:r,error:n}=x3s();return r?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..."})]})}):n||!t?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."})]})}):e.jsx(g3s,{siteConfig:t,children:e.jsx(_3s,{siteConfig:t,children:e.jsxs(P2e,{children:[e.jsx(Cs,{path:"/",element:e.jsx(S3s,{siteConfig:t,themeConfig:s??void 0})}),e.jsx(Cs,{path:"/search",element:e.jsx(R3s,{siteConfig:t})}),e.jsx(Cs,{path:"/listing/:mlsNumber",element:e.jsx(V3s,{siteConfig:t})}),e.jsx(Cs,{path:"/about",element:e.jsx(H3s,{siteConfig:t})}),e.jsx(Cs,{path:"/contact",element:e.jsx(W3s,{siteConfig:t})}),e.jsx(Cs,{path:"/account",element:e.jsx(G3s,{siteConfig:t})}),e.jsx(Cs,{path:"/blog",element:e.jsx(Kze,{siteConfig:t})}),e.jsx(Cs,{path:"/blog/:slug",element:e.jsx(Kze,{siteConfig:t})}),e.jsx(Cs,{path:"/community",element:e.jsx(K3s,{siteConfig:t})}),e.jsx(Cs,{path:"/*",element:e.jsx(a5s,{siteConfig:t})})]})})})}function a5s({siteConfig:t}){const r=nu().pathname.match(/^\/homes-for-sale-in-(.+)$/);return r?e.jsx(r5s,{siteConfig:t,citySlugOverride:r[1]}):null}const i5s=({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(Pe,{className:"cursor-pointer hover:shadow-md transition-shadow group",onClick:s,children:[e.jsx(Dt,{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(zt,{className:"text-lg truncate",children:t.name}),t.description&&e.jsx(xr,{className:"mt-1 line-clamp-2",children:t.description})]}),e.jsxs(tt,{variant:"secondary",className:"ml-2 shrink-0",children:[e.jsx(mr,{className:"h-3 w-3 mr-1"}),(r==null?void 0:r.count)??"…"]})]})}),e.jsxs(Re,{className:"space-y-3",children:[(r==null?void 0:r.leaderProfile)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(_n,{className:"h-6 w-6",children:[e.jsx(za,{src:r.leaderProfile.avatar_url||""}),e.jsx(wn,{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(Im,{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(Th,{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(tt,{variant:"outline",className:"text-xs py-0",children:"Lead Pond"}),t.shared_assets_enabled&&e.jsx(tt,{variant:"outline",className:"text-xs py-0",children:"Shared Assets"}),t.shared_videos_enabled&&e.jsx(tt,{variant:"outline",className:"text-xs py-0",children:"Shared Videos"})]})]})]})},o5s=()=>{const{user:t,isAdmin:s,isBrokerageManager:r,brokerageId:n,managedBrokerages:a,selectedBrokerageId:o}=Rs(),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:b,removeMember:_,updateMemberRole:j}=fC(i),[w,N]=k.useState(!1),[C,M]=k.useState(null),{data:I}=mt({queryKey:["all-brokerages-for-teams"],queryFn:async()=>{const{data:q,error:U}=await H.from("brokerages").select("id, name").order("name");if(U)throw U;return q||[]},enabled:s}),{data:L}=mt({queryKey:["brokerage-agents-for-teams",l],queryFn:async()=>{const{data:q,error:U}=await H.from("profiles").select("id, name, email, avatar_url").eq("brokerage_id",l).order("name");if(U)throw U;return q||[]},enabled:!!l}),R=async q=>{const U=q.brokerage_id||l||null,B=await p.mutateAsync({name:q.name,brokerage_id:U,description:q.description});if(q.leaderId&&q.leaderId!=="none"&&await b.mutateAsync({team_id:B.id,user_id:q.leaderId,role:"team_leader"}),q.memberIds)for(const V of q.memberIds)await b.mutateAsync({team_id:B.id,user_id:V,role:"team_member"});N(!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(mr,{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:()=>N(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Team"]})]}),e.jsx(ntt,{open:w,onOpenChange:N,onCreateTeam:R,isCreating:p.isPending,brokerageAgents:L||[],isAdmin:s,allBrokerages:I,activeBrokerageId:l}),u&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:[1,2,3].map(q=>e.jsx(Pe,{children:e.jsxs(Re,{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"})]})},q))}),!u&&c.length===0&&!C&&e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{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:()=>N(!0),children:[e.jsx(qs,{className:"mr-2 h-4 w-4"}),"Create Your First Team"]})]})}),!u&&c.length>0&&!C&&e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:c.map(q=>e.jsx(i5s,{team:q,onSelect:()=>M(q)},q.id))}),C&&e.jsx(rtt,{team:C,brokerageAgents:L||[],onBack:()=>M(null),onUpdate:q=>f.mutateAsync({id:C.id,...q}).then(U=>M(U)),onAddMember:(q,U)=>b.mutateAsync({team_id:C.id,user_id:q,role:U}),onRemoveMember:q=>_.mutateAsync({team_id:C.id,member_id:q}),onUpdateRole:(q,U)=>j.mutateAsync({team_id:C.id,member_id:q,role:U}),onDeleteTeam:()=>g.mutate(C.id),isUpdating:f.isPending,isAddingMember:b.isPending})]})})},l5s=()=>{const{data:t,isLoading:s}=Bx(),{useTeamMembers:r}=fC(),{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(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(mr,{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(tt,{variant:t.role==="team_leader"?"default":"secondary",className:"capitalize",children:t.role==="team_leader"?e.jsxs(e.Fragment,{children:[e.jsx(Im,{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(ja,{defaultValue:"members",className:"space-y-4",children:[e.jsxs(ga,{className:"flex-wrap",children:[e.jsx(us,{value:"members",children:"Members"}),o.contact_visibility!=="private"&&e.jsxs(us,{value:"contacts",children:[e.jsx(Y4,{className:"mr-1 h-3.5 w-3.5"}),"Team Contacts"]}),o.lead_pond_enabled&&e.jsxs(us,{value:"lead-pond",children:[e.jsx(Zg,{className:"mr-1 h-3.5 w-3.5"}),"Lead Pond"]}),o.shared_assets_enabled&&e.jsxs(us,{value:"shared-assets",children:[e.jsx(Lm,{className:"mr-1 h-3.5 w-3.5"}),"Shared Assets"]})]}),e.jsx(ks,{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(Pe,{children:e.jsxs(Re,{className:"flex items-center gap-3 p-4",children:[e.jsxs(_n,{className:"h-10 w-10",children:[e.jsx(za,{src:((i=l.profile)==null?void 0:i.avatar_url)||""}),e.jsx(wn,{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(tt,{className:"ml-auto bg-amber-500/10 text-amber-600 border-amber-500",children:[e.jsx(Im,{className:"mr-1 h-3 w-3"})," Leader"]}):e.jsx(tt,{variant:"secondary",className:"ml-auto",children:"Member"})]})},l.id)})}),o.contact_visibility!=="private"&&e.jsx(ks,{value:"contacts",className:"space-y-4",children:e.jsx(Pke,{})}),o.lead_pond_enabled&&e.jsx(ks,{value:"lead-pond",className:"space-y-4",children:e.jsx(Ike,{teamId:t.teamId})}),o.shared_assets_enabled&&e.jsx(ks,{value:"shared-assets",className:"space-y-4",children:e.jsx(stt,{teamId:t.teamId})})]})]})})};function c5s(){const{user:t}=Rs(),s=es(),r=mt({queryKey:["booking-settings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_settings").select("*").eq("user_id",t.id).maybeSingle();if(N)throw N;return w},enabled:!!t}),n=mt({queryKey:["booking-types",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_types").select("*").eq("user_id",t.id).order("sort_order");if(N)throw N;return w},enabled:!!t}),a=mt({queryKey:["availability-slots",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_availability_slots").select("*").eq("user_id",t.id).order("day_of_week").order("start_time");if(N)throw N;return w},enabled:!!t}),o=mt({queryKey:["blocked-dates",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("agent_blocked_dates").select("*").eq("user_id",t.id).order("blocked_date");if(N)throw N;return w},enabled:!!t}),l=mt({queryKey:["bookings",t==null?void 0:t.id],queryFn:async()=>{const{data:w,error:N}=await H.from("bookings").select("*, booking_type:agent_booking_types(*)").eq("agent_user_id",t.id).order("booking_date",{ascending:!1});if(N)throw N;return w},enabled:!!t}),i=Lt({mutationFn:async()=>{const{data:w,error:N}=await H.from("agent_booking_settings").insert({user_id:t.id,slug:""}).select().single();if(N)throw N;const C=[{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(C.map(R=>({...R,user_id:t.id})));if(M)throw M;const I=[1,2,3,4,5].map(R=>({user_id:t.id,day_of_week:R,start_time:"09:00",end_time:"17:00"})),{error:L}=await H.from("agent_availability_slots").insert(I);if(L)throw L;return w},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),s.invalidateQueries({queryKey:["booking-types"]}),s.invalidateQueries({queryKey:["availability-slots"]}),he.success("Scheduler set up successfully!")},onError:w=>he.error(w.message)}),c=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_booking_settings").update(w).eq("user_id",t.id);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-settings"]}),he.success("Settings updated")},onError:w=>he.error(w.message)}),u=Lt({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await H.from("agent_booking_types").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await H.from("agent_booking_types").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),he.success("Booking type saved")},onError:w=>he.error(w.message)}),p=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_booking_types").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["booking-types"]}),he.success("Booking type deleted")},onError:w=>he.error(w.message)}),f=Lt({mutationFn:async w=>{const N={...w,user_id:t.id};if(w.id){const{error:C}=await H.from("agent_availability_slots").update(N).eq("id",w.id);if(C)throw C}else{const{error:C}=await H.from("agent_availability_slots").insert(N);if(C)throw C}},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>he.error(w.message)}),g=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_availability_slots").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["availability-slots"]})},onError:w=>he.error(w.message)}),b=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_blocked_dates").insert({...w,user_id:t.id});if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]}),he.success("Date blocked")},onError:w=>he.error(w.message)}),_=Lt({mutationFn:async w=>{const{error:N}=await H.from("agent_blocked_dates").delete().eq("id",w);if(N)throw N},onSuccess:()=>{s.invalidateQueries({queryKey:["blocked-dates"]})},onError:w=>he.error(w.message)}),j=Lt({mutationFn:async({id:w,reason:N})=>{const{error:C}=await H.from("bookings").update({status:"cancelled",cancelled_at:new Date().toISOString(),cancel_reason:N}).eq("id",w);if(C)throw C},onSuccess:()=>{s.invalidateQueries({queryKey:["bookings"]}),he.success("Booking cancelled")},onError:w=>he.error(w.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:b,removeBlockedDate:_,cancelBooking:j}}const Zze={Home:"🏠",Search:"🔍",DollarSign:"💰",Coffee:"☕",Calendar:"📅",Users:"👥",Phone:"📞",Video:"🎥"};function d5s({types:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.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(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(zt,{children:"Booking Types"}),e.jsx(xr,{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(Re,{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:Zze[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(tt,{variant:"secondary",className:"text-xs",children:"Inactive"}),p.qualification_enabled&&e.jsxs(tt,{variant:"outline",className:"text-xs gap-1",children:[e.jsx(hL,{className:"h-3 w-3"})," Qualifying"]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(mn,{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(Da,{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(_s,{children:e.jsxs(bs,{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(ye,{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(ye,{children:"Description"}),e.jsx(Er,{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(ye,{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(ye,{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(ye,{children:"Icon"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(Zze).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(ye,{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(ye,{children:"Pre-Qualification Questions"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask qualifying questions before booking"})]}),e.jsx($r,{checked:n.qualification_enabled||!1,onCheckedChange:p=>a({...n,qualification_enabled:p})})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(ye,{children:"Active"}),e.jsx($r,{checked:n.is_active??!0,onCheckedChange:p=>a({...n,is_active:p})})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:u,children:"Save"})]})]})})]})}const Yze=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function u5s({slots:t,onSave:s,onDelete:r}){const[n,a]=k.useState(null),[o,l]=k.useState("09:00"),[i,c]=k.useState("17:00"),u=Yze.map((f,g)=>t.filter(b=>b.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(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(mn,{className:"h-5 w-5"}),"Weekly Availability"]}),e.jsx(xr,{children:"Set your available hours for each day"})]}),e.jsx(Re,{className:"space-y-2",children:Yze.map((f,g)=>{const b=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:[b.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-1",children:"Unavailable"}):b.map(_=>{var j,w;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ze,{type:"time",className:"w-28 h-8 text-sm",defaultValue:(j=_.start_time)==null?void 0:j.slice(0,5),onBlur:N=>s({id:_.id,start_time:N.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:(w=_.end_time)==null?void 0:w.slice(0,5),onBlur:N=>s({id:_.id,end_time:N.target.value})}),e.jsx($r,{checked:_.is_active,onCheckedChange:N=>s({id:_.id,is_active:N})}),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 h5s={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 m5s({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(to,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium",children:o.guest_name}),e.jsx(tt,{className:`text-xs ${h5s[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(Dd,{className:"h-3.5 w-3.5"}),ps(new Date(o.booking_date+"T00:00:00"),"MMM d, yyyy")]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(mn,{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(dr,{className:"h-3 w-3"}),o.guest_email]}),o.guest_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Un,{className:"h-3 w-3"}),o.guest_phone]})]}),o.booking_type&&e.jsx(tt,{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(xc,{className:"h-4 w-4 mr-1"})," Cancel"]})]},o.id)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsx(zt,{children:"Upcoming Bookings"}),e.jsxs(xr,{children:[r.length," upcoming appointment",r.length!==1?"s":""]})]}),e.jsx(Re,{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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{children:"Past & Cancelled"})}),e.jsx(Re,{children:e.jsx("div",{className:"space-y-3",children:n.slice(0,20).map(o=>a(o))})})]})]})}function p5s({blockedDates:t,onAdd:s,onRemove:r}){const[n,a]=k.useState(!1),[o,l]=k.useState(""),[i,c]=k.useState(""),u=()=>{o&&(s({blocked_date:o,reason:i||void 0}),a(!1),l(""),c(""))};return e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(QI,{className:"h-5 w-5"}),"Blocked Dates"]}),e.jsx(xr,{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(Re,{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:ps(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(Or,{className:"h-3.5 w-3.5"})})]},p.id))})]})]})}function f5s(){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:b,cancelBooking:_}=c5s(),[j,w]=k.useState(""),[N,C]=k.useState(15);j||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(Dd,{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),he.success("Booking link copied!")},children:[e.jsx(gi,{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(an,{className:"h-4 w-4 mr-1"})," Preview"]})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{htmlFor:"scheduler-active",className:"text-sm",children:"Active"}),e.jsx($r,{id:"scheduler-active",checked:t.is_active,onCheckedChange:I=>i.mutate({is_active:I})})]})]})]}),e.jsxs(ja,{defaultValue:"types",className:"space-y-4",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"types",children:"Booking Types"}),e.jsx(us,{value:"availability",children:"Availability"}),e.jsx(us,{value:"settings",children:"Settings"}),e.jsxs(us,{value:"bookings",children:["Bookings",a.filter(I=>I.status==="confirmed").length>0&&e.jsx(tt,{variant:"secondary",className:"ml-1.5 text-xs",children:a.filter(I=>I.status==="confirmed").length})]})]}),e.jsx(ks,{value:"types",children:e.jsx(d5s,{types:s,onSave:I=>c.mutate(I),onDelete:I=>u.mutate(I)})}),e.jsx(ks,{value:"availability",children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(u5s,{slots:r,onSave:I=>p.mutate(I),onDelete:I=>f.mutate(I)}),e.jsx(p5s,{blockedDates:n,onAdd:I=>g.mutate(I),onRemove:I=>b.mutate(I)})]})}),e.jsx(ks,{value:"settings",children:e.jsxs(Pe,{children:[e.jsxs(Dt,{children:[e.jsxs(zt,{className:"flex items-center gap-2",children:[e.jsx(NL,{className:"h-5 w-5"}),"General Settings"]}),e.jsx(xr,{children:"Configure your booking page defaults"})]}),e.jsxs(Re,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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),he.success("Copied!"))},children:e.jsx(gi,{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(ye,{htmlFor:"meeting-link",children:[e.jsx(cl,{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:I=>i.mutate({meeting_link:I.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(ye,{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:I=>i.mutate({buffer_minutes:parseInt(I.target.value)||15})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"min"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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:I=>i.mutate({min_notice_hours:parseInt(I.target.value)||2})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"hours"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(ye,{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:I=>i.mutate({max_advance_days:parseInt(I.target.value)||30})}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"days"})]})]})]})]})]})}),e.jsx(ks,{value:"bookings",children:e.jsx(m5s,{bookings:a,onCancel:I=>_.mutate({id:I})})})]})]})}):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(Dd,{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(Pe,{children:e.jsxs(Re,{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(I=>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:I.icon}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:I.title}),e.jsx("p",{className:"text-xs text-muted-foreground",children:I.desc})]})]},I.title))}),e.jsx(sl,{}),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(un,{className:"h-4 w-4 mr-2"}),l.isPending?"Setting up...":"Activate Scheduler"]})]})})]})})}const Xze=[{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 x5s(){const{user:t}=Rs(),s=li(),{toast:r}=qa(),n=pr(),a=es(),[o,l]=k.useState(!1),[i,c]=k.useState(null),[u,p]=k.useState(null),[f,g]=k.useState({title:"",description:"",page_type:"lead_capture"}),{data:b=[],isLoading:_}=mt({queryKey:["landing-pages",s],queryFn:async()=>{const{data:C,error:M}=await H.from("landing_pages").select("*").eq("user_id",s).order("created_at",{ascending:!1});if(M)throw M;return C},enabled:!!s}),j=Lt({mutationFn:async()=>{const C=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(),I=f.page_type==="just_listed"||f.page_type==="just_sold",{data:L,error:R}=await H.from("landing_pages").insert({user_id:s,title:f.title,description:f.description||null,page_type:f.page_type,slug:C,hero_headline:I?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:I?f.page_type.replace("just_",""):null}).select().single();if(R)throw R;const q=g5s(f.page_type);if(q.length>0){const{error:U}=await H.from("landing_page_fields").insert(q.map((B,V)=>({...B,page_id:L.id,sort_order:V})));if(U)throw U}return L},onSuccess:C=>{a.invalidateQueries({queryKey:["landing-pages"]}),l(!1),g({title:"",description:"",page_type:"lead_capture"}),r({title:"Landing page created!"}),n(`/mission-control/landing-pages/${C.id}`)},onError:C=>r({title:"Error",description:C.message,variant:"destructive"})}),w=Lt({mutationFn:async C=>{const{error:M}=await H.from("landing_pages").delete().eq("id",C);if(M)throw M},onSuccess:()=>{a.invalidateQueries({queryKey:["landing-pages"]}),c(null),r({title:"Landing page deleted"})}}),N=C=>`https://pages.relevelup.com/${C}`;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"})}):b.length===0?e.jsx(Pe,{children:e.jsxs(Re,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(En,{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:b.map(C=>{var M;return e.jsx(Pe,{className:"hover:shadow-md transition-shadow",children:e.jsx(Re,{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/${C.id}`),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold truncate",children:C.title}),e.jsx(tt,{variant:C.is_published?"default":"secondary",className:"text-[10px]",children:C.is_published?"Published":"Draft"}),e.jsx(tt,{variant:"outline",className:"text-[10px]",children:((M=Xze.find(I=>I.id===C.page_type))==null?void 0:M.label)||C.page_type})]}),C.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:C.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(qn,{className:"h-3 w-3"})," ",C.view_count," views"]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(En,{className:"h-3 w-3"})," ",C.submission_count," submissions"]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[C.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>p(N(C.slug)),children:e.jsx(o1,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(N(C.slug)),r({title:"Link copied!"})},children:e.jsx(gi,{className:"h-3.5 w-3.5"})}),e.jsx(K,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:N(C.slug),target:"_blank",rel:"noopener noreferrer",children:e.jsx(an,{className:"h-3.5 w-3.5"})})})]}),e.jsxs(au,{children:[e.jsx(iu,{asChild:!0,children:e.jsx(K,{size:"sm",variant:"ghost",children:e.jsx(mx,{className:"h-4 w-4"})})}),e.jsxs(zd,{align:"end",children:[e.jsxs(Ca,{onClick:()=>n(`/mission-control/landing-pages/${C.id}`),children:[e.jsx(Da,{className:"h-3.5 w-3.5 mr-2"})," Edit"]}),e.jsxs(Ca,{onClick:()=>c(C.id),className:"text-destructive",children:[e.jsx(Nr,{className:"h-3.5 w-3.5 mr-2"})," Delete"]})]})]})]})]})})},C.id)})})]}),e.jsx(xs,{open:o,onOpenChange:l,children:e.jsxs(fs,{children:[e.jsx(_s,{children:e.jsx(bs,{children:"Create Landing Page"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Page Title"}),e.jsx(ze,{value:f.title,onChange:C=>g(M=>({...M,title:C.target.value})),placeholder:"e.g. Veterans Home & Land Expo"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description (optional)"}),e.jsx(Er,{value:f.description,onChange:C=>g(M=>({...M,description:C.target.value})),placeholder:"Brief internal description...",rows:2})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Page Template"}),e.jsxs(Ys,{value:f.page_type,onValueChange:C=>g(M=>({...M,page_type:C})),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:Xze.map(C=>e.jsx(Mt,{value:C.id,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:C.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:C.description})]})},C.id))})]})]})]}),e.jsxs(zn,{children:[e.jsx(K,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(K,{onClick:()=>j.mutate(),disabled:!f.title.trim()||j.isPending,children:j.isPending?"Creating...":"Create Page"})]})]})}),e.jsx(_c,{open:!!i,onOpenChange:()=>c(null),children:e.jsxs(Zl,{children:[e.jsxs(Yl,{children:[e.jsx(Ql,{children:"Delete Landing Page?"}),e.jsx(Jl,{children:"This will permanently delete this page and all its submissions."})]}),e.jsxs(Xl,{children:[e.jsx(ec,{children:"Cancel"}),e.jsx(Ll,{onClick:()=>i&&w.mutate(i),children:"Delete"})]})]})}),e.jsx(xs,{open:!!u,onOpenChange:()=>p(null),children:e.jsxs(fs,{className:"max-w-sm",children:[e.jsx(_s,{children:e.jsx(bs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[u&&e.jsx(jR,{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(gi,{className:"h-3.5 w-3.5 mr-1"})," Copy URL"]})]})]})})]})}function g5s(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 y5s=[{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 v5s(){const{pageId:t}=yo(),s=pr(),{user:r}=Rs(),n=li(),{toast:a}=qa(),o=es(),[l,i]=k.useState(null),[c,u]=k.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:b}=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:j=[]}=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")}),[w,N]=k.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"}),[C,M]=k.useState([]);k.useEffect(()=>{p&&N({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]),k.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 I=Lt({mutationFn:async()=>{const{error:ne}=await H.from("landing_pages").update({title:w.title,hero_headline:w.hero_headline,hero_subtext:w.hero_subtext||null,hero_image_url:w.hero_image_url,logo_url:w.logo_url,primary_color:w.primary_color,accent_color:w.accent_color,agent_name:w.agent_name||null,agent_phone:w.agent_phone||null,agent_email:w.agent_email||null,agent_photo_url:w.agent_photo_url,success_message:w.success_message,is_published:w.is_published,description:w.description||null,lead_magnet_file_url:w.lead_magnet_file_url,lead_magnet_file_name:w.lead_magnet_file_name,lead_magnet_external_url:w.lead_magnet_external_url,listing_id:w.listing_id,property_address:w.property_address||null,property_price:w.property_price||null,property_beds:w.property_beds||null,property_baths:w.property_baths||null,property_sqft:w.property_sqft||null,property_description:w.property_description||null,property_photos:w.property_photos,property_status:w.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),C.length>0){const{error:re}=await H.from("landing_page_fields").insert(C.map((le,pe)=>({page_id:t,field_type:le.field_type,label:le.label,placeholder:le.placeholder||null,is_required:le.is_required,options:le.options?JSON.parse(le.options):null,sort_order:pe})));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"})}),L=async(ne,re)=>{const le=ne.name.split(".").pop(),pe=`landing-pages/${r.id}/${re}-${Date.now()}.${le}`,{error:xe}=await H.storage.from("recruit-landing").upload(pe,ne);if(xe)throw xe;const{data:{publicUrl:_e}}=H.storage.from("recruit-landing").getPublicUrl(pe);return _e},R=async(ne,re)=>{var pe;const le=(pe=ne.target.files)==null?void 0:pe[0];if(le){i(re);try{const xe=await L(le,re);N(_e=>({..._e,[re]:xe})),a({title:"Image uploaded!"})}catch(xe){a({title:"Upload failed",description:xe.message,variant:"destructive"})}finally{i(null)}}},q=async ne=>{var le;const re=(le=ne.target.files)==null?void 0:le[0];if(re){i("lead_magnet");try{const pe=await L(re,"lead-magnet");N(xe=>({...xe,lead_magnet_file_url:pe,lead_magnet_file_name:re.name})),a({title:"File uploaded!"})}catch(pe){a({title:"Upload failed",description:pe.message,variant:"destructive"})}finally{i(null)}}},U=async ne=>{const re=ne.target.files;if(!(!re||re.length===0)){i("property_photos");try{const le=[];for(const pe of Array.from(re)){const xe=await L(pe,"property-photo");le.push(xe)}N(pe=>({...pe,property_photos:[...pe.property_photos,...le]})),a({title:`${le.length} photo(s) uploaded!`})}catch(le){a({title:"Upload failed",description:le.message,variant:"destructive"})}finally{i(null)}}},B=async ne=>{const re=j.find(pe=>pe.id===ne);if(!re)return;const{data:le}=await H.from("listing_photos").select("photo_url").eq("listing_id",ne).order("sort_order");N(pe=>({...pe,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:(le==null?void 0:le.map(xe=>xe.photo_url))||pe.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}])},Y=(ne,re)=>{M(le=>le.map((pe,xe)=>xe===ne?{...pe,...re}:pe))},J=ne=>{M(re=>re.filter((le,pe)=>pe!==ne))},te=p?`https://pages.relevelup.com/${p.slug}`:"",X=(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||b?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:w.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(ri,{className:"h-4 w-4"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold",children:w.title||"Untitled Page"}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx(tt,{variant:w.is_published?"default":"secondary",className:"text-[10px]",children:w.is_published?"Published":"Draft"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(qn,{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(mr,{className:"h-3 w-3"})," ",_.length," submissions"]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[w.is_published&&e.jsxs(e.Fragment,{children:[e.jsx(K,{size:"sm",variant:"outline",onClick:()=>u(!0),children:e.jsx(o1,{className:"h-3.5 w-3.5"})}),e.jsxs(K,{size:"sm",variant:"outline",onClick:()=>{navigator.clipboard.writeText(te),a({title:"Link copied!"})},children:[e.jsx(gi,{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:te,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(an,{className:"h-3.5 w-3.5 mr-1"})," Preview"]})})]}),e.jsxs(K,{onClick:()=>I.mutate(),disabled:I.isPending,children:[e.jsx(ed,{className:"h-4 w-4 mr-2"}),I.isPending?"Saving...":"Save"]})]})]}),e.jsxs(ja,{defaultValue:"design",children:[e.jsxs(ga,{children:[e.jsx(us,{value:"design",children:"Design"}),X&&e.jsx(us,{value:"lead_magnet",children:"Lead Magnet"}),ce&&e.jsx(us,{value:"property",children:"Property Details"}),e.jsxs(us,{value:"fields",children:["Form Fields (",C.length,")"]}),e.jsxs(us,{value:"submissions",children:["Submissions (",_.length,")"]}),e.jsx(us,{value:"settings",children:"Settings"})]}),e.jsxs(ks,{value:"design",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Page Details"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Page Title (internal)"}),e.jsx(ze,{value:w.title,onChange:ne=>N(re=>({...re,title:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description (internal)"}),e.jsx(ze,{value:w.description,onChange:ne=>N(re=>({...re,description:ne.target.value}))})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Hero Section"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Headline"}),e.jsx(ze,{value:w.hero_headline,onChange:ne=>N(re=>({...re,hero_headline:ne.target.value})),placeholder:"Join us for..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Subtext"}),e.jsx(Er,{value:w.hero_subtext,onChange:ne=>N(re=>({...re,hero_subtext:ne.target.value})),rows:2,placeholder:"A brief description..."})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Background Image"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.hero_image_url&&e.jsx("img",{src:w.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(oi,{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=>R(ne,"hero_image_url")})]}),w.hero_image_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(ne=>({...ne,hero_image_url:null})),children:e.jsx(Nr,{className:"h-3.5 w-3.5"})})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Branding"})}),e.jsxs(Re,{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(ye,{children:"Logo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.logo_url&&e.jsx("img",{src:w.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(oi,{className:"h-3.5 w-3.5 mr-1"}),l==="logo_url"?"...":"Upload"]})}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:ne=>R(ne,"logo_url")})]})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Agent Photo"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.agent_photo_url&&e.jsx("img",{src:w.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(oi,{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=>R(ne,"agent_photo_url")})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Primary Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.primary_color,onChange:ne=>N(re=>({...re,primary_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.primary_color,onChange:ne=>N(re=>({...re,primary_color:ne.target.value})),className:"font-mono text-xs"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Accent Color"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("input",{type:"color",value:w.accent_color,onChange:ne=>N(re=>({...re,accent_color:ne.target.value})),className:"h-9 w-12 rounded border cursor-pointer"}),e.jsx(ze,{value:w.accent_color,onChange:ne=>N(re=>({...re,accent_color:ne.target.value})),className:"font-mono text-xs"})]})]})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Agent Info (shown on page)"})}),e.jsx(Re,{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(ye,{children:"Name"}),e.jsx(ze,{value:w.agent_name,onChange:ne=>N(re=>({...re,agent_name:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Phone"}),e.jsx(ze,{value:w.agent_phone,onChange:ne=>N(re=>({...re,agent_phone:ne.target.value}))})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Email"}),e.jsx(ze,{value:w.agent_email,onChange:ne=>N(re=>({...re,agent_email:ne.target.value}))})]})]})})]})]}),X&&e.jsx(ks,{value:"lead_magnet",className:"space-y-4 mt-4",children:e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Ci,{className:"h-4 w-4"})," Giveaway File"]})}),e.jsxs(Re,{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(ye,{children:"Upload File (PDF, guide, checklist, etc.)"}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[w.lead_magnet_file_name&&e.jsxs(tt,{variant:"outline",className:"gap-1",children:[e.jsx(Ci,{className:"h-3 w-3"})," ",w.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(oi,{className:"h-3.5 w-3.5 mr-1"}),l==="lead_magnet"?"Uploading...":"Upload File"]})}),e.jsx("input",{type:"file",className:"hidden",onChange:q})]}),w.lead_magnet_file_url&&e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>N(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(ye,{className:"flex items-center gap-1",children:[e.jsx(cl,{className:"h-3.5 w-3.5"})," External URL"]}),e.jsx(ze,{value:w.lead_magnet_external_url||"",onChange:ne=>N(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(ks,{value:"property",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Sn,{className:"h-4 w-4"})," Import from Listing Exchange"]})}),e.jsxs(Re,{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(Ys,{value:w.listing_id||"",onValueChange:ne=>B(ne),children:[e.jsx(Gs,{children:e.jsx(Qs,{placeholder:"Select a listing to import..."})}),e.jsx(Ks,{children:j.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(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Property Information"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Property Address"}),e.jsx(ze,{value:w.property_address,onChange:ne=>N(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(ye,{children:"Price"}),e.jsx(ze,{value:w.property_price,onChange:ne=>N(re=>({...re,property_price:ne.target.value})),placeholder:"$450,000"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Beds"}),e.jsx(ze,{value:w.property_beds,onChange:ne=>N(re=>({...re,property_beds:ne.target.value})),placeholder:"4"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Baths"}),e.jsx(ze,{value:w.property_baths,onChange:ne=>N(re=>({...re,property_baths:ne.target.value})),placeholder:"3"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Sq Ft"}),e.jsx(ze,{value:w.property_sqft,onChange:ne=>N(re=>({...re,property_sqft:ne.target.value})),placeholder:"2,400"})]})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Description"}),e.jsx(Er,{value:w.property_description,onChange:ne=>N(re=>({...re,property_description:ne.target.value})),rows:3,placeholder:"Beautiful home in a great neighborhood..."})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Property Photos"})}),e.jsxs(Re,{className:"space-y-4",children:[w.property_photos.length>0&&e.jsx("div",{className:"grid grid-cols-3 md:grid-cols-4 gap-2",children:w.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:()=>N(le=>({...le,property_photos:le.property_photos.filter((pe,xe)=>xe!==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(oi,{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(ks,{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"]})]}),C.length===0?e.jsx(Pe,{children:e.jsx(Re,{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:C.map((ne,re)=>e.jsx(Pe,{children:e.jsx(Re,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ju,{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(ye,{className:"text-xs",children:"Field Type"}),e.jsxs(Ys,{value:ne.field_type,onValueChange:le=>Y(re,{field_type:le}),children:[e.jsx(Gs,{children:e.jsx(Qs,{})}),e.jsx(Ks,{children:y5s.map(le=>e.jsx(Mt,{value:le.value,children:le.label},le.value))})]})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Label"}),e.jsx(ze,{value:ne.label,onChange:le=>Y(re,{label:le.target.value}),placeholder:"e.g. Full Name"})]}),e.jsxs("div",{children:[e.jsx(ye,{className:"text-xs",children:"Placeholder"}),e.jsx(ze,{value:ne.placeholder||"",onChange:le=>Y(re,{placeholder:le.target.value}),placeholder:"Optional hint text"})]})]}),(ne.field_type==="select"||ne.field_type==="multiselect")&&e.jsxs("div",{children:[e.jsx(ye,{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:le=>Y(re,{options:JSON.stringify(le.target.value.split(",").map(pe=>pe.trim()).filter(Boolean))}),placeholder:"Option 1, Option 2, Option 3"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($r,{checked:ne.is_required,onCheckedChange:le=>Y(re,{is_required:le})}),e.jsx(ye,{className:"text-xs",children:"Required"})]})]}),e.jsx(K,{variant:"ghost",size:"sm",onClick:()=>J(re),children:e.jsx(Nr,{className:"h-3.5 w-3.5 text-destructive"})})]})})},re))})]}),e.jsx(ks,{value:"submissions",className:"mt-4",children:_.length===0?e.jsx(Pe,{children:e.jsx(Re,{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(Pe,{children:e.jsx(Re,{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(tt,{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,le])=>e.jsxs("div",{children:[e.jsxs("span",{className:"font-medium text-muted-foreground",children:[re,":"]})," ",e.jsx("span",{children:String(le)})]},re))})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:new Date(ne.created_at).toLocaleDateString()})]})})},ne.id))})}),e.jsxs(ks,{value:"settings",className:"space-y-4 mt-4",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Publishing"})}),e.jsxs(Re,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Published"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Make this page publicly accessible"})]}),e.jsx($r,{checked:w.is_published,onCheckedChange:ne=>N(re=>({...re,is_published:ne}))})]}),w.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:te})]})]})]}),e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsx(zt,{className:"text-base",children:"Thank You Message"})}),e.jsx(Re,{children:e.jsx(Er,{value:w.success_message,onChange:ne=>N(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(_s,{children:e.jsx(bs,{children:"QR Code"})}),e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4",children:[e.jsx(jR,{value:te,size:240}),e.jsx("p",{className:"text-xs text-muted-foreground text-center break-all",children:te})]})]})})]}):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 Qze({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(HI,{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(VI,{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(m0,{className:"h-3 w-3"}),"0%"]})}const b5s={Phone:Un,MessageSquare:io,Mail:dr,Gift:No,PenTool:$_,Video:Cn},Jze=["bg-primary","bg-emerald-500","bg-amber-500","bg-sky-500","bg-purple-500","bg-orange-500","bg-pink-500","bg-teal-500"];function _5s(){const t=pr(),{contactsWithScores:s,stats:r}=wue(),{data:n}=zO(365),{data:a}=NNe(),{data:o}=FO(),l=_Ne(),i=k.useMemo(()=>{if(!n)return{touchesThisMonth:0,touchesLastMonth:0,touchTrend:0};const M=new Date,I=Lc(M),L=lx(M),R=Lc(f4(M,1)),q=lx(f4(M,1)),U=n.filter(Y=>Og(new Date(Y.completed_at),{start:I,end:L})).length,B=n.filter(Y=>Og(new Date(Y.completed_at),{start:R,end:q})).length,V=B>0?Math.round((U-B)/B*100):U>0?100:0;return{touchesThisMonth:U,touchesLastMonth:B,touchTrend:V}},[n]),c=k.useMemo(()=>{if(!n)return 0;const M=new Date,I=Lc(M),L=lx(M);return new Set(n.filter(R=>Og(new Date(R.completed_at),{start:I,end:L})).map(R=>R.contact_id)).size},[n]),u=k.useMemo(()=>{if(!a)return{closedThisMonth:0,totalGCI:0};const M=new Date,I=Lc(M),L=lx(M),R=a.filter(q=>q.close_date&&Og(Il(q.close_date),{start:I,end:L}));return{closedThisMonth:R.length,totalGCI:R.reduce((q,U)=>q+(Number(U.commission_amount)||0),0)}},[a]),p=k.useMemo(()=>{if(!s.length)return{newThisMonth:0,newLastMonth:0,trend:0};const M=new Date,I=Lc(M),L=Lc(f4(M,1)),R=lx(f4(M,1)),q=s.filter(V=>new Date(V.created_at)>=I).length,U=s.filter(V=>Og(new Date(V.created_at),{start:L,end:R})).length,B=U>0?Math.round((q-U)/U*100):q>0?100:0;return{newThisMonth:q,newLastMonth:U,trend:B}},[s]),f=k.useMemo(()=>{if(!n||!o)return[];const M=new Date,I=Lc(M),L=lx(M),R=n.filter(B=>Og(new Date(B.completed_at),{start:I,end:L})),q={};R.forEach(B=>{const V=B.action_type_id;q[V]=(q[V]||0)+1});const U=R.length||1;return o.filter(B=>q[B.id]).map(B=>({id:B.id,name:B.name,icon:B.icon,count:q[B.id]||0,percent:Math.round((q[B.id]||0)/U*100)})).sort((B,V)=>V.count-B.count)},[n,o]),g=k.useMemo(()=>[...s].filter(M=>M.relationshipScore.status==="at-risk"||M.relationshipScore.status==="cooling").sort((M,I)=>{const L=M.relationshipScore.daysSinceTouch??9999;return(I.relationshipScore.daysSinceTouch??9999)-L}).slice(0,5),[s]),b=k.useMemo(()=>{if(!n)return[];const M=new Date,I=Lc(M),L=lx(M),R=new Set(n.filter(q=>Og(new Date(q.completed_at),{start:I,end:L})).map(q=>q.contact_id));return s.filter(q=>q.relationshipScore.status==="warm"&&R.has(q.id)&&q.relationshipScore.touchCountLast12Months>=2).sort((q,U)=>U.relationshipScore.score-q.relationshipScore.score).slice(0,5)},[s,n]),_=k.useMemo(()=>{if(!n)return{currentStreak:0,longestStreak:0};const M=new Set(n.map(V=>{const Y=new Date(V.completed_at);return`${Y.getFullYear()}-${Y.getMonth()}-${Y.getDate()}`})),I=new Date;I.setHours(0,0,0,0);let L=0,R=new Date(I);for(;M.has(`${R.getFullYear()}-${R.getMonth()}-${R.getDate()}`);)L++,R.setDate(R.getDate()-1);let q=0,U=0;if(Array.from(M).sort().length>0){const V=n.map(Y=>{const J=new Date(Y.completed_at);return J.setHours(0,0,0,0),J.getTime()}).filter((Y,J,te)=>te.indexOf(Y)===J).sort((Y,J)=>Y-J);U=1;for(let Y=1;Y[...s].sort((M,I)=>M.relationshipScore.score-I.relationshipScore.score),[s]),w=j.filter(M=>M.relationshipScore.status==="warm"),N=j.filter(M=>M.relationshipScore.status==="cooling"),C=j.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:[ps(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(Qu,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(ii,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(jh,{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(Qze,{value:i.touchTrend})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["vs ",i.touchesLastMonth," last month"]})]})}),e.jsx(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(mr,{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(Pe,{children:e.jsxs(Re,{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mb-1",children:[e.jsx(Ol,{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(Qze,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Rm,{className:"h-4 w-4 text-primary"}),"Weekly Goal"]})}),e.jsxs(Re,{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(xo,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(Qu,{className:"h-4 w-4 text-orange-500"}),"Momentum"]})}),e.jsxs(Re,{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(Pe,{children:[e.jsx(Dt,{className:"pb-2",children:e.jsxs(zt,{className:"text-base flex items-center gap-2",children:[e.jsx(jh,{className:"h-4 w-4"}),"How You're Reaching Out"]})}),e.jsx(Re,{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,I)=>{const L=b5s[M.icon||""]||jh;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(L,{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:Pt("h-1.5 bg-muted [&>div]:",Jze[I%Jze.length])})]},M.id)})})})]})]}),g.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-primary",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(Un,{className:"h-5 w-5 text-primary"}),"Who to Reach Out to Today"]}),e.jsxs(tt,{variant:"secondary",children:[g.length," contacts"]})]}),e.jsx(xr,{children:"These relationships need attention the most"})]}),e.jsx(Re,{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(g8,{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:I=>{I.stopPropagation(),window.open(`tel:${M.phone}`)},children:e.jsx(Un,{className:"h-4 w-4"})}),M.email&&e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:I=>{I.stopPropagation(),window.open(`mailto:${M.email}`)},children:e.jsx(dr,{className:"h-4 w-4"})}),e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})]})]},M.id))})})]}),b.length>0&&e.jsxs(Pe,{className:"border-l-4 border-l-emerald-500",children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs(zt,{className:"text-lg flex items-center gap-2",children:[e.jsx(bc,{className:"h-5 w-5 text-emerald-500"}),"Biggest Wins This Month"]}),e.jsx(xr,{children:"Relationships you've successfully warmed up"})]}),e.jsx(Re,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:b.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(Pe,{className:"border-l-4 border-l-emerald-500",children:e.jsxs(Re,{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(Pe,{className:"border-l-4 border-l-amber-500",children:e.jsxs(Re,{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(Pe,{className:"border-l-4 border-l-red-500",children:e.jsxs(Re,{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(Pe,{children:e.jsx(Re,{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(aL,{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(ja,{defaultValue:"at-risk",children:[e.jsxs(ga,{children:[e.jsxs(us,{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(us,{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(us,{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:C},{key:"cooling",contacts:N},{key:"warm",contacts:w}].map(({key:M,contacts:I})=>e.jsx(ks,{value:M,children:e.jsx(Pe,{children:e.jsx(Re,{className:"p-0",children:I.length===0?e.jsx("p",{className:"p-6 text-center text-muted-foreground",children:"No contacts in this category"}):e.jsxs(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Contact"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Last Touch"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Touches (12mo)"}),e.jsx(kt,{children:"Score"}),e.jsx(kt,{className:"w-10"})]})}),e.jsx(On,{children:I.slice(0,20).map(L=>e.jsxs(Ss,{className:"cursor-pointer",onClick:()=>t(`/mission-control/contacts/${L.id}`),children:[e.jsxs(dt,{className:"font-medium",children:[L.first_name," ",L.last_name]}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:L.relationshipScore.daysSinceTouch===null?"Never":L.relationshipScore.daysSinceTouch===0?"Today":`${L.relationshipScore.daysSinceTouch}d ago`}),e.jsx(dt,{className:"hidden md:table-cell",children:L.relationshipScore.touchCountLast12Months}),e.jsx(dt,{children:e.jsx(g8,{score:L.relationshipScore,showScore:!0})}),e.jsx(dt,{children:e.jsx(xa,{className:"h-4 w-4 text-muted-foreground"})})]},L.id))})]})})})},M))]})]})})}function wct(){const{user:t}=Rs(),s=es(),{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"]}),he.success("Connect page created!")},onError:u=>{var p;(p=u.message)!=null&&p.includes("duplicate")?he.error("That slug is already taken. Try another."):he.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"]}),he.success("Page updated!")},onError:()=>he.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 w5s(){const{user:t}=Rs();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 j5s(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 EI=[{key:"email",label:"Missing Email",icon:dr,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:Un,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:Ba,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:Sh,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:Sn,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:Om,description:"Untagged — won't appear in filtered lists or plans",check:t=>!t.tags||t.tags.length===0,color:"text-slate-500"}];function $5(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 N5s({contact:t,onClose:s}){const r=yNe(),[n,a]=k.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=EI.filter(i=>i.fieldKey&&i.check(t));return e.jsx(QA,{open:!0,onOpenChange:()=>s(),children:e.jsxs(mC,{className:"sm:max-w-md overflow-y-auto",children:[e.jsxs(JA,{children:[e.jsxs(eE,{children:["Quick Edit — ",t.first_name," ",t.last_name]}),e.jsxs(RZe,{children:["Fill in missing fields to improve this contact's completeness (",$5(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(tt,{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(ye,{className:"flex items-center gap-1.5",children:[e.jsx(dr,{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:Pt(!t.email&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Un,{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:Pt(!t.phone&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Ba,{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:Pt(!t.address&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Sh,{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:Pt(!t.birthday&&"border-amber-500/50")})]}),e.jsxs("div",{children:[e.jsxs(ye,{className:"flex items-center gap-1.5",children:[e.jsx(Sn,{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:Pt(!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(ed,{className:"h-4 w-4 mr-1.5"}),r.isPending?"Saving...":"Save Changes"]}),e.jsx(K,{variant:"outline",onClick:s,children:"Cancel"})]})]})]})})}const Pye="Quick favor — can you update your info? 🙏",e9e=`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 k5s(){const t=pr(),{data:s,isLoading:r}=Wm(),{data:n}=Ux(),{intakePage:a}=wct(),{isGmailConnected:o,gmailEmail:l}=$0(),{data:i}=w5s(),[c,u]=k.useState("blocked"),[p,f]=k.useState("all"),[g,b]=k.useState(null),[_,j]=k.useState(!1),[w,N]=k.useState(!1),[C,M]=k.useState(null),[I,L]=k.useState([]),[R,q]=k.useState(""),[U,B]=k.useState(""),V=k.useMemo(()=>s?p==="all"?s:s.filter(Ce=>{var Me;return(Me=Ce.tags)==null?void 0:Me.some($e=>$e.relationship_type_id===p)}):[],[s,p]),Y=k.useMemo(()=>V.filter(Ce=>!Ce.email&&!Ce.phone),[V]),J=k.useMemo(()=>{if(!V.length)return{overallCompleteness:0,fullyComplete:0,contactsByGap:{}};const Ce={};Ce.blocked=Y,EI.forEach(Te=>{Ce[Te.key]=V.filter(Te.check)});const Me=V.map($5),$e=V.length>0?Math.round(Me.reduce((Te,ft)=>Te+ft,0)/V.length):0,ct=Me.filter(Te=>Te===100).length;return{contactsByGap:Ce,overallCompleteness:$e,fullyComplete:ct}},[V,Y]),te=k.useMemo(()=>{if(!s||s.length===0)return null;const Ce=Lc(f4(new Date,1)),Me=s.filter(ft=>new Date(ft.created_at)ft+me,0)/Me.length),ct=J.overallCompleteness,Te=ct-$e;return{oldCompleteness:$e,currentCompleteness:ct,diff:Te,oldCount:Me.length}},[s,J.overallCompleteness]),X=V.length,ce=k.useCallback(()=>{var nt;const Ce=J.contactsByGap[c];if(!(Ce!=null&&Ce.length))return;const Me=c==="blocked"?"Outreach Blocked":((nt=EI.find(et=>et.key===c))==null?void 0:nt.label)||c,$e=["First Name","Last Name","Email","Phone","Address","Birthday","Home Anniversary","Completeness %"],ct=Ce.map(et=>[et.first_name,et.last_name||"",et.email||"",et.phone||"",et.address||"",et.birthday||"",et.home_anniversary||"",$5(et).toString()]),Te=[$e.join(","),...ct.map(et=>et.map(Se=>`"${Se.replace(/"/g,'""')}"`).join(","))].join(` `),ft=new Blob([Te],{type:"text/csv"}),me=URL.createObjectURL(ft),Ve=document.createElement("a");Ve.href=me,Ve.download=`sphere-gaps-${Me.toLowerCase().replace(/\s+/g,"-")}-${ps(new Date,"yyyy-MM-dd")}.csv`,Ve.click(),URL.revokeObjectURL(me),vn({title:`Exported ${Ce.length} contacts to CSV`})},[J.contactsByGap,c]),ne=k.useCallback(async Ce=>{if(!a)return null;try{const{data:Me,error:$e}=await H.from("contact_intake_tokens").insert({contact_id:Ce,intake_page_id:a.id}).select("token").single();if($e)throw $e;return Me.token}catch{return null}},[a]),re=k.useCallback(Ce=>a?`https://contacts.relevelup.com/${a.slug}?t=${Ce}`:"",[a]),le=k.useCallback(async Ce=>{if(!a){he.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=await ne(Ce);Me?(await navigator.clipboard.writeText(re(Me)),he.success("Update link copied!")):he.error("Failed to generate link")},[a,ne,re,t]),pe=k.useCallback(async Ce=>{if(!a){he.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}if(!Ce.email){he.error("This contact has no email address");return}const Me=await ne(Ce.id);if(!Me){he.error("Failed to generate link");return}const $e=re(Me),ct=e9e.replace("{{update_link}}",$e).replace(/\{\{first_name\}\}/g,Ce.first_name).replace(/\{\{last_name\}\}/g,Ce.last_name||""),Te=Pye.replace(/\{\{first_name\}\}/g,Ce.first_name).replace(/\{\{last_name\}\}/g,Ce.last_name||"");if(o)M({id:Ce.id,first_name:Ce.first_name,last_name:Ce.last_name,email:Ce.email}),L([]),q(Te),B(ct),N(!0);else{const ft=encodeURIComponent(Pye.replace("{{first_name}}",Ce.first_name)),me=encodeURIComponent(ct.replace(/\{\{first_name\}\}/g,Ce.first_name));window.location.href=`mailto:${Ce.email}?subject=${ft}&body=${me}`}},[a,ne,re,o,t]),xe=k.useCallback(async Ce=>{if(!a){he.error("Set up your Connect Page first",{action:{label:"Set Up",onClick:()=>t("/mission-control/connect-page")}});return}const Me=Ce.filter(Te=>Te.email);if(!Me.length){he.error("No contacts with email addresses in this group");return}const $e=new Set((i||[]).map(Te=>Te.contact_id)),ct=Me.filter(Te=>!$e.has(Te.id));if(ct.length===0){he.info(`All ${Me.length} contacts with email have already been sent this update request.`);return}if(ct.lengthrt.id),intake_page_id:a.id}});if(ft)throw ft;const me=typeof Te=="string"?JSON.parse(Te):Te,Ve=Array.isArray(me)?me:Array.isArray(me==null?void 0:me.tokens)?me.tokens:[],nt=new Map(Ve.filter(rt=>(rt==null?void 0:rt.contact_id)&&(rt==null?void 0:rt.token)).map(rt=>[rt.contact_id,rt.token]));if(nt.size===0&&(await Promise.all(Me.map(async Ge=>({contactId:Ge.id,token:await ne(Ge.id)})))).forEach(({contactId:Ge,token:lt})=>{lt&&nt.set(Ge,lt)}),nt.size===0){he.error("Failed to generate update links. Please try again.");return}const et=ct.filter(rt=>nt.has(rt.id)).map(rt=>({id:rt.id,first_name:rt.first_name,last_name:rt.last_name,email:rt.email,updateLink:re(nt.get(rt.id))})),Se=e9e;M(null),L(et),q(Pye),B(Se),N(!0),he.success(`Ready to email ${et.length} contacts`)}catch{he.error("Failed to generate links")}finally{j(!1)}},[a,o,re,ne,t]),fe=[{key:"blocked",label:"Outreach Blocked",icon:Dv,color:"text-destructive",description:"Missing BOTH email AND phone — completely unreachable"},...EI].find(Ce=>Ce.key===c),we=J.contactsByGap[c]||[],Ie=we.filter(Ce=>Ce.email).length,Ne=new Set((i||[]).map(Ce=>Ce.contact_id)),Ae=we.filter(Ce=>Ce.email&&Ne.has(Ce.id)).length,Fe=Ie-Ae;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(Yg,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs(Ys,{value:p,onValueChange:f,children:[e.jsx(Gs,{className:"w-[180px]",children:e.jsx(Qs,{placeholder:"Filter by tag"})}),e.jsxs(Ks,{children:[e.jsx(Mt,{value:"all",children:"All Contacts"}),n==null?void 0:n.map(Ce=>e.jsx(Mt,{value:Ce.id,children:Ce.name},Ce.id))]})]})]})]}),e.jsx(Pe,{children:e.jsxs(Re,{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:[J.overallCompleteness,"%"]}),te&&te.diff!==0&&p==="all"&&e.jsxs("div",{className:Pt("flex items-center gap-1 px-2 py-1 rounded-full text-xs font-medium",te.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:[te.diff>0?"↑":"↓"," ",Math.abs(te.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:[J.fullyComplete," ",e.jsxs("span",{className:"text-base font-normal text-muted-foreground",children:["/ ",X]})]})]})]}),e.jsx(Bi,{value:J.overallCompleteness,className:"h-3"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:J.overallCompleteness>=80?"🎉 Great job! Your database is well maintained.":J.overallCompleteness>=50?"⚡ Good start — fill in the gaps below to unlock more outreach channels.":"🔍 Your database needs attention. Start with emails and phone numbers."})]})}),Y.length>0&&e.jsx(Pe,{className:Pt("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(Re,{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(Dv,{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:Y.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:EI.map(Ce=>{var ft;const Me=((ft=J.contactsByGap[Ce.key])==null?void 0:ft.length)||0,$e=X>0?Math.round(Me/X*100):0,ct=Ce.icon,Te=c===Ce.key;return e.jsx(Pe,{className:Pt("cursor-pointer transition-all hover:shadow-md",Te&&"ring-2 ring-primary"),onClick:()=>u(Ce.key),children:e.jsxs(Re,{className:"pt-5 pb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ct,{className:Pt("h-5 w-5",Ce.color)}),e.jsx("span",{className:"text-sm font-medium",children:Ce.label})]}),e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsx("span",{className:"text-2xl font-bold",children:Me}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[$e,"% of contacts"]})]}),e.jsx(Bi,{value:100-$e,className:"mt-2 h-1.5"})]})},Ce.key)})}),e.jsxs(Pe,{children:[e.jsxs(Dt,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(zt,{className:"text-lg",children:[(fe==null?void 0:fe.label)||"Contacts"," — Contacts to Fix"]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(tt,{variant:"secondary",children:[we.length," contacts"]}),Ae>0&&e.jsxs(tt,{variant:"outline",className:"gap-1 text-muted-foreground",children:[e.jsx(la,{className:"h-3 w-3"}),Ae," already emailed"]}),we.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs(K,{variant:"outline",size:"sm",onClick:ce,className:"gap-1.5",children:[e.jsx(Ci,{className:"h-3.5 w-3.5"}),"Export"]}),Fe>0&&a&&e.jsxs(K,{size:"sm",onClick:()=>xe(we),disabled:_,className:"gap-1.5",children:[_?e.jsx(ws,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Rn,{className:"h-3.5 w-3.5"}),"Email ",Fe," Update Links"]})]})]})]}),e.jsx(xr,{children:fe==null?void 0:fe.description})]}),e.jsx(Re,{className:"p-0",children:we.length===0?e.jsxs("div",{className:"p-8 text-center",children:[e.jsx(la,{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(Ln,{children:[e.jsx(Dn,{children:e.jsxs(Ss,{children:[e.jsx(kt,{children:"Contact"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Email"}),e.jsx(kt,{className:"hidden md:table-cell",children:"Phone"}),e.jsx(kt,{children:"Completeness"}),e.jsx(kt,{className:"w-28",children:"Actions"})]})}),e.jsx(On,{children:we.map(Ce=>{const Me=j5s(i,Ce.id);return e.jsxs(Ss,{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/${Ce.id}`),children:[Ce.first_name," ",Ce.last_name]}),!Ce.email&&!Ce.phone&&c!=="blocked"&&e.jsx(tt,{variant:"destructive",className:"text-[10px] px-1 py-0",children:"Blocked"}),Me&&e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsxs(tt,{variant:"outline",className:"text-[10px] px-1.5 py-0 gap-1 text-muted-foreground border-muted",children:[e.jsx(dr,{className:"h-2.5 w-2.5"}),_d(new Date(Me),{addSuffix:!0})]})}),e.jsxs(gc,{children:["Last bulk emailed ",ps(new Date(Me),"MMM d, yyyy h:mm a")]})]})]})}),e.jsx(dt,{className:"hidden md:table-cell text-muted-foreground",children:Ce.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:Ce.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:$5(Ce),className:"h-2 w-16"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[$5(Ce),"%"]})]})}),e.jsx(dt,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>b(Ce),children:e.jsx(Rv,{className:"h-3.5 w-3.5"})})}),e.jsx(gc,{children:"Quick edit"})]}),(Ce.email||Ce.phone)&&a&&e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>le(Ce.id),children:e.jsx(gi,{className:"h-3.5 w-3.5"})})}),e.jsx(gc,{children:"Copy update link"})]}),Ce.email&&a&&e.jsxs(Oc,{children:[e.jsx(Rc,{asChild:!0,children:e.jsx(K,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>pe(Ce),children:e.jsx(dr,{className:"h-3.5 w-3.5"})})}),e.jsx(gc,{children:"Email update link"})]})]})})]},Ce.id)})})]})})]})]}),g&&e.jsx(N5s,{contact:g,onClose:()=>b(null)}),e.jsx(jE,{open:w,onOpenChange:N,contact:C||void 0,bulkContacts:I.length>0?I:void 0,defaultSubject:R,defaultBody:U,gmailEmail:l})]})}function S5s(){const{user:t}=Rs(),{intakePage:s,isLoading:r,createPage:n,updatePage:a,submissions:o,loadingSubmissions:l}=wct(),[i,c]=k.useState(""),[u,p]=k.useState(""),[f,g]=k.useState(!1);k.useEffect(()=>{s&&p(s.welcome_message||"")},[s]),k.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 b=s?`https://contacts.relevelup.com/${s.slug}`:"",_=()=>{navigator.clipboard.writeText(b),he.success("Link copied!")};if(r)return e.jsx(Pe,{children:e.jsx(Re,{className:"p-6 flex items-center justify-center",children:e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"})})});if(!s)return e.jsxs(Pe,{children:[e.jsx(Dt,{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(cl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(xr,{children:"Create a public link to capture contact info from new leads or update existing contacts"})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{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(ws,{className:"h-4 w-4 animate-spin mr-2"}):null,"Create Connect Page"]})]})})]});const j=o.filter(M=>!M.is_processed),w=o.filter(M=>M.is_processed),N=j.length,C=(M,I)=>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(tt,{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(mn,{className:"h-3 w-3"}),ps(new Date(M.created_at),"MMM d")]}),I&&e.jsx(la,{className:"h-4 w-4 text-emerald-500"})]})]},M.id);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(Pe,{children:[e.jsx(Dt,{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(cl,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx(zt,{children:"Connect Page"}),e.jsx(xr,{children:"Share this link to capture contact info"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{htmlFor:"active-toggle",className:"text-sm text-muted-foreground",children:"Active"}),e.jsx($r,{id:"active-toggle",checked:s.is_active,onCheckedChange:M=>a.mutate({is_active:M})})]})]})}),e.jsxs(Re,{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:b}),e.jsxs(K,{size:"sm",variant:"outline",onClick:_,children:[e.jsx(gi,{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:b,target:"_blank",rel:"noopener noreferrer",children:e.jsx(an,{className:"h-3.5 w-3.5"})})})]}),e.jsxs("div",{children:[e.jsx(ye,{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(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(mr,{className:"h-5 w-5 text-primary"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"New Submissions"}),N>0&&e.jsxs(xr,{children:[N," awaiting sync"]})]})]}),N>0&&e.jsxs(K,{size:"sm",onClick:async()=>{try{const{data:M,error:I}=await H.functions.invoke("process-intake-submissions",{body:{action:"process_all"}});if(I)throw I;he.success(`Synced ${M.processed} contacts to your CRM!`)}catch{he.error("Failed to sync")}},className:"gap-1.5",children:["Sync ",N," to CRM"]})]})}),e.jsx(Re,{children:l?e.jsx(ws,{className:"h-5 w-5 animate-spin text-muted-foreground"}):j.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:j.map(M=>C(M,!1))})})]}),w.length>0&&e.jsxs(Pe,{children:[e.jsx(Dt,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(la,{className:"h-5 w-5 text-emerald-500"}),e.jsxs("div",{children:[e.jsx(zt,{className:"text-base",children:"Synced to CRM"}),e.jsxs(xr,{children:[w.length," contacts already in your database"]})]})]})}),e.jsx(Re,{children:e.jsxs("div",{className:"space-y-3",children:[w.slice(0,10).map(M=>C(M,!0)),w.length>10&&e.jsxs("p",{className:"text-xs text-muted-foreground text-center pt-1",children:["+ ",w.length-10," more synced contacts"]})]})})]})]})}function C5s(){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(S5s,{})]})})}const M5s=k.lazy(()=>jc(()=>import("./PostcardManager-BXjSoQ2f.js"),__vite__mapDeps([0,1]))),T5s=k.lazy(()=>jc(()=>import("./HomeReelManager-CdEfMFyp.js"),[])),A5s=k.lazy(()=>jc(()=>import("./AdminCredits-CCf8S2OR.js"),[])),E5s=k.lazy(()=>jc(()=>import("./DirectMail-DA9iFmMT.js").then(t=>t.D),__vite__mapDeps([2,1]))),P5s=k.lazy(()=>jc(()=>import("./InnerCirclePopbyMap-CA6EHOTK.js"),[])),I5s=k.lazy(()=>jc(()=>import("./LiveVisitorFeed-BVhiOYb1.js"),[])),L5s=k.lazy(()=>jc(()=>import("./LeadSites-Do8yBBud.js"),[])),t9e=k.lazy(()=>jc(()=>import("./LeadSiteEditor-tGRGnyuO.js"),[])),D5s=k.lazy(()=>jc(()=>import("./AdminMlsFeeds-CWBlh0pQ.js"),[])),O5s=k.lazy(()=>jc(()=>import("./AdminLeadSiteAnalytics-BNUUkKNW.js"),[])),R5s=k.lazy(()=>jc(()=>import("./MLSListings-6UVxlCbp.js"),[])),F5s=k.lazy(()=>jc(()=>import("./MLSListingDetail-C-iu_k1g.js"),[])),z5s=k.lazy(()=>jc(()=>import("./MarketReportPage-DbBuB-AB.js"),[])),B5s=k.lazy(()=>jc(()=>import("./WebsiteActivity-CCyaB8l4.js"),[])),$5s=k.lazy(()=>jc(()=>import("./EmailCampaigns-CmQbH1Sb.js"),[])),q5s=k.lazy(()=>jc(()=>import("./EmailCampaignComposer-DjvRXNCF.js"),[])),U5s=k.lazy(()=>jc(()=>import("./EmailCampaignDetail-DgCXzwag.js"),[])),V5s=k.lazy(()=>jc(()=>import("./SharedCampaignTemplates-5IrWtJRM.js"),[])),s9e=k.lazy(()=>jc(()=>import("./TheLocalMoveHome-BX5mj1JV.js"),[])),H5s=new Z0t,W5s=()=>{const t=window.location.hostname;return t==="listings.relevelup.com"||t.startsWith("listings.")},G5s=()=>{const t=window.location.hostname;return t==="cards.relevelup.com"||t.startsWith("cards.")},K5s=()=>{const t=window.location.hostname;return t==="presentations.relevelup.com"||t.startsWith("presentations.")},Z5s=()=>{const t=window.location.hostname;return t==="guestbook.relevelup.com"||t.startsWith("guestbook.")},Y5s=()=>{const t=window.location.hostname;return t==="clients.relevelup.com"||t.startsWith("clients.")},X5s=()=>{const t=window.location.hostname;return t==="cardstudio.relevelup.com"||t.startsWith("cardstudio.")},Q5s=()=>{const t=window.location.hostname;return t==="booking.relevelup.com"||t.startsWith("booking.")},J5s=()=>{const t=window.location.hostname;return t==="contacts.relevelup.com"||t.startsWith("contacts.")},eMs=()=>{const t=window.location.hostname;return t==="pages.relevelup.com"||t.startsWith("pages.")},jct=()=>{const t=window.location.hostname;return t==="thelocalmove.com"||t==="www.thelocalmove.com"},tMs=()=>window.location.hostname.endsWith(".thelocalmove.com")&&!jct(),sMs=()=>e.jsx(evt,{client:H5s,children:e.jsx(bUe,{children:e.jsxs(F1,{children:[e.jsx(fgt,{}),e.jsx(Ggt,{}),e.jsx(u1t,{children:e.jsx(pwt,{children:e.jsx(fwt,{children:e.jsxs(gwt,{children:[e.jsx(xwt,{}),e.jsx(Zjt,{}),e.jsx(uNt,{}),X5s()?e.jsx(d3s,{}):G5s()?e.jsx(Akt,{}):W5s()?e.jsx(QNt,{}):K5s()?e.jsx(Ikt,{}):Z5s()?e.jsx(vEt,{}):Y5s()?e.jsx(OEt,{}):Q5s()?e.jsx(u3s,{}):J5s()?e.jsx(h3s,{}):eMs()?e.jsx(m3s,{}):jct()?e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(s9e,{})}):tMs()?e.jsx(n5s,{}):e.jsxs(P2e,{children:[e.jsx(Cs,{path:"/",element:e.jsx(HEt,{})}),e.jsx(Cs,{path:"/the-local-move",element:e.jsx(k.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(s9e,{})})}),e.jsx(Cs,{path:"/privacy-policy",element:e.jsx(WEt,{})}),e.jsx(Cs,{path:"/terms-of-service",element:e.jsx(GEt,{})}),e.jsx(Cs,{path:"/data-deletion",element:e.jsx(KEt,{})}),e.jsx(Cs,{path:"/public/listings",element:e.jsx(XWe,{})}),e.jsx(Cs,{path:"/public/listing/:slugOrId",element:e.jsx(LIt,{})}),e.jsx(Cs,{path:"/card/:slug",element:e.jsx(DIt,{})}),e.jsx(Cs,{path:"/join-brokerage/:slug",element:e.jsx(hCs,{})}),e.jsx(Cs,{path:"/recruit-video/:shareToken",element:e.jsx(pCs,{})}),e.jsx(Cs,{path:"/connect/:slug",element:e.jsx(OYe,{})}),e.jsx(Cs,{path:"/auth",element:e.jsx(YEt,{})}),e.jsx(Cs,{path:"/subscription-success",element:e.jsx(XEt,{})}),e.jsx(Cs,{path:"/subscription",element:e.jsx(ar,{children:e.jsx(UPt,{})})}),e.jsxs(Cs,{path:"/share/video",element:e.jsx(AIt,{}),children:[e.jsx(Cs,{path:":shareToken",element:e.jsx(mIe,{})}),e.jsx(Cs,{path:":shareToken/r/:recipientToken",element:e.jsx(mIe,{})})]}),e.jsx(Cs,{path:"/p/:shareToken",element:e.jsx(PCs,{})}),e.jsx(Cs,{path:"/portal/:slug",element:e.jsx(zCs,{})}),e.jsx(Cs,{path:"/og/video/:token",element:e.jsx(EIt,{})}),e.jsx(Cs,{path:"/setup-brokerage",element:e.jsx(ar,{children:e.jsx(VPt,{})})}),e.jsx(Cs,{path:"/claim-account",element:e.jsx(dIe,{})}),e.jsx(Cs,{path:"/claim",element:e.jsx(dIe,{})}),e.jsx(Cs,{path:"/join",element:e.jsx(HPt,{})}),e.jsx(Cs,{path:"/trial",element:e.jsx(sIt,{})}),e.jsx(Cs,{path:"/trial/success",element:e.jsx(rIt,{})}),e.jsx(Cs,{path:"/dashboard",element:e.jsx(ar,{children:e.jsx(s8t,{})})}),e.jsx(Cs,{path:"/profile",element:e.jsx(ar,{children:e.jsx(BBt,{})})}),e.jsx(Cs,{path:"/apps",element:e.jsx(ar,{children:e.jsx(e$t,{})})}),e.jsx(Cs,{path:"/admin",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(zUt,{})})}),e.jsx(Cs,{path:"/admin/apps",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(qUt,{})})}),e.jsx(Cs,{path:"/admin/members",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(YUt,{})})}),e.jsx(Cs,{path:"/admin/invite-codes",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(XUt,{})})}),e.jsx(Cs,{path:"/admin/events",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(rVt,{})})}),e.jsx(Cs,{path:"/events",element:e.jsx(ar,{children:e.jsx(YBt,{})})}),e.jsx(Cs,{path:"/events/:eventId",element:e.jsx(ar,{children:e.jsx(QBt,{})})}),e.jsx(Cs,{path:"/templates",element:e.jsx(ar,{children:e.jsx(t$t,{})})}),e.jsx(Cs,{path:"/templates/:templateId",element:e.jsx(ar,{children:e.jsx(a$t,{})})}),e.jsx(Cs,{path:"/admin/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(aVt,{})})}),e.jsx(Cs,{path:"/academy",element:e.jsx(ar,{children:e.jsx(i$t,{})})}),e.jsx(Cs,{path:"/academy/:videoId",element:e.jsx(ar,{children:e.jsx(l$t,{})})}),e.jsx(Cs,{path:"/admin/academy",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(oVt,{})})}),e.jsx(Cs,{path:"/toolbox",element:e.jsx(ar,{children:e.jsx(c$t,{})})}),e.jsx(Cs,{path:"/toolbox/:kitId",element:e.jsx(ar,{children:e.jsx(d$t,{})})}),e.jsx(Cs,{path:"/admin/toolbox",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(lVt,{})})}),e.jsx(Cs,{path:"/social-swag",element:e.jsx(ar,{children:e.jsx(u$t,{})})}),e.jsx(Cs,{path:"/social-swag-2",element:e.jsx(ar,{children:e.jsx(cUt,{})})}),e.jsx(Cs,{path:"/social-swag/:swagId",element:e.jsx(ar,{children:e.jsx(dUt,{})})}),e.jsx(Cs,{path:"/social-connections",element:e.jsx(ar,{children:e.jsx(fCs,{})})}),e.jsx(Cs,{path:"/social-connections/callback",element:e.jsx(ar,{children:e.jsx(xCs,{})})}),e.jsx(Cs,{path:"/social-connections/linkedin-callback",element:e.jsx(ar,{children:e.jsx(yCs,{})})}),e.jsx(Cs,{path:"/social-connections/google-callback",element:e.jsx(ar,{children:e.jsx(gCs,{})})}),e.jsx(Cs,{path:"/admin/social-swag",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(cVt,{})})}),e.jsx(Cs,{path:"/admin/social-swag-2",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(WHt,{})})}),e.jsx(Cs,{path:"/community",element:e.jsx(ar,{children:e.jsx(TUt,{})})}),e.jsx(Cs,{path:"/support",element:e.jsx(ar,{children:e.jsx(AUt,{})})}),e.jsx(Cs,{path:"/admin/community",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(GHt,{})})}),e.jsx(Cs,{path:"/admin/support-tickets",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Dvs,{})})}),e.jsx(Cs,{path:"/admin/email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Rvs,{})})}),e.jsx(Cs,{path:"/admin/agent-email-templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Fvs,{})})}),e.jsx(Cs,{path:"/admin/analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Pvs,{})})}),e.jsx(Cs,{path:"/admin/brokerage-resources",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Ivs,{})})}),e.jsx(Cs,{path:"/admin/dashboard-management",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Lvs,{})})}),e.jsx(Cs,{path:"/brokerage/dashboard",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(Yvs,{})})}),e.jsx(Cs,{path:"/brokerage/teams",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(o5s,{})})}),e.jsx(Cs,{path:"/brokerage/recruiting",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(R4s,{})})}),e.jsx(Cs,{path:"/my-team",element:e.jsx(ar,{children:e.jsx(l5s,{})})}),e.jsx(Cs,{path:"/my-brokerage",element:e.jsx(ar,{children:e.jsx(s1s,{})})}),e.jsx(Cs,{path:"/brokerage-content",element:e.jsx(ar,{children:e.jsx(l1s,{})})}),e.jsx(Cs,{path:"/brokerage-content/:contentId",element:e.jsx(ar,{children:e.jsx(m1s,{})})}),e.jsx(Cs,{path:"/brokerage-resources",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(OUt,{})})}),e.jsx(Cs,{path:"/brokerage-resources/:resourceId",element:e.jsx(ar,{requireBrokerageManager:!0,children:e.jsx(RUt,{})})}),e.jsx(Cs,{path:"/newsletters",element:e.jsx(ar,{children:e.jsx(p1s,{})})}),e.jsx(Cs,{path:"/newsletters/:id",element:e.jsx(ar,{children:e.jsx(x1s,{})})}),e.jsx(Cs,{path:"/wishlist",element:e.jsx(ar,{children:e.jsx(v1s,{})})}),e.jsx(Cs,{path:"/wishlist/:itemId",element:e.jsx(ar,{children:e.jsx(b1s,{})})}),e.jsx(Cs,{path:"/admin/wishlist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(_1s,{})})}),e.jsx(Cs,{path:"/admin/levelup-brief",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(w1s,{})})}),e.jsx(Cs,{path:"/admin/newsletters",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(y1s,{})})}),e.jsx(Cs,{path:"/admin/additional-services",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(j1s,{})})}),e.jsx(Cs,{path:"/admin/discounts",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(N1s,{})})}),e.jsx(Cs,{path:"/admin/subscriptions",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k1s,{})})}),e.jsx(Cs,{path:"/admin/referrals",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(S1s,{})})}),e.jsx(Cs,{path:"/admin/prospector",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(v4s,{})})}),e.jsx(Cs,{path:"/admin/recruiting",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(O4s,{})})}),e.jsx(Cs,{path:"/admin/beta/social-post-generator",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(FSs,{})})}),e.jsx(Cs,{path:"/admin/credits",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(A5s,{})})})}),e.jsx(Cs,{path:"/admin/beta/postcard-manager",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(M5s,{})})})}),e.jsx(Cs,{path:"/admin/beta/homereel",element:e.jsx(ar,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(T5s,{})})})}),e.jsx(Cs,{path:"/admin/lms",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(QSs,{})})}),e.jsx(Cs,{path:"/admin/lms/stats",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(rCs,{})})}),e.jsx(Cs,{path:"/admin/lms/:courseId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(JSs,{})})}),e.jsx(Cs,{path:"/levelup-u",element:e.jsx(ar,{children:e.jsx(nCs,{})})}),e.jsx(Cs,{path:"/levelup-u/:courseId",element:e.jsx(ar,{children:e.jsx(iCs,{})})}),e.jsx(Cs,{path:"/admin/brokerage-content-activity",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(F4s,{})})}),e.jsx(Cs,{path:"/admin/onboarding-checklist",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(M1s,{})})}),e.jsx(Cs,{path:"/admin/marketplace",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(Yks,{})})}),e.jsx(Cs,{path:"/admin/agent-points",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(bks,{})})}),e.jsx(Cs,{path:"/admin/reward-store",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(u4s,{})})}),e.jsx(Cs,{path:"/admin/integrations",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(m4s,{})})}),e.jsx(Cs,{path:"/admin/integrations/callback",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(y4s,{})})}),e.jsx(Cs,{path:"/admin/email-campaigns",element:e.jsx(ar,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx($5s,{})})})}),e.jsx(Cs,{path:"/admin/email-campaigns/templates",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(V5s,{})})})}),e.jsx(Cs,{path:"/admin/email-campaigns/new",element:e.jsx(ar,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(q5s,{})})})}),e.jsx(Cs,{path:"/admin/email-campaigns/:id",element:e.jsx(ar,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(U5s,{})})})}),e.jsx(Cs,{path:"/reward-store",element:e.jsx(ar,{children:e.jsx(SCs,{})})}),e.jsx(Cs,{path:"/additional-services",element:e.jsx(ar,{children:e.jsx(z1s,{})})}),e.jsx(Cs,{path:"/additional-services/:serviceId",element:e.jsx(ar,{children:e.jsx(B1s,{})})}),e.jsx(Cs,{path:"/ai-toolkit",element:e.jsx(ar,{children:e.jsx($1s,{})})}),e.jsx(Cs,{path:"/mission-control",element:e.jsx(ar,{children:e.jsx(nbs,{})})}),e.jsx(Cs,{path:"/mission-control/contacts",element:e.jsx(ar,{children:e.jsx(qbs,{})})}),e.jsx(Cs,{path:"/mission-control/contacts/:contactId",element:e.jsx(ar,{children:e.jsx(x_s,{})})}),e.jsx(Cs,{path:"/mission-control/plans",element:e.jsx(ar,{children:e.jsx(g_s,{})})}),e.jsx(Cs,{path:"/mission-control/popbys",element:e.jsx(ar,{children:e.jsx(b_s,{})})}),e.jsx(Cs,{path:"/mission-control/popbys/map",element:e.jsx(ar,{children:e.jsx(P5s,{})})}),e.jsx(Cs,{path:"/admin/notification-settings",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(f4s,{})})}),e.jsx(Cs,{path:"/admin/agent-os",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(A1s,{})})}),e.jsx(Cs,{path:"/mission-control/listings",element:e.jsx(ar,{children:e.jsx(V_s,{})})}),e.jsx(Cs,{path:"/mission-control/listings/new",element:e.jsx(ar,{children:e.jsx(s7e,{})})}),e.jsx(Cs,{path:"/mission-control/listings/:listingId",element:e.jsx(ar,{children:e.jsx(aws,{})})}),e.jsx(Cs,{path:"/mission-control/listings/:listingId/edit",element:e.jsx(ar,{children:e.jsx(s7e,{})})}),e.jsx(Cs,{path:"/admin/listing-exchange",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(pks,{})})}),e.jsx(Cs,{path:"/mission-control/pipeline",element:e.jsx(ar,{children:e.jsx(_Ns,{})})}),e.jsx(Cs,{path:"/mission-control/tasks",element:e.jsx(ar,{children:e.jsx(ENs,{})})}),e.jsx(Cs,{path:"/mission-control/my-card",element:e.jsx(ar,{children:e.jsx(XNs,{})})}),e.jsx(Cs,{path:"/mission-control/integrations",element:e.jsx(ar,{children:e.jsx(oks,{})})}),e.jsx(Cs,{path:"/mission-control/integrations/gmail/callback",element:e.jsx(ar,{children:e.jsx(lks,{})})}),e.jsx(Cs,{path:"/mission-control/integrations/canva/callback",element:e.jsx(cks,{})}),e.jsx(Cs,{path:"/mission-control/integrations/meta/callback",element:e.jsx(ar,{children:e.jsx(dks,{})})}),e.jsx(Cs,{path:"/mission-control/scorecard",element:e.jsx(ar,{children:e.jsx(L_s,{})})}),e.jsx(Cs,{path:"/admin/scorecard",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(hks,{})})}),e.jsx(Cs,{path:"/admin/scorecard/:userId",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(fze,{})})}),e.jsx(Cs,{path:"/mission-control/scorecard/:userId",element:e.jsx(ar,{children:e.jsx(fze,{})})}),e.jsx(Cs,{path:"/mission-control/relationship-scorecard",element:e.jsx(ar,{children:e.jsx(_5s,{})})}),e.jsx(Cs,{path:"/mission-control/sphere-gaps",element:e.jsx(ar,{children:e.jsx(k5s,{})})}),e.jsx(Cs,{path:"/mission-control/connect-page",element:e.jsx(ar,{children:e.jsx(C5s,{})})}),e.jsx(Cs,{path:"/admin/membership-reviews",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(fks,{})})}),e.jsx(Cs,{path:"/admin/weekly-digest",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(yks,{})})}),e.jsx(Cs,{path:"/mission-control/video/record",element:e.jsx(ar,{children:e.jsx(ojs,{})})}),e.jsx(Cs,{path:"/mission-control/video-library",element:e.jsx(ar,{children:e.jsx(wjs,{})})}),e.jsx(Cs,{path:"/marketplace",element:e.jsx(ar,{children:e.jsx(vCs,{})})}),e.jsx(Cs,{path:"/marketplace/:productId",element:e.jsx(ar,{children:e.jsx(bCs,{})})}),e.jsx(Cs,{path:"/marketplace/cart",element:e.jsx(ar,{children:e.jsx(_Cs,{})})}),e.jsx(Cs,{path:"/marketplace/orders",element:e.jsx(ar,{children:e.jsx(wCs,{})})}),e.jsx(Cs,{path:"/marketplace/orders/:orderId",element:e.jsx(ar,{children:e.jsx(NCs,{})})}),e.jsx(Cs,{path:"/marketplace/success",element:e.jsx(ar,{children:e.jsx(kCs,{})})}),e.jsx(Cs,{path:"/admin/agent-cards",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(_ks,{})})}),e.jsx(Cs,{path:"/admin/presentation-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(x4s,{})})}),e.jsx(Cs,{path:"/admin/guest-book-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(g4s,{})})}),e.jsx(Cs,{path:"/mission-control/smart-drips",element:e.jsx(ar,{children:e.jsx(l3s,{})})}),e.jsx(Cs,{path:"/mission-control/direct-mail",element:e.jsx(ar,{children:e.jsx(k.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:"Loading..."}),children:e.jsx(E5s,{})})})}),e.jsx(Cs,{path:"/mission-control/presentations",element:e.jsx(ar,{children:e.jsx(CCs,{})})}),e.jsx(Cs,{path:"/mission-control/presentations/new",element:e.jsx(ar,{children:e.jsx(zze,{})})}),e.jsx(Cs,{path:"/mission-control/presentations/:id",element:e.jsx(ar,{children:e.jsx(zze,{})})}),e.jsx(Cs,{path:"/mission-control/guest-book",element:e.jsx(ar,{children:e.jsx(RCs,{})})}),e.jsx(Cs,{path:"/mission-control/guest-book/live/:id",element:e.jsx(ar,{children:e.jsx(I5s,{})})}),e.jsx(Cs,{path:"/guestbook/:slug",element:e.jsx(EGe,{})}),e.jsx(Cs,{path:"/mission-control/card-studio",element:e.jsx(ar,{children:e.jsx(HCs,{})})}),e.jsx(Cs,{path:"/mission-control/scheduler",element:e.jsx(ar,{children:e.jsx(f5s,{})})}),e.jsx(Cs,{path:"/c/:shareToken",element:e.jsx(hct,{})}),e.jsx(Cs,{path:"/book/:slug",element:e.jsx(pct,{})}),e.jsx(Cs,{path:"/page/:slug",element:e.jsx(fct,{})}),e.jsx(Cs,{path:"/mission-control/landing-pages",element:e.jsx(ar,{children:e.jsx(x5s,{})})}),e.jsx(Cs,{path:"/mission-control/landing-pages/:pageId",element:e.jsx(ar,{children:e.jsx(v5s,{})})}),e.jsx(Cs,{path:"/my-website/:siteId/edit",element:e.jsx(ar,{children:e.jsx(k.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(t9e,{})})})}),e.jsx(Cs,{path:"/my-website/:siteId/activity",element:e.jsx(ar,{children:e.jsx(k.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(B5s,{})})})}),e.jsx(Cs,{path:"/my-website/mls-listings",element:e.jsx(ar,{children:e.jsx(k.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(R5s,{})})})}),e.jsx(Cs,{path:"/my-website/mls-listings/:mlsId",element:e.jsx(ar,{children:e.jsx(k.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(F5s,{})})})}),e.jsx(Cs,{path:"/my-website/market-report",element:e.jsx(ar,{children:e.jsx(k.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(z5s,{})})})}),e.jsx(Cs,{path:"/admin/lead-sites",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.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(L5s,{})})})}),e.jsx(Cs,{path:"/admin/lead-sites/:siteId/edit",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.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(t9e,{})})})}),e.jsx(Cs,{path:"/admin/mls-feeds",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.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(D5s,{})})})}),e.jsx(Cs,{path:"/admin/lead-site-analytics",element:e.jsx(ar,{requireAdmin:!0,children:e.jsx(k.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(O5s,{})})})}),e.jsx(Cs,{path:"*",element:e.jsx(mct,{})})]}),")"]})})})})]})})}),r9e=window.location.hostname,rMs=r9e.includes("lovable.app")||r9e.includes("lovableproject.com");rMs&&"serviceWorker"in navigator&&(navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(s=>{s.unregister()})}),"caches"in window&&caches.keys().then(t=>{t.forEach(s=>caches.delete(s))}));C$e(document.getElementById("root")).render(e.jsx(sMs,{}));export{Nr as $,bs as A,K as B,Pe as C,wc as D,ye as E,Ys as F,Gs as G,Qs as H,ze as I,Ks as J,Mt as K,ws as L,zn as M,pMs as N,ps as O,Cl as P,No as Q,Er as R,$r as S,ja as T,mr as U,fl as V,Yne as W,U4 as X,wa as Y,ed as Z,gi as _,Dt as a,HQ as a$,pr as a0,Ts as a1,ri as a2,dr as a3,tS as a4,Rn as a5,qi as a6,oi as a7,Da as a8,un as a9,Dse as aA,Uke as aB,zke as aC,Hke as aD,NMs as aE,cV as aF,$ke as aG,JO as aH,Wke as aI,GS as aJ,Ju as aK,Oc as aL,Rc as aM,Jv as aN,gc as aO,Vte as aP,to as aQ,Un as aR,Bo as aS,$o as aT,Do as aU,Gi as aV,qc as aW,JI as aX,la as aY,Nl as aZ,qn as a_,F_ as aa,Rs as ab,XQ as ac,fa as ad,Pt as ae,Dm as af,rl as ag,Nae as ah,Wg as ai,zv as aj,Or as ak,Bi as al,Ci as am,TM as an,Wo as ao,xu as ap,Cn as aq,u1 as ar,aS as as,m0 as at,RPt as au,_n as av,za as aw,wn as ax,Fke as ay,Ble as az,zt as b,pf as b$,zQ as b0,GI as b1,ah as b2,QU as b3,En as b4,hn as b5,CM as b6,DL as b7,Cx as b8,Wr as b9,yMs as bA,bd as bB,l1 as bC,yZe as bD,cl as bE,Qu as bF,Sn as bG,Ws as bH,Ol as bI,V_ as bJ,mn as bK,io as bL,QA as bM,mC as bN,JA as bO,eE as bP,vre as bQ,Sx as bR,Su as bS,an as bT,gL as bU,Cee as bV,cn as bW,zM as bX,AQ as bY,Nu as bZ,Hh as b_,jc as ba,$j as bb,F1 as bc,Ro as bd,EL as be,Gu as bf,Ba as bg,yL as bh,Lo as bi,vn as bj,Pmt as bk,Ao as bl,ht as bm,To as bn,mbs as bo,hbs as bp,fbs as bq,xl as br,cX as bs,tJ as bt,xi as bu,yo as bv,fMs as bw,aGe as bx,xMs as by,gMs as bz,xr as c,B0 as c$,xct as c0,Im as c1,sc as c2,rc as c3,Ov as c4,t1 as c5,Kh as c6,Jn as c7,CMs as c8,Sp as c9,Rv as cA,Lm as cB,Hre as cC,G4 as cD,tke as cE,rke as cF,a9t as cG,vat as cH,fke as cI,mke as cJ,pke as cK,W4 as cL,Q4 as cM,kM as cN,SM as cO,Ch as cP,h0 as cQ,q4 as cR,V4 as cS,zo as cT,dS as cU,oS as cV,JNe as cW,nu as cX,_f as cY,nT as cZ,gat as c_,eL as ca,yue as cb,Nx as cc,yd as cd,Np as ce,Nh as cf,rS as cg,$0 as ch,eSe as ci,kp as cj,o1 as ck,sl as cl,ku as cm,Kne as cn,ll as co,xa as cp,jR as cq,die as cr,ii as cs,Xg as ct,jh as cu,_d as cv,RS as cw,Yo as cx,fi as cy,d1 as cz,Re as d,nR as d0,up as d1,xat as d2,eC as d3,tC as d4,P1 as d5,bh as d6,WI as d7,qa as d8,rd as d9,Pm as da,Th as db,Fm as dc,Vv as dd,ga as e,us as f,Om as g,ks as h,mt as i,e as j,Lt as k,he as l,qs as m,Ln as n,Dn as o,Ss as p,kt as q,k as r,H as s,On as t,es as u,dt as v,tt as w,xs as x,fs as y,_s as z};